Linux Networking/SLIP client
SLIP devices are named `sl0', `sl1' etc. with the first device configured being assigned `0' and the rest incrementing sequentially as they are configured.
Kernel Compile Options:
Network device support ---> [*] Network device support <*> SLIP (serial line) support [ ] CSLIP compressed headers [ ] Keepalive and linefill [ ] Six bit SLIP encapsulation
SLIP (Serial Line Internet Protocol) allows you to use tcp/ip over a serial line, be that a phone line with a dialup modem, or a leased line of some sort. Of course to use SLIP you need access to a SLIP- server in your area. Many universities and businesses provide SLIP access all over the world.
Slip uses the serial ports on your machine to carry IP datagrams. To do this it must take control of the serial device. Slip device names are named sl0, sl1 etc. How do these correspond to your serial devices? The networking code uses what is called an ioctl (i/o control) call to change the serial devices into SLIP devices. There are two programs supplied that can do this, they are called dip and slattach
dip (Dialup IP) is a smart program that is able to set the speed of the serial device, command your modem to dial the remote end of the link, automatically log you into the remote server, search for messages sent to you by the server and extract information for them such as your IP address and perform the ioctl necessary to switch your serial port into SLIP mode. dip has a powerful scripting ability and it is this that you can exploit to automate your logon procedure.You can find it at: metalab.unc.edu.
To install it, try the following:
user% tar xvzf dip337o-uri.tgz user% cd dip-3.3.7o user% vi Makefile root# make install
The Makefile assumes the existence of a group called uucp, but you might like to change this to either dip or SLIP depending on your configuration.
slattach as contrasted with dip is a very simple program, that is very easy to use, but does not have the sophistication of dip. It does not have the scripting ability, all it does is configure your serial device as a SLIP device. It assumes you have all the information you need and the serial line is established before you invoke it. slattach is ideal to use where you have a permanent connection to your server, such as a physical cable, or a leased line.
When do I use which ?
You would use dip when your link to the machine that is your SLIP server is a dialup modem, or some other temporary link. You would use slattach when you have a leased line, perhaps a cable, between your machine and the server and there is no special action needed to get the link working. See section `Permanent Slip connection' for more information.
Configuring SLIP is much like configuring an Ethernet interface (read section `Configuring an ethernet device' above). However, there are a few key differences.
First of all, SLIP links are unlike ethernet networks in that there is only ever two hosts on the network, one at each end of the link. Unlike an ethernet that is available for use as soon are you are cabled, with SLIP, depending on the type of link you have, you may have to initialize your network connection in some special way.
If you are using dip then this would not normally be done at boot time, but at some time later, when you were ready to use the link. It is possible to automate this procedure. If you are using slattach then you will probably want to add a section to your rc.inet1 file. This will be described soon.
There are two major types of SLIP servers: Dynamic IP address servers and static IP address servers. Almost every SLIP server will prompt you to login using a username and password when dialing in. dip can handle logging you in automatically.
Static SLIP server with a dialup line and DIP.
A static SLIP server is one in which you have been supplied an IP address that is exclusively yours. Each time you connect to the server, you will configure your SLIP port with that address. The static SLIP server will answer your modem call, possibly prompt you for a username and password, and then route any datagrams destined for your address to you via that connection. If you have a static server, then you may want to put entries for your hostname and IP address (since you know what it will be) into your /etc/hosts. You should also configure some other files such as: rc.inet2, host.conf, resolv.conf, /etc/HOSTNAME and rc.local. Remember that when configuring rc.inet1, you don't need to add any special commands for your SLIP connection since it is dip that does all of the hard work for you in configuring your interface. You will need to give dip the appropriate information and it will configure the interface for you after commanding the modem to establish the call and logging you into your SLIP server. If this is how your SLIP server works then you can move to section `Using Dip' to learn how to configure dip appropriately.
Dynamic SLIP server with a dialup line and DIP.
A dynamic SLIP server is one which allocates you an IP address randomly, from a pool of addresses, each time you logon. This means that there is no guarantee that you will have any particular address each time, and that address may well be used by someone else after you have logged off. The network administrator who configured the SLIP server will have assigned a pool of address for the SLIP server to use, when the server receives a new incoming call, it finds the first unused address, guides the caller through the login process and then prints a welcome message that contains the IP address it has allocated and will proceed to use that IP address for the duration of that call.
Configuring for this type of server is similar to configuring for a static server, except that you must add a step where you obtain the IP address that the server has allocated for you and configure your SLIP device with that.
Again, dip does the hard work and new versions are smart enough to not only log you in, but to also be able to automatically read the IP address printed in the welcome message and store it so that you can have it configure your SLIP device with it. If this is how your SLIP server works then you can move to section `Using Dip' to learn how to configure dip appropriately.
As explained earlier, dip is a powerful program that can simplify and automate the process of dialing into the SLIP server, logging you in, starting the connection and configuring your SLIP devices with the appropriate ifconfig and route commands. Essentially to use dip you'll write a `dip script', which is basically a list of commands that dip understands that tell dip how to perform each of the actions you want it to perform. See sample.dip that comes supplied with dip to get an idea of how it works. dip is quite a powerful program, with many options. Instead of going into all of them here you should look at the man page, README and sample files that will have come with your version of dip.
You may notice that the sample.dip script assumes that you're using a static SLIP server, so you know what your IP address is beforehand. For dynamic SLIP servers, the newer versions of dip include a command you can use to automatically read and configure your SLIP device with the IP address that the dynamic server allocates for you. The following sample is a modified version of the sample.dip that came supplied with dip337j-uri.tgz and is probably a good starting point for you. You might like to save it as /etc/dipscript and edit it to suit your configuration:
# # sample.dip Dialup IP connection support program. # # This file (should show) shows how to use the DIP # This file should work for Annex type dynamic servers, if you # use a static address server then use the sample.dip file that # comes as part of the dip337-uri.tgz package. # # # Version: @(#)sample.dip 1.40 07/20/93 # # Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> # main: # Next, set up the other side's name and address. # My dialin machine is called 'xs4all.hacktic.nl' (== 184.108.40.206) get $remote xs4all.hacktic.nl # Set netmask on sl0 to 255.255.255.0 netmask 255.255.255.0 # Set the desired serial port and speed. port cua02 speed 38400 # Reset the modem and terminal line. # This seems to cause trouble for some people! reset # Note! "Standard" pre-defined "errlevel" values: # 0 - OK # 1 - CONNECT # 2 - ERROR # # You can change those grep'ping for "addchat()" in *.c... # Prepare for dialing. send ATQ0V1E1X4\r wait OK 2 if $errlvl != 0 goto modem_trouble dial 555-1234567 if $errlvl != 1 goto modem_trouble # We are connected. Login to the system. login: sleep 2 wait ogin: 20 if $errlvl != 0 goto login_trouble send MYLOGIN\n wait ord: 20 if $errlvl != 0 goto password_error send MYPASSWD\n loggedin: # We are now logged in. wait SOMEPROMPT 30 if $errlvl != 0 goto prompt_error # Command the server into SLIP mode send SLIP\n wait SLIP 30 if $errlvl != 0 goto prompt_error # Get and Set your IP address from the server. # Here we assume that after commanding the SLIP server into SLIP # mode that it prints your IP address get $locip remote 30 if $errlvl != 0 goto prompt_error # Set up the SLIP operating parameters. get $mtu 296 # Ensure "route add -net default xs4all.hacktic.nl" will be done default # Say hello and fire up! done: print CONNECTED $locip ---> $rmtip mode CSLIP goto exit prompt_error: print TIME-OUT waiting for sliplogin to fire up... goto error login_trouble: print Trouble waiting for the Login: prompt... goto error password:error: print Trouble waiting for the Password: prompt... goto error modem_trouble: print Trouble occurred with the modem... error: print CONNECT FAILED to $remote quit exit: exit
The above example assumes you are calling a dynamic SLIP server, if you are calling a static SLIP server, then the sample.dip file that comes with dip337j-uri.tgz should work for you.
When dip is given the get $local command it searches the incoming text from the remote end for a string that looks like an IP address, ie strings numbers separated by `.' characters. This modification was put in place specifically for dynamic SLIP servers, so that the process of reading the IP address granted by the server could be automated.
The example above will automatically create a default route via your SLIP link, if this is not what you want, you might have an ethernet connection that should be your default route, then remove the default command from the script. After this script has finished running, if you do an ifconfig command, you will see that you have a device sl0. This is your SLIP device. Should you need to, you can modify its configuration manually, after the dip command has finished, using the ifconfig and route commands.
Please note that dip allows you to select a number of different protocols to use with the mode command, the most common example is cSLIP for SLIP with compression. Please note that both ends of the link must agree, so you should ensure that whatever you select agrees with what your server is set to.
The above example is fairly robust and should cope with most errors. Please refer to the dip man page for more information. Naturally you could, for example, code the script to do such things as redial the server if it doesn't get a connection within a prescribed period of time, or even try a series of servers if you have access to more than one.
Permanent SLIP connection using a leased line and slattach.
If you have a cable between two machines, or are fortunate enough to have a leased line, or some other permanent serial connection between your machine and another, then you don't need to go to all the trouble of using dip to set up your serial link. slattach is a very simple to use utility that will allow you just enough functionality to configure your connection.
Since your connection will be a permanent one, you will want to add some commands to your rc.inet1 file. In essence all you need to do for a permanent connection is ensure that you configure the serial device to the correct speed and switch the serial device into SLIP mode. slattach allows you to do this with one command. Add the following to your rc.inet1 file:
# # Attach a leased line static SLIP connection # # configure /dev/cua0 for 19.2kbps and cslip /sbin/slattach -p cslip -s 19200 /dev/cua0 & /sbin/ifconfig sl0 IPA.IPA.IPA.IPA pointopoint IPR.IPR.IPR.IPR up # # End static SLIP. Where: IPA.IPA.IPA.IPA represents your IP address. IPR.IPR.IPR.IPR represents the IP address of the remote end.
slattach allocates the first unallocated SLIP device to the serial device specified. slattach starts with sl0. Therefore, the first slattach command attaches SLIP device sl0 to the serial device specified and sl1 the next time, etc. slattach allows you to configure a number of different protocols with the -p argument. In your case you will use either SLIP or cSLIP depending on whether you want to use compression or not. Note: both ends must agree on whether you want compression or not.