dhcp-client passing ISP dsn info to dhcpd

Glenn Satchell Glenn.Satchell at uniq.com.au
Thu Apr 27 14:51:52 UTC 2006


>From: "fbsd" <fbsd at a1poweruser.com>
>To: <dhcp-users at isc.org>
>Subject: RE: dhcp-client passing ISP dsn info to dhcpd
>Date: Thu, 27 Apr 2006 10:03:15 -0400
>
>Sorry but your solutions is not a solution at all.
>
>It just changes where I have to do the hand edit and consumes
>more resources by running a un-needed caching domain name server.

Yes, I realise that.

>Since dhcp-client and dhcpd are same basic application it seems to
>me
>that the developers missed seeing the need to have them talk to each
>other.
>
>This seems like am simple oversight.

Well without knowing the original design specs, etc, it would seem that
dhcp server and client typically run on different machines and only
interract using the dhcp boot protocol. Your case it special in that
you want them to run on the same box. This is allowed for, by modifying
the dhclient-script to perform customised operations.

>I am sure I am not the only user who wants the dhcp-client to
>automatically
>update dhcpd with the ISP's new dns ip address when the ISP changes
>them.

I only remember this being discussed once or twice in the past few years.

>Other people have suggested to modify the dhcp-client script that
>updates resolv.conf
>by having it issue stop command to dhcpd, auto edit
>dhcpd.conf "option domain-name-servers" line and issue start dhcpd
>so dhcpd.conf gets re-read.
>
>
>That kind of script writing is way above my ability.
>
>Does anybody on this list have such a customized script or is there
>some place where users post such things to share with the public
>that I can search for it?

Here's how I'd go about it using fairly simple scripting techniques.
Note that this might not work for you, no guarantees, YMMV, etc.

In dhcpd.conf comment out the line "option domain-name-servers" and add
a line

  include "/etc/dhcpd.name-servers";

This will include the contents of the named file into dhcpd.conf. It is
easier to manipulate a small separate file, rather than trying to
manage the whole dhcpd.conf file

There is a OS specific script installed as dhclient-script, so you'll
need to poke around there to find exactly the right place. Anyway, in
the function that creates /etc/resolv.conf (make_resolv_conf() on my
version) add lines like this:

make_resolv_conf() {
  if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
    echo search $new_domain_name >/etc/resolv.conf
    for nameserver in $new_domain_name_servers; do
      echo nameserver $nameserver >>/etc/resolv.conf
    done
    
    # replace dhcpd.conf include file contents (should be one long line)
    echo "option domain-name-servers $new_domain_name_servers ;" > 
/etc/dhcpd.name-servers.tmp
    # see if different to existing file
    cmp -s /etc/dhcpd.name-servers.tmp /etc/dhcpd.name-servers
    if [ $? -gt 0 ]; then
        # move the new file into place
        mv /etc/dhcpd.name-servers.tmp /etc/dhcpd.name-servers
        # restart dhcp using whatever is appropriate for your platform
        service dhcpd restart
    fi
    # end of changes

  fi
}

After renewing the lease on the interface check the contents of 
/etc/dhcpd.name-servers to see that it contains valid syntax.

Note however, that your clients on the private lan will only pick up
this change the next time they renew their lease.

Also the overhead of running a caching name server means that any
cached lookups will happen a lot faster. eg if more than one system
looks up, say, www.google.com, etc. It also allows for the future
possibility of running your own internal DNS zones, rather than using,
say, host files on evey system.

regards,
-glenn

>-----Original Message-----
>From: dhcp-users-bounce at isc.org [mailto:dhcp-users-bounce at isc.org]On
>Behalf Of Glenn Satchell
>Sent: Thursday, April 27, 2006 8:46 AM
>To: dhcp-users at isc.org
>Subject: Re: dhcp-client passing ISP dsn info to dhcpd
>
>
>
>>From: "fbsd" <fbsd at a1poweruser.com>
>>To: <dhcp-users at isc.org>
>>Subject: dhcp-client passing ISP dsn info to dhcpd
>>Date: Thu, 27 Apr 2006 08:21:37 -0400
>>
>>I use dhcp-client to fetch the dhcp info from my ISP at boot time.
>>The resolv.conf file gets updated with the ISP's dsn ip address.
>>
>>I also run an private LAN and use dhcpd.
>>I have to explicitly edit by hand the dhcpd.conf "option
>>domain-name-servers"
>>statement when ever my ISP changes their default dns ip addresses.
>>
>>
>>Is there some option I missed that will automatically update the
>>dchpd
>>parameter when dhcp-client changes the content in resolv.conf?
>>
>>Does anyone have a custom script to perform this function they are
>>willing to share?
>>
>>
>The simplest way around this is to run your own caching domain name
>server. On the gateway client dhclient runs as it does now. But in
>dhcpd.conf you point all the private clients to your local dns
>server
>address.  The only trick with this is that whenever the ISP changes
>the
>IP address of the DNS server you'll need to update the forwarding
>entry
>for your new DNS server.
>
>regards,
>-glenn
>
>
>



More information about the dhcp-users mailing list