Linux Index

Internet connection with PPP


Introduction

If you want to connect to the Internet, you have to use the pppd daemon.

In KDE, you will find kppp which is an easy graphical interface to manage the connection. For a first test, you try it.

If you have special requirements or if kppp doesn't work properly, don't be afraid, you can configure pppd manually. That's not so difficult and you have more control. Another benefit is that you can make a connection script where you can manage automatic tasks such as fetching and sending mails.

Step 1 : Make the link /dev/modem

The special character device /dev/cua0 .. /dev/cua3 correspond respectively to the serial port COM1 .. COM4. Make a link to /dev/modem to the appropriate character device. For example, if you use port COM2 for your modem, you can type (as user root)
ln -s /dev/cua1 /dev/modem

Step 2 : Check the serial port parameters

Type
setserial -a /dev/modem
to see the serial port parameters. Check that it corresponds with what you expect.

Step 3 : Select the serial port baud rate

This is the data rate between the computer and the modem.

  • Select 115200 bps if you have a 16550 UART (the most frequent case)
  • Select 38500 bps if you have a 16450 UART
  • Select 19200 bps if you have a 8250 UART

Start the communication software minicom and try to communicate with this baud-rate : set the correct speed in the 'serial port setup' and type 'AT' in the terminal. If it communicates, you should get 'OK' as answer. If not, look into your modem manual.

Step 4 : Set the modem parameters

You should try to set correct parameters in the flash of your modem. It's really important that you carefully look in your manual. In order to communicate with your modem, use minicom. You should take care at the following :

  • The answer sequence (typically ATBn) : choose between US in the states and the ITU-T answer sequence in Europe.
  • The flow control must be on ! Otherwise, you could experience communication cuts-off (especially in a upload).

Step 5 : check that you don't have any default route

When you are querying for an IP address, the system looks into his routing table to see which interface has to be used. As one should expect, the default route specifies the default interface. After connection, ppp will automatically try to set the default route to ppp0, at least if there is no default route defined at this moment.

Check that you don't have any default route by typing :
/sbin/route -n

If present, you can identify the default route by the address 0.0.0.0 in the first column. In this case, you have to remove it by typing
/sbin/route del default

Step 6 : Make the secret files

This concerns the files which contains the password to connect to your local Internet provider. There are mainly two authentication protocols, namely PAP and CHAP. Typically one provider will use only one of those two protocols, but it doesn't hurt if you configure both.

My PAP secret file looks like this :

# Secrets for authentication using PAP
# client   server  secret       IP addresses
dfzt12     *       kdwMlp45
In this example, 'dfzt12' is the login name and 'ldwMlp45' is the password. The name of the PAP secret file is /etc/ppp/pap-secrets

My CHAP secret file is exactly the same than the PAP secret file. The name of the PAP secret file is /etc/ppp/chap-secrets

Change the right access of those files :
chmod 0600 /etc/ppp/*secrets

Step 7 : set the name servers

To translate a domain name in a IP address, you need a domain name server. Your Internet provider give you one or more domain name server addresses.

You can make the /etc/resolv.conf file with a maximum of 3 name server addresses. For example,

domain localdomain
nameserver 193.11.11.11
nameserver 193.22.22.22

As you see, the keyword 'domain' serves to declare the local domain name.

Step 8 : make the /etc/ppp/ppp-on-dialer file

This is basically a script which use the chat command to dial the number. For example, my file looks like this :
TELEPHONE=012355447
exec /usr/sbin/chat -v                                \
        TIMEOUT         3                             \
        ABORT           '\nBUSY\r'                    \
        ABORT           '\nNO ANSWER\r'               \
        ABORT           '\nRINGING\r\n\r\nRINGING\r'  \
        ''              \rAT                          \
        'OK-+++\c-OK'   ATH0                          \
        TIMEOUT         30                            \
        OK               ATDT$TELEPHONE               \
        CONNECT         ''

If needed, you can set your modem init string in this file. See the chat manual page for details.

Step 9 : Edit the pppd options file

This file is named /etc/ppp/options. This file must contain security sensitive parameters. But you can set all the parameters in this file.

lock
modem
crtscts
/dev/modem
115200
asyncmap a0000
escape FF
kdebug 0
0.0.0.0:0.0.0.0
noipdefault
defaultroute
connect /etc/ppp/ppp-on-dialer
name dfzt12

Two important parameters are :

  • The baud rate of the serial port (here '115200')
  • the name of the client that must be searched in the secret files (here 'dfzt12')

Change the right access of this file :
chmod 0600 /etc/options

Step 10 : have a look at /etc/ppp/ppp-on and /etc/ppp/ppp-off

These two files are meant to start and to stop the connection. The former just call pppd (optionally with extra parameters) and the later send the signal 'INT' to pppd. To send a signal to the process pppd, one need to know the process number. You can find it in /var/run/ppp0.pid

My /etc/ppp/ppp-on is really minimum and looks like this :

#!/bin/sh
exec /usr/sbin/pppd

My /etc/ppp/ppp-off is also very short

#!/bin/sh
if [ -r /var/run/$DEVICE.pid ]; then
     kill -INT `cat /var/run/$DEVICE.pid`
     if [ ! "$?" = "0" ]; then
          rm -f /var/run/$DEVICE.pid
          echo "ERROR: Removed stale pid file"
          exit 1
     fi
fi

Step 11 : Set user id for pppd

If you want that every user be able to initiate a connection, type
chmod a+s /usr/sbin/pppd

Step 12 : try it

To connect, type
/etc/ppp/ppp-on

To check that your are connected, type
/sbin/route -n
and see if the default route (address 0.0.0.0) is attached to the ppp0 interface.

An other way to check for the connection is to type
/sbin/ifconfig ppp0
If the answer contains the word 'UP', it is connected.

To disconnect, type
/etc/ppp/ppp-off

Step 13 : If it doesn't work ...

If you experience problems with the connection, don't panic ! In order to enable logging information, edit the file /etc/syslog.conf and check that the following line is present :
daemon.* /dev/console

To reset the syslogd deamon without rebooting, send it the signal SIGHUP :
killall -HUP syslogd

As root user, start the xconsole by typing:
xconsole

Modify the logon script (/etc/ppp/ppp-on) to add debugging information :

#!/bin/sh
exec /usr/sbin/pppd debug