[Dnsmasq-discuss] Dnsmasq stops resolving addresses after return from suspend and wlan re-assoc

Toke Høiland-Jørgensen toke at toke.dk
Mon Oct 20 04:10:20 BST 2014


I've been bothered for a while that my laptop (which runs a local
dnsmasq instance for caching) stops resolving names after returning from
suspend, and sometimes spontaneously as well. Restarting dnsmasq would
always fix this.

It finally started bothering me enough to debug it, and what I think
happens is something like this:

- Dnsmasq is configured to use the resolv.conf file maintained by
  systemd-resolved, the nameserver manager component of
  systemd-networkd. This file is updated whenever nameservers change
  from DHCP or configuration.

- Sometimes, it seems, systemd-resolved rewrites this file twice within
  a fairly short time; once empty and again shortly after with the right
  nameservers. Dnsmasq only picks up the first rewrite:

Oct 19 19:44:50 alrua-x1 dnsmasq[30391]: reading /etc/dnsmasq-resolv.conf
Oct 19 19:44:50 alrua-x1 dnsmasq[30391]: ignoring nameserver 127.0.0.1 - local interface

But subsequently touching the file makes dnsmasq pick up on the change
and name resolution works again:

Oct 19 19:49:30 alrua-x1 sudo[2104]: alrua : TTY=pts/4 ; PWD=/home/alrua ; USER=root ; COMMAND=/usr/bin/touch /run/systemd/resolve/resolv.conf
Oct 19 19:49:30 alrua-x1 sudo[2104]: pam_unix(sudo:session): session opened for user root by (uid=0)
Oct 19 19:49:30 alrua-x1 sudo[2104]: pam_unix(sudo:session): session closed for user root
Oct 19 19:49:33 alrua-x1 dnsmasq[30391]: reading /etc/dnsmasq-resolv.conf
Oct 19 19:49:33 alrua-x1 dnsmasq[30391]: ignoring nameserver 127.0.0.1 - local interface
Oct 19 19:49:33 alrua-x1 dnsmasq[30391]: using nameserver 10.61.32.1#53
Oct 19 19:49:33 alrua-x1 dnsmasq[30391]: using nameserver 1.1.1.1#53


Oddly enough, when first connecting to a network, there's a delay
between the two writes of the resolv-file, which means things work:

Oct 19 20:05:59 alrua-x1 systemd-networkd[960]: wlan0           : gained carrier
Oct 19 20:05:59 alrua-x1 systemd-networkd[960]: wlan0           : DHCPv4 address 10.71.0.250/20 via 10.71.0.1
Oct 19 20:05:59 alrua-x1 dnsmasq[22661]: reading /etc/dnsmasq-resolv.conf
Oct 19 20:05:59 alrua-x1 dnsmasq[22661]: ignoring nameserver 127.0.0.1 - local interface
Oct 19 20:06:03 alrua-x1 dnsmasq[22661]: reading /etc/dnsmasq-resolv.conf
Oct 19 20:06:03 alrua-x1 dnsmasq[22661]: ignoring nameserver 127.0.0.1 - local interface
Oct 19 20:06:03 alrua-x1 dnsmasq[22661]: using nameserver 10.61.32.1#53
Oct 19 20:06:03 alrua-x1 dnsmasq[22661]: using nameserver 1.1.1.1#53


Either way, fixing dnsmasq to always notice the updated files would be
desirable. Not sure if the recently posted nanosecond resolution patch
is the way to go about it, but consider this a motivation to do
*something* :)

-Toke



More information about the Dnsmasq-discuss mailing list