Re: dhcp server and isp's dns...

From: Andrey Asadchev (dont.spam.me_at_softhome.net)
Date: 12/30/03


Date: Tue, 30 Dec 2003 14:32:09 -0500


> No, that was a bit unclear. What I meant was that all the hardware
> routers I've ever owned have not had any difficulty getting DHCP and
> nameserver information and passing them on to my client computers, even
> with nameservers changing. So it seems like the most popular DHCP
> servers on one of the most configurable operating systems should be able
> to handle this as well, but I haven't seen/heard of how to do it yet....
> anyone know how?

Ok. You can do that. Something crude and very simple :

NAMESERVERS=$(
for i in $( cat /etc/resolv.conf | grep ^nameserver | cut -d " " -f2); do
echo -n $i", ";
done | sed 's/, $//'
)

# the sed line should be a single line.
DHCPD=$(cat /etc/dhcp3/dhcpd.conf |
sed "s/^\([[:space:]]*option domain\-name\-servers\).*$/\1 $NAMESERVERS;/g")

echo "$DHCPD" > /etc/dhcp3/dhcpd.conf
/etc/init.d/dhcpd restart

Make this into a script file and call it from dhcp client hooks or from
/etc/dhclient-sciprt when nameserver info changes. Check out the man
pages for dhclient.

The better way would be to get nameserver information directly from dhcp
client, check for unexpected values and have some kind of template
dhcpd.conf. But this is just to give an idea



Relevant Pages

  • DCHP overrides default gateway and nameserver on double-nic server.
    ... I am setting up several Linux boxes (RedHat Enterprise Linux 2.1, ... get a default gateway from the DHCP-server. ... the Windows DHCP that seems to say no info on gateway nor nameserver ...
    (comp.os.linux.networking)
  • Re: DCHP overrides default gateway and nameserver on double-nic server.
    ... > kernel 2.4.9-e.27) that use two different ethernet interfaces. ... > get a default gateway from the DHCP-server. ... > the Windows DHCP that seems to say no info on gateway nor nameserver ...
    (comp.os.linux.networking)
  • Re: Automatically get nameservers
    ... the FreeBSD machine ... There's really no need for DHCP. ... the FreeBSD machine can get *its* nameserver addresses from the ... his Windows machines connected thru the FreeBSD machine *automatically* ...
    (freebsd-questions)
  • Re: taming resolv.conf
    ... I still want the nameserver address that is supplied by DHCP to be ... I don't think the static dns server in the interfaces file will override ... the resolvconf docs for this. ...
    (Debian-User)
  • Re: domain name not resolution too slow or timeouts
    ... That is typical of a nameserver not responding. ... server. ... I don't use DHCP but I've noticed ... Bill Vermillion - bv @ wjv. ...
    (freebsd-net)