coding
Posts: 40
Joined: Sun Jul 20, 2014 7:23 am

Dnsmasq won't work anymore after a reboot

Fri Nov 27, 2015 6:52 pm

I run Dnsmasq to respond to local network DNS queries.
Recently Dnsmasq has a problem with reboots. Whenever I reboot, DNS queries are not served anymore.
I found this in Dnsmasq's log file:

Code: Select all

dnsmasq[498]: Ignoring query from non-local network
That line is the only difference. When I restart Dnsmasq (which fixes the whole problem) all new lines are the same. But those "Ignoring query" line is missing.
What might be happening during a boot that makes Dnsmasq think my network devices are "non-local"?
Again, "sudo service dnsmasq restart" fixes the problem.

Raspbian Jessie, fully updated (but not installed from the latest image, which currently is 2015-11-21)

User avatar
DougieLawson
Posts: 36312
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Dnsmasq won't work anymore after a reboot

Fri Nov 27, 2015 11:34 pm

Are you setting a static IP address in the wrong configuration file? Don't put that stuff in /etc/network/interfaces it goes in /etc/dhcpcd.conf now.

If ANY interface comes up active but can't get a response from a DHCP server it gets a 169.254.rrr.rrr IP address (bottom two segments (last 16 bits) are random).
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

coding
Posts: 40
Joined: Sun Jul 20, 2014 7:23 am

Re: Dnsmasq won't work anymore after a reboot

Fri Nov 27, 2015 11:44 pm

I didn't touch /etc/network/interfaces.
I put these two lines into /etc/dhcp.conf:

Code: Select all

static ip_address=192.168.1.10/24
static routers=192.168.1.1
I can reach the Pi at IP address 192.168.1.10 via SSH after a reboot. Then I can restart Dnsmasq.
Not sure if the Pi somehow gets two IP addresses, and Dnsmasq decides (at the first run) to see 169.254. as local network. I remember I had a double IP address problem before, but I forgot how to check this.
Maybe I need more lines than the two above?

User avatar
DougieLawson
Posts: 36312
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Dnsmasq won't work anymore after a reboot

Sat Nov 28, 2015 12:59 am

The way to check is ip addr show
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

coding
Posts: 40
Joined: Sun Jul 20, 2014 7:23 am

Re: Dnsmasq won't work anymore after a reboot

Sat Nov 28, 2015 9:40 am

ip addr show says there is an IPv6 address with prefix fe80::/64.
A quick research told me this should be the equivalent of 169.254. in IPv4.

So your assumption might be true: During system start Dnsmasq may think that 169.254. is the local network, and applies its rules (block non-local network requests). After a manual Dnsmasq restart, the true IPv4 local network address is properly recognized by Dnsmasq.
What remains is the standard IPv6 address, which is unused but giving a hint that something went wrong earlier.

But how to prevent this? It seems unnecessary that the system creates a fallback IP before even reading dhcpcd.conf.

User avatar
DougieLawson
Posts: 36312
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Dnsmasq won't work anymore after a reboot

Sun Nov 29, 2015 12:35 am

I wouldn't worry about the IPv6 link-local address I don't think that's any part of your problem.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

coding
Posts: 40
Joined: Sun Jul 20, 2014 7:23 am

Re: Dnsmasq won't work anymore after a reboot

Sun Nov 29, 2015 7:10 am

You're probably right.
I now created a root cronjob which restarts Dnsmasq 30 seconds after reboots to work around the problem.

beta-tester
Posts: 1242
Joined: Fri Jan 04, 2013 1:57 pm
Location: de_DE

Re: Dnsmasq won't work anymore after a reboot

Sun Nov 29, 2015 4:53 pm

coding wrote:...Recently Dnsmasq has a problem with reboots. Whenever I reboot, DNS queries are not served anymore...
do you maybe have some dependency order cycles like me

Code: Select all

dmesg
...
[    3.494252] systemd[1]: Found ordering cycle on ...
[    3.506955] systemd[1]: Found dependency on ...
...
[    3.580419] systemd[1]: Breaking ordering cycle by deleting job rpcbind.service/start
[    3.594361] systemd[1]: Job rpcbind.service/start deleted to break ordering cycle starting with basic.target/start
...
nfs-kernel-server not starting anymore since few days/weeks
any chance to fix dependency ordering cycle of systemd?
{ I only give negative feedback }
RPi B (rev1, 256MB), B (rev2, 512MB), B+, 2B, 3B, 3B+, ZeroW, ...

coding
Posts: 40
Joined: Sun Jul 20, 2014 7:23 am

Re: Dnsmasq won't work anymore after a reboot

Sun Nov 29, 2015 7:16 pm

No, I don't see any of those lines in the dmesg output.

baxter12
Posts: 1
Joined: Fri Sep 09, 2016 3:31 pm

Re: Dnsmasq won't work anymore after a reboot

Fri Sep 09, 2016 3:40 pm

I believe I've figured this out.

There is a race condition between the startup of dnsmasq and the assignment of the IP address on the local interface.

If dhcpcd is responsible for setting the IP address, then the local interface's IP address may not be set by the time dnsmasq starts, instead having some bogus IP address. When dnsmasq applies the '--local-service' rules, it results in it thinking that only requests from the bogus IP address are from the local LAN.

In my case, I was using a static IP address, but I had configured dhcpcd to set the IP address via it's 'static' parameters (I wanted dhcpcd running for other reasons). To fix this, I modified /etc/network/interfaces to set the IP address immediately as the interface was brought up, so when dnsmasq started, the IP address was already correctly set.

dnsmasq is now fully operational immediately after every reboot.

Return to “Raspbian”