Monday, July 30, 2018

How to Flush the DNS Cache on Linux

https://www.maketecheasier.com/flush-dns-cache-linux


There is no single standard for DNS servers on Linux. Each distribution uses something different, so you’ll need to see which one is running on your system. Of course, it doesn’t hurt to just try these and see which works. The procedure is nearly the same.
Most modern distributions are running either “systemd-resolve” or “nscd.” There is a chance, though, that you might be working with “dnsmasq” or “BIND.” In any case, flushing the cache is usually as simple as restarting whichever daemon is running.
Ubuntu and other Debian-based distributions are probably running systemd-resolve. It’s a convenient DNS daemon that’s built in to systemd, which your system already utilizes for a ton of things. If you are running Ubuntu, everything is already set up and ready to go. Clear your cache by telling systemd to flush it.
Flush DNS Cache Systemd
That’s all there is to it. You can check whether it worked by asking for the statistics.
DNS Cache Stats Systemd
If you see a zero by the cache size, you’ve successfully flushed your system’s cache.
Flush DNS Cache NSCD
If you’re running a different distribution, there’s a good chance it’s using nscd. It’s the choice of the Red Hat distributions and Arch Linux. This one is just as easy to use. You only need to restart the service to clear out the cache.
dnsmasq is another option. It’s more common on servers than it is on desktop machines, but it is still often used. Dnsmasq is great for local DNS servers, and it’s often used on routers. Like with nscd, you only need to restart the service.
Finally, BIND is a more traditional option. Not a lot of distributions use it by default, but you certainly might encounter it. BIND is still used for purpose-built DNS servers.
Whichever DNS service your computer is running, you shouldn’t have any problem clearing your DNS cache. Restarting most DNS servers is an easy fix. For Debian-based distributions, you can use a built-in function in systemd to clear your cache. In all cases, the process is simple, and it doesn’t require a restart of your whole system.

No comments:

Post a Comment