DNS stands for Domain Name System, and is like the phonebook for the internet. It translates human-readable domain names into IP addresses, so browsers know how to render a specific website. Without DNS, you’d have to remember and type IP addresses instead of URLs, and that’s not exactly practical.
Along with DNS, there is something called the DNS cache. It stores DNS records for the websites you visit regularly, so loading those websites in your browser is considerably faster.
However, the DNS cache isn’t perfect and is susceptible to problems that can lead to an inability to load sites (or slow loading speeds), general networking issues, and page crashing. The DNS cache can become corrupt for a lot of reasons (such as multiple IP addresses for a single domain, malformed entries, or even a changed IP address). If you find your Linux machine experiencing a slow internet connection while your other machines aren’t, the problem is isolated and can be resolved.
Also: How to turn on Android’s Private DNS mode – and why turning it off is a big mistake
When your computer’s network speed slows down (and you’ve restarted your modem/router as your ISP will instruct you to do), one thing you can try is flushing the DNS cache.
Here’s how you do that on Linux.
How to flush your DNS cache on Linux
What you’ll need: The only things you’ll need for this are a running instance of Linux and a user with sudo privileges.
The next thing you’ll want to do is make sure your computer is using a DNS cache. On Linux, this can be checked with the systemctl command like so:
systemctl is-active systemd-resolved
The output should say active. If that’s the case, continue on.
Now, we’ll check the cache size. For this, we’ll use the resolvectl command like so:
resolvectl statistics
In the output, you’ll see a listing for Current Cache Size. My results show a cache with 14 entries (it’s low because I recently flushed my cache).
It’s time to flush the cache on your system. To do that, we’ll stick with the resolvectl command like so:
resolvectl flush-caches
After you’ve flushed your cache, you can make sure it worked by running the resolvectl command again like this:
resolvectl statistics
The Current Cache Size should now be listed as 0.
Huzzah! You’ve officially cleared your DNS cache. Hopefully, this will resolve your slow internet speeds on your Linux machine. If not, you probably have other issues on your LAN or with your ISP and will need to investigate further.
Also: 5 surprisingly productive things you can do with the Linux terminal
Get the morning’s top stories in your inbox each day with our Tech Today newsletter.
Source link
#Slow #internet #speed #Linux #30second #fix #difference