Using a HOSTS file on OS X

In the Windows world it’s a reasonably straightforward process to add pseudo domain names using the HOSTS file usually located in c:\windows\system32\drivers\etc\. Open the file, add a name / IP address entry, save the changes and you’re off and running. It’s slightly more involved on OS X as this site details. OS X uses lookupd to do name resolution and by default (at least on my machine) it is configured to look to a DNS server before referencing the local HOSTS file, which is not how Windows works. Turns out it’s reasonably easy to change (as detailed on the link mentioned above):

cd /etc
sudo mkdir lookupd
cd lookupd
cp hosts hosts.original
sudo echo LookupOrder Cache FF NI DNS DS > hosts
sudo kill -HUP 'cat /var/run/'

After that’s done, you can add / delete / modify domain name to IP address mappings using the NetInfo Manager tool.

Leave a Reply

Your email address will not be published. Required fields are marked *