wiki:PPP

Version 10 (modified by alexander@…, 14 years ago) ( diff )

cleanups

PPP

The book says that "The main trick is scripting the connection. This can be done either using the chat program which comes with this package or by using WvDial". Example configuration files using the "chat" program are shown below.

The book also says that the PPP driver may be compiled as a module (its name will be ppp_generic). While it is true, udev won't load it automatically, you have to add it to the /etc/sysconfig/modules file.

DNS Server Configuration

If you don't run your own caching DNS server, create a simple "ip-up" script that populates the "/etc/resolv.conf" file with nameservers specified by the ISP once the connection is brought up.

cat >/etc/ppp/ip-up <<"EOF"
#!/bin/sh
if [ "$USEPEERDNS" = "1" ] && [ -s /etc/ppp/resolv.conf ]
then
        install -m 644 /etc/ppp/resolv.conf /etc/resolv.conf
fi
EOF
chmod 755 /etc/ppp/ip-up

If you use a caching DNS server such as Bind or Pdnsd, the script above is wrong for you. In such case, write your own script that tells your caching nameserver to forward queries to upstream DNS servers specified in the $DNS1 and $DNS2 environment variables.

Dialup Modem Connection

The scripts below do exactly the same as WvDial in the "stupid" mode, and assume a typical Windows-friendly ISP.

Create the chat script that automates the connection:

cat >/etc/ppp/dialup.chat <<"EOF"
ABORT BUSY ABORT 'NO CARRIER' ABORT VOICE ABORT 'NO DIALTONE' ABORT 'NO DIAL TONE'
ABORT 'NO ANSWER' ABORT DELAYED ABORT ERROR ABORT BLACKLISTED

TIMEOUT 5
'' AT
# \T is the phone number, passed from /etc/ppp/peers/dialup
OK-+++\dATH0-OK ATD\T
TIMEOUT 75
CONNECT \d\c
EOF

Create the ppp peer file for your dialup connection:

cat >/etc/ppp/peers/dialup <<"EOF"
# Your username at the ISP
user "jdoe"
# Replace TTTTTTT with the ISP phone number
connect "/usr/sbin/chat -T TTTTTTT -f /etc/ppp/dialup.chat"

# Specify your modem serial port and speed below
/dev/ttyS0
115200

# The settings below usually don't need to be changed
updetach
noauth
hide-password
debug
lock
defaultroute
noipdefault
usepeerdns
remotename dialup
EOF

Set up the password, as explained below.

GPRS Connection

Create the chat script that automates the connection process:

cat >/etc/ppp/gprs.chat <<"EOF"
ABORT BUSY ABORT 'NO CARRIER' ABORT VOICE ABORT 'NO DIALTONE' ABORT 'NO DIAL TONE'
ABORT 'NO ANSWER' ABORT DELAYED ABORT ERROR ABORT BLACKLISTED

TIMEOUT 5
'' AT
OK-+++\dATH0-OK ATZ
# \T is the APN, passed from /etc/ppp/peers/gprs
OK AT+CGDCONT=1,"IP","\T"
OK "ATD*99***1#"
CONNECT \d\c
EOF

Create the ppp peer file for your GPRS connection:

cat /etc/ppp/peers/gprs <<"EOF"
# Replace inet.example.com with the proper APN for your provider
connect "/usr/sbin/chat -T inet.example.com -f /etc/ppp/gprs.chat"

# Specify your cellphone serial port and speed below
# Note: you must manually reprogram certain old cell phones
# in order to achieve connection speed more than 9600 bits ber second.
# See http://www.esato.com/board/viewtopic.php?topic=14638&r=a
/dev/ttyS1
115200

# The settings below usually don't need to be changed
noauth
updetach
debug
lock
defaultroute
noipdefault
usepeerdns
EOF

With GPRS, authentication is always based on the phone number. Ignore any login/password information supplied by your cellphone company.

PPPoE Connection

It is possible to create PPPoE connections using just pppd and the kernel-mode PPPoE driver.

Create the ppp peer file for your PPPoE connection:

cat >/etc/ppp/peers/pppoe <<"EOF"
# The plugin comes from the "ppp" package
# there's no need to install rp-pppoe
plugin rp-pppoe.so
# Replace "eth0" with your network interface name
eth0
# Replace "jdoe" with your username at the ISP
user "jdoe"

# The settings below usually don't need to be changed
noauth
hide-password
updetach
debug
defaultroute
noipdefault
usepeerdns
remotename pppoe
EOF

Set up the password, as explained below.

Note: before connecting, it is necessary to run this command:

ip link set eth0 up

Dealing with Passwords

Note: there was a report that the "pcall" script doesn't work. All distributions store passwords in cleartext in /etc/ppp/{pap,chap}-secrets.

pppd can be set up to ask a dialup password each time the user runs it. In order to utilize this feature, create a script:

cat >/usr/bin/pcall <"EOF"
#!/bin/bash
# Begin /usr/bin/pcall

# The use of bash is essential: we rely upon the "echo" being a builtin
# so that the password isn't visible through /proc

if [ $# -eq 0 ] ; then
    echo "Usage: pcall peer [arguments]"
    exit 1
fi

if grep -q "^user" "/etc/ppp/peers/$1" ; then
    read -rsp "Password: " PASSWORD
    echo "$PASSWORD" | /usr/sbin/pppd call "$@" plugin passwordfd.so passwordfd 0
else
    /usr/sbin/pppd call "$@"
fi
# End /usr/bin/pcall
EOF
chmod 755 /usr/bin/pcall

This script asks for a password if necessary, and then calls a PPP peer specified as its first argument. All other arguments are passed to pppd.

An alternative to using this script is to store the password in a file that pppd reads (note that stored cleartext passwords are an inherent risk and should be avoided if possible):

touch /etc/ppp/pap-secrets
chmod 600 /etc/ppp/pap-secrets
cat >/etc/ppp/pap-secrets <<"EOF"
# username      remotename    password        IP for the peer
jdoe            dialup        guessit         *
EOF

The remotename field must match the "remotename" option specified in the PPP peer file. An asterisk means that the password can be used with all peers.

Make a symlink so that the same password is used for more secure CHAP authentication:

ln -nsf pap-secrets /etc/ppp/chap-secrets

Bringing the Connection Up and Down

If you stored the password in the /etc/ppp/pap-secrets file, or if your connection doesn't require a password (as it is the case with GPRS), the following command will establish the connection:

pppd call peername

where "peername" refers to a file in the /etc/ppp/peers directory (i.e., one of dialup, gprs or pppoe if you followed the examples exactly)

If you want to be asked for the password, or if your connection doesn't require a password (as it is the case with GPRS), use the following command instead:

pcall peername

It is possible to write a bootscript that would call pppd at boot time, for persistent connections.

To disconnect, run the following command:

killall pppd

Up
Top

Note: See TracWiki for help on using the wiki.