Have you ever wanted to connect your computer to a network? Perhaps you have two computers that you want to run Mosaic, ftp, or X11 between? Do you want to let your friends experience the full power of your magnificent new Linux box? SLIP is one way you can do all these things.
Have you ever wanted to connect your computer to a network? Perhaps you have two computers that you want to run Mosaic, ftp, or X11 between? Do you want to let your friends experience the full power of your magnificent new Linux box? SLIP is one way you can do all these things.
by Warren Baird
SLIP (Serial Line Internet Protocol) is a protocol that allows you to make a TCP/IP connection over a serial line. TCP/IP stands for Transmission Control Protocol/Internet Protocol, and is the protocol used on the Internet and on most local ethernets. Many common Unix programs (like X11, Mosaic, gopher, IRC, talk, telnet and ftp) use TCP/IP to communicate. If you want to use programs like this to talk to the rest of the world over the Internet, or if you want to connect two (or more) local machines, SLIP is a good option.
There are actually two variants of SLIP: normal SLIP, and CSLIP (which stands for Compressed SLIP). CSLIP compresses various TCP/IP headers to give a higher throughput on a serial line. (Note: CSLIP doesn't compress the data that is being transmitted, just the headers added by TCP/IP.) Unfortunately not all systems support it. Even with CSLIP, the throughput on a serial line is quite low compared to ethernet and other Local Area Networks (LANs). It's possible to run high bandwidth applications like Mosaic and xv over a SLIP link, but the response times may be quite low.
One of the most common uses of SLIP is to connect to a commercial Internet provider. There are many companies that provide full access to the Internet by allowing you to make a SLIP connection using a modem.
Another use of SLIP is to connect two or more machines using a null-modem cable. Since SLIP is implemented for many different platforms, you can connect your Linux box to many different types of systems. For example, I have an Amiga 2000 connected to my 386 running Linux 1.0.8.
If you are really ambitious, you can even set up your Linux box as a SLIP server. You could do this to give your friends access to your machine, or as part of a BBS setup.
Configuring something like SLIP under Unix is always very dependent on the flavor and version of Unix that you are running. The details given here are for the Slackware 1.2.0 (Linux 1.0.8) distribution. The exact details may vary somewhat with other versions of Linux and other distributions.
There is a whole host (no pun intended) of files that control the behavior of a Unix system, and a number of them need to be modified to set up SLIP.
Looking up host names: /etc/hosts, /etc/resolv.conf, and /etc/host.conf
The /etc/hosts file maps hostnames (for example acme.gadgets.com) to IP addresses (for example 129.50.49.234). If you are using SLIP to connect two local machines, your /etc/hosts file only needs to contain the hostnames and IP addresses of your two machines. If you are connected to a larger network, but talk to only a few sites, you can put their names and IP addresses in your /etc/hosts file.
If you are connecting to many hosts (or using a program like Mosaic that connects to many hosts), you'll need to tell your system who it should ask to find IP addresses for unknown hostnames. There are systems called nameservers that will lookup an IP address for a given hostname. The /etc/resolv.conf file tells your system which nameserver(s) to use. It also tells your system what your domain name is. The domain name is your full hostname with the machine name removed—for example, if your hostname is acme.gadgets.com, your domain name would be gadgets.com.
If your domain name is gadgets.com, and you have a nameserver at the IP address 128.34.54.27, your /etc/resolve.conf file could read:
domain gadgets.com nameserver 128.34.54.27
It's possible to list multiple nameservers in a resolve.conf file. The /etc/host.conf file tells the system what order it should use to lookup hostnames. Normally this file contains
order hosts,bind multi on
which tells the system to check the /etc/hosts file first, and then to try any nameservers it knows about.
The names of the Internet startup files vary even between different Linux distributions. On most Linux systems the files used are /etc/rc.d/rc.inet1 and /etc/rc.d/rc.inet2. Whichever startup file is used, there are a number of daemons that must be running for any TCP/IP program to work. The NET-2 HOWTO describes which daemons are available, and what they do. Minimally, you need to have the inetd daemon running. The inetd daemon coordinates the startup of many other TCP/IP daemons.
Additionally, if you are setting up a permanent link to another computer over a dedicated line, you may want to actually initialize the SLIP link in the startup files.
There are two primary ways that you can connect to another machine using SLIP. If it is a link over a leased line, or a null-modem cable, you should use slattach. If you are connecting over a modem (or allowing other computers to connect to yours over a modem) you should use dip.
To configure a SLIP connection with slattach, you need to execute the commands:
/sbin/slattach -p prot -s baud dev & /sbin/ifconfig sl0 iplocal pointtopoint ipremote up /sbin/route add default dev sl0 &
where prot is the protocol to use (normally slip or cslip), baud is the baud rate to connect at, dev is the device to use, iplocal is your local IP address, and ipremote is the remote IP address. For example, if your IP address is 129.45.43.76, and you want to connect to a machine with IP address 129.50.49.234 using slip at 19200 baud on /dev/ttyS1 (COM2), you would give the commands:
/sbin/slattach -p slip -s 19200 /dev/ttyS1 & /sbin/ifconfig sl0 129.45.43.76 pointtopoint\ 129.50.49.234 up /sbin/route add default dev sl0 &
These commands can either be added to a startup file, if you always want the SLIP connection to be initialized, or you can create a simple shell script to execute them for you. You'll have to run this shell script as root for slattach to work. If, instead of a shell script, you create a C or perl program owned by root, you can make it setuid (always run as root) by typing chmod u+s file (where file is the name of the program). Take note of the “&” following the /sbin/slattach line. Older versions of the NET-2 HOWTO omitted the ampersand, which caused Linux to lock up when booted if the commands were added to the startup files.
The dip program is a little more complicated to use. To use it to connect to another machine, you must create a script file telling dip how to call the machine, log onto it, and start slip (if slip isn't started automatically). The NET-2 HOWTO and the dip(8) man page both give sample dip scripts (dip(8) means that the man page for dip is in chapter 8 of the man pages, so you can read the man pages with the command man 8 dip). Dip can also be used to allow other people to connect to your machine using SLIP. To do this, you must create a special userid that has dip as its shell. Instructions for doing this are in the dip(8) man page.
Troubleshooting: Some common problems and how to fix them
Linux locking up at boot time
As I mentioned before, if you start slattach in your system startup files, you must add an ampersand (“&”) after the slattach line to run slattach in the background. Otherwise your system will lock up when you reboot.
Packets disappear without a trace
There can be many causes of this. The first thing to check is that your serial link is correct. If you are using a null-modem cable, make sure that it's plugged in at each end. If you are connecting over a modem, make sure that the modem is working correctly. If you are using a null-modem cable, and you have easy access to both ends of the link, try starting a terminal program on one end, and see if anything shows up if you ping the machine running the terminal program. If garbage appears in the terminal program, then you know that your serial link is working.
There seems to be a problem with CSLIP in some versions of Linux. If you are using CSLIP and packets seem to be disappearing, try using SLIP instead.
Unknown host errors occur
The first thing to do is to try using an IP address instead of a hostname. If you were trying to type ping acme when you got the Unknown host error, find the IP address of the machine acme, and ping it instead. For example, if acme has an IP address of 128.155.123.6, type
ping 128.155.123.6
instead. If using the IP address works, you have a problem with translating hostnames into IP addresses. Make sure your /etc/hosts file has a correct entry for your hostname, or if you are using a nameserver, make sure that your system isn't having trouble contacting the nameserver. As a temporary fix, adding an entry for the hostname into your /etc/hosts should solve the problem.
If the IP address doesn't work either, you may need to use the route command to tell your system how to find the remote system. The NET-2 HOWTO and the route(8) man page show you how to use the route command.
“Network is Unreachable” Errors
If you see messages like:
ping: sendto: Network is unreachable
when you are trying to use ping, the most likely cause is incorrect routing. Using the /sbin/route command by itself shows you the current routing table. If the routing table is configured correctly, you should see something like:
Destination Gateway Genmask Flags Metric Ref Use Iface 127.0.0.0 * 255.0.0.0 U 0 0 0 lo default * * U 0 0 3 sl0
If the last line isn't present, and you are using slattach, make sure that the /sbin/route line described above has been used. If the last line is present, or if you are using dip, see the NET-2 HOWTO, and the dip(8) and route(8) man pages.
What alternatives are there to SLIP?
There are other programs that provide functionality similar to SLIP. Here is a brief overview of some of the most popular.
If you want to connect two local machines, the best way is to use ethernet, which gives far higher throughput than a serial link. Unfortunately, ethernet cards can be fairly expensive. If you can't afford a pair of ethernet cards, or if you want to connect to another machine using a modem, there are other options. SLIP isn't the only protocol that provides TCP/IP (or TCP/IP-like) connectivity over a serial line. PPP (Point-to-Point Protocol) is a newer protocol that serves a purpose similar to SLIP. PPP was designed specifically to be an Internet standard, and is documented in a number of Internet RFCs (Requests for Comments). This design process makes PPP more standardized than SLIP. Additionally, PPP was designed to address known weaknesses of SLIP in areas of security and robustness. Unfortunately, since PPP is a lot newer and more difficult to implement than SLIP, it isn't available on as many systems as SLIP is.
Another common program is term. Term does not provide a full TCP/IP connection, but it does allow some similar functionality. It will let you run multiple terminal sessions over a single serial line (like SLIP does), but it won't let you run TCP/IP programs (like ftp, Mosaic, or telnet) on your Linux box without recompiling them to include term support. It will let you display remote X11 programs on your local machine, so you could, for instance, run Mosaic remotely and display it on your Linux box. You can also use term to connect ports on the local machine to ports on the remote machine, which allows you to read news and mail on your Linux box. The biggest advantage that term has over SLIP is that it can be set up on both ends without requiring root privileges. Unlike SLIP, you don't have to change any system configuration files to use term.
PLIP (Parallel Line Internet Protocol) is a SLIP-like protocol that runs over a parallel line. PLIP is only intended to connect two machines locally, but it gives higher transfer rates than a comparable SLIP connection at the cost of using more CPU time than SLIP. To use PLIP you need a special parallel cable, like those used in a number of DOS PC-to-PC file transfer packages.
If you only want to connect two local machines, you might want to consider just running a terminal program over a serial link. The configuration is certainly simpler than setting up SLIP (you need to start a getty process on the appropriate serial port), and if you run a program like screen (which allows multiple sessions in a manner similar to virtual consoles), you might get all the functionality that you need. Certain operations (like transferring files) are more efficient when just using a terminal program, since there isn't the overhead imposed by SLIP. The disadvantage is that you can't run X11, or any other TCP/IP programs through a terminal program.
Recommended reading
The Serial and NET-2 HOWTOs have a lot of useful information about networking and serial links with Linux in general. The NET-2 HOWTO has an entire section devoted to SLIP. The HOWTO files can be found in /usr/doc/faq/howto on most Linux systems, or on the ftp site sunsite.unc.edu in the directory /pub/Linux/docs/HOWTO.
The Usenet newsgroups comp.os.linux.help and comp.os.linux.admin both discuss SLIP quite regularly. Reading these newsgroups will often answer simple questions about SLIP (and many other things). It's a good idea to read the appropriate HOWTOs and FAQs (Frequently Asked Question lists) before asking any questions, since some people become quite irate when you ask questions that are answered somewhere else.
There are a number of books that address administrating TCP/IP connections. The best I have come across is TCP/IP Network Administration, by Craig Hunt, published by O'Reilly & Associates, ISBN 0-937175-82-X.
SLIP isn't the newest TCP/IP protocol around, but it is commonly available and is usually quite stable. It's a good choice for many serial TCP/IP links.
Warren Baird runs Linux on a 386 DX-33, and has been hacking various flavours of Unix for five years. He is on the verge of getting a B.Math joint-honours degree in Computer Science and Com-binatorics & Optimization at the University of Waterloo, Ontario, Canada. He can be reached at wjbaird@uwaterloo.ca , or baird@asc.on.ca .