MandrakeUser.Org - Your Mandrake-Linux Knowledge Base!


 
 

* DocIndex - Connectivity

Dial-up Networking (PPP) I

*Preparations
*Setting Up The Connection Files

Related Resources:

Modem HOWTO
A List of PPP Utilities

Revision / Modified: July 31, 2001
Author: Tom Berger

 

In most cases, configuring a dial-up connection on Linux is about as simple as it is in Windows. You either use 'DrakNet' from the Mandrake Control Center or one of the many other dialers provided (like kppp or GnomePPP).
However, there may be times you want a more generic and general solution, be it that you have to provide a multiuser system with dial-up connections or be it that you can't get it working with graphical tools. Or maybe you are looking for a more powerful - i.e. scripted - solution. Then you might find this article helpful.

* Preparations

OK, before going right into heavy editing mode, check if you have all the needed hardware, software and data and hand:

  • A modem supported by Linux. Some modems, like most internal PCI modems or some external USB modems are so-called WinModems. Which means that they rely on Windows-only software to work.
    Read Winmodems are not modems for more information and a compatibility list and check out Linmodems.org for (a few) drivers.

  • The modem's init-string. GNU/Linux does not have an equivalent to the Windows hardware information file (.inf) mechanism. You may have to find out the init-string for your modem yourself. It should(TM) be listed in your hardware's documentation or in the modem's INF file, but there are also online sources like this list of modem init-strings. If you have no clue at all, use ATZ, that works with many modems.

  • Provider data. You'll need your login name, password and the telephone number. DNS addresses would be fine, too, but are optional for recent versions of pppd.

Check if your modem is connected correctly to the system or properly recognized by it.
With an external modem, that's pretty easy. As 'root' do echo >/dev/ttyS0 and watch the modem LEDs. You should see them flicker for a moment. If not, try echo >/dev/ttyS1 in case your modem is connected to the second serial port.
With an internal modem, use HardDrake to check if the system sees the modem. Or use this command to query the PCI list directly: cat /proc/pci. If it's an ISA bus modem, check '/etc/isapnp.conf' if it is listed there. If you don't have that file, you'll have to generate it. Read isapnpfaq.txt in the isapnptools doc directory or man isapnp orman isapnp.conf.

* Setting Up The Connection Files

You will have to edit or create these files:

  • '/etc/ppp/peers/[peer]' will be the ISP specific communication setup file. It determines how your machine will talk to the other machine (the provider's login server).
  • '/etc/ppp/chat-[peer]' will be the ISP specific login file. It determines how your machine will connect to the ISP.
  • '/etc/ppp/chap-secrets', '/etc/ppp/pap-secrets' contain the account data necessary to identify you to the other machine.
  • '/etc/ppp/options' contains general options valid for all PPP connections.

'/etc/ppp/peers/[...]'

Create a new file in the directory '/etc/ppp/peers/'. The filename should reflect the name of your ISP, but you can name it as you please. For demonstration purposes I will assume the name 'isp1'.
Put these lines in there:

/dev/ttyS[0,1,2,3] 115200 crtscts
connect '/usr/sbin/chat -v -f /etc/ppp/chat-isp1'
noauth user [username]


/dev/ttyS[0,1,2,3] refers to the serial port your modem is connected to. 'ttyS0' is the first serial port (or 'Com1' in DOS), 'ttyS1' the second (Com2) etc.
115200 is the modem speed in baud/second. '115200' is suited for all 56k or better modems and ISDN TAs. If your modem is older, use '57200' instead.
crtcts enables the hardware flow control. This is the correct setting for most modems.
connect '/usr/sbin/chat -v -f /etc/ppp/chat-isp1' tells pppd to connect using the chat program, which in turn is told ('-f') to use the specified chat-file ('/etc/ppp/chat-isp1'). The filename 'chat-isp1' is arbitrary since you still have to create this file, the only thing to note is that the filename given here and the name of the chatfile you are to create later have to be identical.
'-v' will give you more output in the log files.
noauth is important, because it tells the local pppd not to require authentication from the remote machine (the ISP's server). PPP is short for 'Peer-to-Peer Protocol', by default both machines ('peers') using this protocol are required to authenticate to their respective peer. ISP machines however usually refuse to authenticate themselves in order to reduce overhead. In the default setting ('auth') this would lead to the local PPP program dropping the connection. user [username] sets the name of your machine for authentication purposes to your 'username'. Use the username (aka account name, login or similar) supplied to you by your provider.

'/etc/ppp/chat-[peer]

In this example, the name of the 'chat' peers file to be created is 'chat-isp1' as determined by the 'peers' file in '/etc/ppp/peers/'. It contains the exact instructions for the 'chat' program how to handle your modem. It looks like this:

TIMEOUT 20
ABORT "NO CARRIER"
ABORT "NO DIALTONE"
ABORT ERROR
ABORT "NO ANSWER"
ABORT BUSY
ABORT "Username/Password Incorrect"
"" +++[modem init-string]
OK ATDT[ISP server phonenumber]
CONNECT ""
~-- ""

This file mustn't contain any empty lines. Save this file under the name you've specified in the peers file.
'chat' uses this file to initialize your modem, dial the number and report connect to pppd which then starts the authentication procedure. If the modem encounters one of the error conditions defined by 'ABORT...', 'chat' returns the error to pppd, which will then terminate itself after 20 seconds. Some error conditions are quoted because their names contain empty spaces.
The second part contains 'expect-from-modem send-to-modem' pairs, separated by an empty space. Empty spaces which do not separate expect/send pairs will cause the 'chat' script to fail.

In the vast majority of cases, ISPs use CHAP or PAP for authentication, if your provider requires a terminal login however, you'll have to provide the authentication data in the chat file, too:

ogin:--ogin: [accountname]
word: [password]

The chat-file is by default world-readable. This is certainly a bad idea if this file contains your account information. On the other hand it must be readable by the user who uses it. What to do? Open '/etc/group' in your editor as 'root' and add your local login name to the group 'ppp-users'. Save and close. As 'root', run

chmod 640 /etc/ppp/chat-[name] && chown root:pppusers /etc/ppp/chat-[name]

Now only 'root' and members of the pppusers group have read-access to this file and only 'root' may edit it.

'/etc/ppp/[pap|chap]-secrets'

Most ISPs use either PAP (Password Authentication Protocol) or CHAP (Challenge Handshake Authentication Protocol) for authenticating clients, with PAP being the more popular of the two.

Most providers won't tell you if they use PAP or CHAP, but that's no problem since the PPP program will happily try both if the authentication data are in both files. The syntax is the same for both files. Open one of them in an editor (as 'root'), the file should look like this:

# Secrets for authentication using [PAP|CHAP]
# client     server   secret         IP addresses

The clever thing is that you can provide wildcards ('*') for values you don't know about, like the server name or IP addresses. The only important values are 'client' (=username) and 'secret' (=password). So enter these values and put in '*' for the other fields. Separate entries with the 'TAB' key. It should now look like this:

# Secrets for authentication using [PAP|CHAP]
# client     server   secret         IP addresses
[yourusername] * [yourpassword] *

If you're using more than one provider, just enter every username - password combination you have. 'pppd' will try every combination until it finds one that matches.

'/etc/ppp/options'

This file keeps some general options for pppd, options that should apply for every connection regardless of which peers-file you are going to use.
A typical 'options' file might look like this:

lock
defaultroute
noipdefault
idle 1200
usepeerdns

  1. lock tells pppd to create a lockfile as soon as it gets hold of the modem. This will prevent other programs from accessing the device while pppd uses it.

  2. defaultroute tells pppd to create a default lookup route while it is running, using your ISP's server as a standard gateway. This is necessary to keep the different networking layers on your machine separate.

  3. noipdefault tells pppd to accept every IP-number your ISP will assign to your machine when it connects.

  4. idle 1200 tells pppd to cut the connection after twenty minutes (1200 seconds) of inactivity. I am forgetful from time to time ;-). Note that man pppd advises you not to use this option without the option demand. From my experience however there is no reason not to use it on its own.

  5. usepeerdns will use the DNS server addresses supplied by your ISP's server and write them to '/etc/ppp/resolv.conf'.

There are many more options available (listed in man pppd), but the less the better. The PPP troubleshooting page lists some options you should try, if your connection doesn't work with this basic set.

* section index * top

* Testing And Customization


 
Legal: All texts on this site are covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB (Tom Berger) and Mandrakesoft 1999-2002.