How to flush the DNS cache in Linux


systemctl is-active systemd-resolved

sudo systemd-resolve --flush-caches


$ systemd-resolve --statistics
systemctl restart systemd-resolved.service




How to flush the DNS cache when using BIND

sudo rndc dumpdb -cache

sudo rndc flush
sudo cat /var/named/data/cache_dump.db

How to flush the DNS cache when using Dnsmasq

systemctl is-active dnsmasq
service dnsmasq status
sudo systemctl restart dnsmasq

sudo service dnsmasq restart

How to flush the DNS cache when using nscd

systemctl is-active nscd
service nscd status
sudo nscd --invalidate=hosts
sudo nscd -g
$ sudo nscd -g