HOW TO NETWORK USING THE PARALLEL PORT AND A NULL-MODEM CABLE
Copyright (C) 2004 Daniel Brodzik
This document is free software; you may distribute and/or modify it under the terms of the GNU Free Documentation License; either version 1.2 of the license or, at your option, any later version, with no Front Cover Texts, no Back Cover Texts, and no Invariant Sections.
INTRODUCTION
About five months before I switched from using Windows to Linux, I bought a parallel data transfer cable. This type of cable is commonly called a LapLink cable after the software that originated the cable design. I bought this after my friend gave me his old 486 laptop (which was, and still is broken). Using InterLink for DOS or Direct Cable Connection for Windows, I could create a network between two PC's, and I could even share drives or printers. I got a 486 desktop system from my mother's boyfriend which had Windows 95 OSR2 on it. The other computer, my 120 MHz Pentium, had Windows 98 SE. When I quit using Windows, I thought I had to use FreeDOS to transfer files between the two computers. (Since then, the Pentium was replaced twice, first with a 166 MHz Pentium MMX, and now a 333 MHz Pentium II.) I didn't have any big problems with it, only minor annoyances. First, any filenames longer than 8.3 would be truncated. The second annoyance was that I'd lose the file permissions by copying files onto my FAT16 partition. The third annoyance was the FAT16 (DOS) partitions are smaller than my EXT3 (Linux) partitions. The fourth, and biggest, annoyance: I had to reboot my computers to run DOS.
So, I started doing research trying to find easy-to-follow directions for networking through the parallel port. (I spent $5 for the cable, and I was determined to use it!) I found out that using the parallel port like an Ethernet card is called 'PLIP', for 'Parallel Line Internet Protocol'. In other words, the parallel port equivalent of SLIP. The first time I tried it, I failed with "Can't connect: connection refused" messages. Now that I know a lot more about Linux, I decided to try again with the PLIP HOWTO from the Linux Documentation Project. I finally had success!! Now, I will share with you the steps I took to set up parallel-port networking with NFS (NFS=Network File System=file sharing) under Linux. The PLIP HOWTO did not give me any help on how to mount the other computer's filesystem, so I had to figure that out on my own.
Now that I have a new laptop which doesn't have a floppy drive, I am finding this setup very helpful.
As an added bonus, I have added directions on how to log in to one computer while typing at the other remotely. I will also demonstrate the network transparency of the X Window System by showing you how to start and run an X program on one computer and have it appear on the computer on the other end of the parallel cable. This is quite fun!
Here's what you will need to set this up:
Two computers capable of running Linux and that have a capable parallel port (Before I bought my laptop, I used two desktop systems, a 486 and a Pentium II, but most people use either a desktop and a laptop or two laptops)
A LapLink-style parallel null-modem data-transfer cable. This guide does not go into the serial null-modem cable. (The parallel cable is much faster and, since most new laptops don't come with serial ports but still come with parallel ports, the parallel cable will be the only choice.)
A Linux kernel with 'lp' and 'plip' support compiled as modules (they're not likely to work otherwise). See my kernel compiling guide for more information on compiling a custom kernel.
A console-based text editor (I recommend ne or nano)
The root passwords for both systems
A normal user account with the SAME name on both machines is HIGHLY recommended to allow data transfer as a non-root user. In fact, I don't think it will work unless you have the same user name on both machines because, by default, Linux 'squashes' root access to files over any kind of a network to prevent someone who, for example, connects to your computer over a wide-area network, such as the Internet, using their root account on their computer without you knowing about it and messing up your files. Disabling the 'rootsquash' option is NOT recommended!
These instructions were primarily tested on two Debian GNU/Linux systems with no networks besides the parallel-port network. The directions were also tested successfully on two Fedora systems and a combination of a Debian and a Fedora system as well. If you already have a network set up, talk to your administrator to find out if the IP addresses and host names ('one' and 'two') given in this guide need to be changed. If you just have an Internet connection, you should be fine because the IP addresses in this guide are in the 'private network' range.
Note that a few modifications to these directions will allow you to set up a cable connection between two network interface cards.
STEPS: SETTING UP A PARALLEL-PORT NETWORK UNDER LINUX
Under the X Window System, get to a terminal/shell window, and type 'su'.
After entering your root password, type 'cd /usr/local/sbin'.
Create these scripts with any text editor. Highlight the stuff in monospace, point into your text editor, and press the middle button of your mouse. This can be your wheel button, a regular middle button, or both the left and right button pressed simultaneously. Now, for the IP addresses and scripts. Alternatively, you can download the scripts here: plipscripts.tar.gz
NETWORK: 192.168.0.0
NETMASK: 255.255.255.255
COMPUTER #1 (SERVER): 192.168.0.1
COMPUTER #2 (CLIENT): 192.168.0.2
Script name: plip1on
#! /bin/sh
if [ `whoami` != 'root' ]
then
echo $0': You must be root to execute this script.'
exit 1
fi
rmmod lp
modprobe plip
#route add -net 192.168.0.0 netmask 255.255.255.0 dev plip0
ifconfig plip0 one pointopoint two up
#route add two plip0
portmap
rpc.mountd
rpc.nfsd
plipconfig plip0 nibble 10000 trigger 5000
Script name: plip2on
#! /bin/sh
if [ `whoami` != 'root' ]
then
echo $0': You must be root to execute this script.'
exit 1
fi
rmmod lp
insmod plip
#route add -net 192.168.0.0 netmask 255.255.255.255 dev plip0
ifconfig plip0 two pointopoint one up
#route add one plip0
portmap
rpc.mountd
rpc.nfsd
plipconfig plip0 nibble 10000 trigger 5000
Script name: plipoff
#! /bin/sh
if [ `whoami` != 'root' ]
then
echo $0': You must be root to execute this script.'
exit 1
fi
umount /mnt/plip
ifconfig plip0 down
rmmod plip
insmod lp
Copy these scripts to a floppy disk, USB flash drive, or other writable medium so you can copy them to the other computer. (The word 'media' is very often misused. Many people don't realize that 'media' is really the plural form of 'medium', so 'media' is often used as if it was singular.)
To make sure they are executable, you need to set the 'execute' permission. Do a 'chmod a+x plip*' on both computers.
We will now set up the directories that you wish to make accessible on the other computer. Still as root, type 'nano /etc/exports'. Then, use these lines as a guide to add your own lines. This example gives read & write permission to the /home directory:
# <directory> <machine and options>
/home two(rw)
Type 'exportfs -r' to make the changes to '/etc/exports' to take effect immediately. You will have to do this after modifying that file. If you don't, the changes will not take effect until you reboot, which is the Windows way of doing things...
Now, type 'nano /etc/hosts' and add these lines to the top of the file but after the first non-comment line:
192.168.0.1 one
192.168.0.2 two
Type 'mkdir -m 777 /mnt/plip'.
Repeat steps 6, 7, 8, and 9 for the other computer.
For best performance, you should tell Linux what the IRQ of your parallel port is. If 'parport_pc' is compiled as a module (type 'modinfo parport_pc' to find out) and your distribution is Debian, type 'nano /etc/modutils/parport', type 'options parport_pc io=io_port irq=irq', replacing io_port with the I/O port address (usually 0x378, 0x3bc, or 0x278) and irq with the IRQ of the parallel port, save and exit, and run 'update-modules' followed by 'reboot'. If 'parport_pc' is compiled as a module and your distribution is not Debian, then do the same, but add 'options parport_pc io=io_port irq=irq' to /etc/modules.conf instead of a separate file, and then reboot. Do this on both computers. By default, Linux doesn't probe parallel port IRQ's. When in IRQ-less mode, the computers ask the parallel port so many times per second for input/output. When IRQ's are enabled, the parallel port is able to interrupt the operating system so the operating system doesn't have to keep checking the parallel port, thus yielding better performance. NOTE: You do NOT have to do this with Fedora and possibly other distributions.
Now that you have everything set up, here's what you need to do whenever you want to use the link:
Plug the cable in. (duh!)
Log in to a console session as root (hint: CTRL-ALT-F1).
On the computer you want to use as the server, type 'plip1on'.
On the computer you want to use as the client, type 'plip2on'.
(Optional) From the server, type 'ping -c 10 two'. If you get an error message, then see the end of this guide for help.
(Optional) From the client, type 'ping -c 10 one'. If you get error messages, then see the end of this guide for help.
On the client, type 'mount one:directory /mnt/plip', substituting directory with one of the directories you marked as 'sharable' in /etc/exports on the server. For example, if you exported the
Log out! Log in as a normal user! If you mounted the /home directory from the server and you have at least one normal user account with the same name common to both computers, you should have no problem transferring files between the two computers. Remember that the server's shared directory is mounted on '/mnt/plip'.
When you're done, log in as root to a console session on both computers.
On both computers, type 'plipoff'. Start with the CLIENT!
Do you want to try running programs over the cable? Go to the section after the 'Trouble?' section!
TROUBLE?
If you're having trouble, first make sure the cable works... You can test it using File Maven for DOS (free-as-in-price), Micro$oft InterLink, LapLink for DOS or Windows, or Micro$oft Windows Direct Cable Connection (I once got it working, but, as I quit using Windows several months ago, I don't remember how to do it anymore. I do remember that it was kind of complicated.).
If it appears to be OK, then watch what 'plipxon' reports is the interface name (it looks like plip0, plip1, or plip2.) If it's different from plip0, then edit the scripts and change every occurrence of 'plip0' to what it is on your computer. (The number actually depends on the I/O port address of your parallel port, not just whether it's the first, second or third port.)
If you're getting timeout errors, a number of things could have caused them. I actually get a lot of timeout errors, but I haven't had any data loss, so I don't worry about it. Timeout errors usually mean that one of the computers is performing much slower than the other, and they're having to re-sync a lot. If you use fast (i.e., Pentium II or faster) computers, you probably won't have as many timeout errors as you would if you connected a slower computer to a faster one.
If you're getting a message that the parallel port doesn't have an IRQ, which is what I get, don't worry too much about it.
If nothing works, and you have an existing network, make sure that there are no computers named 'one' or 'two' and/or that have IP addresses 192.168.0.1 or 192.168.0.2 on your existing network. To check, disconnect both computers from the parallel-port network both using 'plipoff' and physically, and try these commands: 'ping -c 10 one', 'ping -c 10 two', 'ping -c 10 192.168.0.1', and 'ping -c 10 192.168.0.2'. If you get anything except errors, contact your administrator to find out what the PLIP addresses and/or names should be changed to.
Here's how to do remote logins and how to use the remote access features of the X Window System. To demonstrate that these instructions work, I am sitting at my Pentium II desktop system using my parallel-port network to run OpenOffice.org on my laptop, which is at the other end of the cable; OpenOffice.org is being displayed on my desktop system while it is running on my laptop. I first allowed my laptop to access my desktop's X server. Then, I did a remote login from an xterm using SSH. After that, I started OpenOffice.org from the remote shell.
Doing a remote login (using one computer as a terminal to the other):
Set up the link as described above. In this case, you do not have to mount the other computer's drive. It also doesn't matter which computer is 'one' and which computer is 'two'.
At a command prompt as any user, type 'ssh one' if you are sitting at 'two' or 'ssh two' if you are sitting at 'one'. This will prompt you for your account password on the other computer if you have an identically-named account on the other computer. If not, use the '-l' option with 'ssh' to specify which account you want to log in to with 'ssh'. If you get a 'ssh: command not found' error, go to http://www.openssh.org and download OpenSSH. If you received an error message about not being allowed to connect, and you're running Debian on the remote computer, you need to type 'dpkg-reconfigure ssh' as root on the remote computer and tell it to start 'sshd'.
If all went well, have fun! To quit the remote shell, type 'exit'.
Sharing your X session part 1: starting your programs on the computer on which it's going run:
Start the network. As above, it doesn't matter which computer is 'one' and which is 'two'.
Start up an X session on the computer on which you want the programs to display. You do not need X running on both computers, though it is fun to play with this when both are running X! You should be running this as a normal user!
In a terminal window, such as the Konsole or an xterm, you will need to use 'xhost'. If you want to share your X display with anyone (NOT recommended for security reasons if you're connected to the Internet or another large network), type 'xhost +' ('xhost -' undoes this). If you want just the other computer to be able to connect, use 'xhost +one' if you're sitting at two or 'xhost +two' if you are sitting at one.
From a command prompt as a normal user on the computer that is going to run the program, use this syntax: 'DISPLAY=name:0 command', replacing name with the name of the computer that is going to display the program and replacing command with the command you are going to run. For example, to run xterm on 'one' but to display it on 'two', type this on 'one': 'DISPLAY=two:0 xterm'.
Sharing your X session part 2: combining the remote login with sharing your X session (starting the program from the computer you wish to display it on, but the program is actually running on the other computer):
As usual, start the network. After this step, you will be doing everything from the computer you wish to display everything on.
In an xterm or the Konsole (or rxvt or any other terminal window), share your X session with the remote computer as described above using 'xhost'.
In the same terminal window, do a remote login using 'ssh' as described above.
In the remote shell, if you're using Bash (which is most likely the case), type 'export DISPLAY=name:0', replacing name with the name of the computer you're sitting at, which is either one or two.
Type the command to run the program you want to run over the network. If you want to keep the terminal window free (for example, to run multiple programs from the same shell), you can put an & at the end of the command.
Note that programs that require the 'xvidmode' and/or the 'xshm' extensions will probably not work over the network!