Developer Open source

How to flush the DNS cache on Ubuntu Server

Jack Wallen reveals you ways to flush the DNS cache on your Ubuntu Servers to keep away from DNS-released networking points.

dns-cache-flush-ubuntu
Image: gonin/Adobe Stock

Sometimes a community connection doesn’t appear to perform how we count on them to. And it doesn’t matter how a lot you troubleshoot the situation, the downside doesn’t go away. You’ve configured a static IP deal with, you realize that configuration is stable and you’ll ping your gateway, however one thing is inflicting that Linux server from reaching the outdoors world in the method you count on.

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 unsuitable with DNS, your machine might need hassle reaching the outdoors world. I’ve skilled, on a number of events, a DNS cache to be the downside. When that occurs, what do you do? You flush the DNS cache.

This is an effective activity to undertake from time to time, as your DNS cache cannot solely develop too giant, however 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 Kit: Network Engineer (TechRepublic Premium)

What you’ll want

The solely factor you’ll want to flush the DNS cache on your Ubuntu Server is a consumer with sudo privileges. With that consumer at the prepared, let’s get to the flushing.

How to flush your DNS cache

Once 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. But for those who’ve upgraded to Jammy Jellyfish (22.04), the course of has modified. This new command is backward suitable with 20.04.

First, let’s view the statistics of our DNS cache with the command:

resolvectl statistics

You ought to see output related to this:

Transactions

Current Transactions: 0

Total Transactions: 3520

Cache

Current Cache Size: 1

Cache Hits: 9

Cache Misses: 1388

DNSSEC Verdicts

Secure: 0

Insecure: 0

Bogus: 0

Indeterminate: 0

To flush the cache, situation the command:

resolvectl flush-caches

You ought to see the Cache Size entry reset to 0.

Believe it or not, that’s all there’s to flush a DNS cache in Ubuntu. This works for each Ubuntu Server and Ubuntu Desktop. If you’ve gone down a community troubleshooting rabbit gap and nothing appears to work, you would possibly strive 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.

admin

Leave a Reply

Your email address will not be published.Required fields are marked *

*