How to Flush the DNS Cache in Ubuntu & Why You Might Need To
Domain Name Servers are one of the backbones of the internet. Without them, the entire system of domain names wouldn’t work and we’d have to navigate the web using straight IP addresses — not my idea of fun, if you ask me.
Whenever you access a domain name, your system keeps a record of which IP address that domain points to (this is called a cache). This makes your next access to that domain much faster because you don’t have to look it up, which could take seconds.
But sometimes your local domain name cache falls out of sync with the actual mapping of a domain name to IP address. That’s why sometimes you can’t access a website even though the website isn’t down — especially if that website has moved servers recently.
When that happens, you need to flush your DNS cache. Fortunately, this can be done with a simple terminal command on Ubuntu and other Debian systems:
$ sudo /etc/init.d/dns-clean
There are other DNS-related tricks that might prove useful to you, such as optimizing DNS for faster internet speeds and changing your DNS for improved online security , so look into that when you can.
Did this work? If you’re using a DNS service, let us know which one you’re using in a comment down below!