Linux: Disable DNS cache in systemd

New Linux distributions are enabling local DNS caching. For most users this is a sane default, but as a system administrator this can sometimes get in the way. You can check if your local cache is running and see the statistics with:

resolvectl statistics

Which will tell you how active your cache is, what the hit/miss ratio is, and information about DNSSEC. If you need to clear your local cache you can run:

resolvectl flush-caches

Doing this repeatedly can get cumbersome if you are testing remote DNS frequently. If you want to disable local caching all together you can run:

systemctl disable systemd-resolved.service --now

Remember to update your /etc/resolv.conf to point at the correct DNS server after you're done.



Note: Replies will be formatted with PHP Markdown Extra syntax.

Name: Email (Not Required):
 
Logged IP: 3.147.47.177
To prevent spam please submit by clicking the kitten: