9

Using sudo systemd-resolve --statistics I can see the current DNS cache statistics, for example:

Cache                     
  Current Cache Size: 68  
          Cache Hits: 412 
        Cache Misses: 461

I would like to see all the entries of the DNS cache (here 68), is it possible?

3
  • 1
    think you can do: killall -USR1 systemd-resolved (the output will be redirected to journald)
    – user986805
    Jul 10, 2020 at 6:56
  • But this is going to kill the process rather than printing the cache?
    – johhnry
    Jul 14, 2020 at 19:01
  • 1
    no, it wil just sending SIGUSR1 to systemd-resolved, you can find a description in man systemd-resolved
    – user986805
    Jul 14, 2020 at 19:26

1 Answer 1

18

You can use the following command to send signal USR1 (User-defined signal 1) to systemd-resolved:

sudo pkill -USR1 systemd-resolve

This will NOT stop the service. It just tells systemd-resolved to write all the current cache entries (and some other information) to the system log.

You can then export the log messages written by systemd-resolved to a text file with the following command:

sudo journalctl -u systemd-resolved > ~/resolved.txt

Open the text file generated this way in the text editor of your choice and search for CACHE:. After this, the list of cache entries will follow.

Please note that the text file might contain several lines containing CACHE:.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .