- How to Clear/Flush the DNS Cache on Linux
- What is DNS cache and what it Does?
- What is nscd DNS Cache
- What is dnsmasq DNS Cache
- What is BIND Server DNS Cache
- How to Clear/Flush the DNS Cache on Linux
- 1) How to Flush DNS Cache on Linux Using the systemd Resolve Service
- 2) How to Clear BIND Server DNS Cache on Linux
- 3) How to Flush nscd server DNS Cache on Linux
- 4) How to Clear the dnsmasq Server DNS Cache on Linux
- 5) How to Clear the DNS Cache on Windows
- Conclusion
- Boost Your Network Performance: How To Clear DNS Cache on Linux
- Checking DNS Cache on Linux
- Clearing DNS Cache on Linux Using the Command Line
- Clearing DNS Cache on Linux Using Systemd-Resolved
- Clearing DNS Cache on Linux Using NetworkManager
- Clearing DNS Cache on Linux Using Nscd
- Conclusion
How to Clear/Flush the DNS Cache on Linux
You may need to flush or clear the local DNS cache on your Linux system for various reasons.
This could be one of the below reasons.
- Sometimes you may have difficulty reaching certain websites.
- When troubleshooting network related issues.
- After DNS resolvers change.
When you run flush DNS cache, this will destroy the DNS entries in the cache and perform a subsequent query to resolve the domain based on the newly configured DNS settings.
What is DNS cache and what it Does?
The DNS cache is a temporary database maintained by the computer’s operating system.
It stores information about previous DNS lookups (like information on recently visited websites and other web domains).
This will quickly resolve DNS queries when you visit the cached website by getting details from the local DNS database instead of the actual DNS server.
If you want to know DNS information about a website, use one of the commands below.
What is nscd DNS Cache
nscd stands for name service cache daemon, nscd is a daemon that provides a cache for the most common name service requests. The default configuration file located at /etc/nscd.conf .
What is dnsmasq DNS Cache
Dnsmasq is a lightweight, small footprint, easy to configure, DNS forwarder and DHCP server. It is designed to provide DNS and optionally, DHCP, to a small network & suitable for resource constrained routers and firewalls. It can serve the names of local machines which are not in the global DNS. It is designed for personal computer use and small size networks, not for big networks.
What is BIND Server DNS Cache
BIND stands for “Berkeley Internet Name Domain”. The most widely used Name Server Software, BIND is open source software that implements the Domain Name System (DNS) protocols for the Internet. BIND is by far the most widely used DNS software on the Internet, providing a robust and stable platform.
How to Clear/Flush the DNS Cache on Linux
By default, DNS caching is not installed or enabled at the OS level, but if you have installed any of the caching services listed below, use the appropriate commands to flush them.
Below is a list of the major DNS cache services used in the Linux operating system.
- systemd Resolved Service
- nscd DNS Cache
- dnsmasq DNS Cache
- BIND server DNS Cache
1) How to Flush DNS Cache on Linux Using the systemd Resolve Service
Most modern Linux operating systems use systemd, so use the command below to flush the DNS cache.
Run the below command to check if the DNS cache service is active on your system.
$ sudo systemctl is-active systemd-resolve.service
You can check the DNS statistics using the below command.
$ sudo systemd-resolve --statistics
If it’s active and the service is running, use the below command to flush it.
$ sudo systemd-resolve --flush-caches
2) How to Clear BIND Server DNS Cache on Linux
The BIND DNS server is used on most servers where the Web Hosting Control Panel is installed. We have seen this on servers where cPanel and CentOS Web Panel are installed.
Run the below command to flush the BIND server DNS cache on Systemd-based Linux systems.
$ sudo systemctl restart named
Run the following command to clear the BIND server DNS cache on SysVinit-based Linux systems.
$ sudo service named restart or $ sudo /etc/init.d/named restart
Also, you can use the following commands for the BIND service.
To clear the BIND DNS cache, use the below command.
To clear DNS cache for a particular domain, use the below command.
$ sudo rndc flushname 2daygeek.com
To clear DNS cache for LAN, use the below command.
To clear DNS cache for WAN, use the below command.
3) How to Flush nscd server DNS Cache on Linux
Some Linux distributions use the nscd DNS server. If so, flush it using the below commands.
Run the below command to flush the nscd server DNS cache on Systemd-based Linux systems.
$ sudo systemctl restart nscd
Run the following command to clear the nscd server DNS cache on SysVinit-based Linux systems.
$ sudo service nscd restart or $ sudo /etc/init.d/nscd restart
4) How to Clear the dnsmasq Server DNS Cache on Linux
Some distribution may use the dnsmasq DNS server. If so, use the below commands to flush it.
Run the below command to flush the dnsmasq server DNS cache on Systemd-based Linux systems.
$ sudo systemctl restart dnsmasq
Run the following command to clear the dnsmasq server DNS cache on SysVinit-based Linux systems.
$ sudo service dnsmasq restart or $ sudo /etc/init.d/dnsmasq restart
5) How to Clear the DNS Cache on Windows
Use the below command to Flush the dns cache on windows systems.
C:\Windows\system32>ipconfig /flushdns Windows IP Configuration Successfully flushed the DNS Resolver Cache.
Conclusion
You have learned how to clear or flush DNS cache on Windows and Linux operating systems.
Boost Your Network Performance: How To 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
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!