If your web browser formats this page incorrectly, try viewing the
page source. In netscape 4, click the view menu, then click page source.
This explains how to set up a simple PPP connection on a linux computer,
connecting to the internet using a typical ISP (Internet Service Provider).
The first question is, do you really need PPP? If your ISP gives you a
shell account, you can use a program like minicom to call your ISP and log
in to your shell account; and then you can run ftp, telnet, mail programs,
news programs, and text web browsers like lynx. But
if you want to use a graphical web browser like netscape, then you need PPP.
The second question is, do you want to manually configure PPP, or do you
want to use a program which configures PPP for you, like kppp or
redhat-config-network? The configurator programs ask you some questions
about your ISP account, and then hopefully PPP will work. Most people think
this is easy, and you do not have to know anything about PPP. Howver, if the
configurator programs do not work, then you will have to configure PPP
manually. Also, the configurator programs hide the information about your
ISP. This is good because it makes it hard for anyone to steal your
passwords. However, if you are trying to copy the information to another
computer, or if you are trying to backup the information, or if you are
trying to write a program which manipulates the ISP information, then the
hidden information is a problem. If you enter your password into the
configurator program, then later forget your password, you might not be able
to retrieve your password from the configurator program. An expert can
create a PPP configuration by editing a few files with a text editor in less
time than it takes to run a configurator program.
To have a PPP connection to the internet with Linux, you need a program
named 'pppd', and some miscellaneous utilities, devices, and libraries; and
some things need to be compiled into the kernel. The complete list of
everything you need is very long, and it depends on which version of which
distribution you have. However, if you have a normal Linux distribution, you
probably have everything you need. Also, you need a modem and an ISP.
pppd is a very complicated program which can have more than one PPP
connection at the same time; it can allow some users and not others to use
the PPP connections; and it can be used to run your own ISP. Most of the
documentation (the man pages, the PPP howto, the PPP FAQ, etc) are about
features which are not used in a simple PPP connection. This document will
explain only the features needed for a simple connection. Simple
connection means one user, no ethernet or other LAN, and one PPP connection
to the internet using a typical modem and a typical ISP.
pppd reads options from file /etc/ppp/options, then from $HOME/.ppprc,
then device options but not nondevice options from the command line, then
from /etc/ppp/options.[DEVICE], then from the command line. Later options
take precedence over earlier options, so command line options overide other
options. If the device is /dev/ttyS0, then /etc/ppp/options.[DEVICE] is
/etc/ppp/options.ttyS0. It is not an error if any or all of these files are
blank or do not exist. Some options call other option files, which may call
other option files. Some options call other programs or scripts, which may
call other programs or scripts. Thus it is possible to create very
complicated pppd configurations, with one options file for each serial port,
one options file for each modem, one options file for each ISP, etc.
This was written for pppd version 2.3. It might or might not be correct
for other versions of pppd.
First you should make sure that linux is configured correctly to use pppd.
Your linux distribution should have done this already, but I think you
should check these things anyway, because pppd will not work if linux is not
configured correctly. Note that linux does not have to be configured exactly
like this. Similar configurations will work. The configuration which I am
recommending is good for most home personal computers and small networks. It
is less suitable for a workstation attached to a major corporate network,
much less suitable for a major corporate network server, and even less
suitable for an internet server. If you are looking for information about
how to set up an internet server, you are looking in the wrong place.
All these configuration files need to be edited as root, so log in as
root before you start editing these files.
make sure there is a file named /etc/hosts and it includes a line:
27.0.0.1 localhost
make sure there is a file named /etc/host.conf and it includes a line:
order hosts,bind
make sure there is a file named /etc/nsswitch.conf and it includes a line:
hosts: files dns
make sure there is a file named /etc/hosts.deny, and it includes a line:
ALL: ALL
make sure there is a file named /etc/hosts.allow and it includes a line:
ALL: LOCAL
/etc/hosts.deny and /etc/hosts.allow create a simple firewall. PPP will
work fine if /etc/hosts.deny and /etc/hosts.allow are empty or missing, but
it is a good idea to have a firewall.
get an account at an ISP. find out: phone number to dial, login, password,
IP number of the nameserver, does PPP start automatically or do you have to
do something to start PPP. Your login is a word you use to login; your ISP
may call it a user name or user id.
make sure there is a file named /etc/ppp/pap-secrets, and it includes a
line:
joe_schmoe * password
but replace joe_schmoe with your login and replace password with your
password. etc/ppp/pap-secrets contains passwords, so you need to prevent
other people from reading it by doing 'chmod 0600 /etc/ppp/pap-secrets'.
make sure there is a file named /etc/resolv.conf, and it includes a line:
nameserver 191.72.1.1
but replace '191.72.1.1' with the IP number of the nameserver for your ISP.
Most ISPs have two nameservers, so make two lines, one for each nameserver.
Some people say you should have domain and search lines in /etc/resolv.conf,
but domain and search are not needed; my internet access works fine without
domain or search.
There are two ways to make a simple pppd configuration. You can make a
shell script which runs pppd, with all pppd options given on the command
line, with no pppd options files. In other words, put all options in the
shell script file. This is good if you want to run some other commands just
before or just after running pppd. The second way is to put all options
into /etc/ppp/options, with no other options files, and then just run pppd.
I like the second method. /etc/ppp/options should look like this:
/dev/modem # serial port which the modem is attached to
115200 # speed of serial port (modem). Use 115200 for 56K modems.
lock # make lockfile in /var/lock for modem device, to prevent any other
# program from using the modem device while pppd is running
crtscts # use RTS/CTS hardware flow control
modem # normal modem (not cable modem, isdn, etc) on normal serial port
defaultroute # PPP is our connection to the internet
noipdefault # We do not have an IP number; after we connect, the other
# computer will tell us our IP number
persist # reconnect if we were cut off
holdoff 5 # if we were cut off, wait 5 seconds before reconnecting
idle 600 # disconnect if we do not use PPP for 600 seconds (10 minutes)
name joe_schmoe # login
# run this command to connect to the ISP:
connect "/usr/sbin/chat ABORT ERROR ABORT 'NO DIALTONE' ABORT BUSY ABORT 'NO CARRIER' TIMEOUT 70 '' AT OK 'ATDT 123 4567' CONNECT"
The last line begins with connect and is very long. Do not be confused if
whatever program you are using to read this breaks the last line into
several lines or hides the end of the line. You need to change the phone
number in the last line to the phone number for your ISP. You need to change
the name to your login name at your ISP.
Microsuck Windoze prefers to use PAP, so most ISPs use PAP to accomodate
Microsuck Windoze. This example uses PAP, and therefore should work with
most ISPs. If it does not work, you probably need to do something to tell
your ISP to start PPP, like send a carriage return, or log in to a shell
account and send the command ppp. Ask your ISP. For example, the following
is similar to the previous connect command, except the following sends a
carriage return after CONNECT is received, and then logs in to a shell
account and sends the command ppp:
connect "/usr/sbin/chat ABORT ERROR ABORT 'NO DIALTONE' ABORT BUSY ABORT 'NO CARRIER' TIMEOUT 70 '' AT OK 'ATDT 123 4567' CONNECT '' ogin: joe_schmoe assword: password '$' ppp"
Note that chat recognizes some words like ABORT and TIMEOUT, and these
words usually have options, and all other words come in pairs, first a word
to receive, then a word to send. A return character is added to the end of
every word to send. If the word to receive is '', then chat does not wait.
If the word to send is '', then chat sends a return. chat is easier to
understand if you create a chat script with comments like this:
#!/usr/sbin/chat -f
# abort on errors
ABORT ERROR
ABORT 'NO DIALTONE'
ABORT BUSY
ABORT 'NO CARRIER'
# set timeout to 70 seconds
TIMEOUT 70
# don't wait, send AT to the modem
'' AT
# wait for the modem to say OK, then send the dial command
OK 'ATDT 123 4567'
# wait for the modem to say CONNECT, then send a carriage return
CONNECT ''
# wait for the login prompt 'Login: ', then send the login
ogin: joe_schmoe
# wait for the password prompt 'Password: ', then send the password
assword: password
# wait for the command prompt 'joe_schmoe@isp.net:~$ ',
# then send the command ppp to start ppp
'$' ppp
To start the PPP connection to your ISP, run the command 'pppd'.
Wait for about a minute. You should hear your modem dialing and connecting
to your ISP. If you do not see any error messages, it is probably working.
If pppd is not working, read the documentation for pppd and chat for
information about how to debug. You might want to test the chat script
by itself with a command like:
chat_script <> /dev/modem
For more information, run the commands 'man pppd' and 'man chat', and see
the PPP howto and the PPP FAQ.
To shut off the PPP connection and hang up the
modem, run the command 'killall pppd'.
Now you have your PPP connection working; you can use web browsers, ftp,
and telnet. But if you want your computer to exchange mail and news with
your ISP, then you need to configure news and mail transfer programs like
sendmail, fetchmail, etc.
Once pppd is connected, pppd will run /etc/ppp/ip-up. If /etc/ppp/ip-up
does not exist, pppd will not do anything, pppd will not even tell you that
/etc/ppp/ip-up does not exist. Usually /etc/ppp/ip-up is a shell script
which does things like synchronize your computer's clock with some clock on
the internet, or runs a mail fetch program to get email from various mail
servers out on the internet. So if you want to automatically check your
email accounts whenever you access the internet, put the commands in
/etc/ppp/ip-up. To adjust your computer clock, use 'ntpd -q' (use ntp time
server from /etc/ntpd.conf) or 'ntpdate [name of ntp time server]'. Ntpdate
is obsolete and has fewer features than ntpd, but ntpdate is easier to use.
In Linux the word 'networking' has many meanings. If you configure the
kernel with make config, and it asks if you want networking, you
should say yes, because PPP will not work without kernel support for
networking; PPP requires this kind of networking. But if your Linux has
several runlevels, and runlevels 2 and 3 are the same except networking is
running in runlevel 3, then PPP will work fine in both runlevels 2 and
3; PPP does not require this kind of networking.
If the serial port for your modem has an unusual configuration, you may
need to use setserial to configure the serial port. For more
information, run the command 'man setserial'. If the serial port driver is
compiled into your kernel, the setserial command should be put in your
startup scripts, /etc/rc.serial or /etc/rc.d/rc.local or something. But if
the serial port driver is a module, put the setserial command in
/etc/modules.conf; use a line like:
post-install serial setserial [setserial options]
Some old version of linux do not allow you to set the serial port speed
to more than 38400. You can overcome this by using setserial
to reconfigure the serial port driver so that when a program sets the
serial port speed to 38400, the serial port driver will set the serial
port speed to 57600 or 115200 or something. If you have this problem, put
38400 for the serial port speed in /etc/ppp/options, and put the setserial
command in your startup scripts or in /etc/modules.conf. Linux 1.x
probably has this problem. Linux 2.4.x probably does not have this problem.