Knowledgebase

Linux - Distribution Independent

Fundamental Requirements

You will need the following setup in Linux, before you can start:

  • Kernel with PPP support compiled in.
  • pppd and chat user programs compatible with kernel ppp support.

Most recent Linux distributions have the above setup by default.

Assuming that the PPP link is the only way you intend to connect then you can ignore most of the lines in the file /etc/rc.d/rc.inet1

rc.inet1

#! /bin/sh 
# 
# rc.inet1 This shell script boots up the base INET system. 
# 

HOSTNAME=`cat /etc/HOSTNAME` 

# Attach the loopback device. 
/sbin/ifconfig lo 127.0.0.1 
/sbin/route add -net 127.0.0.0 

# IF YOU HAVE AN ETHERNET CONNECTION, use these lines below to configure the 
# eth0 interface. If you're only using loopback or SLIP, don't include the 
# rest of the lines in this file. 

# Edit for your setup. 
#IPADDR="0.0.0.0" # REPLACE with YOUR IP address! 
#NETMASK="255.255.255.0" # REPLACE with YOUR netmask! 
#NETWORK="0.0.0.0" # REPLACE with YOUR network address! 
#BROADCAST="0.0.0.0" 
 # REPLACE with YOUR broadcast address, 
 # if you have one. If not, leave blank and 
 # edit below. 
#GATEWAY="194.133.7.1" # REPLACE with YOUR gateway address! 

# Uncomment ONLY ONE of the three lines below. If one doesn't work, try again. 
# /sbin/ifconfig eth0 ${IPADDR} netmask ${NETMASK} broadcast ${BROADCAST} 
# /sbin/ifconfig eth0 ${IPADDR} broadcast ${BROADCAST} netmask ${NETMASK} 
# /sbin/ifconfig  eth0 ${IPADDR} netmask ${NETMASK} 

# Uncomment these to set up your IP routing table. 
#/sbin/route add -net ${NETWORK} netmask ${NETMASK} 
#/sbin/route add default gw ${GATEWAY} metric 1 

# End of rc.inet1 

 

The following scripts are for dialing in ppp-on and disconnecting ppp-off are stored in the directory /etc/ppp. This directory also contains an empty file called options. The chat script is stored in the file /etc/ppp/ppp-on-dialer

ppp-on

#!/bin/sh 
# 
# Script to initiate a ppp connection. This is the first part of the 
# pair of scripts. This is not a secure pair of scripts as the codes 
# are visible with the 'ps' command.  However, it is simple. 
# 
# These are the parameters. Change as needed. 
TELEPHONE=5556969 # The telephone number for the connection 
ACCOUNT=username   # The account name for logon (as in 'George Burns') 
PASSWORD=password # The password for this account (and 'Gracie Allen') 
LOCAL_IP=0.0.0.0 # Local IP address if known. Dynamic = 0.0.0.0 
REMOTE_IP=0.0.0.0 # Remote IP address if desired. Normally 0.0.0.0 
NETMASK=255.255.255.224 # The proper netmask if needed 
# 
# Export them so that they will be available at 'ppp-on-dialer' time. 
export TELEPHONE ACCOUNT PASSWORD 
# 
# This is the location of the script which dials the phone and logs 
# in.  Please use the absolute file name as the $PATH variable is not 
# used on the connect option.  (To do so on a 'root' account would be 
# a security hole so don't ask.) 
# 
DIALER_SCRIPT=/etc/ppp/ppp-on-dialer 
# 
# Initiate the connection 
# 
# I put most of the common options on this command. Please, don't 
# forget the 'lock' option or some programs such as mgetty will not 
# work. The asyncmap and escape will permit the PPP link to work with 
# a telnet or rlogin connection. You are welcome to make any changes 
# as desired. Don't use the 'defaultroute' option if you currently 
# have a default route to an ethernet gateway. 
# 
exec /usr/local/bin/ppp/pppd debug lock modem crtscts /dev/ttyS1 38400 \ 
 asyncmap 20A0000 escape FF kdebug 0 $LOCAL_IP:$REMOTE_IP \ 
 noipdefault netmask $NETMASK defaultroute connect $DIALER_SCRIPT 

ppp-on-dialer

#!/bin/sh 
# 
# This is part 2 of the ppp-on script. It will perform the connection 
# protocol for the desired connection. 
# 
exec /usr/local/bin/ppp/chat -v                 \ 
 TIMEOUT  3                               \ 
 ABORT  '\nBUSY\r'                      \ 
 ABORT  '\nNO ANSWER\r'                 \ 
 ABORT  '\nRINGING\r\n\r\nRINGING\r'    \ 
 ''  \rATZ                               \ 
 'OK-+++\c-OK' 'AT&F$V4X4'                 \ 
 TIMEOUT  35                              \ 
 OK  ATDT$TELEPHONE                      \ 
 CONNECT  ''                              \ 
 ogin:--ogin: $ACCOUNT                    \ 
 assword: $PASSWORD 

ppp-off

#!/bin/sh 
#################################################### 
# 
# Determine the device to be terminated. 
# 
if [ "$1" = "" ]; then 
 DEVICE=ppp0 
else 
 DEVICE=$1 
fi 

##################################################### 
# 
# If the ppp0 pid file is present then the program is running. Stop it. 
if [ -r /var/run/$DEVICE.pid ]; then 
        kill -INT `cat /var/run/$DEVICE.pid` 
# 
# If the kill did not work then there is no process running for this 
# pid. It may also mean that the lock file will be left. You may wish 
# to delete the lock file at the same time. 
        if [ ! "$?" = "0" ]; then 
                rm -f /var/run/$DEVICE.pid 
                echo "ERROR: Removed stale pid file" 
                exit 1 
        fi 
# 
# Success. Let pppd clean up its own junk. 
        echo "PPP link to $DEVICE terminated." 
        exit 0 
fi 
# 
# The ppp process is not running for ppp0 
echo "ERROR: PPP link is not active on $DEVICE" 
exit 1 

Domain Name Service (DNS)

The domain name service is controlled by a file called /etc/resolv.conf. This file just specifies which server it should query for DNS information. Since your computer is on the internet once the PPP connection/routing is up you can query your own computer for this info which in turns asks another computer. This allows you to cache DNS lookups locally and save some bandwidth but you need plently of RAM to make it worthwhile.

resolv.conf

search isp.com 
nameserver 123.213.123.212 
nameserver 123.213.123.213

Most ISP's terminal servers are configured to allow PAP authentication. Users may also login the old fashioned way of supplying a username and password either manually or with a chat script.

However if your PPP access software has been configured to use PAP the terminal server will realise this and authenticate using PAP instead. Generally, this is a more reliable and faster way of getting connected.

To authenticate using PAP you should use isp-pap instead of ppp-on

isp-pap

#!/bin/sh 
USERNAME=username 
TELEPHONE=5556969    # The telephone number for the connection 
LOCAL_IP=0.0.0.0 # Local IP address if known. Dynamic = 0.0.0.0 
REMOTE_IP=0.0.0.0 # Remote IP address if desired. Normally 0.0.0.0 
export TELEPHONE 
DIALER_SCRIPT=/etc/ppp/dialer 
exec /usr/local/bin/pppd debug lock modem crtscts /dev/ttyS1 38400 \ 
 asyncmap 20A0000 escape FF kdebug 0 $LOCAL_IP:$REMOTE_IP \ 
 noipdefault defaultroute name $USERNAME \ 
 user $USERNAME connect $DIALER_SCRIPT

You also need the following files:

  • pap-secrets
  • chap-secrets

NB: you need the file chap-secrets even though you wont be using chap. Just copy pap-secrets to chap-secrets.

username * password

You also need a dialer that won't wait for username and password prompts.

dialer

#!/bin/sh 
# 
# This is part 2 of the isp-pap script. It will perform the connection 
# protocol for the desired connection. 
# 
exec /usr/local/bin/chat -v   \ 
 TIMEOUT  3  \ 
 ABORT  '\nBUSY\r'  \ 
 ABORT  '\nNO ANSWER\r' \ 
 ABORT  '\nRINGING\r\n\r\nRINGING\r' \ 
 ''  \rATZ               \ 
 'OK-+++\c-OK' 'AT&F$V4X4' \ 
 TIMEOUT  35  \ 
 OK  ATDT$TELEPHONE \ 
 CONNECT  ''

This script assumes pppd and chat are located in /usr/local/bin/ppp.

If you run into problems trying to connect, type in tail -f /var/log/messages to see what is going on during the connection. All going well you should see a local and remote IP number being assigned to you in the /var/log/messages file.

Once you are connected, you can browse the web using Netscape (X Windows required) or run your own webserver using Apache.

Useful Links

Linux Usergroup of Ireland

Linux Homepage

Redhat Software

The information on this page was put together by Peter Lonergan