In addition to networking using ethernet and local loophack there are also several arrangements for point to point links between pairs of machines using RS232 serial or Centronics parallel ports.
The first one to look at, and probably the best, is PPP which operates over a standard RS232 serial link. PPP stands for point to point protocol and it is a standard internet protocol.
The PPP software comes in two parts. The first part is built into the kernel which means that you will need to build kernels for the machines at each end of the link which have PPP configured into them. This is just a matter of saying yes to the PPP option when running make config. The second part is a daemon called pppd which will need to be running on both machines when the PPP link is established.
The most common use of PPP is on modem dial-up connections and that is the setup we will consider here. Suppose that you have a Linux machine at home and you want to dial up another Linux machine at a remote site which is attached to the Internet. When the PPP link is set up this arrangement will give you full Internet access from your machine at home.
The first thing to consider is the setup at the remote site. The simplest way to get this working is to create a PPP login on that machine specifically for your dial-in purposes. Start by adding a line to the password file such as the following:
ppp: off :700:700:PPP account:/home/ppp:/home/ppp/ppplogin
You should insert your own ppp account name, uid, gid and home directory in place of my examples. You should then create the account home directory /home/ppp (or whatever yours is called) and change its ownership appropriately:
# mkdir /home/ppp # chown ppp. /home/ppp
Notice that the password line you added specifies the login 'shell' as:
/home/ppp/ppplogin
This isn't actually a shell but a script that will be used to start up the pppd daemon on the remote system. Typical contents for this file would be:
#! /bin/sh exec /usr/sbin/pppd 38400 modem asyncmap 0 proxyarp\ 194.61.21.2:194.61.21.49
which probably requires some explanation. The first line specifies that the rest of the script should be executed by /bin/sh. The other line (a \ on the end of a line means that the next line is just a continuation of the current line) runs the exec command which will replace the program in the current process with the specified program (here pppd). The rest of the line is just a set of command line parameters to pppd.
The first parameter (38400) is the speed at which pppd should drive the serial interface to the modem. The modem parameter specifies that pppd should use the modem control lines in the RS232 interface to make sure that the PPP connection is broken cleanly when you hang up the phone line at the local end.
The next parameter is asyncmap 0. Depending upon the precise details of your serial connection to the remote machine, it is possible that your connection uses some of the ASCII control codes (codes 0 to 31) for special purposes, so that these codes are not available to be transmitted as part of a data packet. In this case you need to tell pppd not to use these control codes but to replace them with special two character escape sequences. The number after the asyncmap keyword is a 32-bit hexadecimal number, where each bit that is set corresponds to an ASCII code which pppd must not use. If you have a serial link which is 8-bit clean, then asyncmap 0 specifies that none of the ASCII control codes needs to be escaped. If no asyncmap option is given then the default is to escape all 32 control codes.
The physical ethernet that sits under a TCP/IP network does not know about IP address numbers. It routes its data packets on the basis of hardware ethernet addresses. The protocol that translates IP address numbers to hardware ethernet addresses is called the Address Resointion Protocol (ARP). A typical machine ARP table can he displayed with the arp command, as follows:
# arp -a Address HW type HW address Flags Mask 194.61.21.1 lOMbps Ethernet 08:00:2B:F7:E2:44 C * 194.61.21.6 lOMbps Ethernet 08:00:2B:57:89:CE C * 194.61.21.252 lOMbps Ethernet AA:00:04:40:OA:OG C * 194.61.21.50 lOMbps Ethernet 00:40:95:85:0G:B5 CMP * 194.61.21.49 lOMbps Ethernet 00:40:95:85:OC:B5 CMP *
The proxyarp parameter to pppd will add an entry to the arp table on the remote machine which contains the IP address number of your local machine listed along side the hardware ethernet address of the remote machine. This makes the remote machine respond with its own hardware ethernet address whenever it sees requests for the hardware ethernet address of your local machine. IP packets addressed to your local machine will then be picked up by the remote machine and routed over the PPP link to your local machine. The last two entries in the example arp table are proxyarp entries, both sharing the hardware ethernet address of the remote machine but having the IP address numbers of two machines at the local end of the PPP link.
The last parameter to the pppd command specifies the IP address numbers of the remote machine and your local machine respectively, separated by a colon.
There are other options which can be specified, especially if you want to run pppd with authentication of machines switched on, for extra security. The details of these options can be found in the pppd manual page.
The last thing that needs to be done at the remote site is to set an appropriate password on the ppp account.
The setup on the local machine is relatively straightforward. It consists of writing a shell script which will run the pppd daemon on your local machine and then dial the remote machine over your modem and log you into its ppp login. The simplest way to do this is to use pppd in conjunction with a dial-up program called chat.
The pppd and chat programs are automatically loaded, along with several other useful programs and scripts, when you install the ppp package from your Linux distribution.
A typical script to connect to the remote machine could be:
/usr/sbin/pppd connect '/usr/sbin/chat "" ATDT334566 CONNECT "" ogin: ppp word: PA55word' /dev/modem 38400 modem defaultroute -ip 194.61.21.49:194.61.21.233
This script should all be entered as a single long line in a text file and made executable with chmod. This script just runs the pppd command and passes it various parameter values. The first command line parameter to pppd is connect cmd, where cmd is a command or script to run to establish the modem link.
In this example, cmd is everything between the single quotes ('). The contents of the quotes is a call to the chat program with all the parameters it requires to operate. The parameters to the chat program specify a dialogue which is to take place over the serial line to which the modem is attached. This dialogue takes the form of pairs of expect and send strings. As an expect string, a pair of empty double quotes ("") means expect nothing. The following send string (ATDT334566) is a Hayes-compatible modem command to tell the local modem to dial the number of the remote modem.
The next expect/send string pair is CONNECT "". This says expect to receive the CONNECT string and when that happens send a newline down the line (as a send string, a pair of empty quotes mean send a newline). The word CONNECT is sent by the remote modem when it has answered the local modem's ring and after it has negotiated an operating speed.
In response to the newline, the remote machine should send us a login: prompt and wait for a login name to be sent. Therefore, the next expect/send string pair is ogin: ppp. Using ogin: allows the login prompt to start with either an upper or lower case letter. So, the string pair says: expect to receive a string from the remote system ending in ogin: and when you get it respond with the ppp login name.
Having entered a login name, the remote system should ask for the associated password. Therefore, the last string pair says: expect to receive a string from the remote system ending in word: and respond to it by sending the password to the ppp login (PA55word in this example).
If all goes according to plan then the remote system should now run its ppplogin script which, as you have already seen, will activate the pppd daemon on the remote machine.
The next three parameters to pppd in the local startup script specify the device special file associated with the local modem, the baud rate at which to 'talk' to the modem, and an instruction to use modem control lines in the serial link.
The next parameter (defaultroute) instructs pppd to add a default route to the kernel's routing table which sends network packets for any machines not already specified in the routing table over the PPP link to the remote machine. The defaultroute option will only work if the kernel's routing table doesn't already contain a default entry. This means that in order to use this option, your rc.inet1 file should not contain the last line given in our previous example file, which sets up a default route to your gateway machine. In our PPP scenario the remote machine will be the gateway to the rest of the world and pppd will set up the default route to this machine when the link is established.
The final parameters to pppd (-ip 194.61.21.49:194.61.21.233) tell it not to negotiate IP address numbers with the remote machine but to use the two IP numbers specified, for the local machine and remote machine respectively.
Once the PPP link is established it will operate just as though your local machine was connected directly to the Internet. When you have finished with the link, you just execute the supplied script called ppp-off and the link will be terminated and the systems reset ready for the next time the link is required.
Extra information on PPP is available in the pppd and chat manual pages and in the PPP-HOWTO document supplied as part of the Linux documentation.