Clear dnsmasq cache without restarting the service

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

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like