Dnsmasq hanging on internet outage

I'm running dnsmasq-full (2.84test3) on a recent-ish snapshot (r15673). My router is a MikroTik RB750Gr3. I have dnsmasq doing both dhcp and dns, including local resolution of names I've defined on my home network.

Lately the cable service on my street has been unreliable, often going down for a few minutes at a time throughout the day. I've noticed that when the internet side is down, ALL dnsmasq operations start hanging. Dnsmasq won't answer any dhcp requests or dns queries (even for local addresses).

Looking on my router while this is happening, if I strace the dnsmasq process, I see that it's blocking on a TCP connection on port 53 from one of my internal clients (usually a Windows 10 laptop). My guess is that Windows first does its query over UDP, doesn't get a response, then resends over TCP, and this causes the dnsmasq process to block.

After the internet connection comes back up, dnsmasq never recovers. I'm working around this using a hotplug script which restarts dnsmasq after the WAN connection changes, but it's problematic that I lose local name resolution in the meantime.

I'm thinking that dnsmasq is probably single-threaded and there's something in the TCP request handler which causes the whole process to block. Has anybody else seen this issue?

Thanks for the pointer. I was having the opposite problem -- dnsmasq wasn't forking at all. After knowing that it's supposed to though, I was able to track down the issue. The startup script was using --no-daemon when it should have been using --keep-in-foreground.

Within a few minutes of switching it, I had another internet blip and everything continued to work just fine. I saw the forked processes start to stack up but there was no interruption to dhcp or local resolution. Thanks for your help!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.