[Dnsmasq-discuss] dnsmaq stops forwarding queries (part 2)

Simon Kelley simon at thekelleys.org.uk
Sat Sep 16 21:45:33 BST 2006


graham wrote:
> Hi,
> 
> I seem to have the same problem as Holger Mauermann:
> 
> http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2006q2/000754.html
> 
> 
> My resolv.conf contains just: nameserver 127.0.0.1
> 
> and my alternative resolv file (/etc/resolv.dnsmasq) defined in 
> dnsmasq.conf contains:
> 
> # OpenDNS nameservers 
> nameserver 208.67.222.222 
> nameserver 208.67.220.220
> 
> On initial boot of the server no queries are forwarded to the opendns
>  servers: it's as if dnsmasq had never read resolv.dnsmasq Touch 
> resolv.dnsmasq, and everything immediately works correctly. After a 
> while (not sure of the period, seems to be variable but can be as
> little as 30 minutes) dnsmasq again stops forwarding queries;
> touching the conf file again immediately restores proper behaviour.
> 
> I am running Debian Sarge with the stable version of dnsmasq (2.22,
> so quite old). Am running ntpdate, and times are correct. My
> dnsmasq.conf file has:
> 
> domain-needed bogus-priv resolv-file=/etc/resolv.dnsmasq 
> local=/mynet.net/ interface=eth1 expand-hosts domain=mynet.net 
> dhcp-range=192.168.0.20,192.168.0.100,12h dhcp-host=goofy 
> dhcp-authoritative # I have gentoo clients...
> 
> The log files look just like Holger's..
> 
> Since I've only found the one other person reporting this problem I 
> guess this is something more to do with my setup than with dnsmasq,
> but can't work out what. Any suggestions?
> 

What (if anything) writes to /etc/resolv.dnsmasq? Holger's problem
turned out to be a script which emptied /etc/resolv.dnsmasq and then
wrote the new nameservers. It's possible to get unlucky, so that
following events all occur in order within one second:

1) Write or create empty resolv.dnsmasq
2) dnsmasq reads empty file -> no nameservers
3) write resolv.conf with new nameservers.

Since the timestamp on the file only has one second resolution, dnsmasq
never sees the second write, and never re-reads the file.

This problem is largely fixed in later dnsmasq releases: if dnsmasq
reads an empty file, it will keep re-reading every second until  it gets
real data. Since you are using 2.22 you don't have that code.

Actually, there's a better way, which is to update resolv.dnsmasq by
writing data into resolv.dnsmasq.new, and then doing
"mv resolv.dnsmasq.new resolv.dnsmasq". The mv operation is atomic, so
that eliminates the race.

If you have a script which re-writes /etc/resolv.dnsmasq on a regular
basis, then the fix probably involves tweaking that script. If you have
no control over the code which writes /etc/resolv.dnsmasq then upgrading
to the latest release should provide a workaround in dnsmasq.

HTH

Simon.


> 
> Graham
> 
> 
> 
> _______________________________________________ Dnsmasq-discuss
> mailing list Dnsmasq-discuss at lists.thekelleys.org.uk 
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
> 





More information about the Dnsmasq-discuss mailing list