This section explains how I have set things up to automate everything. My way might not suit you at all, but you might get a idea from something I've done. Also, I use ppp for dialup, while many use slip or cslip, so almost everything in your setup can be different from mine. But slip's dip program should be able to do many of the things I do.
Normaly, when I'm not connected to the net I have a
resolv.conf
file simply containing the line
domain uio.no
This ensures I don't have to wait for the hostname resolving
library to try to connect to a nameserver that can't help me. But
when I connect I want to start my named and have a resolv.conf
looking like the one described above. I have solved this by keeping
two resolv.conf
'template' files named resolv.conf.local
and
resolve.conf.connected
. The latter looks like the
resolve.conf
described before in this document.
To automaticaly connect to the net I run a script called 'ppp-on':
#!/bin/sh echo calling... pppd
pppd has a file called options
that tells it the particulars
of how to get connected. Once my ppp connection is up the pppd starts
a script called ip-up
(this is described in the pppd man page).
This is parts of the script:
#!/bin/sh interface="$1" device="$2" speed="$3" myip="$4" upip="$5" ... echo 1&2 PPP: IP up cp -v /etc/resolv.conf.connected /etc/resolv.conf ... /usr/sbin/named echo PPP: ip-up finished
I.e. I start my named there. When ppp is disconnected pppd runs a
script called ip-down
:
#!/bin/sh echo 1>&2 PPP: IP down cp /etc/resolv.conf.local /etc/resolv.conf read namedpid </var/run/named.pid kill $namedpid
So this gets things configured and up when connecting and disconfigured and down when disconnecting.
Some programs, irc and talk come to mind, make a few too many
assumptions, and for irc the dcc features and talk to work right you
have to fix your hosts file. I insert have this in my ip-up
script:
cp /etc/hosts.ppp /etc/hosts echo $myip roke >>/etc/hosts
hosts.ppp
simply contains
127.0.0.1 localhost
and the echo thing inserts the ip# i have received for my host name (roke).
It is probably not smart to run named when you are not connected to the net, this is because named will try to send queries to the net and it has a long timeout, and you have to wait for this timeout every time some program tries to resolve a name. If you're using dialup you should start named when connecting and kill it when disconnecting. I have received mail saying it isn't so, but I have not been able to make it work having to wait for long timeouts. Please mail all details if you have better information.