DHCP & nameservers

Eric Thornton gonesurfing at nc.rr.com
Sat Nov 13 05:47:55 GMT 2004


On Sat, 2004-11-13 at 00:26 -0500, Andrew Smith wrote:
> I'm using my FreeBSD box as the gateway machine for my cable modem. 
> Obviously the cable modem side has to be set as DHCP, which automaticlly 
> sets the DNS nameservers in resolve.conf.
> 
> However I am running a caching name server on the box, and would like to 
> have resolve.conf only point to local host.  Is there any way to keep DHCP 
> from updating resolve.conf?
> 
> Thanks in advance,
> 
> Andrew 

To keep dhclient from updating /etc/resolv.conf, create a file
called /etc/dhclient-enter-hooks with the contents

#!/bin/sh
make_resolv_conf() 
{
}

If you want to point your cache at a list of upstream servers you can
put dhclient info in a file for use by your server. I have the following
in my enter hooks so that dnscache (djbdns) can use the info instead of
going to root servers every time.

#!/bin/sh
#This script will update dnscache forwarders list

make_resolv_conf() {
  if [ x"$new_domain_name_servers" != x ]; then
    rm /etc/dnslist
    for nameserver in $new_domain_name_servers; do
      echo $nameserver >> /etc/dnslist
    done
  fi
}

Hope this helps.

Eric





More information about the freebsd-questions mailing list