###Flush and Reset All DNS Caches in OS X Yosemite
Quickly clear all dns caches in OS X Yosemite with this bash alias.
- Edit your local ~/.bash_profile and add the following alias:
alias cleardns="sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches; sudo discoveryutil udnscachestats; sudo discoveryutil mdnscachestats;"
- Make sure to reload your bash profile (or restart your terminal):
$ source .bash_profile
- Then simply run the new alias:
$ cleardns
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