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

Max Barry mythtv at maxbarry.com
Fri Oct 23 03:33:57 BST 2009


On 23/10/09 09:05, Max Barry wrote:
> 
> Simon Kelly wrote:
>> 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.
> 
> Thanks for the help! Results:
> 
> 1: lo: <LOOPBACK> mtu 16436 qdisc noop state DOWN
>     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
> 2: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
>     link/ether 00:1f:c6:85:29:28 brd ff:ff:ff:ff:ff:ff
> 3: wmaster0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
>     link/ieee802.11 00:24:01:12:87:8d brd ff:ff:ff:ff:ff:ff
> 4: wlan1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
>     link/ether 00:24:01:12:87:8d brd ff:ff:ff:ff:ff:ff
> 
> For comparison, this is what it looks like if I then restart dnsmasq 
> manually:
> 
> 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
>     link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
>     inet 127.0.0.1/8 scope host lo
>     inet6 ::1/128 scope host
>        valid_lft forever preferred_lft forever
> 2: eth2: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state 
> UNKNOWN qlen 1000
>     link/ether 00:1f:c6:85:29:28 brd ff:ff:ff:ff:ff:ff
> 3: wmaster0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast 
> state UNKNOWN qlen 1000
>     link/ieee802.11 00:24:01:12:87:8d brd ff:ff:ff:ff:ff:ff
> 4: wlan1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1492 qdisc pfifo_fast 
> state UP qlen 1000
>     link/ether 00:24:01:12:87:8d brd ff:ff:ff:ff:ff:ff
>     inet 192.168.0.2/24 brd 192.168.0.255 scope global wlan1
>     inet6 fe80::224:1ff:fe12:878d/64 scope link
>        valid_lft forever preferred_lft forever
> 
> I will see if I can get dnsmasq-2.52test3 working as per your other post.

Yay! dnsmasq-2.52test3 does indeed seem to work correctly. While the 'ip 
addr show' results are the same upon boot (lo registered as LOOPBACK but 
not with address 127.0.0.1), dnsmasq correctly refuses to listen to it:

Oct 23 13:12:34 eve dnsmasq[2404]: started, version 2.52test3 cachesize 150
Oct 23 13:12:34 eve dnsmasq[2404]: compile time options: IPv6 GNU-getopt 
no-DBus no-I18N DHCP TFTP
Oct 23 13:12:34 eve dnsmasq[2404]: no servers found in /etc/resolv.conf, 
will re
try
Oct 23 13:12:34 eve dnsmasq[2404]: read /etc/hosts - 16 addresses
Oct 23 13:12:40 eve NetworkManager: <info>  starting...
...snip...
Oct 23 13:12:57 eve NetworkManager: <info>  Activation (wlan1) Stage 5 
of 5 (IP Configure Commit) complete.
Oct 23 13:12:57 eve dnsmasq[2404]: query[SOA] local from 127.0.0.1
Oct 23 13:12:57 eve dnsmasq[2404]: query[SOA] local from 127.0.0.1
Oct 23 13:12:58 eve ntpd[2972]: ntpd exiting on signal 15
Oct 23 13:12:58 eve dnsmasq[2404]: reading /etc/resolv.conf
Oct 23 13:12:58 eve dnsmasq[2404]: using nameserver 208.67.220.220#53
Oct 23 13:12:58 eve dnsmasq[2404]: using nameserver 208.67.222.222#53
Oct 23 13:12:58 eve dnsmasq[2404]: using nameserver 61.9.133.193#53
Oct 23 13:12:58 eve dnsmasq[2404]: using nameserver 61.9.134.49#53
Oct 23 13:12:58 eve dnsmasq[2404]: ignoring nameserver 127.0.0.1 - local 
interface

I notice the compile-time options are slightly different this time 
around (no-DBus vs DBus, no I18N) but am not sure if that's relevant.

Thanks for the help!

Max.




More information about the Dnsmasq-discuss mailing list