How can I see systemd-resolve dns cache?
As mentioned by bac0n, you can use the following command to send signal USR1
to systemd-resolved
:
sudo killall -USR1 systemd-resolved
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 CACHE:
.
johhnry
Updated on September 18, 2022Comments
-
johhnry over 1 year
Using
sudo systemd-resolve --statistics
let me 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?
-
bac0n almost 4 yearsthink you can do: killall -USR1 systemd-resolved (the output will be redirected to journald)
-
johhnry almost 4 yearsBut this is going to kill the process rather than printing the cache?
-
bac0n almost 4 yearsno, it wil just sending SIGUSR1 to systemd-resolved, you can find a description in man systemd-resolved
-
-
johhnry over 3 yearsThanks a lot, this is helpful!