DNS (Domain Name Server) is a network protocol that translates IP address to fully qualified Domain names and vice versa. It is more user-friendly on your Linux platform. To use DNS on your Linux you must have DNS server configured to handle the resolution process. Linux is the well known operating system used by a lot of people around the world. If you are facing any issues, you are required to flush the DNS cache stored on your Linux devices to resolve the issues.
DNS cache is a temporary data which contains the information related to your DNS. Like the web browsers, the operating system will store cache files called Domain Name System cache. DNS Cache stores information related to all your visited websites. One of the main disadvantages of DNS caches is that it makes easier for the hackers to track your online activities. Flushing DNS cache involves different navigation depending on OS.
Contents
How to Flush DNS Cache on Linux?
By default, the Linux never store any OS-level DNS caches. If you manually installed DNSMasq, nscd, or systemd-resolves on your Linux, it might store any temporary files.
Flush DNS Cache using Systemd Resolved
Before flushing the DNS cache, you need to check whether the service is running or not by using the following command line.
sudo systemctl is-active systemd-resolved.service
Note: If any service is opened, then you can easily kill the process on Linux using the command line.
If the service is running on your Linux, the command will print active. If it is not, it will print inactive in the command line.
To flush the Systemd Resolved DNS cache, type the following command,
sudo systemd-resolve --flush-caches
Clear DNS Cache using DNSMasq
If your Linux device uses DNSMasq and a cache server, you need to restart the DNSMasq service to clear the DNS cache.
Press Ctrl+Alt+T to open the terminal on your Linux.
Enter the following command to restart the DNSMasq service.
sudo systemctl restart dnsmasq.service
In case the above command line doesn’t work, enter the following command line.
sudo service dnsmasq restart
Clear DNS Cache using nscd
If your Linux device store the DNS cache thorough nscd, then you need to restart the nscd service.
Open the terminal using Ctrl+Alt+T keyboard keys.
Enter the following command line into the terminal:
sudo systemctl restart nscd.service
Or use another command line:
sudo service nscd restart
Flush DNS Cache on Linux using named
BIND is one of the traditional options to delete the built-in DNS servers stored in your Linux device.
Open the Terminal by using Ctrl+Alt+T keyboard keys. Now enter the following command line:
sudo systemctl restart named
Our Opinion
Flushing DNS doesn’t alter any activities on your Linux. By flushing DNS, issues related to DNS will get resolved. By following the above steps, you can easily clear DNS cache on your Linux Operating System.
If you have any queries or feedback, comment it in the section below. Stay connected with us on Facebook and Twitter for more updates.