34

To list the entries of DNS cache in OSX 10.11.6, I tried dscacheutil -statistics but that didn't work.

$ sudo dscacheutil -statistics
Unable to get details from the cache node

How can I just print what is there in the DNS cache without flushing it?

2 Answers 2

23

mDNSResponder (multicast DNS daemon) SIGINFO signal can dump a snapshot summary of the internal state to /var/log/system.log, including the cache details. To do this:

Keep system log opened in one terminal:

tail -f /private/var/log/system.log

Send a SIGINFO signal to mDNSResponder from another terminal:

sudo killall -INFO mDNSResponder

Then check the logs in first terminal, you would be able to see cache dump:

mDNSResponder[98]: ------------ Cache -------------
mDNSResponder[98]: Slt Q     TTL if     U Type rdlen
mDNSResponder[98]:  52      1827 -U-      CNAME   17 www.sublimetext.com. CNAME sublimetext.com.
...
...
mDNSResponder[98]: Cache currently contains 154 entities; 3 referenced by active questions

(For more info: man mDNSResponder)

10
  • 12
    I tried this under Mac OS X Sierra 10.12.2 and it doesn't do anything!
    – Olivier
    Jan 21, 2017 at 21:38
  • 16
    @OlivierdeBroqueville To check logs of sudo killall -INFO mDNSResponder in Sierra, open Console app, select your device on the left sidebar, then apply search filter mdnsresponder, DNS cache logs can be seen there. Jan 30, 2017 at 10:14
  • 7
    On newer macOS versions the logs were moved to a new logging system. You can either see them using the Console app, as @PraseethaKR has mentioned, or you can get them from your shell with following command: log stream --predicate 'process == "mDNSResponder"' --info
    – kjagiello
    Jul 9, 2018 at 19:55
  • 7
    on my 10.14 MacOS it shows a bunch of private and not the actual info
    – Neal
    Dec 12, 2018 at 2:55
  • 1
    I am trying in macOS BigSur. This plan will not work.
    – Bob Du
    Jun 8, 2021 at 9:30
21

As @PrasseethaKR and @kjagiello point out, on High Siera mDNSResponer has moved from syslog to log. In addition, your DNS lookup messages are now considered private and will show as <private> in both Console and log stream by default.

To view your DNS lookups on High Sierra open an Terminal and run:

sudo log config --mode "private_data:on"
log stream --predicate 'process == "mDNSResponder"' --info

To go back to using private just run the following command.

sudo log config --mode "private_data:off"

Cheers!

2
  • 3
    No longer works for BigSur Sep 22, 2021 at 12:26
  • 13
    log: Invalid Modes 'private_data:on' Feb 5, 2022 at 0:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.