Sunday, April 09, 2006 

Creating Hosts under Mac OS X

Under UNIX systems, normally your hosts file is located in /etc/hosts - this is not the case in Mac OS X. The recommended procedure you'll normally see online is to use the Net Info Manager, an application under the Utilities folder. While this isn't difficult, it's certainly not as fast as editing a text file using emacs or vi.

Thankfully Apple started using hosts files starting in Jaguar (10.2). To do it, open up a terminal session and do the following commands:
cd /private/etc
sudo emacs hosts
You will be prompted for your administrator password since this file is accessible to root by default. Once there you just need to add the IP address, hit tab, and then key in the domain as follows:
192.168.0.1 your.host.com
Save the file in the editor (Ctr-X, Ctrl-S in emacs and :wq in vi) and you should now be able to resolve the host properly.