-->
Previous Table of Contents Next


Using dip with Static IP Addresses

Assigning individual IP addresses to each machine that uses a SLIP provider is very common. When your machine initiates a SLIP link to the remote host, dip configures the SLIP interface with this known address. Listing 29.1 is a dip script using static IP addresses for initiating a SLIP link from linux2.burwell.com to linux1.burwell.com.

Listing 29.1 A Sample dip Script for Using Static IP Addresses over SLIP


# Connect linux2 to linux1 using static IP Addresses

# Configure Communication Parameters

port /dev/cua1 # use modem on /dev/cua1 serial line

speed 38400

modem HAYES

reset                             # Send initialization string to modem

flush                             # Throw away modem response



get $local linux2                 # Set local IP address

get $remote linux1                # Set remote IP address



# Dial number for linux1 modem

dial 555-1234

if $errlvl != 0 goto error        # If the dial command fails, error out

wait CONNECT 75

if $errlvl != 0 goto error        # If we don’t get a CONNECT string

# from the modem, error out



send \r\n                         # Wake up login program

wait ogin: 30                     # Wait 30 seconds for login prompt

if $errlvl != 0 goto error        # Error out if we don’t get login prompt

send Slinux2\n                    # Send SLIP login name for linux2

wait ssword: 5                    # Wait 5 seconds for password prompt

if $errlvl != 0 goto error        # Error out if we don’t get password

send be4me\n                      # Send password

wait running 30                   # Wait for indication that SLIP is up

if $errlvl != 0 goto error        # Otherwise error out



# We’re in, print out useful information

print Connected to $remote with address $rmtip

default                           # Make this link our default route

mode SLIP                         # Turn on SLIP mode on our end



# Error routine in case things don’t work

error:

print SLIP to $remote failed.


TIP:  Tracking SLIP accounts can be difficult. Traditionally, UNIX user accounts are assigned login names with all lowercase letters. Using the client machine name with a capital S added to the front as the login name for that machine’s SLIP account makes tracking it easier and avoids login name collisions with normal user accounts.

The script in Listing 29.1 initializes the modem and sets the local and remote IP addresses for the SLIP link. If you use host names here, dip resolves them to their IP address equivalents. The script then dials the modem and works its way through the login sequence. When logged in and sure that the SLIP link is up on the remote host, the script has dip configure the routing table and then switch the serial line into SLIP mode.

If an error occurs, the error routine at the end of the script prints a warning message and aborts the script. dip is excellent about leaving the serial line in a reasonable state when it’s done with it.

Using dip with Dynamic IP Addresses

As SLIP became more popular, the task of managing IP addressees for SLIP clients got more and more difficult. This problem got worse when terminal servers supporting SLIP came into use. Now, you might be assigned any one of a range of IP addresses, depending on which port the terminal server received your call. This led to changes in dip that captured IP address information from the incoming data on the serial line. Listing 29.2 is a dip script that captures the local and remote IP addresses from the serial line.

Listing 29.2 A Sample dip Script for Dynamic IP Addresses


# Connection script for SLIP to server with dynamic IP address

# assignment. The terminal server prints out:

#

# remote address is XXX.XXX.XXX.XXX the local address is YYY.YYY.YYY.YYY



# Set the desired serial port and speed.

port /dev/cua1

speed 38400



# Reset the modem and terminal line.

Reset

flush



# Prepare for dialing.

dial 555-1234

if $errlvl != 0 goto error

wait CONNECT 60

if $errlvl != 0 goto error



# We are connected. Login to the system.

login:

wait name: 10                         # Log in to system

if $errlvl != 0 goto error

send Slinux2\n                        # Send user ID

wait ord: 10

if $errlvl != 0 goto error

send be4me\n                          # Send password

if $errlvl != 0 goto error

get $remote remote 10                 # Get remote IP address

if $errlvl != 0 goto error

get $local remote 10                  # Get local IP address

if $errlvl != 0 goto error

done:

print CONNECTED to $remote with address $rmtip we are $local

default                               # Set routing

mode SLIP                             # Go to SLIP mode

goto exit

error:

print SLIP to $host failed.

exit

The script in Listing 29.2 uses get $remote remote 10 to watch the serial line and to capture the first thing that looks like an IP address in the $remote variable. The command times out in 10 seconds with an error if it doesn’t see an IP address.

Using diplogin to Provide SLIP Service

The dip program automates starting SLIP links from the client machine. Linux also supports incoming dial-up SLIP links. A few packages are available for doing this as well. You use the diplogin program here, which is really just another name for dip.

Providing SLIP service to others requires that you create a specific account for each person on your Linux box and configure that account correctly. You also need to write an /etc/diphosts file with appropriate information for each host that you’re providing SLIP service for.

Creating SLIP Accounts

You can manually create the SLIP account or use the adduser script with appropriate responses to each question. Here’s an example /etc/passwd entry for linux2.burwell.com in the passwd file on linux1.burwell.com:


Slinux2:IdR4gDZ7K7D82:505:100:linux2 SLIP Account:/tmp:/sbin/diplogin

It’s recommended that /tmp be used as the home directory for SLIP accounts to minimize security risks by preventing SLIP users from writing files into sensitive areas of your file system by default. Make sure that you use the correct path to the diplogin program.


Previous Table of Contents Next