Context
According to Cloudflare docs, the sequence of a DNS query from Chrome to the recursive resolver looks something like this:
Check browser DNS cache --miss--> Check OS DNS cache --miss--> Recursive resolver
| |
V V
hit hit
Chrome's DNS cache chrome://net-internals/#dns and firefox's DNS cache about:networking#dns lists entries in one or another, and the Windows DNS cache can be accessed with ipconfig /displaydns.
The Windows version looks like this:
PS C:\> ipconfig /displaydns
Windows IP Configuration
chrome.cloudflare-dns.com
----------------------------------------
Record Name . . . . . : chrome.cloudflare-dns.com
Record Type . . . . . : 1
Time To Live . . . . : 54
Data Length . . . . . : 4
Section . . . . . . . : Answer
A (Host) Record . . . : 104.18.27.211
vortex.data.microsoft.com
----------------------------------------
Record Name . . . . . : vortex.data.microsoft.com
Record Type . . . . . : 5
Time To Live . . . . : 6
Data Length . . . . . : 8
Section . . . . . . . : Answer
CNAME Record . . . . : asimov.vortex.data.trafficmanager.net
...
systemd-resolve
On my Ubuntu 20.04 VPS, this looks promising, but I can't get a way to list all entries.
rj@VPS:~$ systemd-resolve motel6.com
motel6.com: 23.35.171.243 -- link: eth0
-- Information acquired via protocol DNS in 85.2ms.
-- Data is authenticated: no
rj@VPS:~$ systemd-resolve motel6.com
motel6.com: 23.35.171.243 -- link: eth0
-- Information acquired via protocol DNS in 1.4ms.
-- Data is authenticated: no
I would assume on the second instance, it's pulling from the OS DNS cache, but a DNS request to VPS' DNS server could also be 1.4ms and now cached.
Question
How do you see all entries in the DNS cache for Linux?
(Bonus points for macos as well, but I'm scoping this to Linux)