PPP and dynamic IP and DNS allocation

Geoff Shang gshang10 at scu.edu.au
Sun Jun 18 03:37:32 EDT 2000

Hi all:

I wrote up this mighty message in order to send it to the blinux-newbie
list.  I mentioned to Gene that I was writing it and he suggested sending
it here ... so I am.  Apologies to anyone else like myself who is
subscribed to both.


---------- Forwarded message ----------

Hi all:

OK, a bit on PPP and dynamic allocations.  There are 2 things that a PPP
server may allocate to you when you dial in - an IP address and a DNS
server address.  Most people using a PPP dialup connection will have a
dynamically allocated IP address, unless you've paid good money to get a
static IP address allocated to you (if you have, guard it with your life -
it's a precious thing).  The reason for this is that ISPs usually allocate
IP addresses to modems or other hardware devices, which means that the IP
address you are using right now can be used by someone else when you hang
up.  Since IP V4 addresses are beginning to run out, the ability to
conserve IP addresses is surely a good thing.  This allocation of IP
address is no problem for linux, as long as the PPP daemon knows it is
going to happen.  Personally, any PPP configuration script that does not
allow for a dynamic IP needs to be rewritten, so chances are all the
various PPP config scripts around will allow for it.

OK, that's the easy one out of the way.  The whole reason I wrote this
though is because of dynamically allocated DNS server addresses and whether
or not we can cope with these.  Before I get into this, I'll briefly
explain what a DNS server is.  A DNS server makes life infinitely easier to
deal with the internet.  It's what allows you to type in an address like
www.linux-speakup.org rather than typing  It also allows
you to do the opposite, for those occasions when you or the system needs

First, some easy answers.  It is infinitely easier to deal with static DNS
server addresses, so if you can harass your ISP's helpdesk into giving you
the address of one of their DNS servers, life will be much simpler.  Since
they need to use these addresses too, they're not likely to change them
often.  If you have no luck in this regard however, fear not.  Linux can
deal with these addresses, though it's a bit of a fiddle and does depend on
your version of PPPD.

Actually, until last night, I thought that linux couldn't cope with
dynamically allocated DNS server addresses.  But reading Brent's message
saying that he was using it led me to do some research on the matter.  And
here's what I found.

The core of the linux PPP system is the PPP daemon called PPPD.  The
various config scripts merely provide a convenient front-end to PPPD and
make it easy to define how it will work.  The ability to accept dynamically
allocated DNS server addresses was introduced in PPPD version 2.3.6 and was
bug-fixed in PPPD 2.3.7.  This obviously means that if your distribution
comes with a version of PPPD older than 2.3.6 then you are out of luck.  
Since debian 2.2 comes with 2.3.11 and debian 2.1 came with 2.3.5 over a
year ago, I think all current distributions should be OK ... but check
anyway.  You can do this by typing:

pppd --version

Now, pppd uses what's referred to as an options file.  There are usually
different options files for each connection.  These define the various
characteristics of the connection, and is almost certainly what your
configuration script will modify.  The reason PPPD takes this approach is
that the list of available options continues to grow at quite a steady
rate, and a command line to specify them would read like a short novel.  
These files are stored in /etc/ppp/peers.  That is to say, that's where
they are on my system and I can't find an;ywhere that this is configured,
so unless it is a compile-time option, that's where it should be.  The
script that puts up my PPP connection invokes PPPD as follows:

/usr/sbin/pppd call <filename>

Where filename is a file in /etc/ppp/peers which contains the information
for a given connection.  Your script, such as pppgo, probably reads in a
similar fashion.

The reason I've gone into all of this is that you may well have to look in
your pppgo script to find out which file is being looked at.  you can find
out exactly where your pppgo script lives by typing:

which pppgo

Use the path and filename that is returned to find the file and view it
with more or something similar.  If it is not clear which file is being
read, send me a copy of the script and I'll try to figure it out, though
I'm no shell programmer.

OK, so now we've found the file to modify.  To get PPPD to read the
ISP-supplied DNS server address, put a line in this file that reads:


So what exactly does this do?  Well, it doesn't do much, actually.  It
writes the IP address into a file called /etc/ppp/resolv.conf, in the
format expected to exist in /etc/resolv.conf.  This is where the DNS server
address usually lives on systems that aren't running a DNS server.  If you
are running one, see below.

So what now?  Well, PPP runs a script called /etc/ppp/ip-up when the link
goes up, and /etc/ppp/ip-down when the link is taken down.  So all you have
to do is make sure that the information gets moved where it is needed when
the link goes up and is shuffled harmlessly out of the way when the link is
taken down again.  And that's where the attached scripts come in.  These
come from the PPPD documentation and do just this.  Note that debian has
ip-up run a list of scripts in /etc/ppp/ip-up.d, meaning that all you have
to do is put the script in there.  Other distributions may play tricks like
this so you might want to see what is in /etc/ppp/ip-up and
/etc/ppp/ip-down before pasting the attached scripts to the end of them.  
Also note that debian 2.2 already comes with scripts to do this, they are
/etc/ppp/ip-up.d/0dns-up and /etc/ppp/ip-down.d/0dns-down and debian's
pppconfig will handle this as Brent said earlier.  It also comes with a
script /etc/init.d/dns-clean that will tidy things up on boot-up if the
system goes down while online.

So what do the attached scripts do?  Well, the ip-up.local.add script backs
up your /etc/resolv.conf file and then moves the new DNS information into
it, remembering to maintain any other information that was already there
(apart from other DNS server entries).  The ip-down.local.add script does
the reverse - it restores your /etc/resolv.conf backup and clears the DNS
information out of the way till next time.

As for people running their own DNS server, well you technically wouldn't
really have to bother about it, since the server should already have the
necessary root-server information needed to resolve a DNS query.  However,
if you do prefer to use a nearby DNS server as a forwarder, you can, if you
are adept at scripting, copy the information into your DNS server
configuration file and then restart named.  I run bind 8.2.2 under debian
and the file it would go in would be /etc/bind/named.conf in the forwarders

If you would like further information on PPP and how it is set up, check
out the following:

1.  Your system's PPP documentation.  You more than likely have some
somewhere.  Try /usr/doc or, under debian 2.2 at least,

2.  Check out the manpages for your configuration and activation scripts
(e.g. pppsetup and pppgo).  Also take a look at the pppd manpage if you're
into that.

3.  Although it is now over 3 years out of date (more's the pity), have a
look at the PPP-howto.  It doesn't take into account scripts like pppsetup
and pppgo, but it does give you a good idea of what is actually going on
with PPP and I do recommend it if you want to know this stuff.  Of course,
options like usepeerdns won't be documented.

Finally, for the curious, the original PPPD documentation has an examples
directory with lots of goodies. That's where these scripts came from.  If
you want some idea of what else can be done, take a look in there.

Hope all this helps someone.  I sure learned a bit.


Geoff Shang <gshang10 at scu.edu.au> ICQ number 43634701

More information about the Speakup mailing list