How To Flush DNS Cache On Linux (For systemd-resolved, BIND, Dnsmasq Or nscd)

This article explains how to flush the DNS cache (clear it) on Linux, not only for systems that use systemd-resolved (e.g. Ubuntu 18.04 and newer), but also for those using nscd, BIND or Dnsmasq to cache DNS queries.

DNS, or Domain Name System, is like the Internet's phonebook, translating human-friendly computer hostnames into IP addresses. For example, google.com is translated to the 216.58.214.238 IPv4 address, and 2a00:1450:400d:808::200e IPv6 address. This way the domain name can change the IP address without affecting its users, and without changing the its name.

The DNS cache (or DNS resolver cache) is a temporary database that stores these records, which is used to quickly lookup a website when you're trying to visit it.

If the DNS is cached, you might not be able to access some hostnames that were changed recently - until your DNS cache is updated or cleared, that's why it's useful in some situations to flush / clear the DNS cache. After the DNS cache is cleared, the new addresses are taken from the DNS server set for your network.

0 Comments