Linux

Boost Your Network Performance: How To Clear DNS Cache on Linux

Clear DNS Cache on Linux

As a Linux user, you might have experienced slow internet connections or the inability to access some websites. Often, this issue can be traced back to your DNS cache. DNS cache is used by your system to store recently visited websites’ domain name resolutions, making it faster to access them in the future. However, sometimes this cache can become corrupted, leading to issues such as slow internet speed or incorrect website resolution. In such a situation, clearing the DNS cache can solve the problem.

In this blog post, we will be discussing how to clear the DNS cache on Linux systems. We will cover the step-by-step process of clearing the DNS cache, including the use of various commands and tools available on Linux. We will also discuss the importance of clearing the DNS cache, the common issues caused by a corrupted DNS cache, and how flushing the DNS cache can help solve these problems. By the end of this post, you will have a clear understanding of how to flush the DNS cache on Linux systems, and you will be able to do so efficiently and effectively. So, let’s get started!

Checking DNS Cache on Linux

Before we proceed with clearing the DNS cache, it is essential to check if there is any outdated or incorrect information stored in the cache. To check the DNS cache on your Linux machine, open a terminal and enter the following command:

sudo systemd-resolve --statistics

This command will show you the statistics of your DNS cache, including the number of queries, cache hits, and cache misses. If you notice a high number of cache misses or outdated information, it might be time to clear your DNS cache.

Clearing DNS Cache on Linux Using the Command Line

The most common method to clear the DNS cache on Linux is by using the command line. Here are the steps to follow:

Step 1. Open a terminal on your Linux machine.

Step 2. Type the following command to clear the DNS cache:

sudo systemd-resolve --flush-caches

This command will flush both the positive and negative DNS caches.

Step 3. To confirm that the DNS cache has been cleared, type the following command:

sudo systemd-resolve --statistics

This command will show you the updated statistics of your DNS cache.

Clearing DNS Cache on Linux Using Systemd-Resolved

Systemd-Resolved is a system service that manages network name resolution. It is used by many modern Linux distributions, including Ubuntu and Fedora. Here are the steps to clear the DNS cache on Linux using Systemd-Resolved:

Step 1. Open a terminal on your Linux machine.

Step 2. Type the following command to restart the Systemd-Resolved service:

sudo systemctl restart systemd-resolved.service

This command will restart the Systemd-Resolved service and clear the DNS cache.

Step 3. To confirm that the DNS cache has been cleared, type the following command:

sudo systemd-resolve --statistics

This command will show you the updated statistics of your DNS cache.

Clearing DNS Cache on Linux Using NetworkManager

NetworkManager is a popular utility used in many Linux distributions to manage network connections. Here are the steps to clear the DNS cache on Linux using NetworkManager:

Step 1. Open a terminal on your Linux machine.

Step 2. Type the following command to restart the NetworkManager service:

sudo systemctl restart NetworkManager.service

This command will restart the NetworkManager service and clear the DNS cache.

Step 3. To confirm that the DNS cache has been cleared, type the following command:

sudo systemd-resolve --statistics

This command will show you the updated statistics of your DNS cache.

Clearing DNS Cache on Linux Using Nscd

Nscd (Name Service Caching Daemon) is a service used to cache various name service lookups, including DNS. To clear the DNS cache using nscd, follow the steps below:

Step 1. Open a terminal window.

Step 2. Type the following command to restart the nscd service:

sudo systemctl restart nscd

This command will clear the DNS cache stored by nscd.

Conclusion

Clearing the DNS cache on Linux is a straightforward process that can help you resolve internet connectivity issues or improve website loading speed. In this article, we have shown you different methods to clear the DNS cache on Linux: using the command line, Systemd-Resolved, and NetworkManager. We recommend that you check your DNS cache regularly

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button