dnsosx-elcapitanoscache

How to view DNS cache in OSX?


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?


Solution

  • 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)