Quickly Setting Up PLIP and NFS

by Loris Renggli

If you have two computers running Linux, one of which is a notebook, you are most likely tired of exchanging data between them using floppy disks. This article explains how to quickly set up these two computers so that you can use networking instead. Don't be afraid if you have no prior knowledge of networking; just follow the instructions step by step. If you have successfully installed Linux by yourself on your computer, you will be able to do this as well.

I'll start by setting up a PLIP (Parallel Line Internet Protocol) connection, which is simply a network connection through the parallel port. This port is most often used to connect a printer, and it is most probably located at the back of your computer. It has a connector with 25 holes. You will need a special cable to make this connection. Once made, you will have a full network connection allowing you to use ftp or rcp to transfer files between the computers.

Next, I'll discuss using NFS and mounting the disk of the notebook computer on the desktop computer. In this way, the disk of the notebook computer will appear as if it were a local disk on your desktop computer, and you can manipulate (edit, copy, etc.) your notebook files using your favorite commands.

Finally, I will show you how to access the Internet through PLIP from the notebook computer if your desktop computer has Internet access.

Assumptions and Conventions

I am using the Slackware 3.2 distribution of Linux (kernel 2.0.27), so if you have another distribution, some interpolation may be necessary—in particular, for the kernel configuration and the location of the system files. You will need the following:

  • two computers with Slackware 3.2—generic Slackware kernel—or your favorite Linux distribution

  • root access on both computers

  • your own account on both computers (with same UID for NFS)

  • TCP/IP package installed

  • parallel port plip1 on each computer (IO 0x378, IRQ 7)

I will use the following conventions for commands:

  • commands with prompt ending in # are issued as root

  • commands with prompt ending in > are issued as an unprivileged user

Finally, when editing files as root, remember to always make a backup copy of all configuration files before you alter them during the configuration process!

Part 1. What is PLIP?

PLIP is similar to SLIP (Serial Line Internet Protocol), except that it uses a parallel cable for the connection. SLIP is used for networking over serial lines (like modems, or the serial ports of your computer, usually with 9-hole connectors). Your printer and the PLIP connection cannot both be used at the same time, since they both use the parallel port. However, our primary goal is to have a temporary connection between the two computers, and switching between the printer and the connection is quite easy. You will have to connect/disconnect the cable manually, which may involve crawling under your desk. If you do this often, you may wish to consider buying a data switch box.

Setting Up PLIP

As already mentioned, the first thing you need is a “null-printer” parallel cable, which is often sold under the name “Laplink” cable or “PC-to-PC” cable. It is cheap (about $10 US) and easy to find in any computer store. There are also instructions on how to build one yourself in the NET-2-HOWTO, but I don't think it is worth the trouble and you could end up damaging your parallel port if you make a mistake—so just buy one.

Check the Kernel

Next, check your kernel. If you are using the distribution kernel that came with your Slackware 3.2 distribution, then you're all set. (If you don't know which kernel you are using, then you probably just have the generic one.) If not, check that you have loadable module support, networking support, PLIP and printer support as a module (no built-in printer support). If you have to recompile the kernel, then check the appropriate documentation and make sure to turn on these options:

CONFIG_MODULES=y
CONFIG_NET=y
CONFIG_INET=y
CONFIG_NETDEVICES=y
CONFIG_PLIP=m
CONFIG_PRINTER=m

Recompiling the kernel is not hard. You need to know what hardware you have and understand what all the options mean. Check the Kernel-HOWTO and the Documentation/Config.help file that comes with the kernel sources. If you have to recompile the kernel, first read this entire article, because later I will mention some additional options you may want to turn on.

With the correct options for the kernel, start the configuration, taking the following steps (as described in the next two sections):

  • Check for modules in /etc/rc.d/rc.modules and update /etc/hosts.

  • Write scripts to start/stop the connection.

Network Setup

You have to be root to edit the files. On both computers, in /etc/rc.d/rc.modules, comment out the line enabling printer support. (To comment out a statement in the file, just put the # character at the beginning of the line.) For example:

#/sbin/modprobe lp

Check that PLIP support is also commented out.

#/sbin/modprobe plip
I will load/unload the modules as needed from script files. Choose names for the two computers; I will call the desktop computer “zeus”, and the notebook “hermes”. (Hermes was the god of travel and business in Ancient Greece, and Zeus was his “boss”, being the god of the sky and master of all gods.) On both zeus and hermes, edit the file /etc/hosts and add the following two lines:
192.168.93.1     zeus
192.168.93.2     hermes
The addresses 192.168.93.xxx are safe to use; they will not conflict with existing addresses unless you already have a local network using these addresses. These IP addresses follow the convention for IP addressing: they are used only for local networks. (See NET-2-HOWTO and RFC1597 for more information.) You could skip this step and use the numeric addresses, but it is easier to remember zeus and hermes.
Scripts

On zeus, create the following script, /usr/sbin/plip-on.sh:

#!/bin/sh
/sbin/modprobe -r lp
/sbin/modprobe plip
/sbin/ifconfig plip1 zeus pointopoint hermes up
/sbin/route add hermes dev plip1

The modprobe commands unload module lp (printer module) and load the plip module. (Actually, PLIP works on my system with lp loaded, but the available documentation says it won't work; feel free to experiment.) ifconfig is then run to set up the network interface plip1. route tells the computer how to find its way to the network; here, host hermes is located through the network interface plip1. Next, create the following script, /usr/sbin/plip-off.sh:

#!/bin/sh
/sbin/route del hermes
/sbin/ifconfig plip1 down
/sbin/modprobe -r plip
/sbin/modprobe lp
Similarly, on hermes, write the following script, /usr/sbin/plip-on.sh:
#!/bin/sh
/sbin/modprobe -r lp
/sbin/modprobe plip
/sbin/ifconfig plip1 hermes pointopoint zeus up
/sbin/route add zeus dev plip1
/sbin/route add default gw zeus dev plip1
The main difference between the plip-on.sh file on zeus is that I have swapped zeus and hermes throughout. I have also added a default route, that is, when a connection (other than to zeus) is requested to the network, I use plip1 by default. I need this default to connect hermes to the Internet through zeus using masquerading as discussed at the end of this article; for PLIP and NFS, it is not needed. Now write the following script, /usr/sbin/plip-off.sh:
#!/bin/sh
/sbin/route del default
/sbin/route del zeus
/sbin/ifconfig plip1 down
/sbin/modprobe -r plip
/sbin/modprobe lp
Remember to change permissions (chmod +x plip-*.sh) on both computers to make the scripts executable. Now, you can plug in your cable and issue this command (as root):
# /usr/sbin/plip-on
on both zeus and hermes. (It does not matter on which you issue it first.) You should now have full connectivity between zeus and hermes. From hermes type:
hermes:~> telnet zeus
and log in to zeus. Congratulations. You have just set up your own private local network.
Running the Scripts as root

Working as root to run the scripts is not only annoying, it is also potentially dangerous. You could easily damage your Linux system by mistakenly removing files thus losing precious hours of sometimes difficult and tedious customization. That's why you should use the technique described in “Safely Running Programs as Root” by Phil Hughes, Linux Journal May 1997, and create executables named plip-on and plip-off with suid root to allow any user to start and stop the connection. All the executables do is run the scripts assuming root identity regardless of which user runs them. Example source code is available at ftp://sunsite.unc.edu/pub/Linux/docs/linux-journal/listings/issue37 in the file 2114.tgz.

Transferring Files

I now have a full network connection between zeus and hermes, so all the network software will work (TELNET, FTP, rlogin, etc.). Try to exchange files between the two computers using ftp. (The FTP server is turned on by default in Slackware; check the /etc/inetd.conf file and the man pages for inetd(8), ftpd(8).) Quicker even than ftp, you can use rcp (remote copy; see the man pages rcp(1), rlogin(1), rsh(1)). The transfer rate that I get on my systems is about 25KB per second using FTP.

Part 2. What is NFS?

NFS (Networked File System) allows you to access remote file systems of other computers through a network connection. In other words, you can manipulate files on another computer directly, as if they were files on your own computer. Your kernel must have NFS support enabled (default on Slackware), and you need to run programs (called “daemons”) which listen to the network for connection requests and act accordingly when one is received. You also need to specify which directories can be accessed and which hosts are allowed to access them.

Setting Up NFS

NFS is an even better way to access files between the two computers than using ftp or rcp. (To have NFS support enabled, the option is CONFIG_NFS_FS=y; again, this is the default with Slackware.) The setup described here allows you to consider the disk of hermes as being a disk on zeus, thereby allowing you to access all the files directly without having to log in (as with ftp) or setting rhosts access (as with rcp). Before you start, check your user identification number (UID) on both machines using the command id:

zeus:~> id
uid=401(zeusname) gid=100(users) groups=100(users)
hermes:~> id
uid=401(hermname) gid=100(users) groups=100(users)

I will assume that both numbers to the right of “uid=” match. (This number could be something other than 401.) If they do not match, refer to the section ahead called “If UIDs Don't Match”. Now take the following steps (described in the next three sections):

  • Start the RPC (remote procedure call) daemons in the /etc/rc.d/rc.inet2 file.

  • Create a list of hermes directories to be exported.

  • Mount the exported directories of hermes on zeus.

RPC daemons

On hermes, check that the rpc daemons are launched in the /etc/rc.d/rc.inet2 file. These daemons process the network requests to handle NFS. They are launched by default in Slackware, so if you haven't changed the re.inet2 file from the original distribution, there is nothing to do, and you can skip the rest of this section.

First, type ps a | grep rpc to check that the daemons are running. On my system, I get this output:

hermes:~> ps a | grep rpc
80  ?  S     0:00 /usr/sbin/rpc.mountd
83  ?  S     0:00 /usr/sbin/rpc.nfsd
74  ?  S     0:00 /usr/sbin/rpc.portmap

If they are not running, edit the /etc/rc.d/rc.inet2 file (make a backup copy first) and append the lines:

/usr/sbin/rpc.portmap
/usr/sbin/rpc.mountd
/usr/sbin/rpc.nfsd
If you make any changes to the /etc/rc.d/rc.inet2 file, reboot the computer and check to be sure the daemons are now running. These commands could always be issued as root from the command line instead of rebooting.
Exporting Directories

On hermes, edit the /etc/exports file, which contains the directories you wish to make accessible from zeus. You have to choose which directories you want to export. You could just export the root directory /, thus exporting the whole disk; but usually you just want to access the user files located in /home, so in this example I export only /home. Add the following line to the /etc/exports file:

/home  zeus

See the exports(5) man page for the format of the file and the available options. In particular, you will be able to write from zeus onto hermes' disk; if you don't think this is a good idea, use:

/home  zeus(ro)
The option ro stands for “read-only”. Notice that user root cannot write on hermes' disk from zeus unless you specifically allow it using the options described in exports(5). You can add other directories, one on each line, using the same syntax.

Now tell the nfsd and mountd daemon that the exports file has changed by sending them a signal using the command:

hermes# killall -HUP rpc.nfsd rpc.mountd
Mounting the Directories

From zeus, you can check that hermes is now ready to export by issuing the command:

zeus# /usr/sbin/showmount -e hermes
Export list for hermes:
/home    zeus

Finally, on zeus, chose a “mount point”; this is just an empty directory that you will use to access the remote directory on hermes. I suggest:

zeus# mkdir /nfs
zeus# mkdir /nfs/hermes
Ready to mount? From zeus type:
zeus# /sbin/mount -t nfs hermes:/home /nfs/hermes
All the files on hermes in directory /home are now accessible from zeus. Type:
zeus:~> ls /nfs/hermes/hermname
and you will see the listing of all your files on hermes (if your account has “hermname” as user name). Once you are finished and wish to shutdown the notebook computer, unmount hermes' file system by giving:
zeus# /sbin/umount /nfs/hermes
then close the connection using the script, plip-off.sh.

I can even make things a bit more comfortable by adding the following line in the file /etc/fstab on zeus:

hermes:/home  /nfs/hermes  nfs  noauto   0  0

This command tells Linux to add to its list of file systems the directory /home on host hermes, which has to be mounted under /nfs/hermes on zeus, but not automatically (in particular, not at boot time), and that hermes has the type nfs. (See the man pages nfs(5), filesystems(9), fstab(4) for details.) By adding that line, the mount command is reduced to:

zeus# /sbin/mount /nfs/hermes
Finally, if you are using PLIP solely to use NFS, you could add the mount command at the end of the zeus script plip-on.sh and umount at the beginning of plip-off.sh. In this case, you must start PLIP first on hermes and shut it down first on zeus, otherwise mount cannot reach the network.
If UIDs Don't Match

If you have two different UIDs on hermes and zeus, you can still read files on zeus from hermes in directory /nfs/hermes/hermname provided the files are world readable. Thus, you can list and copy files, but you won't be able to modify them, even if the directory was exported with read and write access. This is true because zeusname and hermname are considered to be two distinct users. Linux identifies users by using their UID, not their account names.

If all you want is to copy files from hermes to zeus and it does not bother you that files are world (or group) readable on hermes, you can leave things the way they are. More likely you will wish to write files on hermes' disk as well as read them. You must choose the same UID for zeusname on zeus and hermname on hermes, and it must be distinct from any other UID that might already exist on both systems. It is also better to have the same identification number for the group, GID, but this is probably the case already; using Slackware, the default group for users is just “users” with GID equal to 100.

The UID is stored in the /etc/passwd file. On each line of this file is the information for a particular user beginning with the user name. The UID is the third field from the beginning of the line, fields being separated by colons (:). Once you have determined a UID that suits you, edit the /etc/passwd file and insert the proper UID. Assuming the UID 410 on zeus can be used on hermes as well and the GID is 100, there is nothing to change on zeus. Then change ownership of the files in your home directory on hermes by giving the command:

hermes# chown -R 410.100 hermname .

Make sure you issue the command from your home directory or else expect to face some problems. Have a look at the man page of chown to make sure you understand how it works. In the case where you have to change the UIDs on both zeus and hermes, issue the same command from your home directory on zeus.

Note: Make sure that changing ownership won't affect file access for other users. This could cause trouble if you had files or directories that you own but which you share with other users in the same group.

IP Masquerading

I now have two computers, connected using a local network with PLIP, file sharing with NFS. Sounds pretty good, doesn't it? Yes, but we want more.

If we have Internet access from zeus via a PPP connection (or an Ethernet card), we can use zeus as a gateway for hermes to have Internet access. In other words, we can use the PPP connection on zeus from hermes through the parallel cable. We will do this using IP masquerading. This is the subject of a stand-alone article (see “IP Masquerading with Linux” by Chris Kostick Linux Journal July 1996), so I am just going to give pointers to some relevant documentation. See Resources for the web address of the IP Masquerade HOWTO and the Firewall-HOWTO. You will have to recompile the kernel to activate masquerading. Create a /usr/sbin/ipmasq-on.sh script on zeus containing the lines:

#!/bin/sh
ipfwadm -F -p deny
ipfwadm -F -a m -S 192.168.93.0/24 -D 0.0.0.0/0

Invoke the script as root on zeus when the PLIP connection is active. I know this is not enough information, but masquerading is not the subject of this article and the HOWTO contains all the details.

Conclusion

I said in the beginning of the article that I just wanted a temporary connection between zeus and hermes; it looks like I got a little carried away and am close to making it permanent. By the way, I wrote most of this article on hermes, with the file residing on a zeus file system mounted via NFS. Yes, I think it is truly becoming permanent.

Resources

Loris Renggli is a mathematician who holds a Ph.D. in numerical analysis from the Swiss Federal Institute of Technology. For the past four years, he has been teaching and doing research in Switzerland, Finland, France and the U.S. He was last seen at Florida State University as an assistant professor in mathematics. When you will read this article, he will be elsewhere; he prefers to be reached electronically at renggli@math.fsu.edu.
Load Disqus comments