3

I have cache enabled in my dnsmasq, because it is fast.

In some situations (for example, with VPN off), dnsmasq caches wrong results. I want a quick way to clean the cache (when I connect to the VPN for example). Restarting the service works, but it is slow (takes some seconds). I have tried sending SIGHUP, which as expected reloads the configuration, but does not flush the cache.

Is there a way to flush the dnsmasq cache without restarting it?

1 Answer 1

6

If you add the following to your dnsmasq.conf this will allow you to clear the cache on a reload rather than a restart.

clear-on-reload

Then we you want to clear the cache you trigger a reload..

pkill -HUP dnsmasq

You can check the contents (dumps stats to the log) of the cache with

pkill -USR1 dnsmasq
7
  • Strange, I tried it but the cache is not cleared after HUP ...
    – blueFast
    Feb 9, 2021 at 13:47
  • Does the SIGUSR1 trigger the stats dump to logs? Feb 9, 2021 at 14:28
  • Yes. HUP triggers reload, and SIGUSR1 dumps the cache, which is not empty, even after making sure that the clear-on-reload directive is enabled in the config.
    – blueFast
    Feb 9, 2021 at 20:28
  • Weird one I use SIGHUP on my custom AP's and it works.. Now last when you restart dnsmasqd are there any warning or errors when it loads the config file?. Feb 10, 2021 at 8:16
  • Not really. I even made sure of that by forcing errors to see the difference between a good config and a bad config
    – blueFast
    Feb 11, 2021 at 11:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .