Linux PPP/SLIP Configuration

WARNING: This Linux configuration document is long. You may wish to to download the ASCII version (lxppptxt.zip or linuxppp.txt.gz) or the Postscript version (lxpppps.zip or linuxppp.ps.gz), and print it out for reference while you're setting up networking.


This file is intended to help those interested in getting SLIP or PPP running between their Linux box and Internet Nebraska. While numbers and settings are specifically tailored to the Internet Nebraska system, it should be trivial to put this information to use on another service.

Acknowledgments

This Document was written by Steve Weaver (sweaver@inetnebr.com). Much of the PPP information was generously contributed by Jeff McCombs (keyoke@inetnebr.com).

I'd also like to thank Terry Dawson (terryd@extro.ucc.su.oz.au) for his excellent NET-2-HOWTO document and Ian Goldberg (iagoldbe@csclub.uwaterloo.edu) for his "PPP Primer for Linux."

Disclaimer

The techniques described in this document are intended only as a guide. They work for me, but they are not guaranteed to work for anyone else. If you do have any problems, email me at sweaver@inetnebr.com. I will attempt to help you (to the best of my ability) and I will include the information in the next release (if there is one.) Another good source of information is the newsgroup comp.os.linux.networking.

Requirements

In order to use SLIP or PPP with Linux, it is necessary to build SLIP and/or PPP support into the kernel. I also suggest that you have a recent version of the kernel. If you have version 1.2.0 or later and are sure that you have SLIP and/or PPP support built into the kernel (It will say at bootup), then you will not need to re-compile your kernel.

If you have an older kernel or don't have networking support, I strongly suggest that you get the latest kernel version and compile it yourself. The latest stable kernel is available at:

ftp.cdrom.com:/pub/linux/sunsite/kernel/v1.2/linux-1.2.x.tar.gz

where x is the minor revision number. You should get the newest one they have there, as it's more likely to incorporate more bug-fixes than earlier versions. At the time of this writing, the latest version is 1.2.13.

The README included with the kernel source describes in detail how to compile the kernel, if you are unfamiliar with doing so.

The important thing to remember when compiling the kernel is to include support for everything you need to get SLIP/PPP working. The following will give you an idea of how to configure the kernel for your setup.

       *
       * General setup
       *
        ...
        ...
       Networking support (CONFIG_NET) [y] y
        ...
        ...
In the General setup section, you MUST answer y to networking support.

       *
       * Networking options
       *
       TCP/IP networking (CONFIG_INET) [y]
       IP forwarding/gatewaying (CONFIG_IP_FORWARD) [n]
       IP multicasting (CONFIG_IP_MULTICAST) [n]
       IP firewalling (CONFIG_IP_FIREWALL) [n]
       IP accounting (CONFIG_IP_ACCT) [n]
       *
       * (it is safe to leave these untouched)
       *
       PC/TCP compatibility mode (CONFIG_INET_PCTCP) [n]
       Reverse ARP (CONFIG_INET_RARP) [n]
       Assume subnets are local (CONFIG_INET_SNARL) [y]
       Disable NAGLE algorithm (normally enabled) (CONFIG_TCP_NAGLE_OFF) [n]
       The IPX protocol (CONFIG_IPX) [n]
       *
You must answer y to TCP/IP networking, as those protocols are fundamental to the operation of both SLIP and PPP. The only other option you might have to touch (unlikely) is IP forwarding/gatewaying. You only need to enable this if you plan on using your SLIP connected Linux box as a gateway to other locally connected computers. For example, if you have 2 computers running Linux at home, and you'd like them both connected at the same time over one line, you'd need to connect the second machine to the first via SLIP, connect the first machine to the network via SLIP or PPP, and enable IP forwarding/ gatewaying in the first (Internet connected) machine.

It is safe to choose the default values for the rest of the options.

  *
  *
  * Network device support
  *
  Network device support? (CONFIG_NETDEVICES) [y]
  Dummy net driver support (CONFIG_DUMMY) [y]
  SLIP (serial line) support (CONFIG_SLIP) [y]
   CSLIP compressed headers (CONFIG_SLIP_COMPRESSED) [y]
   16 channels instead of 4 (SL_SLIP_LOTS) [n]
  PPP (point-to-point) support (CONFIG_PPP) [y]
  PLIP (parallel port) support (CONFIG_PLIP) [n]
  Do you want to be offered ALPHA test drivers (CONFIG_NET_ALPHA) [n]
  Western Digital/SMC cards (CONFIG_NET_VENDOR_SMC) [n]
  3COM cards (CONFIG_NET_VENDOR_3COM) [n]
  Other ISA cards (CONFIG_NET_ISA) [n]
  EISA, VLB, PCI and on board controllers (CONFIG_NET_EISA) [n]
  Pocket and portable adaptors (CONFIG_NET_POCKET) [n]
  *
This section is possibly the most important. If you are planning to use SLIP and/or PPP, I suggest using the setup above. If you only plan on using one or the other, it's not COMPLETELY necessary to include support for the one you don't plan on using, but it will save you from another kernel compile if you change your mind. Dummy net driver support will allow you to use network services (finger, for example) locally while the SLIP/PPP link is not established.

       *
       * Filesystems
       *
        ...
        ...
       /proc filesystem support (CONFIG_PROC_FS) [y]
       NFS filesystem support (CONFIG_NFS_FS) [y]
        ...
        ...
It's not necessary to include the NFS filesystem unless you plan on being an NFS client, but unless you're low on RAM (I know I am) you might as well include it, just in case. You should always include /proc filesystem support as many common Linux utilities depend on it, as does the networking support.

After configuring the kernel, compile it and install it as explained in the kernel README.

You will also need to have the network tools package and network applications. Please note that if you installed from the Slackware distribution (which you should have :-) ) all the networking stuff you'll need is in the N disk set. It'll save you much work if you just install everything relevant from there. If you installed from another distribution, check to see if the networking stuff is available through your distribution. If not or if you`d like to install everything manually, ftp

sunacm.swan.ac.uk: /pub/misc/Linux/Networking/PROGRAMS/NetTools/net-tools-1.x.x.tar.gz

Get the highest numbered package that is less than your current kernel version.

Also get:

ftp.funet.fi:/pub/OS/Linux/PEOPLE/Linus/net-source/base/NetKit-A-xxx.bin.tar.gz
ftp.funet.fi:/pub/OS/Linux/PEOPLE/Linus/net-source/base/NetKit-B-xxx.bin.tar.gz

Get the newest versions. Or, get the source (same name, but without the "bin") and compile it yourself. If you install the files manually, you're on your own for installing them, as I installed from the Slackware distribution.

Configuration

There are many configuration files for the network. The first we will look at is /etc/rc.d/rc.inet1. Again, please note that if you installed from the Slackware or other distribution, much of the configuration will already be done for you. You will still have to follow along to make SURE everything is set up correctly, and to change the various system specific settings.

The first step in your network configuration is to configure the loopback device. The loopback entry will be called 'lo' and will have an IP address of `127.0.0.1'.

Here is the first part of the /etc/rc.d/rc.inet1 file:

       #!/bin/sh
       #
       # rc.inet1   --  configures network devices.
       #
       # Attach the loopback device.
       /sbin/ifconfig lo 127.0.0.1
       #
       # Add a route to point to the loopback device.
       /sbin/route add 127.0.0.1
       # End loopback
       #
This will correctly configure the loopback device.

Next, you need to configure the routing mechanisms on your machine. Add this to your /etc/rc.d/rc.inet1 file:

       #
       # Add a default route.
       #
       /sbin/route add default gw 199.184.119.2
       #
Please note that 199.184.119.2 in the line above is the address of Internet Nebraska's router.

Next, you will have to set up any network daemons that may need to be running. Slackware does an excellent job of this during the installation of the N disk set, but you may want to follow along just in case. Here's an example of the /etc/rc.d/rc.inet2 file that will do this:

  #! /bin/sh
  #
  # rc.inet2      This shell script boots up the entire INET system.
  #               Note, that when this script is used to also fire
  #               up any important remote NFS disks (like the /usr
  #               distribution), care must be taken to actually
  #               have all the needed binaries online _now_ ...
  #
  # Version:      @(#)/etc/rc.d/rc.inet2  2.18    05/27/93
  #
  # Author:       Fred N. van Kempen, 
  #

  # Constants.
  NET="/usr/sbin"
  IN_SERV="lpd"
  LPSPOOL="/var/spool/lpd"

  # At this point, we are ready to talk to The World...
  echo -e "\nMounting remote file systems ..."
  /bin/mount -t nfs -v            # This may be our /usr runtime!!!

  echo -e "\nStarting Network daemons ..."
  # Start the SYSLOG daemon.  This has to be the first server.
  # This is a MUST HAVE, so leave it in.
  echo -n "INET: "
  if [ -f ${NET}/syslogd ]
  then
  echo -n "syslogd "
  ${NET}/syslogd
  fi

  # Start the SUN RPC Portmapper.
  if [ -f ${NET}/rpc.portmap ]
  then
  echo -n "portmap "
  ${NET}/rpc.portmap
  fi

  # Start the INET SuperServer
  # This is a MUST HAVE, so leave it in.
  if [ -f ${NET}/inetd ]
  then
  echo -n "inetd "
  ${NET}/inetd
  else
  echo "no INETD found.  INET cancelled!"
  exit 1
  fi

  # Start the NAMED/BIND name server.
  # NOTE: you probably don't need to run named.
  #if [ ! -f ${NET}/named ]
  #then
  #        echo -n "named "
  #        ${NET}/named
  #fi

  # Start the ROUTEd server.
  # NOTE: routed is now obsolete. You should now use gated.
  #if [ -f ${NET}/routed ]
  #then
  #        echo -n "routed "
  #        ${NET}/routed -q #-g -s
  #fi

  # Start the GATEd server.
  if [ -f ${NET}/gated ]
  then
  echo -n "gated "
  ${NET}/gated
  fi

  # Start the RWHO server.
  if [ -f ${NET}/rwhod ]
  then
  echo -n "rwhod "
  ${NET}/rwhod -t -s
  fi

  # Start the U-MAIL SMTP server.
  if [ -f XXX/usr/lib/umail/umail ]
  then
  echo -n "umail "
  /usr/lib/umail/umail -d7 -bd /dev/null 2>&1 &
  fi

  # Start the various INET servers.
  for server in ${IN_SERV}
  do
  if [ -f ${NET}/${server} ]
  then
                  echo -n "${server} "
                  ${NET}/${server}
  fi
  done

  # Start the various SUN RPC servers.
  if [ -f ${NET}/rpc.portmap ]
  then
  if [ -f ${NET}/rpc.ugidd ]
  then
                  echo -n "ugidd "
                  ${NET}/rpc.ugidd -d
  fi
  if [ -f ${NET}/rpc.mountd ]
  then
                  echo -n "mountd "
                  ${NET}/rpc.mountd
  fi

  if [ -f ${NET}/rpc.nfsd ]
  then
                  echo -n "nfsd "
                  ${NET}/rpc.nfsd
  fi

  # Fire up the PC-NFS daemon(s).
  if [ -f ${NET}/rpc.pcnfsd ]
  then
                  echo -n "pcnfsd "
                  ${NET}/rpc.pcnfsd ${LPSPOOL}
  fi
  if [ -f ${NET}/rpc.bwnfsd ]
  then
                  echo -n "bwnfsd "
                  ${NET}/rpc.bwnfsd ${LPSPOOL}
  fi

  fi
  echo network daemons started.
  # Done!
This will start most network daemons, and many of them won't be necessary to your particular setup, but the script is designed to not start any servers that you don't have.

For those who don't know, inetd is a master daemon that starts other daemons when it gets an incoming request for services (such as telnet, ftp, etc.)

It is necessary to configure inetd through the file /etc/inetd.conf, which should look like this:

       #
       # The internal services.
       #
       # Authors:      Original taken from BSD UNIX 4.3/TAHOE.
       #               Fred N. van Kempen, 
       #
       echo    stream tcp nowait root  internal
       echo    dgram  udp wait   root  internal
       discard stream tcp nowait root  internal
       discard dgram  udp wait   root  internal
       daytime stream tcp nowait root  internal
       daytime dgram  udp wait   root  internal
       chargen stream tcp nowait root  internal
       chargen dgram  udp wait   root  internal
       #
       # Standard services.
       #
       ftp     stream tcp nowait root  /usr/sbin/tcpd in.ftpd ftpd
       telnet  stream tcp nowait root  /usr/sbin/tcpd in.telnetd
       #
       # Shell, login, exec and talk are BSD protocols.
       #
       shell   stream tcp nowait root  /usr/sbin/tcpd in.rshd
       login   stream tcp nowait root  /usr/sbin/tcpd in.rlogind
       exec    stream tcp nowait root  /usr/sbin/tcpd in.rexecd
       talk    dgram  udp wait   root  /usr/sbin/tcpd in.talkd
       ntalk   dgram  udp wait   root  /usr/sbin/tcpd in.talkd
       #
       # Status and Information services.
       #
       finger  stream tcp nowait root  /usr/sbin/tcpd in.fingerd
       systat  stream tcp nowait guest /usr/sbin/tcpd /usr/bin/ps -auwwx
       netstat stream tcp nowait guest /usr/sbin/tcpd /bin/netstat
       #
       # End of inetd.conf.
Your /etc/services file should look something like:

  #
  # /etc/services - database of service name, socket number
  #                 and protocol.
  #
  # Original Author:
  #     Fred N. van Kempen, 
  #
  tcpmux     1/tcp
  echo       7/tcp
  echo       7/udp
  discard    9/tcp   sink null
  discard    9/udp   sink null
  systat     11/tcp  users
  daytime    13/tcp
  daytime    13/udp
  netstat    15/tcp
  chargen    19/tcp  ttytst source
  chargen    19/udp  ttytst source
  ftp-data   20/tcp
  ftp        21/tcp
  telnet     23/tcp
  smtp       25/tcp  mail
  time       37/tcp  timserver
  time       37/udp  timserver
  name       42/udp  nameserver
  whois      43/tcp  nicname    # usually to sri-nic
  domain     53/tcp
  domain     53/udp
  finger     79/tcp
  link       87/tcp  ttylink
  hostnames  101/tcp hostname   # usually to sri-nic
  sunrpc     111/tcp
  sunrpc     111/tcp portmapper # RPC 4.0 portmapper TCP
  sunrpc     111/udp
  sunrpc     111/udp portmapper # RPC 4.0 portmapper UDP
  auth       113/tcp authentication
  nntp       119/tcp usenet     # Network News Transfer
  ntp        123/tcp            # Network Time Protocol
  ntp        123/udp            # Network Time Protocol
  snmp       161/udp
  snmp-trap  162/udp
  exec       512/tcp            # BSD rexecd(8)
  biff       512/udp comsat
  login      513/tcp            # BSD rlogind(8)
  who        513/udp whod       # BSD rwhod(8)
  shell      514/tcp cmd        # BSD rshd(8)
  syslog     514/udp            # BSD syslogd(8)
  printer    515/tcp spooler    # BSD lpd(8)
  talk       517/udp            # BSD talkd(8)
  route      520/udp routed     # 521/udp too
  timed      525/udp timeserver
  mount      635/udp            # NFS Mount Service
  pcnfs      640/udp            # PC-NFS DOS Authentication
  bwnfs      650/udp            # BW-NFS DOS Authentication
  listen     1025/tcp listener  # RFS remote_file_sharing
  ingreslock 1524/tcp           # ingres lock server
  nfs        2049/udp           # NFS File Service
  irc        6667/tcp           # Internet Relay Chat
  # End of services.
This file basically tells what type of connection will come in on each port. This file should be the same on every internet-connected machine.

You should have (or make) an /etc/protocols file that looks like:

       #
       # /etc/protocols - database of protocols.
       #
       # Original Author:
       #   Fred N. van Kempen, 
       #
       ip   0   IP   # internet protocol
       icmp 1   ICMP # internet control message protocol
       igmp 2   IGMP # internet group multicast protocol
       ggp  3   GGP  # gateway-gateway protocol
       tcp  6   TCP  # transmission control protocol
       pup  12  PUP  # PARC universal packet protocol
       udp  17  UDP  # user datagram protocol
       idp  22  IDP
       raw  255 RAW
       #
       # End of protocols.
You will need an /etc/hosts file, which contains machine name --> IP mappings for when the machine is not yet connected to the network and can't access a DNS machine. It should look like this:

  # /etc/hosts
  # List of hostnames and their ip addresses
  127.0.0.1               localhost
  199.184.119.1           falcon.inetnebr.com falcon
  199.184.119.2           router.inetnebr.com router
  199.184.119.3           pm1.inetnebr.com pm1
  199.184.119.5           pm2.inetnebr.com pm2
  199.184.119.6           pm3.inetnebr.com pm3
  # end of hosts
You probably won't need all of these in your hosts file, but they won't hurt anything if they're there.

You will need an /etc/networks file that looks like this:

       #
       # /etc/networks: list all networks that you wish to add route commands
       #                for in here
       #
       default         0.0.0.0         # default route    - recommended
       loopnet         127.0.0.0       # loopback network - recommended
       #
       # end of networks
You need an /etc/host.conf that has these two lines:

       order hosts,bind
       multi on
You also need an /etc/resolv.conf file. It should look like:

       domain inetnebr.com
       nameserver 199.184.119.1
       nameserver 199.2.252.10
You should then create a file /etc/HOSTNAME which contains a fully qualified domainname. For example, mine says:

       blackbird.inetnebr.com
Yours should contain whatever you'd like to name your machine, followed by .inetnebr.com

You must then add a line to your /etc/rc.d/rc.inet1 that says:

       /bin/hostname -F /etc/HOSTNAME
Your configuration files are basically set up correctly now. You should reboot for these changes to take effect.

SLIP Setup

Now is the point that you must decide whether you're going to connect using SLIP or PPP. There is little difference between the two as far as the user is concerned, the dip program (discussed later) for SLIP is a little more straightforward to set up than the pppd daemon for PPP, but either is a good choice.

I'll discuss SLIP first, if you're sure you'd rather setup PPP you can skip ahead to that section.

For setting up a SLIP connection to Internet Nebraska, you will almost certainly want to use dip, an excellent connection program for SLIP users.

You can get dip from:

sunsite.unc.edu:/pub/Linux/system/Network/serial/dip337n-uri.tgz

Dip is also included in the Slackware and (I assume) other distributions.

In order to use dip, you will need to have a `dip script'. I am including one here that works for the Internet Nebraska server. Save it as /etc/slip.dip or whatever you'd like. Be sure to change the modem init string, com port, speed, username, and password to match your settings.

  #
  # 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, 
  # Modified for Internet Nebraska by Steve Weaver 

  main:
    # Next, set up the other side's name and address.
    get $remote 199.184.119.3
    # Set netmask on sl0 to 255.255.255.0
    netmask 255.255.255.0
    # Set the desired serial port and speed.
    # Put in the correct numbers for your machine here
    port cua1
    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 ATZ\r
    if $errlvl != 0 goto modem_trouble
    dial 434-6910
    if $errlvl != 1 goto modem_trouble

    # We are connected.  Login to the system.
  login:
    sleep 2
    wait ogin: 20
    if $errlvl != 0 goto login_error
    send Cusername\r
    wait ord: 20
    if $errlvl != 0 goto password_error
    send password\r
  loggedin:

    # We are now logged in.
    #wait SOMEPROMPT 30
    #if $errlvl != 0 goto prompt_error

    #Wait to be given IP address
    wait to 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 552
    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 ocurred with the modem...
  error:
    print CONNECT FAILED to $remote
    quit

  exit:
    exit
Now that you have everything set up, just type

root# dip /etc/slip

This will dialup, set up SLIP operation, and return you to the command prompt. You are now connected to the internet. All network programs you have are now operational. Ftp, telnet, finger. etc. should all work. Enjoy your net connection!

To close the connection, simply type:

root# dip -k

to kill the connection.

PPP Setup

This is what the NET-2-HOWTO says about PPP:

  The Point to Point Protocol is a modern and efficient protocol for
  conveying multiple protocols, tcp/ip for one, across serial links,
  that a lot of people use in place of slip. It offers enhanced
  functionality, error detection and security options. It corrects a
  number of deficiencies that are found in slip, and is suitable for
  both asynchronous links and synchronous links alike.
In order to use PPP, you must first have the pppd daemon. It is included in the Slackware distribution and is also available from:

sunsite.unc.edu:/pub/Linux/system/Network/serial/ppp-2.1.2c.tar.gz

You will need to read the README.linux file for information on compiling and installation.

Save this next section as a file called ppp-on and put it in /usr/local/bin (or somewhere else in your path). Be sure and change username, password, modem, etc. to reflect yours. Give it permissions 700.

#!/bin/bash

## ppp-on
##
## Set up a PPP link
##
## Fixed up and commented by Ian Goldberg 

## The following two should be correct in most cases

## Where your lockfiles go
LOCKDIR=/var/spool/locks
## The name of your modem device
DEVICE=modem
## The location of the chatscript
CHATSCRIPT=/etc/ppp/chatscript

## Check if the modem is in use
if [ -f $LOCKDIR/LCK..$DEVICE ]
then
    echo "PPP device is locked"
    exit 1
fi

## Grab the device
/bin/touch $LOCKDIR/LCK..$DEVICE

## Fix the permissions (just in case)
/usr/lib/ppp/fix-cua $DEVICE

{
    ## Set some parameters; change 2400 to your modem speed
    /bin/stty 2400 -tostop

    ## Try to connect
    if /usr/lib/ppp/chat -v -f $CHATSCRIPT
    then
        ## Connect successful!  Start pppd.
        ## If you go faster than 9600, remove "mru 296 mtu 296" from the
        ##    next line.
        /usr/lib/ppp/pppd mru 296 mtu 296 crtscts defaultroute /dev/$DEVICE
        exit 0
    else
        ## Couldn't connect.  Darn.
        echo "PPP call failed" 1>&2
        /bin/rm -f $LOCKDIR/LCK..$DEVICE
        exit 1
    fi
} <> /dev/$DEVICE
You will now need to make a "chatscript" for the above script. Save the following section as /etc/ppp/chatscript. Give it permissions 600, owned by root. It will contain your password, so it should not be readable by anyone except yourself.

You will need to replace username with your username and password with your password. Also change ATZ to the appropriate init string for your modem.

ABORT BUSY
ABORT 'NO DIALTONE'
ABORT 'NO CARRIER'

'' ATZ OK ATDT434-6910 CONNECT '' ogin:
Pusername word: password
Next, call the following script ppp-off and place it in /usr/local/bin or elsewhere in your path. Give it permissions 700.

#!/bin/bash

## ppp-off
##
## Close all ppp connections
##
## Fixed up and commented by Ian Goldberg 

## The following two should be correct in most cases

## Where your lockfiles go
LOCKDIR=/var/spool/locks
## The name of your modem device
DEVICE=modem

## Send an INT to the pppd process
/bin/killall -INT pppd || exit 1

## Wait for the connection to close
/usr/bin/sleep 1

## Release the modem device
/bin/rm -f $LOCKDIR/LCK..$DEVICE

exit 0
That's it! To start the PPP connection, just type:

root# ppp-on

This will dialup, set up PPP operation, and return you to the command prompt. You are now connected to the internet. All network programs you have are now operational. Ftp, telnet, finger. etc. should all work. Enjoy your net connection!

root# ppp-off

This will terminate the PPP connection, and hang up the modem.


[RETURN] manager@inetnebr.com
Last updated 4/04/96