

	PPP-Client MINI-HOWTO
	---------------------

Version:	0.1	(THIS IS A DRAFT - COMMENTS/FEEDBACK REQUESTED)
Author:		Robert Hart (hartr@hedland.edu.au)
Date:		October 1995

Copyright:	This document may be freely distributed under the terms
		of the GNU "copy left" notice.

Distribution:	This document will be posted to comp.os.linux.answers on a
		monthly basis or more frequently as new versions of the
		document are produced.

Organization:	This document is organized into sections. Each section
		starts with a section number X.X followed by a title
		that is underlined. You can thus search through this
		document section by section by searching for <space>--

Contents
--------

1.0		Introduction
	1.1	Clients and servers
	1.2	IP Numbers
2.0		Aim of this Document
3.0		Other Useful/Important Documents
4.0		Configuring your Kernel
5.0		Getting the Information you need about the PPP service
	5.1	Testing your Modem Connection
	5.2	Configuring your modem
6.0		Setting up the PPP options file
	6.1	What options should I use?
7.0		Setting up your /etc/resolv.conf file
8.0		Setting up the PPP connection manually
9.0		Creating the 'chat' script
	9.1	Creating your ppp-on file
10.0		Testing your chat script
11.0		Shutting down the PPP link
12.0		Routing issues
13.0		Debugging




1.0 Introduction
    ------------

PPP (Point to Point Protocol) is a mechanism for creating and running IP
(and other network protocols) over a serial link - be that a direct
connection or a link made using modems.


1.1 Clients and Servers
    -------------------

When you dial into a site to establish a PPP connection, you are a
'client' (also called the 'remote' machine).

When you are setting up a Linux box to receive and handle dial in PPP
connections, you are setting up a PPP 'server'.

NB: 	At present, this document covers only setting up of the client side
	of a connection.


1.2 IP Numbers
    ----------

Please note that the IP numbers used throughout this document are
FICTITIOUS! If you are connecting to the Internet, YOU MUST use valid IP
numbers. If you start picking IP numbers "out of the air" and use these
whilst connecting to another LAN (let alone the Internet) you will
deserve all that happens to you!

IP numbers are UNIQUE across the entire Internet - use someone else's AT
YOUR PERIL!!!

There are IP numbers that are specifically dedicated to LAN's that do
not connect to the Internet. One of these sequences is 10.0.0.0 to
10.255.255.255. This is the sequence I have used as EXAMPLES in this
document. 


2,0 Aim of this Document
    --------------------

This document attempts to assist people who wish to use Linux & PPP to
dial into a PPP server and set up an IP connection using PPP. It assumes
that PPP has been compiled and installed on your Linux machine (but does
cover reconfiguring/recompiling your kernel to include PPP support).

As the author has no knowledge of DIP, this document describes the
"standard" Linux PPP software (chat/pppd).

This document at present doe NOT cover :-

	* Connecting and configuring a modem to Linux (in detail)
			See the SERIAL HOWTO

	* Setting up a PPP server on Linux
			A PPP server HOWTO is in production

	* Using PAP and CHAP
			This will be included later

	* Using DIP to make PPP connections
			Use chat instead...


3.0 Other Useful/Important Documents
    --------------------------------

Users are advised to read the documentation that comes with the PPP
package, the pppd and chat man pages, the Linux Network Administration
Guide (NAG), and the Net-2 Howto. These documents (as well as various
others, including the relevant RFCs) provide additional and more detailed
explanation than is possible in this HOWTO.


4.0 Configuring your Kernel
    -----------------------

In order to use PPP, your Linux kernel must be compiled to include PPP
support. Obtain the Linux source code for your kernel if you do not
already have this - it belongs in /usr/src/linux on Linux's standard file
system.

In this directory you will find at least one README file. This contains
an excellent explanation of how to go about configuring and compiling a
new kernel. Read this file (it's a good idea to print it out and have a
copy handy whilst you are compiling until you have done this enough times
to know your way around.

One small note - the current 'make config' dialog does NOT allow you to
go backwards - so if you make a mistake in answering one of the
questions, exit by typing <CTRL> C and start again...

You MUST know what cards/devices you have inside your PC if you are going
to recompile your kernel!!!
In order to use PPP, you must configure the kernel to include PPP support
(PPP requires BOTH pppd AND kernel support for PPP). At present, this
requires you to include SLIP support AS WELL AS PPP. The relevant portion
of the 'make config' dialog looks like this...

*
* Network device support
*
Network device support? (CONFIG_NETDEVICES) [n] y
Dummy net driver support (CONFIG_DUMMY) [n] y
SLIP (serial line) support (CONFIG_SLIP) [n] y
 CSLIP compressed headers (CONFIG_SLIP_COMPRESSED) [n] y
 16 channels instead of 4 (SL_SLIP_LOTS) [n] n
PPP (point-to-point) support (CONFIG_PPP) [n] y

Answer the other 'make config' questions according to the hardware in
your PC and the features of the Linux operating system you want. Then
continue to follow the README to compile and install your new kernel.

NOTE: 	If you want to set up you Linux machine as a PPP server, you
	should also include IP forwarding (you will need it!).


5.0 Getting the Information you need about the PPP service
    ------------------------------------------------------

Before you can establish a PPP connection with a server, you need to
obtain the following information (from the sysadmin/user support people
of the PPP server):-

	* The telephone number(s) to dial for the service (if you are
	  behind a PABX, you also need the PABX number that gives you an
	  outside dial tone - this is frequently 0)

	* Does the server use DYNAMIC or STATIC IP numbers? If the server
	  uses STATIC IP numbers, then you need to know what IP number to
	  use for your end of the PPP connection.

	  Most Internet Service Providers use DYNAMIC IP numbers. This
	  has some implications in terms of the services you can use!

	* If you are using static IP numbers, ask for the network mask as
	  well.

	* What are the IP numbers of the server's Domain Name Servers?

	* Does the server require the use of PAP/CHAP?

	*Does the server automatically start PPP or do you need to issue
	 any commands to start PPP on the server once you are logged in?

Carefully note down this information - you are going to use it!


5.1 Testing your Modem Connection
    -----------------------------

You should make sure that your modem is correctly set up and that you
know which serial port it is connected to.

Remember:-
	DOS com1: = Linux /dev/cua0 (and /dev/ttyS0)
	DOS com2: = Linux /dev/cua1 (and /dev/ttyS1)
			et cetera

Using you terminal communications package (such as minicom), dial into
the PPP server you want to connect to with a PPP session. (Note: at this
stage we are NOT trying to make a PPP connection - just establish that we
have the right phone number and also to find out exactly what the server
sends to us in order to get logged in and start PPP).

During this process, either capture (log) the entire login process or
carefully (very carefully) write down *exactly* what prompts the remote
server gives to let you know it is time to enter your user name and
password (and any other commands needed to establish the connection).

If your server automatically starts PPP, once you have logged in, you
will start to see "garbage" on your screen - this is the PPP server
sending your machine information to start up the PPP connection.

This should look something like this :- 

~y}#.!}!}!} }8}!}$}%U}"}&} } } } }%}& ...}'}"}(}"} .~~y}

(and it just keeps on coming!)

At this point, you can hang up your modem (usually,  type +++ quickly
and then issue the ATHO command once your modem responds with "OK").

On some systems PPP must be explicitly started on the server - if this is
the case, issue this command once you have logged in. Again, you will see
"garbage" as the server end of the PPP connection starts up - so you can
now hang up.

If you do NOT see "garbage" on your screen when the server starts up PPP,
it is quite likely (though not certain) that you have done something
wrong. Some PPP servers are set up to be "passive" - they send nothing
until the client starts the PPP process. However, the majority of servers are active and you should see the garbage.

If you can't get your modem to work, read your modem manual, the man
pages for your communications software and the SERIAL HOWTO!


5.2 Configuring your modem
   -----------------------

You will need to configure your modem correctly - to do this READ YOUR
MODEM MANUAL! Most modems come with a "factory default setting" that
selects the options required for PPP. The minimum configuration
specifies:-

	Hardware flow control (RTS/CTS)

Use your communications software (eg minicom) to find out about your
modem configuration and set it to what is required for PPP.

Save your modem configuration in non-volatile RAM (usually the modem
command AT&W will do this - but check in your modem manual).

With the correct modem configuration already in the modem, resetting the
modem will activate this and this simplifies the "chat" script necessary
for the PPP connection.

5.3 Note on Serial Flow Control
    ---------------------------

When data is travelling on serial communication lines, it can happen 
that data arrives faster than a computer can handle it (the computer may 
be "busy" doing something else). In order to ensure that data is not 
lost (data does not "over run" in the input buffer and hence get lost), some 
method of controlloing the flow of data is necessary.

There are two ways of doing this on serial lines:-

	* Using hardware signals ("Clear To Send/Request to Send - CTS/RTS)
	* Using software signals (control S and control Q).

Whilst the latter may be fine for a terminal (text) link, data on a PPP 
link is 8 bits - and it is quite probable that somewhere in the data 
there will be data bytes that translate as ^S and ^Q. So, if a modem is 
set up to software flow control, things can rapidly go beserk.

For PPP (which uses 8 bits of data) hardware flow control is vital.


6.0 Setting up the PPP options file
    -------------------------------

6.1 Using PPP and "root" priveleges
    -------------------------------

Because PPP needs to set up networking devices, change the kernel
routing table and so forth, it requires root priveleges to do this.

The pppd program should be setuid root on installation :-

-r-sr-xr-x   1 root     root        95225 Jul 11 00:27 /usr/sbin/pppd

Depending on how you want your system to operate - specifically if you
want ANY user on your system to be able to initiate a PPP, you should
make your ppp-on/off scripts world read/execute.

However, if you do NOT want just anyone to be able to start up a PPP
connection, you will need to establish a PPP group and :-

	* Make the ppp-on/off scripts owned by group PPP
	* Make the ppp-on/off scripts read/executable by group PPP
	* Make the "other" access rights for ppp-on/off nill.
	* add the users who will be firing up PPP to the PPP group
	  in /etc/group

-rwxr-x---   1 root     PPP           587 Mar 14  1995 /usr/sbin/ppp-on


6.2 Setting up the files
    --------------------

You now need to be logged in as 'root' to create the directories and
edit the files needed to set up PPP, even if you want PPP to be
accessible to all users.

In your /etc directory there should be a directory:-

drwxrwxr-x   2 root     root         1024 Oct  9 11:01 ppp

If it does not exist - create it.

If the directory already existed, it should contain a template options
file called 'options.tpl'. This file is at the end of this
document. Print it out as it contains an explanation of all the PPP
options. Whilst you can use this file as the basis of your
/etc/ppp/options file, it is probably better to create your own options
file that does not include all the comments in the template - it will be
much shorter and easier to read/maintain.

If you have multiple serial lines/modems (typically the case for PPP
servers), create and EMPTY /etc/ppp/options file and set up individual
option files for each serial line on which you will be establishing a PPP
connection. These are named 'options.ttyS1', 'options.ttyS2' and so
forth.
However, for a single PPP connection, you can happily use the
/etc/ppp/options file. Alternatively, you can put all the options as
arguments in the pppd command itself.

It is easier to maintain a setup that uses /etc/ppp/options.*
files. If you use PPP to connect to a number of different sites, you can
create option files for each site in /etc/ppp/options.<site> and then
specify the option file as a parameter to the PPP command as you connect.


6.1 What options should I use?
    --------------------------

Well, that depends...the following is a basic options file that *should*
work for most client connections.

However, if it does NOT work, READ THE TEMPLATE FILE and the pppd man pages
and speak to the sysadmin/user support people who run the server into
which you are connecting.

sample options file for DYNAMIC IP number------------------

# /etc/ppp/options - dynamic IP number supplied by PPP server
#
# use the modem control lines
modem
# use hardware flow control
crtscts
# create a default route for this connection in the routing table
defaultroute
# do NOT set up any "escaped" control sequences
asyncmap 0
# use a maximum transmission packet size of 552 bytes
mtu 552
# use a maximum receive packet size of 552 bytes
mru 552
#
#-------END

sample options file for STATIC IP number------------------

#/etc/ppp/options - STATIC IP number
#
# use the modem control lines
modem
# use hardware flow control
crtscts
# create a default route for this connection in the routing table
defaultroute
# do NOT set up any "escaped" control sequences
asyncmap 0
# use a maximum transmission packet size of 552 bytes
mtu 552
# use a maximum receive packet size of 552 bytes
mru 552
#
<YOUR STATIC IP NUMBER HERE>:<IP NUMBER OF PPP SERVER HERE>
# set up the netmask
netmask <the required netmask here>
#
#--------END


7.0 Setting up your /etc/resolv.conf file
    -------------------------------------

When you forge a PPP connection, you need to tell your Linux machine
where it can get host name to IP number (address) information.

One way is to enter every host that you want to talk to into the
/etc/hosts file (which is in reality totally impossible if you are
connecting to the Internet), another is to use the IP number as opposed
to the name (again - impossible for all but the smallest LANs).

The best way is to set up Linux so that it knows where to go to get this
information - automatically. This service is provided by the Domain Name
Server system. All that is necessary is to enter the IP numbers in your
/etc/resolv.conf file.

Your PPP server sysadmin/user support people should provide you with at
least two DNS IP numbers (only one is necessary - but two gives some
redundancy in the event of failure).

Your /etc/resolv.conf should look like :-

nameserver 203.5.208.1
nameserver 203.5.208.2

NB: If you have already set up a /etc/resolv.conf because you are on a
LAN, simply add the IP numbers of the PPP servers DNS servers to your
existing file.


8.0 Setting up the PPP connection manually
    --------------------------------------

Now that you have created your /etc/ppp/options and /etc/resolv.conf
files, you can test the settings by manually establishing a PPP
connection.

To do this, your communications software must be capable of quitting
WITHOUT resetting the modem. Minicom can do this - <ALT> Q (or in older
version of minicom <CTRL> A Q

Make sure you are logged in as root.

So fire up you comms software, dial into the PPP server and log in as
normal. If you need to issue a command to start up PPP on the server, do
so. You will now see the "garbage" you saw before.

Now quit the comms software without resetting the modem and at the Linux
prompt type

	pppd -d

(the -d option turns on debugging - the ppp connection start up
"conversation" will be logged to your system log - which is useful if you
are having trouble).

Your modem lights should now flash as the PPP convection is established, and after a short while, the command prompt will return, as PPP has
forked into the background.

At this point you can look at the PPP interface, by issuing the command

	ifconfig ppp0

You should see something like

ppp0      Link encap:Point-Point Protocol
          inet addr:10.144.153.104  P-t-P:10.144.153.51  Mask:255.255.255.0
          UP POINTOPOINT RUNNING  MTU:552  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0
          TX packets:0 errors:0 dropped:0 overruns:0

Where
	inet addr:10.144.153.10		is YOUR IP number
	P-t-P:10.144.153.5		is the SERVER's IP number

(Naturally, ifconfig will not report these IP numbers, but the ones used
by your PPP server)

Note: ifconfig also tells you that the link is UP and RUNNING

If you get something like 

ppp0      Link encap:Point-Point Protocol
          inet addr:0.0.0.0  P-t-P:0.0.0.0  Mask:0.0.0.0
          POINTOPOINT  MTU:1500  Metric:1
          RX packets:63287 errors:0 dropped:0 overruns:0
          TX packets:62187 errors:0 dropped:0 overruns:0
  
Your PPP connection has not been made...see that later section on
debugging!

Now test the link by 'ping'ing the server at its IP number as reported by
the ifconfig output, ie

	ping 16.144.153.51

You should receive output like 

PING 10.144.153.51 (10.144.153.51): 56 data bytes
64 bytes from 10.144.153.51: icmp_seq=0 ttl=255 time=328.3 ms
64 bytes from 10.144.153.51: icmp_seq=1 ttl=255 time=190.5 ms
64 bytes from 10.144.153.51: icmp_seq=2 ttl=255 time=187.5 ms
64 bytes from 10.144.153.51: icmp_seq=3 ttl=255 time=170.7 ms

--- 10.144.153.51 ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 170.7/219.2/328.3 ms

(This listing will go on for ever - to stop it press <CTRL> C)

So far so good.

Now try pinging a host at your PPP server's site by name (not the name of
the PPP server itself). For example

	ping hedunx.hedland.edu.au

This time there will be a bit of a pause as Linux obtains the IP number
for the host you have 'ping'ed from the DNS you specified in
/etc/resolv.conf - so don't worry (but you will see your modem lights
flash). Shortly you will receive output like 

PING hedunx.hedland.edu.au (10.144.153.3): 56 data bytes
64 bytes from 10.144.153.3: icmp_seq=0 ttl=254 time=190.1 ms
64 bytes from 10.144.153.3: icmp_seq=1 ttl=254 time=180.6 ms
64 bytes from 10.144.153.3: icmp_seq=2 ttl=254 time=169.8 ms
64 bytes from 10.144.153.3: icmp_seq=3 ttl=254 time=170.6 ms
64 bytes from 10.144.153.3: icmp_seq=4 ttl=254 time=170.6 ms

--- hedunx.hedland.edu.au ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 169.8/176.3/190.1 ms

Again, stop the output by pressing <CTRL> C

If you don't get any response, check in the debugging section of this
document.

If everything works, shut down the connection by typing

	ppp-off

If that does not work, either turn off your modem or fire up your comms
software and interrupt the modem with +++ and then hang up with ATH0 when
you receive the modem's OK prompt.


9.0 Creating the 'chat' script
    --------------------------

A chat script automates the log in and PPP start up so all you have to do
is (as root) issue a single command to fire up your connection.

A chat script basically consists of "expect send" pairs. For example,
once the modem has dialed and connected to the remote modem, we "expect"
to receive a login prompt (possibly preceded by a lot of text - such as
the /etc/issue.net file on the server machine). Once we have received
this, we send our username. Next we expect the password prompt and send
our password.

Quite simple in principle really.

If the ppp package installed correctly, you should have two files in
/usr/sbin called
	ppp-on
	ppp-off

These contain 'templates' for establishing a PPP session using chat. The
ppp-off file was the one we used in the previous section to shut down
our manually established PPP session (so we know it worked - if it did!).
Just in case you DON'T have these templates, here they are:-

/usr/sbin/ppp-on-----------------

#!/bin/sh

#
#       ppp-on
#
#       Set up a PPP link
#

LOCKDIR=/var/spool/lock
DEVICE=com1

PHONE=4511234
USER=Pkarl
PASSWORD=password
OUR_IP_ADDR=137.175.6.3

if [ -f $LOCKDIR/LCK..$DEVICE ]
then
    echo "PPP device is locked"
    exit 1
fi

fix-cua $DEVICE

(
    stty 19200 -tostop

    if chat -l LCK..$DEVICE ABORT "NO CARRIER" ABORT BUSY "" ATZ OK ATs50=255s111=0DT$PHONE CONNECT "" ogin: $USER ssword: \\q$PASSWORD
    then
        pppd asyncmap 0 -detach modem crtscts mru 1500 $OUR_IP_ADDR: /dev/$DEVICE
        rm -f LCK..$DEVICE
        exit 0
    else
        echo "PPP call failed" 1>&2
        exit 1
    fi
) < /dev/$DEVICE > /dev/$DEVICE

#------END

/usr/sbin/ppp-off------------------

#!/bin/sh

DEVICE=ppp0

#
# 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 unsuccessful, ensure that the pid file is removed.
#
        if [ ! "$?" = "0" ]; then
                echo "removing stale $DEVICE pid file."
                rm -f /var/run/$DEVICE.pid
                exit 1
        fi
#
# Success. Terminate with proper status.
#
        echo "$DEVICE link terminated"
        exit 0
fi
#
# The link is not active
#
echo "$DEVICE link is not active"
exit 1

#--------END

The file permissions and ownerships should be :-

-rwxr-xr-x   1 root     root          502 Sep  3 20:04 /usr/sbin/ppp-off
-rwxr-xr-x   1 root     root          612 Sep  3 20:04 /usr/sbin/ppp-on


9.1 Creating your ppp-on file
    -------------------------

Copy the ppp-on file to a new name (I tend to use ppp-<sitename> for
convenience and as an aid to memory as I have quite a few). This way,
you can always go back to the original if you mess up the copy you have
created. 

Now, we are going to edit this, using the information we gathered from
the sysadmin of the PPP server.

'ppp-on' is a Bourne shell script. It first sets up a number of shell
variables for later use.

1) Lock file directory (LOCKDIR)

Have a look in /var and below for your lock file directory. For a Linux
standard file system, this will be /var/lock (not /var/spool/lock as in
the example).

Edit the LOCKDIR= line so it points at your lock directory.


2) Serial device (DEVICE)

This is the serial device to which you have connected you modem - without
the /dev/ prefix.

Edit the DEVICE= line so it points at the serial port on which you have
your modem.


3) PPP server phone number (PHONE)

This is the phone number to dial to reach the PPP server (don't forget
any leading numbers necessary to get past a PABX - you can insert the
standard dial pause command ',' if necessary.

Edit the PHONE= line so it is the PPP server's phone number


4) User name (USER)

This is the user name you use to log into your PPP server.

Edit the USER= line so it is your PPP server username (don't forget, Unix
and most PPP servers are case sensitive - so get the capitals right!).


5) Password (PASSWORD)

This is the password you use to log into your PPP server.

Edit the PASSWORD= line so it contains your password, as you would type
it in at the password: prompt.

Now, this is a bit of a problem! As the file permissions are currently
set up, anyone can read the ppp-on (or whatever you called it) file - and
can thus obtain your password! So, when you have finished editing this
file change its permissions to be 700 (chmod 700 /usr/sbin/ppp-on) so
that only the root user can read this file!!!!

(Remember, even if you are the only user of your machine, you are setting
up a link that connects it to the Internet (or some other network). Linux
is a multi-user operating system and whilst you are connected, anyone on
the Internet may try to get into your system - if they get hold of your
username and password, they can log into your account - at the very least
costing you money!)

6) Your IP address (OUR_IP_ADDR)

If the server you are connecting to uses DYNAMIC IP numbers, set this to
0.0.0.0 - or better, delete this line altogether.

If your PPP server sysadmin has given you your own IP number, you are
using STATIC IP numbers. So edit this line so it is set to the IP number
you have been given. If you have set this up in your /etc/ppp/options
file, you can delete this line altogether.

For static IP numbers, if you haven't put a 'netmask xx.xx.xx.xx' option
in your /etc/ppp/options file, put in a variable for this as well:-

	NETMSK=<your PPP server's netmask>


7) Edit the 'chat' line

The entire chat command must be on one line - no line breaks allowed
(except as specified in the chat man page).

The chat line starts with options to chat itself.
	-l LCK..$DEVICE
This sets up the lock file.

One other VERY useful option for debugging is '-v' which tells chat to
log the entire chat "expect send" conversation to the system log. When
you are first setting up the connection, I strongly suggest you use the
-v option, so the start of the chat line would be
	-v -l LCK..$DEVICE

The expect/send pairs start with
	"" ATZ

This means "expect nothing and send ATZ" (which resets the modem, loading
its default configuration).

Now we have
	OK ATs50=255s111=0DT$PHONE

which "expects" an OK response (the result of the ATZ) and then sends a
modem configuration string and the tone dial command and phone number.

As we have set our modem to be correctly configured once it receives and
ATZ, edit this pair to read
	OK ATDT$PHONE
(If you want to issue modem configuration commands, this is the place to
do it).

The next pair is
	CONNECT ""
which means expect CONNECT (our modem sends this when it connects) and
send nothing.

Now we get to the login process
	ogin: $USER
which looks for the login prompt and sends our username. Edit this
expect string to reflect the login process you carefully captured when
you logged in before.

We now look for the password prompt
	assword: \\q$PASSWORD
which looks for the password prompt and then sends our password. The \\q
tells chat NOT to log the actual text of our password to the system log
file (instead ?????? is recorded instead).

If you need to issue a command to start up PPP on the server, add an
additional "expect send" pair - this one would look for your login prompt
(beware of characters that have a special meaning in the Bourne shell -
such as $) and issue the ppp start up command.

In my case, my PPP server uses the standard Linux Bash prompt
	[hartr@kepler hartr]$
and requires that I type
	ppp
to start up PPP on the server.

so my expect/send pair is
	hartr ppp

(NB - chat has significantly more capability than this - including
recovering from errors and missed "expects" - read the chat man pages for
more information).


8) Edit the pppd line

Because you have set up a /etc/ppp/options file, you do not need to
specify ANY ppp options other than $DEVICE (which tells PPP which serial
port to bind to).

However, all the PPP options can be specified, and the only requirement
is that the pppd command and its options is all on one line AND the
device must be the last option specified.

As we have already seen, you can specify turn on debug information
logging with the -d option to pppd. As we are establishing a new
connection with a new script, put in the -d as the first (and possibly
only option apart from $DEVICE) to pppd.

If you have called your ppp options file anything other than
/etc/ppp/options, specify the file name with the -f option to pppd - eg
	-f options.myserver

9) Save your script

OK that's it - exit the editor and NOW CHANGE THE PERMISSIONS ON YOUR
SCRIPT FILE to 700!!!


10.0 Testing your chat script
     ------------------------

Open a new root xterm (if you are in X) or open a new virtual console and
log in as root.

In this new window, issue the command

	tail -f /var/log/messages

(or whatever your system log file is).
In the first window (or virtual console) issue the command
	ppp-kepler

(or whatever you called your ppp start up script).

Now switch back to the window that is tracking your system log.

You will see something like the following (provided you specified -v to
chat and -d to pppd).

Oct 21 16:09:58 hwin chat[19868]: abort on (NO CARRIER) 
Oct 21 16:09:59 hwin chat[19868]: abort on (BUSY) 
Oct 21 16:09:59 hwin chat[19868]: send (ATZ^M) 
Oct 21 16:09:59 hwin chat[19868]: expect (OK) 
Oct 21 16:10:00 hwin chat[19868]: ATZ^M^M 
Oct 21 16:10:00 hwin chat[19868]: OK -- got it 
Oct 21 16:10:00 hwin chat[19868]: send (ATDT722298^M) 
Oct 21 16:10:00 hwin chat[19868]: expect (CONNECT) 
Oct 21 16:10:00 hwin chat[19868]: ^M 
Oct 21 16:10:22 hwin chat[19868]: ATDT722298^M^M 
Oct 21 16:10:22 hwin chat[19868]: CONNECT -- got it 
Oct 21 16:10:22 hwin chat[19868]: send (^M) 
Oct 21 16:10:22 hwin chat[19868]: expect (ogin:) 
Oct 21 16:10:22 hwin chat[19868]:  57600^M 
Oct 21 16:10:23 hwin chat[19868]: ^[[;H^[[2J^M^M 
Oct 21 16:10:23 hwin chat[19868]: ^M 
Oct 21 16:10:23 hwin chat[19868]: ^M 
Oct 21 16:10:23 hwin chat[19868]: ^I^I      This is node kepler.hedland.edu.au^M 
Oct 21 16:10:23 hwin chat[19868]: ^I^I^I      at Hedland Campus^M 
Oct 21 16:10:23 hwin chat[19868]: ^I^I^I       Hedland College^M 
Oct 21 16:10:23 hwin chat[19868]: ^M 
Oct 21 16:10:23 hwin chat[19868]: ^I^I  Authorised user ONLY are to use this system^M 
Oct 21 16:10:23 hwin chat[19868]: ^M 
Oct 21 16:10:23 hwin chat[19868]: ^M 
Oct 21 16:10:23 hwin chat[19868]: ^I^I For more information, contact Computer Systems^M 
Oct 21 16:10:23 hwin chat[19868]: ^I^I^I     on +61 (0)91 72 0400^M 
Oct 21 16:10:23 hwin chat[19868]: ^I^I^I^I     or^M 
Oct 21 16:10:23 hwin chat[19868]: ^I^I       email: help@hedunx.hedland.edu.au^M 
Oct 21 16:10:23 hwin chat[19868]: ^M 
Oct 21 16:10:23 hwin last message repeated 3 times
Oct 21 16:10:23 hwin chat[19868]: kepler login: -- got it 
Oct 21 16:10:23 hwin chat[19868]: send (hartr^M) 
Oct 21 16:10:23 hwin chat[19868]: expect (ssword:) 
Oct 21 16:10:23 hwin chat[19868]:  hartr^M 
Oct 21 16:10:23 hwin chat[19868]: Password: -- got it 
Oct 21 16:10:23 hwin chat[19868]: send (??????^M) 
Oct 21 16:10:23 hwin chat[19868]: expect (hartr) 
Oct 21 16:10:23 hwin chat[19868]:  ^M^M 
Oct 21 16:10:24 hwin chat[19868]: Last login: Sat Oct 21 14:55:53 on ttyC0^M 
Oct 21 16:10:24 hwin chat[19868]: ^M 
Oct 21 16:10:24 hwin last message repeated 9 times
Oct 21 16:10:24 hwin chat[19868]: ^I^IYou have logged into node kepler.hedland.edu.au^M 
Oct 21 16:10:24 hwin chat[19868]: ^M 
Oct 21 16:10:24 hwin chat[19868]:            This is a Compaq Prolinea 486DX2/50 running Linux 1.1.54^M 
Oct 21 16:10:24 hwin chat[19868]: ^M 
Oct 21 16:10:24 hwin chat[19868]:        This computer operates as the main Hedland Campus communications^M 
Oct 21 16:10:24 hwin chat[19868]: ^I       node, providing dial-in terminal and SLIP access,^M 
Oct 21 16:10:24 hwin chat[19868]: ^I^I      Kepler also runs the Hedland end of^M 
Oct 21 16:10:24 hwin chat[19868]: ^I^I    the Hedland/Newman inter-Campus WAN link^M 
Oct 21 16:10:24 hwin chat[19868]: ^M 
Oct 21 16:10:24 hwin chat[19868]: ^M 
Oct 21 16:10:24 hwin chat[19868]: [hartr -- got it 
Oct 21 16:10:24 hwin chat[19868]: send (ppp^M) 
Oct 21 16:10:27 hwin pppd[19872]: pppd 2.1.2 started by root, uid 0
Oct 21 16:10:27 hwin pppd[19873]: Using interface ppp0
Oct 21 16:10:27 hwin pppd[19873]: Connect: ppp0 <--> /dev/cua1
Oct 21 16:10:27 hwin pppd[19873]: fsm_sdata(LCP): Sent code 1, id 1.
Oct 21 16:10:27 hwin pppd[19873]: LCP: sending Configure-Request, id 1
Oct 21 16:10:27 hwin pppd[19873]: fsm_rconfreq(LCP): Rcvd id 1.
Oct 21 16:10:27 hwin pppd[19873]: lcp_reqci: rcvd MRU
Oct 21 16:10:27 hwin pppd[19873]: (1500)
Oct 21 16:10:27 hwin pppd[19873]:  (ACK)
Oct 21 16:10:27 hwin pppd[19873]: lcp_reqci: rcvd ASYNCMAP
Oct 21 16:10:27 hwin pppd[19873]: (0)
Oct 21 16:10:27 hwin pppd[19873]:  (ACK)
Oct 21 16:10:27 hwin pppd[19873]: lcp_reqci: rcvd MAGICNUMBER
Oct 21 16:10:27 hwin pppd[19873]: (a098b898) Oct 21 16:10:27 hwin pppd[19873]:  (ACK)
Oct 21 16:10:27 hwin pppd[19873]: lcp_reqci: rcvd PCOMPRESSION
Oct 21 16:10:27 hwin pppd[19873]:  (ACK)
Oct 21 16:10:27 hwin pppd[19873]: lcp_reqci: rcvd ACCOMPRESSION
Oct 21 16:10:27 hwin pppd[19873]:  (ACK)
Oct 21 16:10:27 hwin pppd[19873]: lcp_reqci: returning CONFACK.
Oct 21 16:10:27 hwin pppd[19873]: fsm_sdata(LCP): Sent code 2, id 1.
Oct 21 16:10:27 hwin pppd[19873]: fsm_rconfack(LCP): Rcvd id 1.
Oct 21 16:10:27 hwin pppd[19873]: fsm_sdata(IPCP): Sent code 1, id 1.
Oct 21 16:10:27 hwin pppd[19873]: IPCP: sending Configure-Request, id 1
Oct 21 16:10:27 hwin pppd[19873]: fsm_rconfreq(IPCP): Rcvd id 1.
Oct 21 16:10:27 hwin pppd[19873]: ipcp: received ADDR 
Oct 21 16:10:27 hwin pppd[19873]: (10.144.153.51)
Oct 21 16:10:27 hwin pppd[19873]:  (ACK) 
Oct 21 16:10:27 hwin pppd[19873]: ipcp: received COMPRESSTYPE 
Oct 21 16:10:27 hwin pppd[19873]: (45)
Oct 21 16:10:27 hwin pppd[19873]:  (ACK) 
Oct 21 16:10:27 hwin pppd[19873]: ipcp: returning Configure-ACK
Oct 21 16:10:28 hwin pppd[19873]: fsm_sdata(IPCP): Sent code 2, id 1.
Oct 21 16:10:30 hwin pppd[19873]: fsm_sdata(IPCP): Sent code 1, id 1.
Oct 21 16:10:30 hwin pppd[19873]: IPCP: sending Configure-Request, id 1
Oct 21 16:10:30 hwin pppd[19873]: fsm_rconfreq(IPCP): Rcvd id 255.
Oct 21 16:10:31 hwin pppd[19873]: ipcp: received ADDR 
Oct 21 16:10:31 hwin pppd[19873]: (16.144.153.51)
Oct 21 16:10:31 hwin pppd[19873]:  (ACK) 
Oct 21 16:10:31 hwin pppd[19873]: ipcp: received COMPRESSTYPE 
Oct 21 16:10:31 hwin pppd[19873]: (45)
Oct 21 16:10:31 hwin pppd[19873]:  (ACK) 
Oct 21 16:10:31 hwin pppd[19873]: ipcp: returning Configure-ACK
Oct 21 16:10:31 hwin pppd[19873]: fsm_sdata(IPCP): Sent code 2, id 255.
Oct 21 16:10:31 hwin pppd[19873]: fsm_rconfack(IPCP): Rcvd id 1.
Oct 21 16:10:31 hwin pppd[19873]: ipcp: up
Oct 21 16:10:31 hwin pppd[19873]: local  IP address 10.144.153.104
Oct 21 16:10:31 hwin pppd[19873]: remote IP address 10.144.153.51


(Note - I am using STATIC IP numbers - hence my machine sent that to the
PPP server - you won't see this if you are using DYNAMIC IP numbers.)

This looks OK - so test it out as before with pings to IP numbers and
host names.

Fire up you web browser or whatever and go surfing you are connected!


11.0 Shutting down the PPP link
     --------------------------

When you have finished with the PPP link, use the standard ppp-off
command to shut it down (remember - you need to be root!).

In your system log you will see something like:-

Oct 21 16:10:45 hwin pppd[19873]: Interrupt received: terminating link
Oct 21 16:10:45 hwin pppd[19873]: ipcp: down
Oct 21 16:10:45 hwin pppd[19873]: default route ioctl(SIOCDELRT): Bad address
Oct 21 16:10:45 hwin pppd[19873]: fsm_sdata(LCP): Sent code 5, id 2.
Oct 21 16:10:46 hwin pppd[19873]: fsm_rtermack(LCP).
Oct 21 16:10:46 hwin pppd[19873]: Connection terminated.
Oct 21 16:10:46 hwin pppd[19873]: Exit.


12.0 Routing issues
     --------------

If you are connected to a LAN but still want to use PPP, you need to
address some issues of the routes packets need to take from your machine
to reach your LAN (through your ethernet interface) and also to the
remote PPP server and beyond.

This section does NOT attempt to teach you about routing - it deals only
with a simple, special case of )static) routing!

I strongly urge you to read the Network Administrator Guide NAG) if you
are NOT familiar with routing. Also the O'Reilly book "TCP/IP Network
Administration" covers this topic in a very understandable form.

The basic rule of static routing is that the DEFAULT route should be the
one that points to the MOST number of network addresses. For other
networks, enter specific routes to the routing table.

The ONLY situation I am going to cover here is where your Linux box is
on a LAN that is not connected to the Internet - and you want to dial
out to the Internet whilst still connected to the LAN. 

First of all, make sure that your ethernet route is set up to the specific network addresses available across your LAN - NOT set to the
default route!

check this by issuing a route command, you should see something like the
following:-

[root@hwin /root]# route -n
Kernel routing table
Destination     Gateway         Genmask         Flags MSS    Window Use Iface
loopback        *               255.255.255.0   U     1936   0       50 lo
10.0.0.0        *               255.255.255.0   U     1436   0      565 eth0


If your ethernet interface (eth0) is pointing at the default route, (the
first column will show "default" in the eth0 line) you need to change
you ethernet initialisation scripts to make it point at the specific
network numbers rather than the default route (consult the Net2 HOWTO
and NAG).

This will allow pppd to set up your default route as shown below:-

[root@hwin /root]# route -n
Kernel routing table
Destination     Gateway         Genmask         Flags MSS    Window Use Iface
10.144.153.51   *               255.255.255.255 UH    488    0        0 ppp0
127.0.0.0       *               255.255.255.0   U     1936   0       50 lo
10.1.0.0        *               255.255.255.0   U     1436   0      569 eth0
default         10.144.153.51   *               UG    488    0        3 ppp0

As you can see, we have a route to the PPP server ( 10.144.153.51) via
ppp0 and also a default route that uses the PPP server as its gateway.

If your set up needs to be more complex than this - read the routing
documents already mentioned and consult an expert at your site!


13.0 Debugging
     ---------

If you can't get you PPP link to work, go back through this document and
check everything - in conjunction with the output created by "chat
-v..." and "pppd -d" in you system log.

Also consult the PPP documentation and FAQ plus the other documents
mention herein!

If you are still stuck, the comp.os.linux.misc and
comp.os.linux.networking newsgroups are reasonably regularly scanned by
people that can help you with PPP (including myself).

You can try sending me personal email, but I do have a day job and I do
not guarantee to respond quickly (if at all) as this depends on my
current work load and the state of my private life!

In particular - DO NOT POST REAMS OF DEBUGGING OUTPUT TO THE NEWS GROUPS
NOR SEND IT TO ME BY EMAIL - the former wastes huge amounts of network
bandwidth and the latter will be consigned to /dev/null unless I
specifically request it!



----------------------------------
Robert Hart (hartr@hedland.edu.au)

Hedland College
PMB 1
South Hedland      WA 6722
Australia

-- 
---
Robert Hart                                  hartr@hedunx.hedland.edu.au
Voice: +61 (0)91 72 0429                     Fax:   +61 (0)91 72 3560
Hedland College, PMB 1, South Hedland WA 6722 Australia



