25

How is the DNS cache cleared in 22.04?

The method that worked in 20.04:

systemd-resolve --flush-caches

no longer works.

Artur Meinild
  • 26,018

2 Answers2

37

Newer versions of Ubuntu use this syntax (run as root or with sudo):

resolvectl flush-caches 

(This will also work in Ubuntu 20.04.)

Artur Meinild
  • 26,018
  • 1
    I'm on a freshly installed 22.04 and this command did not clear whatever DNS cache dig is using. – Basti Mar 28 '23 at 07:30
13

For Ubuntu 22.04 users, follow the below command to flush DNS Cache(resolvectl) :

resolvectl flush-caches

To check the cache size run the below command:

resolvectl statistics
Stanley
  • 151