OS X Lion: how to display DNS cache and purge DNS cache

Previously I described using “dscacheutil -cachedump” as a means of flushing your local cache and forcing OS X to query your configured DNS servers.

I’ve since learned the combination of “sudo killall -INFO mDNSResponder” and “sudo killall -HUP mDNSResponder” are a better solution for clearing out the DNS cache on Mac OS X 10.7 Lion.

Since Snow Leopard, Apple has made additional changes to their DNS processes and the previous suggestion no longer works for most OS X Lion users.  Some of us who upgraded over previous installations may still having a working version of this utility; or it may still be present, but do nothing at all.

The mDNSResponder system process handles DNS related task in OS X, and there are two terminal commands which can be useful regarding the status of your DNS cache.

The first command, “sudo killall -INFO mDNSResponder” sends a SIGINFO signal to the process.  This will cause the process to dump a snapshot summary of the internal state to /var/log/system.log.

The second command, “sudo killall -HUP mDNSResponder” sends a SIGHUP signal to the process.  This will cause the process to purge its cache.  Upon successful completion, /var/log/system.log will be sent the message, “PM mDNSResponder: SIGHUP: Purge cache”

The “-INFO” command is quite verbose and provides a way of confirming the contents of your DNS cache before and after the purge.

additional notes:

  • The mDNSResponder first appeared in Mac OS X 10.2 (Jaguar) and has provided features for MultiCast DNS and Bounjour.
  • dns-sd appeared in OS X 10.4 (Tiger) and provides a Library API for applications to interact with the mDNSResponder process.  Some command line options are available, but the command line arguments are still subject to change and should not be relied upon for permanent shell scripts.
  • The command line “scutil –dns” will display your current OS X 10.7 DNS configuration.

One thought on “OS X Lion: how to display DNS cache and purge DNS cache

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s