DNS Cache stores the IP Addresses of Web Servers that host the website. Some times you need to Flush, Reset or clear your DNS cache to resolve the new ip address of your favorite website or to take effect /etc/hosts file changes.
Flush DNS cache in Ubuntu
Flush DNS using systemd :
Open your terminal app and type the below command and hit enter.
sudo systemd-resolve --flush-caches
You can check you status of your current cache size using the below command in terminal.
sudo systemd-resolve --statistics
Flush DNS using dns clean:
To flush DNS cache on ubuntu, you need to open terminal and run the below command.
sudo /etc/init.d/dns-clean restart
sudo /etc/init.d/networking force-reload
This should work very well on Ubuntu 14.04 LTS and later. If it is not working for you , can try the above method to flush your DNS,
Flush DNS using nscd:
For older versions you need to install nscd (Name Service Cache Daemon). Name Service Cache Daemon is a daemon which handles passwd, group and host lookups for running programs and caches the results for the next query. You should install this package only if you use slow Services like LDAP, NIS or NIS+.
To install nscd on ubuntu, you need to open a terminal and run the below command.
sudo apt-get update
Then type the below command and hit enter to install the nscd.
sudo aptitude install nscd
To flush DNS cache, open terminal and run the below command.
sudo /etc/init.d/nscd restart
If you want to uninstall nscd just run the below command in terminal.
sudo aptitude remove nscd