Are you using the latest version of Ubuntu and looking for a way using which you can flush your DNS Cache? Well, you are the right place. The following guide shows you how to Flush the DNS Cache in Ubuntu 18.04, alongside with it we will also educate you regarding why you should consider Flushing your DNS Cache once in a while. With that said let starts with the process
Why and How to flush the DNS cache on Ubuntu 18.04?
A DNS cache may become corrupted occasionally, the reason for that could be technical errors or some other viral attacks that input invalid DNS entries into the database and the consequence of this could be that when a user visits a website, it gets redirected to some other website that has a lot of advertisements or it could even have malware. When the cache is corrupted, everyone suggests flushing the DNS cache to the user
Flush Ubuntu DNS Cache
Some Debian Linux like Ubuntu still uses systemd-resolve. This resolve is already built into the system in Ubuntu and it is being used for a lot of things by the operating system automatically without the user’s knowledge. Its already installed and set up in Ubuntu, the user just has to enter the command to flush the DNS and it will get done.
First, you need to open the terminal and enter:
sudo systemd-resolve - -flush-caches
When you enter the command, the terminal does not give any confirmation that the cache has been flushed, to confirm that you have to enter another command that would show the user the statistics, the command is as follows:
sudo system-resolve - -statistics
After you enter the command the statistics will be shown on the terminal and when you see that the ‘current cache size’ is zero, then you get the confirmation that your DNS cache has been flushed.
If you are using another version of Linux other than Ubuntu you can also use the following:
NSCD Command
If you are not using Ubuntu and using some other Linux, then you can also use nscd. The arch Linux mostly uses nscd. If that is the case, then you just have to enter the following command to flush your DNS cache in that Linux.
sudo systemctl restart nscd
You can use the above-mentioned method to clear the DNS Cache in Ubuntu. As already discussed, that why you should flush your DNS Cache once in a while is because it can cause several issues like websites not loading properly, web page scripts not running properly etc. All of these are a result of corrupted DNS Cache and flushing it out and resetting it will probably fix the problem.
So, did you try using the above-mentioned method to clear out the DNS Cache? Did it work out for you? If No, then kindly share with us the method you used in the comment section below.