DNS caching is a technique used by operating systems and applications to temporarily store DNS query results to reduce latency and improve the overall performance of internet browsing. However, sometimes it may become necessary to clear the DNS cache, especially when the cached records are outdated or causing connectivity issues. In this article, we will provide a step-by-step guide on how to flush the DNS cache in Ubuntu and Linux Mint.

Advertisement

Understanding DNS Caching

Unlike Windows and macOS, Ubuntu and Linux Mint do not cache DNS queries at the operating system level by default. However, many Linux distributions, including Ubuntu and Linux Mint, use caching DNS resolvers such as systemd-resolved, dnsmasq, or BIND (named) to cache DNS records. To flush the DNS cache on these systems, you need to clear the cache in the specific caching DNS resolver in use.

You may like:

Flushing DNS Cache in systemd-resolved

Systemd-resolved is a DNS resolver and caching service that comes pre-installed on newer versions of Ubuntu and Linux Mint. To flush the DNS cache in systemd-resolved, follow these steps:

  1. Open a terminal window.
  2. Run the following command:
    sudo systemd-resolve --flush-caches 
    
  3. To verify that the cache has been cleared, you can check the cache statistics using the following command:
    sudo systemd-resolve --statistics 
    

Under “Cache”, you should see “Current Cache Size” set to 0.

Flushing DNS Cache in dnsmasq

Dnsmasq is a lightweight DNS and DHCP server often used in home networks and Linux distributions. To flush the DNS cache in dnsmasq, follow these steps:

  1. Open a terminal window.
  2. Restart the dnsmasq service using the following command:
    sudo systemctl restart dnsmasq 
    

    By restarting the service, you effectively clear the DNS cache.

Flushing DNS Cache in BIND (named)

BIND is a popular DNS server software used by many organizations worldwide. If your system uses BIND as a caching DNS resolver, you can clear its cache with these steps:

  1. Open a terminal window.
  2. Run the following command to flush the DNS cache:
    sudo rndc flush 
    

    This command will clear the entire DNS cache in BIND.

Clearing DNS Cache in Web Browsers

Web browsers like Google Chrome and Mozilla Firefox also maintain their DNS caches to speed up web browsing. To clear the DNS cache in your browser, follow the instructions specific to your browser:

  • Google Chrome: Navigate to “chrome://net-internals/#dns” and click the “Clear host cache” button.
  • Mozilla Firefox: Type “about:networking#dns” in the address bar, then click the “Clear DNS Cache” button.

Conclusion

In this article, we provided a step-by-step guide on how to flush the DNS cache in Ubuntu and Linux Mint for various caching DNS resolvers like systemd-resolved, dnsmasq, and BIND. Additionally, we discussed how to clear the DNS cache in popular web browsers. Clearing the DNS cache can help resolve connectivity issues caused by outdated or incorrect DNS records, ensuring a smoother browsing experience.

Share.

3 Comments

  1. Pinoy tambayan on

    Hi Rahul,

    I’m using linus server and hosted a wordpress site on it but when i open my site even after 3 – 4 days i can’t see my new posts without clearing the browser’s cache. Can you tell me the reason behind this?

Leave A Reply


Exit mobile version