Dnsmasq dies and does not restart itself

drwxr-xr-x    3 root     root           100 Feb 10 06:42 ./
drwxrwxrwt   18 root     root           500 Feb 19 20:00 ../
drwxr-xr-x    2 root     root            80 Feb 19 23:55 ddns/
-rw-r--r--    1 root     root             0 Feb 10 06:42 lastlog
-rw-r--r--    1 root     root             0 Feb 10 06:42 wtmp

My dnsmasq dies occasionally and does not recover after more than 5 minutes and there is nothing in /var/log.

I do have 1 file added under Additional hosts files to block about 8 domains or so, and DDNS + AdBlock installed, but I was not fiddling with them when dnsmasq died.

I have to manually login through SSH and restart it. Any idea how I can deal with it?

Maybe there is something in the logs?

nothing, the whole folder /var/log is empty for some reason

drwxr-xr-x    3 root     root           100 Feb 10 06:42 ./
drwxrwxrwt   18 root     root           500 Feb 19 20:00 ../
drwxr-xr-x    2 root     root            80 Feb 19 23:55 ddns/
-rw-r--r--    1 root     root             0 Feb 10 06:42 lastlog
-rw-r--r--    1 root     root             0 Feb 10 06:42 wtmp

As it should be.

use logread or check in luci

1 Like

got adblock installed ?

is there any additional DNS on the same LAN ?

Post your dhcp config file here, please.

  1. Yes, I have adblock installed
  2. I believe there is only 1 dns (dnsmasq) at the moment
## @domain and @host have been removed
# uci show dhcp
dhcp.@dnsmasq[0]=dnsmasq
dhcp.@dnsmasq[0].domainneeded='1'
dhcp.@dnsmasq[0].localise_queries='1'
dhcp.@dnsmasq[0].rebind_protection='1'
dhcp.@dnsmasq[0].rebind_localhost='1'
dhcp.@dnsmasq[0].local='/lan/'
dhcp.@dnsmasq[0].domain='lan'
dhcp.@dnsmasq[0].expandhosts='1'
dhcp.@dnsmasq[0].cachesize='1000'
dhcp.@dnsmasq[0].authoritative='1'
dhcp.@dnsmasq[0].readethers='1'
dhcp.@dnsmasq[0].leasefile='/tmp/dhcp.leases'
dhcp.@dnsmasq[0].resolvfile='/tmp/resolv.conf.d/resolv.conf.auto'
dhcp.@dnsmasq[0].localservice='1'
dhcp.@dnsmasq[0].ednspacket_max='1232'
dhcp.@dnsmasq[0].confdir='/tmp/dnsmasq.d'
dhcp.lan=dhcp
dhcp.lan.interface='lan'
dhcp.lan.start='10'
dhcp.lan.limit='200'
dhcp.lan.leasetime='12h'
dhcp.lan.dhcpv4='server'
dhcp.lan.dhcpv6='server'
dhcp.lan.ra='server'
dhcp.lan.ra_flags='managed-config' 'other-config'
dhcp.wan=dhcp
dhcp.wan.interface='wan'
dhcp.wan.ignore='1'
dhcp.odhcpd=odhcpd
dhcp.odhcpd.maindhcp='0'
dhcp.odhcpd.leasefile='/tmp/hosts/odhcpd'
dhcp.odhcpd.leasetrigger='/usr/sbin/odhcpd-update'
dhcp.odhcpd.loglevel='4'
dhcp.net_guest=dhcp
dhcp.net_guest.interface='subnet_guest'
dhcp.net_guest.start='100'
dhcp.net_guest.limit='150'
dhcp.net_guest.leasetime='1h'
dhcp.net_iot=dhcp
dhcp.net_iot.interface='subnet_iot'
dhcp.net_iot.start='100'
dhcp.net_iot.limit='150'
dhcp.net_iot.leasetime='1h'
dhcp.net_home=dhcp
dhcp.net_home.interface='subnet_home'
dhcp.net_home.start='100'
dhcp.net_home.limit='150'
dhcp.net_home.leasetime='1h'

thanks let me check luci the next time.

This line looks like it could cause a problem. Try deleting it and restarting the service.

Let's also see some other relevant info:

Please connect to your OpenWrt device using ssh and copy the output of the following commands and post it here using the "Preformatted text </> " button:
grafik
Remember to redact passwords, MAC addresses and any public IP addresses you may have:

ubus call system board
cat /etc/config/network

While I don't remember adding /tmp/dnsmasq.d, it does exists. Why would it cause problems?

# ubus call system board
config/network{
        "kernel": "6.6.73",
        "hostname": "Hall",
        "system": "MediaTek MT7621 ver:1 eco:3",
        "model": "Linksys EA8100",
        "board_name": "linksys,ea8100-v1",
        "rootfs_type": "squashfs",
        "release": {
                "distribution": "OpenWrt",
                "version": "24.10.0",
                "revision": "r28427-6df0e3d02a",
                "target": "ramips/mt7621",
                "description": "OpenWrt 24.10.0 r28427-6df0e3d02a",
                "builddate": "1738624177"
        }
}
root@Hall:/tmp/dnsmasq.d# cat /etc/config/network

config interface 'loopback'
        option device 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd63:3d37:2f9b::/48'
        option packet_steering '1'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'lan1'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'

config device
        option name 'lan1'
        option macaddr '***'

config device
        option name 'lan2'
        option macaddr '***'

config device
        option name 'lan3'
        option macaddr '***'

config device
        option name 'lan4'
        option macaddr '***'

config interface 'lan'
        option device 'br-lan.1'
        option proto 'static'
        option ip6assign '60'
        list ipaddr '192.168.214.1/24'

config device
        option name 'wan'
        option macaddr '***'

config interface 'wan'
        option device 'wan'
        option proto 'dhcp'

config interface 'wan6'
        option device 'wan'
        option proto 'dhcpv6'

config device 'device_guest'
        option type 'bridge'
        option name 'br-guest'

config interface 'subnet_guest'
        option proto 'static'
        option device 'br-guest'
        option ipaddr '192.168.247.1/24'
        list dns '8.8.8.8'
        list dns '1.1.1.1'

config device 'device_iot'
        option type 'bridge'
        option name 'br-iot'

config interface 'subnet_iot'
        option proto 'static'
        option device 'br-lan.2'
        list dns '8.8.8.8'
        list dns '1.1.1.1'
        list ipaddr '192.168.249.1/24'

config device 'device_home'
        option type 'bridge'
        option name 'br-home'

config interface 'subnet_home'
        option proto 'static'
        option device 'br-home'
        list ipaddr '192.168.9.1/24'

config bridge-vlan
        option device 'br-lan'
        option vlan '1'
        list ports 'lan1:u*'
        list ports 'lan2'
        list ports 'lan3'
        list ports 'lan4'

config bridge-vlan
        option device 'br-lan'
        option vlan '2'
        list ports 'lan1:t'

Normally, the config file path isn't explicitly set, allowing the system to create the path per its underlying logic. I'm not positive that it's the culprit, but it's not a default item in the config, so removing it makes sense as a troubleshooting method.

I don't see any issues with the network config file...

What exactly is the symptom? Does it affect all networks or just one/some?

  1. Symptom was: I was not able to reach any website with Chrome on all networks
  2. I did nslookups to 8.8.8.8 - was able to resolve domains like google.com
    • pings to 8.8.8.8 - means provider connection ok
  3. My machine was Windows, I also tried on Android/MacOS connecting via both home and lan, still could not reach any website
  4. Eventually, I execute only the service dnsmasq restart command and everything went back to normal

This does sound like a potential dnsmasq issue -- specifically DNS. But did you specifically test DNS when the network failed (i.e. nslookup openwrt.org 192.168.214.1)? Did the logs show anything about dnsmasq stopping or failing to restart?

I looked in the wrong place /var/log which was empty. When I looked into LuCI earlier, the logs are already gone. No, I did not run nslookup openwrt.org 192.168.214.1, but I assume it failed since I was able to nslookup 8.8.8.8, which led me to execute service dnsmasq restart

Sounds like a reasonable approach.

If it manifests again, check the local DNS to see if it has failed, and use logread to check the logs themselves (you can use logread -e dnsmasq to filter to only dnsmasq entires).

Thanks, I will do that. It doesn't happen that often, it might take a while before I get back.

Actually, it occured more frequently during my initial switch to OpenWrt, but I did not suspect dnsmasq, and just rebooted the router instead.

My main concern now stems from my other non router services failing because dnsmasq did not automatically recover when I'm away for extended periods.

Have you setup any other dns handling (such as adguard, DoH, DoT, etc)?

No, only adblock and ddns. I do add a Additional hosts files that blocks about 8 domains. (Added this info to my OP too)

Adblock could be responsible for the problem.