| 1 |
PPP for Linux |
| 2 |
------------- |
| 3 |
|
| 4 |
Paul Mackerras |
| 5 |
8 March 2001 |
| 6 |
|
| 7 |
for ppp-2.4.2 |
| 8 |
Updated for ppp-2.4.5, Sep 08 |
| 9 |
|
| 10 |
1. Introduction |
| 11 |
--------------- |
| 12 |
|
| 13 |
The Linux PPP implementation includes both kernel and user-level |
| 14 |
parts. This package contains the user-level part, which consists of |
| 15 |
the PPP daemon (pppd) and associated utilities. In the past this |
| 16 |
package has contained updated kernel drivers. This is no longer |
| 17 |
necessary, as the current kernel sources contain up-to-date drivers |
| 18 |
(and have done since the 2.4.x kernel series). |
| 19 |
|
| 20 |
The Linux PPP implementation is capable of being used both for |
| 21 |
initiating PPP connections (as a `client') or for handling incoming |
| 22 |
PPP connections (as a `server'). Note that this is an operational |
| 23 |
distinction, based on how the connection is created, rather than a |
| 24 |
distinction that is made in the PPP protocols themselves. |
| 25 |
|
| 26 |
Mostly this package is used for PPP connections over modems connected |
| 27 |
via asynchronous serial ports, so this guide concentrates on this |
| 28 |
situation. |
| 29 |
|
| 30 |
The PPP protocol consists of two parts. One is a scheme for framing |
| 31 |
and encoding packets, the other is a series of protocols called LCP, |
| 32 |
IPCP, PAP and CHAP, for negotiating link options and for |
| 33 |
authentication. This package similarly consists of two parts: a |
| 34 |
kernel module which handles PPP's low-level framing protocol, and a |
| 35 |
user-level program called pppd which implements PPP's negotiation |
| 36 |
protocols. |
| 37 |
|
| 38 |
The kernel module assembles/disassembles PPP frames, handles error |
| 39 |
detection, and forwards packets between the serial port and either the |
| 40 |
kernel network code or the user-level program pppd. IP packets go |
| 41 |
directly to the kernel network code. So once pppd has negotiated the |
| 42 |
link, it in practice lies completely dormant until you want to take |
| 43 |
the link down, when it negotiates a graceful disconnect. |
| 44 |
|
| 45 |
|
| 46 |
2. Installation |
| 47 |
--------------- |
| 48 |
|
| 49 |
2.1 Kernel driver |
| 50 |
|
| 51 |
Assuming you are running a recent 2.4 or 2.6 (or later) series kernel, |
| 52 |
the kernel source code will contain an up-to-date kernel PPP driver. |
| 53 |
If the PPP driver was included in your kernel configuration when your |
| 54 |
kernel was built, then you only need to install the user-level |
| 55 |
programs. Otherwise you will need to get the source tree for your |
| 56 |
kernel version, configure it with PPP included, and recompile. Most |
| 57 |
Linux distribution vendors ship kernels with PPP included in the |
| 58 |
configuration. |
| 59 |
|
| 60 |
The PPP driver can be either compiled into the kernel or compiled as a |
| 61 |
kernel module. If it is compiled into the kernel, the PPP driver is |
| 62 |
included in the kernel image which is loaded at boot time. If it is |
| 63 |
compiled as a module, the PPP driver is present in one or more files |
| 64 |
under /lib/modules and is loaded into the kernel when needed. |
| 65 |
|
| 66 |
The 2.2 series kernels contain an older version of the kernel PPP |
| 67 |
driver, one which doesn't support multilink. If you want multilink, |
| 68 |
you need to run a 2.4 or 2.6 series kernel. The kernel PPP driver |
| 69 |
was completely rewritten for the 2.4 series kernels to support |
| 70 |
multilink and to allow it to operate over diverse kinds of |
| 71 |
communication medium (the 2.2 driver only operates over serial ports |
| 72 |
and devices which look like serial ports, such as pseudo-ttys). |
| 73 |
|
| 74 |
Under the 2.2 kernels, if PPP is compiled as a module, the PPP driver |
| 75 |
modules should be present in the /lib/modules/`uname -r`/net directory |
| 76 |
(where `uname -r` represents the kernel version number). The PPP |
| 77 |
driver module itself is called ppp.o, and there will usually be |
| 78 |
compression modules there, ppp_deflate.o and bsd_comp.o, as well as |
| 79 |
slhc.o, which handles TCP/IP header compression. If the PPP driver is |
| 80 |
compiled into the kernel, the compression code will still be compiled |
| 81 |
as modules, for kernels before 2.2.17pre12. For 2.2.17pre12 and later, |
| 82 |
if the PPP driver is compiled in, the compression code will also. |
| 83 |
|
| 84 |
Under the 2.4 kernels, there are two PPP modules, ppp_generic.o and |
| 85 |
ppp_async.o, plus the compression modules (ppp_deflate.o, bsd_comp.o |
| 86 |
and slhc.o). If the PPP generic driver is compiled into the kernel, |
| 87 |
the other four can then be present either as modules or compiled into |
| 88 |
the kernel. There is a sixth module, ppp_synctty.o, which is used for |
| 89 |
synchronous tty devices such as high-speed WAN adaptors. |
| 90 |
|
| 91 |
|
| 92 |
2.2 User-level programs |
| 93 |
|
| 94 |
If you obtained this package in .rpm or .deb format, you simply follow |
| 95 |
the usual procedure for installing the package. |
| 96 |
|
| 97 |
If you are using the .tar.gz form of this package, then cd into the |
| 98 |
directory you obtained by unpacking the archive and issue the |
| 99 |
following commands: |
| 100 |
|
| 101 |
$ ./configure |
| 102 |
$ make |
| 103 |
# make install |
| 104 |
|
| 105 |
The `make install' has to be done as root. This makes and installs |
| 106 |
four programs and their man pages: pppd, chat, pppstats and pppdump. |
| 107 |
If the /etc/ppp configuration directory doesn't exist, the `make |
| 108 |
install' step will create it and install some default configuration |
| 109 |
files. |
| 110 |
|
| 111 |
The ./configure script can take various optional arguments to control |
| 112 |
what features are included, what directories are used for installation, |
| 113 |
etc. Type "./configure --help" to see a list of options. |
| 114 |
|
| 115 |
|
| 116 |
2.3 System setup for 2.4 (and later) kernels |
| 117 |
|
| 118 |
Under the 2.4 series kernels, pppd needs to be able to open /dev/ppp, |
| 119 |
character device (108,0). If you are using udev (as most distributions |
| 120 |
do), the /dev/ppp node should be created by udevd. |
| 121 |
|
| 122 |
Otherwise you may need to create a /dev/ppp device node with the |
| 123 |
commands: |
| 124 |
|
| 125 |
# mknod /dev/ppp c 108 0 |
| 126 |
# chmod 600 /dev/ppp |
| 127 |
|
| 128 |
|
| 129 |
2.4 System setup under 2.2 series kernels |
| 130 |
|
| 131 |
Under the 2.2 series kernels, you should add the following to your |
| 132 |
/etc/modules.conf or /etc/conf.modules: |
| 133 |
|
| 134 |
alias tty-ldisc-3 ppp |
| 135 |
alias ppp-compress-21 bsd_comp |
| 136 |
alias ppp-compress-24 ppp_deflate |
| 137 |
alias ppp-compress-26 ppp_deflate |
| 138 |
|
| 139 |
|
| 140 |
3. Getting help with problems |
| 141 |
----------------------------- |
| 142 |
|
| 143 |
If you have problems with your PPP setup, or you just want to ask some |
| 144 |
questions, or better yet if you can help others with their PPP |
| 145 |
questions, then you should join the linux-ppp mailing list. Send an |
| 146 |
email to [email protected] with a line in the body saying |
| 147 |
|
| 148 |
subscribe linux-ppp |
| 149 |
|
| 150 |
To leave the mailing list, send an email to [email protected] |
| 151 |
with a line in the body saying |
| 152 |
|
| 153 |
unsubscribe linux-ppp |
| 154 |
|
| 155 |
To send a message to the list, email it to [email protected]. |
| 156 |
You don't have to be subscribed to send messages to the list. |
| 157 |
|
| 158 |
You can also email me ([email protected]) but I am overloaded with |
| 159 |
email and I can't respond to most messages I get in a timely fashion. |
| 160 |
|
| 161 |
There are also several relevant news groups, such as comp.protocols.ppp, |
| 162 |
comp.os.linux.networking, or comp.os.linux.setup. |
| 163 |
|
| 164 |
|
| 165 |
4. Configuring your dial-out PPP connections |
| 166 |
-------------------------------------------- |
| 167 |
|
| 168 |
Some Linux distribution makers include tools in their distributions |
| 169 |
for setting up PPP connections. For example, for Red Hat Linux and |
| 170 |
derivatives, you should probably use linuxconf or netcfg to set up |
| 171 |
your PPP connections. |
| 172 |
|
| 173 |
The two main windowing environments for Linux, KDE and Gnome, both |
| 174 |
come with GUI utilities for configuring and controlling PPP dial-out |
| 175 |
connections. They are convenient and relatively easy to configure. |
| 176 |
|
| 177 |
A third alternative is to use a PPP front-end package such as wvdial |
| 178 |
or ezppp. These also will handle most of the details of talking to |
| 179 |
the modem and setting up the PPP connection for you. |
| 180 |
|
| 181 |
Assuming that you don't want to use any of these tools, you want to |
| 182 |
set up the configuration manually yourself, then read on. This |
| 183 |
document gives a brief description and example. More details can be |
| 184 |
found by reading the pppd and chat man pages and the PPP-HOWTO. |
| 185 |
|
| 186 |
We assume that you have a modem that uses the Hayes-compatible AT |
| 187 |
command set connected to an async serial port (e.g. /dev/ttyS0) and |
| 188 |
that you are dialling out to an ISP. |
| 189 |
|
| 190 |
The trickiest and most variable part of setting up a dial-out PPP |
| 191 |
connection is the part which involves getting the modem to dial and |
| 192 |
then invoking PPP service at the far end. Generally, once both ends |
| 193 |
are talking PPP the rest is relatively straightforward. |
| 194 |
|
| 195 |
Now in fact pppd doesn't know anything about how to get modems to dial |
| 196 |
or what you have to say to the system at the far end to get it to talk |
| 197 |
PPP. That's handled by an external program such as chat, specified |
| 198 |
with the connect option to pppd. Chat takes a series of strings to |
| 199 |
expect from the modem interleaved with a series of strings to send to |
| 200 |
the modem. See the chat man page for more information. Here is a |
| 201 |
simple example for connecting to an ISP, assuming that the ISP's |
| 202 |
system starts talking PPP as soon as it answers the phone: |
| 203 |
|
| 204 |
pppd connect 'chat -v "" AT OK ATDT5551212 ~' \ |
| 205 |
/dev/ttyS0 57600 crtscts debug defaultroute |
| 206 |
|
| 207 |
Going through pppd's options in order: |
| 208 |
connect 'chat ...' This gives a command to run to contact the |
| 209 |
PPP server. Here the supplied 'chat' program is used to dial a |
| 210 |
remote computer. The whole command is enclosed in single quotes |
| 211 |
because pppd expects a one-word argument for the 'connect' option. |
| 212 |
The options to 'chat' itself are: |
| 213 |
|
| 214 |
-v verbose mode; log what we do to syslog |
| 215 |
"" don't wait for any prompt, but instead... |
| 216 |
AT send the string "AT" |
| 217 |
OK expect the response "OK", then |
| 218 |
ATDT5551212 dial the modem, then |
| 219 |
~ wait for a ~ character, indicating the start |
| 220 |
of a PPP frame from the server |
| 221 |
|
| 222 |
/dev/ttyS0 specifies which serial port the modem is connected to |
| 223 |
57600 specifies the baud rate to use |
| 224 |
crtscts use hardware flow control using the RTS & CTS signals |
| 225 |
debug log the PPP negotiation with syslog |
| 226 |
defaultroute add default network route via the PPP link |
| 227 |
|
| 228 |
Pppd will write error messages and debugging logs to the syslogd |
| 229 |
daemon using the facility name "daemon". These messages may already |
| 230 |
be logged to the console or to a file like /var/log/messages; consult |
| 231 |
your /etc/syslog.conf file to see. If you want to make all pppd |
| 232 |
messages go to a file such as /var/log/ppp-debug, add the line |
| 233 |
|
| 234 |
daemon.* /var/log/ppp-debug |
| 235 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 236 |
This is one or more tabs. Do not use spaces. |
| 237 |
|
| 238 |
to syslog.conf; make sure to put one or more TAB characters (not |
| 239 |
spaces!) between the two fields. Then you need to create an empty |
| 240 |
/var/log/ppp-debug file with a command such as |
| 241 |
|
| 242 |
touch /var/log/ppp-debug |
| 243 |
|
| 244 |
and then restart syslogd, usually by sending it a SIGHUP signal with a |
| 245 |
command like this: |
| 246 |
|
| 247 |
killall -HUP syslogd |
| 248 |
|
| 249 |
|
| 250 |
4.1 Is the link up? |
| 251 |
|
| 252 |
The main way to tell if your PPP link is up and operational is the |
| 253 |
ifconfig ("interface configuration") command. Type |
| 254 |
|
| 255 |
/sbin/ifconfig |
| 256 |
|
| 257 |
at a shell prompt. It should print a list of interfaces including one |
| 258 |
like this example: |
| 259 |
|
| 260 |
ppp0 Link encap Point-to-Point Protocol |
| 261 |
inet addr 192.76.32.3 P-t-P 129.67.1.165 Mask 255.255.255.0 |
| 262 |
UP POINTOPOINT RUNNING MTU 1500 Metric 1 |
| 263 |
RX packets 33 errors 0 dropped 0 overrun 0 |
| 264 |
TX packets 42 errors 0 dropped 0 overrun 0 |
| 265 |
|
| 266 |
Assuming that ifconfig shows the ppp network interface, you can test |
| 267 |
the link using the ping command like this: |
| 268 |
|
| 269 |
/sbin/ping -c 3 129.67.1.165 |
| 270 |
|
| 271 |
where the address you give is the address shown as the P-t-P address |
| 272 |
in the ifconfig output. If the link is operating correctly, you |
| 273 |
should see output like this: |
| 274 |
|
| 275 |
PING 129.67.1.165 (129.67.1.165): 56 data bytes |
| 276 |
64 bytes from 129.67.1.165: icmp_seq=0 ttl=255 time=268 ms |
| 277 |
64 bytes from 129.67.1.165: icmp_seq=1 ttl=255 time=247 ms |
| 278 |
64 bytes from 129.67.1.165: icmp_seq=2 ttl=255 time=266 ms |
| 279 |
--- 129.67.1.165 ping statistics --- |
| 280 |
3 packets transmitted, 3 packets received, 0% packet loss |
| 281 |
round-trip min/avg/max = 247/260/268 ms |
| 282 |
|