mvs5zg
Last Updated: February 25, 2016
·
823
· pmichelazzo
Paulino7

Flushing OS/X Mavericks DNS

Sometimes we use the hosts files (/etc/hosts) to fix some DNS data. But one thing that we need to do after the edition is an update of DNS data. But how?

That's the trick:

sudo launchctl unload /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
sudo launchctl load /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

With these 2 commands you restart your DNS to use the new data inside the hosts file.

Of course that you can put it inside of a batch file to relaunch the DNS in one step. Look an example:

#!/bin/bash
#This script reload the DNS easily
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
echo "DNS unloaded"
sleep 5
sudo launchctl load /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
echo "DNS loaded"
sleep 5
echo "Allright, your DNS is fresh! Good work."

Just copy & paste the lines above in a file and put it in some place of your disk (e.g. your root folder). Also, don't forget to change the permissions to execute it (chmod u+x {filename})

PS: this trick works well with Mountain Lion too.

Cheers!

Say Thanks
Respond