Previous Next Table of Contents

15. 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 also 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.

15.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 (older systems may use /var/spool/lock).

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

15.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.

15.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.

15.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 user name (do not forget, Unix and most PPP servers are case sensitive - so get the capitals/lower case right).

15.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 (again, remember that passwords can be both upper and lower case!).

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 750 /usr/sbin/ppp-on) so that only the root user and members of the PPP group 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 user name and password, they can log into your account - at the very least costing you money if not severe embarrassment or worse if they do "naughty things" using your account!

15.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 (in which case you must also remove $OUR_IPADDR: from the pppd invocation).

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.

15.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 ATDT$PHONE

Which "expects" an OK response (the result of the ATZ) and then sends the tone dial command and phone number. If you cannot configure your modem so that its reset state is the one used for PPP, you can include a modem initialisation string here (consult your modem manual). For example:-

OK ATDT&K3S0=0DT$PHONE

As we have set our modem to be correctly configured once it receives an ATZ, we do not have to include a modem initialisation string.

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 itself.

ogin: $USER

Which looks for the login prompt and sends our user name. 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 we are using the -v option to chat.

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 or (open and close square brackets) - 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).

Unfortunately, some servers produce a very variable set of prompts! You may need to log in several times using minicom to understand what is going on and pick the stable expect strings.

15.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 (followed by the baud rate if specified) must be the last options specified.

As we have already seen, you can 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. (Warning: if your disk space is tight, logging pppd exchanges can rapidly extend your syslog file and run you into trouble - but to do this you must fail to connect and keep on trying for quite a few minutes).

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

-f options.myserver

15.9 Save your script

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


Previous Next Table of Contents