Skip to content

Instantly share code, notes, and snippets.

@brandonsimpson
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brandonsimpson/8f79610ff56c4e223632 to your computer and use it in GitHub Desktop.
Save brandonsimpson/8f79610ff56c4e223632 to your computer and use it in GitHub Desktop.
Flush and Reset All DNS Caches in OS X Yosemite

###Flush and Reset All DNS Caches in OS X Yosemite

Quickly clear all dns caches in OS X Yosemite with this bash alias.

  1. Edit your local ~/.bash_profile and add the following alias:
alias cleardns="sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches; sudo discoveryutil udnscachestats; sudo discoveryutil mdnscachestats;"
  1. Make sure to reload your bash profile (or restart your terminal):
$ source .bash_profile
  1. Then simply run the new alias:
$ cleardns
Results:

After flushing your dns caches, the output of discoveryutil udnscachestats and discoveryutil mdnscachestats should show all cache stats are now 0.

UDNS Cache Stats: Ext Resolver on en0
UDNS Cache Stats: Resolver domain [default], type Unicast, ifIndex 4, port 0, timeout 30, A yes, AAAA no, serviceID 0, scope None, order 0
  server(s) 208.67.222.222, 192.168.100.1
UDNS Cache Stats: Cached 0 of 5000, table size 256, hash coverage 0.00, max miss depth 0, avg miss depth 0.00, reclaims 0
Cached records after aging 0
UDNS Cache Stats: Ext Resolver on en0
UDNS Cache Stats: Resolver domain [default], type Unicast, ifIndex 4, port 0, timeout 30, A yes, AAAA no, serviceID 0, scope InterfaceID, order 0
  server(s) 208.67.222.222, 192.168.100.1
UDNS Cache Stats: Cached 0 of 5000, table size 256, hash coverage 0.00, max miss depth 0, avg miss depth 0.00, reclaims 0
Cached records after aging 0
MDNS Cache Stats: lo0: Cached 0 of 7500, table size 16, hash coverage 0.00, max miss depth 0, avg miss depth 0.00, reclaims 0
Cached records after aging 0
MDNS Cache Stats: awdl0: Cached 0 of 7500, table size 128, hash coverage 0.00, max miss depth 0, avg miss depth 0.00, reclaims 0
Cached records after aging 0
MDNS Cache Stats: en0: Cached 0 of 7500, table size 256, hash coverage 0.00, max miss depth 0, avg miss depth 0.00, reclaims 0
Cached records after aging 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment