[Dnsmasq-discuss] Secondary/tertiary dns servers in dhcp offers?

Simon Kelley simon@thekelleys.org.uk
Fri, 12 Nov 2004 20:50:34 +0000


> 	I have both dns and dhcp set up.  When the dnsmasq returns dhcp offers
> to clients, it is sending itself as the primary dns server, which is
> good.  However, it's not sending any secondary or tertiary dns server
> addresses back to the clients for them to use if the primary dns server
> is not available for some reason.
> 
> 	I would have expected it to send any upstream servers it found
> in /etc/resolv.conf as the secondary and tertiary servers for clients to
> use when the primary is down.  I have gone through all the options in
> dnsmasq.conf, read the FAQ, and googled around a bit, but I can't see
> how to do this.
> 

It's possible to do (nearly) this. As you noticed, dnsmasq sends of few 
DHCP options by default but if you explicitly specify a value for one of 
those options, that will override the default value supplied by dnsmasq.

The option number for DNS servers is 6 (from RFC2132), so adding the 
following line to /etc/dnsmasq.conf will send 1.2.3.4 and 5.6.7.8 as DNS 
servers _instead_ of the default value.

dhcp-option=6,1.2.3.4,5.6.7.8

That's not quite what you want, since you want to use the address of the 
machine using dnsmasq as well as the backup servers. To do that, you 
need to know that dnsmasq will interpret the special value 0.0.0.0 as 
it's own address.

So

dhcp-option=6,0.0.0.0,1.2.3.4,5.6.7.8

will use dnsmasq as the first nameserver, and the last two as backups.

Getting the backup servers from /etc/resolv.conf directly is not possible.

You should think fairly hard before doing this. Don't forget that the 
upstream nameservers will not know about any names which dnsmasq is 
getting from /etc/hosts or the DHCP system, so a query for those names 
which gets sent direct to an upstream nameserver will fail mysteriously. 
Worse, I don't think that the DHCP spec actually specifies that the DNS 
servers are in priority order, so you might come across a client which 
uses a different order and therefore has problems.

Cheers,

Simon.