Jack Wallen exhibits you easy methods to flush the DNS cache in your Ubuntu Servers to keep away from DNS-released networking points.
Generally a community connection doesn’t appear to perform how we anticipate them to. And it doesn’t matter how a lot you troubleshoot the difficulty, the issue doesn’t go away. You’ve configured a static IP deal with, you understand that configuration is strong and you’ll ping your gateway, however one thing is inflicting that Linux server from reaching the skin world within the method you anticipate.
One downside might be the DNS cache. DNS is an important facet of networking for all machines, because it interprets names to IP addresses. When one thing goes incorrect with DNS, your machine may need hassle reaching the skin world. I’ve skilled, on a couple of events, a DNS cache to be the issue. When that occurs, what do you do? You flush the DNS cache.
This can be a good job to undertake every now and then, as your DNS cache cannot solely develop too massive, nevertheless it might additionally include corrupt entries (which may trigger issues with connections). So, how do you flush the DNS cache on Ubuntu Server?
SEE: Hiring Package: Community Engineer (TechRepublic Premium)
What you’ll want
The one factor you’ll must flush the DNS cache in your Ubuntu Server is a person with sudo privileges. With that person on the prepared, let’s get to the flushing.
How one can flush your DNS cache
As soon as upon a time, the DNS cache was flushed with a command like:
sudo systemd-resolve --flush-caches
The above command will nonetheless work on Ubuntu 20.04. However in the event you’ve upgraded to Jammy Jellyfish (22.04), the method has modified. This new command is backward appropriate with 20.04.
First, let’s view the statistics of our DNS cache with the command:
resolvectl statistics
It’s best to see output just like this:
Transactions
Present Transactions: 0
Complete Transactions: 3520
Cache
Present Cache Dimension: 1
Cache Hits: 9
Cache Misses: 1388
DNSSEC Verdicts
Safe: 0
Insecure: 0
Bogus: 0
Indeterminate: 0
To flush the cache, difficulty the command:
resolvectl flush-caches
It’s best to see the Cache Dimension entry reset to 0.
Consider it or not, that’s all there’s to flush a DNS cache in Ubuntu. This works for each Ubuntu Server and Ubuntu Desktop. For those who’ve gone down a community troubleshooting rabbit gap and nothing appears to work, you would possibly attempt flushing the DNS cache and see if that doesn’t resolve your downside.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the newest tech recommendation for enterprise execs from Jack Wallen.