Date: Sat, 08 Mar 2003 10:32:13 -0800 (PST) From: =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= <mbsd@pacbell.net> To: IAccounts <iaccounts@northnetworks.ca> Cc: Lowell Gilbert <freebsd-questions-local@be-well.no-ip.com>, freebsd-questions@FreeBSD.ORG, Philip Hallstrom <philip@adhesivemedia.com> Subject: Re: DHCP Server "learning" name servers since server itself is dhcp'd?? Message-ID: <20030308102326.G6008-100000@atlas.home> In-Reply-To: <20030308102434.M6374-100000@diana.northnetworks.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 8 Mar 2003, IAccounts wrote:
> > > Alternatively is there a way to dynamically tell BIND to get it's
> > > forwarders list from /etc/resolv.conf?
Here is a shell script snippet that I use on my laptop. It gets
called from make_resolv_conf() in /etc/dhclient-enter-hooks, where I
make sure not to overwrite /etc/resolv.conf (it always points to
localhost). Extracting nameserver addresses from resolv.conf is
trivial, though.
A prerequisite is that the "forwarders" clause in named.conf is on a
single line by itself, for example:
forwarders { 192.168.250.254; };
----8<------------------------------------------------------------
LOGGER=echo
named_conf=/etc/namedb/named.conf
# Args: one or more nameserver IPs
update_forwarders() {
address_list=
for nameserver in $* ; do
test X$nameserver = X127.0.0.1 && continue # Stupid server...
address_list="$address_list $nameserver;"
done
address_list="{ $address_list };"
sed_command='/^options/,/^}/s/\([^#\/]*\)forwarders.*/\1forwarders'
sed_command="$sed_command $address_list/"
sed "$sed_command" $named_conf > $named_conf.dhcp
if cmp -s $named_conf $named_conf.dhcp; then :
else
$LOGGER "New DNS servers: $*"
if [ ! -f $named_conf.org ]; then
cp $named_conf $named_conf.org
fi
cp $named_conf.dhcp $named_conf
ndc reload
fi
return 0
}
----8<------------------------------------------------------------
It is more elegant in perl, but dhclient-enter-hooks is a shellscript,
so it felt easier to just add it there.
$.02,
/Mikko
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030308102326.G6008-100000>
