I didn't find a set of ppp scripts that did what I wanted, so
I wrote my own.
Features
- No need to set nameservers manually; either get them
automatically from the ISP (/etc/ppp/dns-resolvconf-up) or use
a local named (/etc/ppp/dns-named-up)
- Support for multiple ISPs; nameservers can be manually
set separately for each if they're not given
(/etc/ppp/dns-resolvconf-up)
- More or less setup for UK ISP OneTel.Net already.
- pppd options file nicely set up for fast performance
- Customizable phone bill cost tracker, logged by user
(/etc/ppp/ppp-connect)
- Nice chat scripts, showing what happened on error
(/etc/ppp/dial)
- Initiating user can have programs executed when ppp
comes up and goes down.
Lacking
- Graphical interface
- Friendly set-up
- Explicit multiple modem support
Bugs
- More than one connection simultaneously: if more than one
ppp-connection is running at the same time, there are issues
with /etc/resolv.conf (see /etc/ppp/dns-resolvconf-up);
nameservers will be overwritten.
- More than one connection simultaneously: if using
/etc/ppp/dns-named-up then the first connection to terminate
will kill named, so you'll have no DNS.
- More than one connection simultaneously: if two
/etc/ppp/ppp-connects are started for the same connection at the
same time, possibly both will think they have the lock
file. (Damn unlikely).
Download tarball
To be untarred in /etc/ppp.
Here it is.
Warning: absolutely no warrantry of any kind
at all, though if it fries your modem,
e-mail me ;-).
Step by step guide
- Get a recent pppd. I am using 2.4.0b2; check linuxcare.com.au for
a later one. Compile it and install.
- Untar vii-ppp-scripts.tar.gz in /etc/ppp.
root:/etc/ppp# tar zxvf /incoming/vii-ppp-scripts.tar.gz
- Files and permissions:
(script filenames in brackets are
where the various paths can be changed).
- Directory /var/log/ppp: must be created. Should be
owned by root or another special user and have 0755
(rwxr-xr-x) permissions. This directory can be changed in
the /etc/ppp/ppp-connect script.
- The file /etc/init/online is executed when the link
comes up. You will probably want to change this filename (in
/etc/ppp/connect-hooks) to your own version: you could flush
the sendmail queue, fetch NNTP news etc. The file .online in
the home directory of the initiating user is executed (as
the initiating user).
- The file /etc/init/offline is executed when the link
goes down. You will probably want to change this filename
(in /etc/ppp/disconnect-hooks) to your own version. The file
.offline in the home directory of the initiating user is
executed (as the initiating user).
- The file /var/log/ppp/status (/etc/ppp/ip-up) is a log
of the output from this command.
- The files /var/log/ppp/$(CONNECTION NAME)
(/etc/ppp/ppp-connect) are the logs of call times, durations
and costs for each connection. You might like to make them
append only (chattr +a on ext2fs).
- The file /var/log/ppp/chat-log (/etc/ppp/dial) is the
concatenation of all chat sessions.
- Directory /var/lock: anybody must be allowed to write
here. I suppose you already have it. This directory can be
changed in the /etc/ppp/ppp-connect script.
- You might like to make a sym link from your modem's
device (e.g. /dev/ttyS3) to /dev/modem, for convenience.
- /etc/ppp/modem-init.chatscript is, cunningly, the chat
script that inits your modem. You should probably tweak it for
your model.
- Add options files for your ISPs in /etc/ppp/peers. The
filenames will be your connection names. Choose them well!
An example file, /etc/peers/onetel for the OneTel.net free ISP
in the UK:
name user@onetel.net.uk
linkname onetel
connect '/etc/ppp/dial 08081401877'
asyncmap 0
defaultroute
noauth
/dev/modem
Change "user@onetel.net.uk" to your username (for ISPs
other than onetel, this usually doesn't include the
@host.net part), the linkname to the name you've chosen
for the connection, and the phone number 08081401877 to the
ISP's dialup number.
- If you're using PAP (and you probably are): add your
password to /etc/ppp/pap-secrets as described in the pppd man
page: here is an example for "user@onetel.net.uk" at OneTel:
# Secrets for authentication using PAP
# client server secret IP addresses
user@onetel.net.uk onetel marmite
(You can leave the IP addresses section blank, because the ISP
isn't authenticating to you).
- If you're not sure if you're using CHAP or PAP you can add
"debug" to the pppd options (for example, in
/etc/ppp/peers/$(CONNECTION NAME)) to see what the server asks
for, or cover your bets by symlinking pap-secrets to
chap-secrets, so you can use either.
- If you're logging in with a custom chat script instead of
using PAP/CHAP, you must give /etc/ppp/dial the name of that
chat script as its third argument in the /etc/peers/isp-name
file. The first two arguments are passed to the script as -T and
-U respectively.
Warning: the output from your script is logged, first to a
file in /tmp with mode 600, and then to the system log
file, /var/log/ppp/chat-log (filename in /etc/ppp/dial). You
might like to turn off echoing when sending your password.
- If you want to calculate call costs, create a script in
/etc/ppp/cost/$(CONNECTION NAME) or make a sym link from a
generic one. The cost calculating program should take two unix
times (integer number of seconds since first of 1970, time_t
datatype in C) as arguments and output a string representing the
cost to stdout. (See /etc/ppp/ppp-connect for filenames,
/etc/ppp/internal-cleanup for the actual call, and look in
/etc/ppp/cost for examples).
- I think that's it. Type /etc/ppp/ppp-connect $(CONNECTION
NAME) to connect. Your terminal will not be released, however:
press control-c in it to disconnect, or run
/etc/ppp/ppp-disconnect from elsewhere. Details of connection
cost, etc. will then be displayed.
Final polish
Here's a connect script to put in your
path that pops up a new rxvt under X.
You can make a symlink, /etc/ppp/peers/default, to your
preferred connection in /etc/ppp/peers so you don't have to give
an argument to ppp-connect.
Nameservers
Do you want to run a local named (DNS server) or use the
two your ISP probably gives you when the connection comes up?
For option one, make change the dns script to use dns-named-up
and dns-named-down. For resolv.conf fiddling, do the same for
dns-resolvconf-up and dns-resolvconf-down (default).
Automatically adjusting resolv.conf
The advantage of this method is obviously that you need not
run a named daemon.
If you have special nameserver needs, you can make a directory
/etc/ppp/peers-resolv.conf/ (see /etc/ppp/dns-resolvconf-up) with
resolv.confs for your various connections. For example, a
resolv.conf for onetel would be called
/etc/ppp/peers-resolv.conf/onetel, and is copied to
/etc/resolv.conf when you connect to onetel. Any nameservers
onetel gives us are prepended to the file.
If there is no /etc/ppp/peers-resolv.conf/$(CONNECTION NAME)
then /etc/ppp/peers-resolv.conf/template is used. If that too does
not exist, if the ISP gives nameservers they are put in
/etc/resolv.conf and all the search and domain entries are carried
over, otherwise /etc/resolv.conf is unmodified.
Running BIND (named)
The advantages of this method are that you're not reliant on
mis-configured ISP nameservers and you get a system wide DNS cache,
so if one program makes a look up, it's available to all
others. It is possible to have named query your ISP's DNS caches,
but doesn't seem to result in much of speedup for me, therefore it
isn't setup by default.
Here's my /etc/named.conf
options {
directory "/var/named";
listen-on { 127.0.0.1; };
allow-query { localhost; };
allow-transfer { localhost; };
allow-recursion { localhost; };
interface-interval 0;
dump-file "/var/spool/named-state.db";
};
zone "localhost" {
type master;
file "private/localhost";
};
zone "0.0.127.in-addr.arpa" {
type master;
notify no;
file "private/127.0.0";
};
zone "." {
type hint;
file "root.cache";
};
/etc/named.boot points to /var/spool/named-state.db (I hope
this means the saved state of the previous session is loaded when
named is started, see /etc/ppp/dns-named-down). Note that this
file must probably be writable by daemon.daemon, which is the
personality named is set to run at in (/etc/ppp/dns-named-up).
Note that the files in /var/named you will have to setup
yourself. See the BIND distribution.
Boost that surfing speed!
- Set your modem to insane baud:
setserial /dev/modem spd_cust baud_base 460800 divisor 2
This is the speed at which your computer connects to the
modem. It ensures that when modem compression is doing its
stuff it isn't slowed up here.
- modprobe the ppp_deflate and bsd_comp kernel modules (or
enable kernel module autoloading at config time). If your ISP
supports them, they'll be used. If so, it's probably a good idea
to disable modem compression (see modem-init.chatscript).
Trouble shooting
Slow connection upstream to ISP
Some moronic sysadmins or more usually moronic managers decide
to disable all ICMP packets to put a stop to ping
flooding. Unfortunately, ICMP isn't just used for pinging (ICMP
ECHO) but for a variety of things, including a way of finding out
the biggest packet you're able to send down a certain route
without fragmenting. To stop trying to do this: (horrible
"workaround")
echo 1 > /proc/sys/net/ipv4/ip_no_pmtu_disc
Try: man chat, man pppd, man setserial. Read: docs in pppd
distribution, PPP-HOWTO, ISP-Hookup-HOWTO, Modem-HOWTO,
Serial-HOWTO, NET3-4-HOWTO.
Don't have any problems here. Send me yours.