Monday, July 29, 2013

Flush DNS on my Mac


Each of these commands must be entered into the command line. You will have to use the Terminal applications ->Applications->Utilities. Launch that app first and then you can just copy and paste the commands in to save some time.

Flush DNS in OS X 10.9 Mavericks

Running OS X 10.9? Here is how to flush the DNS cache:
dscacheutil -flushcache;sudo killall -HUP mDNSResponder
You will need to enter the admin password for this task to complete. If you notice, it combines killing mDNSResponder with the standard dscacheutil, making it a two step process to first, flush cache, then reload the DNS handling in OS X so that the changes take effect.

Flushing DNS in OS X Lion (10.7) and OS X Mountain Lion (10.8)

Launch Terminal and enter the following command, you will need to enter an admin password:
sudo killall -HUP mDNSResponderNote the dscacheutil still exists in 10.7 and 10.8, but the official method to clear out DNS caches is through killing mDNSResponder. You can also find that process running in Activity Monitor.

Flush DNS in Mac OS X 10.5, Mac OS X 10.6

Launch Terminal and issue the following command:
dscacheutil -flushcacheAll done, your DNS has been flushed. The dscacheutil is interesting in general and worth taking a look at, try the -statistics flag instead for some stats.

Flush DNS in Mac OS X 10.4 Tiger, & 10.3

Type the following command in the Terminal:
lookupd -flushcache
That’s it, that’s all there is to it. Now your DNS settings should be as you intended them to be, which you can easily verify with various networking tools like http, ping, nslookup, traceroute, curl, or whatever else is appropriate to your specific situation.
If the command isn’t working and DNS does not change, verify the version of OS X you’re running and use the appropriate commands for that version.


Create a Alias for quick and easy Flushing =)

To setup an alias for that command string in your .bash_profile or in the profile of your shell . A simple bash alias could be this:
alias flushdns='dscacheutil -flushcache;sudo killall -HUP mDNSResponder'
Save that into .bash_profile, then typing “flushdns” would prevent having to use the full command string in the future.