Dnsmasq stops occasionaly

Started by gunnarf, November 03, 2025, 08:49:14 AM

Previous topic - Next topic
this morning I found the pid changed... so I updated the monitor loop to pick up the new PID if it changes again...

sh -c 'while true; do ps -o pid,rss,command -p `cat /var/run/dnsmasq.pid`; date; sleep 3600; done' >> dns_mem_usage.out &

Hi!  It looks like the memory is usage is increasing.  See attached log file.

Here are the last few lines...
  PID    RSS COMMAND
27052 862192 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Tue Jan 13 10:02:59 EST 2026
  PID    RSS COMMAND
27052 875284 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Tue Jan 13 11:02:59 EST 2026
  PID    RSS COMMAND
27052 888480 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Tue Jan 13 12:02:59 EST 2026
  PID    RSS COMMAND
27052 902784 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Tue Jan 13 13:02:59 EST 2026

It looks like it increases indeed. What features are you using? Can you share the /usr/local/etc/dnsmasq.conf

How stable is your WAN connection, do you have any churn in the files or folders referenced in dnsmasq.conf?

E.g very fast lease churn by some aggressive clients, or lots of hostname changes etc... It would be great if we can find the exact feature in the dnsmasq.conf that causes this.

Would be great if this is somehow reproducible.
Hardware:
DEC740

Hi.  I don't see a lot of churn on the files referenced in the conf file
root@OPNsense:/usr/local/etc/dnsmasq.conf.d # ls -l
total 16
-rw-r--r--  1 root wheel  85 Dec 18 08:13 README
-rw-r--r--  1 root wheel  41 Sep 15 15:21 jdownloader.conf
-rw-r--r--  1 root wheel 211 Sep 14 21:26 lucid.conf
-rw-r--r--  1 root wheel  31 Sep 14 19:41 plex.conf

I'm attaching my dnsmasq.conf.  I don't think I'm doing anything special with my installation. 

My WAN connection is stable.  I don't see instability in it but if you tell me what to look for then I can validate the logs to be certain. 


January 13, 2026, 09:35:19 PM #19 Last Edit: January 13, 2026, 09:37:04 PM by Monviech (Cedrik)
You are indeed not doing anything strange (other than having some custom config files but that can be found out).
Can you try some of these things:

- 1. comment these out, one by one, see if anything changes. If we know the exact folder/file that would be great:
(Go to /usr/local/opnsense/service/templates/OPNsense/Dnsmasq/dnsmasq.conf and just put a "#" before these lines one by one. Then restart dnsmasq via Apply in the GUI each time and monitor for a while)
# addn-hosts=/var/etc/dnsmasq-hosts
# addn-hosts=/var/etc/dnsmasq-leases
# conf-dir=/usr/local/etc/dnsmasq.conf.d,*.conf

- 2. Random guess, can you try to disable Router Advertisements/DHCPv6 in the GUI and see if that changes anything?

Try these one by one and see if it changes anything.


PS: Just make sure to mask your dhcp-host entries in that prior dnsmasq.conf file attached to your post, so not everyone knows your network.
Hardware:
DEC740

Sounds good.  I'll start today and will post my results incrementally.  :-)

#addn-hosts=/var/etc/dnsmasq-hosts
  PID   RSS COMMAND
33508 13588 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Wed Jan 14 22:03:00 EST 2026
  PID   RSS COMMAND
33508 25680 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Wed Jan 14 23:03:00 EST 2026
  PID   RSS COMMAND
33508 34596 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Thu Jan 15 00:03:00 EST 2026
  PID   RSS COMMAND
33508 45100 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Thu Jan 15 01:03:00 EST 2026
  PID   RSS COMMAND
33508 54300 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Thu Jan 15 02:03:00 EST 2026
  PID   RSS COMMAND
33508 66420 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Thu Jan 15 03:03:00 EST 2026
  PID   RSS COMMAND
33508 73424 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Thu Jan 15 04:03:00 EST 2026
  PID   RSS COMMAND
33508 80200 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Thu Jan 15 05:03:00 EST 2026
  PID   RSS COMMAND
33508 90912 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Thu Jan 15 06:03:00 EST 2026

I just found out that each time I hit apply in the GUI, opnsense overwrites the dnsmasq.conf file and removes my "#" entries... :-(. Any ideas on how I can continue to troubleshoot?

yeah give my initial post another look, I especially provided the template path.
Hardware:
DEC740

My bad... Thank you for reorienting me.  I'm testing again.

No problem it would be really helpful if you can find something. Thanks for testing :)
Hardware:
DEC740

#addn-hosts=/var/etc/dnsmasq-hosts
  PID   RSS COMMAND
48348 20328 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Thu Jan 15 15:03:00 EST 2026
  PID   RSS COMMAND
48348 36056 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Thu Jan 15 16:03:00 EST 2026
  PID   RSS COMMAND
48348 54044 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Thu Jan 15 17:03:00 EST 2026
  PID   RSS COMMAND
48348 77012 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Thu Jan 15 18:03:00 EST 2026
  PID   RSS COMMAND
48348 91060 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Thu Jan 15 19:03:00 EST 2026
  PID    RSS COMMAND
48348 106724 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Thu Jan 15 20:03:00 EST 2026
  PID    RSS COMMAND
48348 129852 /usr/local/sbin/dnsmasq -x /var/run/dnsmasq.pid -C /usr/local/etc/dnsmasq.conf
Thu Jan 15 21:03:00 EST 2026