[Dnsmasq-discuss] About 127.0.0.1 in resolv.conf [WAS: Web hang ups after repeated access to one site - dnsmasq related?]

Simon Kelley simon at thekelleys.org.uk
Thu Oct 22 13:06:13 BST 2009


Max Barry wrote:
> Simon Kelley wrote:
>> Hugo Heden wrote:
>>> But what happens if dnsmasq then
>>> forwards a ("non-local") dns-query to 127.0.0.1, i.e to itself? Could
>>> that not result in some kind of infinite loop weirdness?
>> dnsmasq knows that it's listening on 127.0.0.1 so it's clever enough not 
>> to forward requests there.
> 
> Hello! Sorry to gravedig, but I'm having this problem: dnsmasq listens 
> on 127.0.0.1 and forwards requests to itself.
> 
>  From /var/log/daemon.log:
> 
> Oct 15 09:24:35 eve dnsmasq[2396]: started, version 2.47 cachesize 150
> Oct 15 09:24:35 eve dnsmasq[2396]: compile time options: IPv6 GNU-getopt 
> DBus I18N TFTP
> Oct 15 09:24:35 eve dnsmasq[2396]: no servers found in /etc/resolv.conf, 
> will retry
> Oct 15 09:24:35 eve dnsmasq[2396]: read /etc/hosts - 16 addresses
> Oct 15 09:24:41 eve NetworkManager: <info>  starting...
> ...snip...
> Oct 15 09:24:49 eve NetworkManager: <info>    address 192.168.0.2
> Oct 15 09:24:49 eve NetworkManager: <info>    prefix 24 (255.255.255.0)
> Oct 15 09:24:49 eve NetworkManager: <info>    gateway 192.168.0.1
> Oct 15 09:24:49 eve NetworkManager: <info>    nameserver '127.0.0.1'
> Oct 15 09:24:49 eve NetworkManager: <info>    nameserver '61.9.134.49'
> Oct 15 09:24:49 eve NetworkManager: <info>    nameserver '61.9.133.193'
> Oct 15 09:24:49 eve NetworkManager: <info>    nameserver '208.67.222.222'
> Oct 15 09:24:49 eve NetworkManager: <info>    nameserver '208.67.220.220'
> Oct 15 09:24:49 eve NetworkManager: <info>    nameserver '192.168.0.1'
> Oct 15 09:24:49 eve NetworkManager: <info>    domain name 
> 'vic.bigpond.net.au'
> Oct 15 09:24:49 eve NetworkManager: <info>  Activation (wlan1) Stage 5 
> of 5 (IP Configure Commit) scheduled...
> Oct 15 09:24:49 eve NetworkManager: <info>  Activation (wlan1) Stage 4 
> of 5 (IP Configure Get) complete.
> Oct 15 09:24:49 eve NetworkManager: <info>  Activation (wlan1) Stage 5 
> of 5 (IP Configure Commit) started...
> Oct 15 09:24:51 eve NetworkManager: <info>  (wlan1): device state 
> change: 7 -> 8
> Oct 15 09:24:51 eve dnsmasq[2396]: reading /etc/resolv.conf
> Oct 15 09:24:51 eve dnsmasq[2396]: using nameserver 208.67.220.220#53
> Oct 15 09:24:51 eve dnsmasq[2396]: using nameserver 208.67.222.222#53
> Oct 15 09:24:51 eve dnsmasq[2396]: using nameserver 61.9.133.193#53
> Oct 15 09:24:51 eve dnsmasq[2396]: using nameserver 61.9.134.49#53
> Oct 15 09:24:51 eve dnsmasq[2396]: using nameserver 127.0.0.1#53
> 
> Note the line above. If I manually restart dnsmasq, that line instead 
> looks like "dnsmasq[3853]: ignoring nameserver 127.0.0.1 - local 
> interface". But each time I turn on my computer each day, and dnsmasq 
> starts automatically, it's as per the above, and it listens to the local 
> interface:
> 
> Oct 15 09:25:49 eve dnsmasq[2396]: query[A] www.bom.gov.au from 127.0.0.1
> Oct 15 09:25:49 eve dnsmasq[2396]: forwarded www.bom.gov.au to 127.0.0.1
> Oct 15 09:25:49 eve dnsmasq[2396]: query[A] weather.noaa.gov from 127.0.0.1
> Oct 15 09:25:49 eve dnsmasq[2396]: forwarded weather.noaa.gov to 127.0.0.1
> Oct 15 09:25:49 eve dnsmasq[2396]: query[A] ntp.ubuntu.com from 127.0.0.1
> Oct 15 09:25:49 eve dnsmasq[2396]: forwarded ntp.ubuntu.com to 127.0.0.1
> Oct 15 09:25:49 eve dnsmasq[2396]: query[A] imap.gmail.com from 127.0.0.1
> Oct 15 09:25:49 eve dnsmasq[2396]: forwarded imap.gmail.com to 127.0.0.1
> Oct 15 09:25:49 eve dnsmasq[2396]: query[A] ntp.ubuntu.com from 127.0.0.1
> Oct 15 09:25:49 eve dnsmasq[2396]: forwarded ntp.ubuntu.com to 127.0.0.1
> 
> These requests time out, making everything very slow.
> 
> $ more /etc/resolv.conf
> # Generated by NetworkManager
> domain vic.bigpond.net.au
> search vic.bigpond.net.au
> nameserver 127.0.0.1
> nameserver 61.9.134.49
> nameserver 61.9.133.193
> # NOTE: the libc resolver may not support more than 3 nameservers.
> # The nameservers listed below may not be recognized.
> nameserver 208.67.222.222
> nameserver 208.67.220.220
> 
> This problem only began after I started using NetworkManager on Ubuntu 
> (previously I had manually configured /etc/network/interfaces).
> 
> Any help appreciated!
> 

It would be useful to get to the bottom of this.

I guess it's something to do with the order in which things happen at 
startup. Dnsmasq doesn't treat 127.0.0.1 specially: when  it starts up 
is enumerates all the interfaces on the machine and notes those with the 
"loopback" flag set. If an address turns up later in /etc/resolv.conf 
which matches one which was owned by a loopback interface during the 
enumeration, then it is rejected.

So, if, at the time dnsmasq is started, the "lo" interface either 1) 
doesn't exist, 2) doesn't have the loopback flag set or 3) doesn't have 
address 127.0.0.1 then the address 127.0.0.1 will not be weeded out.

Could you add something like

ip addr show >/tmp/interface-state

to the /etc/init.d dnsmasq start script, reboot, and post the results here?


Cheers,

Simon.





More information about the Dnsmasq-discuss mailing list