How to clear DNS cache on Ubuntu
Operating systems such as Windows automatically create temporary records on all websites visited in the so-called DNS cache. The information contained is valid for a limited period of time. A DNS flush, i.e. a flushing of the cache, removes data from the system before the time limit expires.
For clear DNS
To clear DNS cache open the terminal and type (until Ubuntu 18.04):
1 |
sudo systemd-resolve --flush-caches |
else from Ubuntu 20.04:
1 |
sudo resolvectl flush-caches |
Type this another command:
1 |
sudo system-resolve - -statistics |
The statistics will be displayed in the terminal. If you see that the “current cache size” is zero, you will get confirmation that your DNS cache has been cleared.
Reference