The /etc/hosts file by default is ignored by OS X. Though it is possible to import hosts into the "machines" directory (see tips here on macosxhints), there is also a way to configure lookupd so it consults /etc/hosts directly.
lookupd can use different agents to lookup hosts: e.g. DNSAgent which consults DNS, FFAgent which consults local files like /etc/hosts, and CacheAgent which will keep a local cache. The trick is to tell lookupd which agents to use in which order.
Read the rest of this article if you'd like the details on making OS X use your local hosts file before it uses the DNS servers.
Here's how I did it. First open a terminal window and become root (you can also use NetInfo mgr if you prefer). type
niutil -create . /locations/lookupd/hosts [hit enter]This means hosts are first looked up in /etc/hosts, if this fails, then DNS is used. Note I did not use the CacheAgent because my local DNS-server/router already keeps a cache.
niutil -createprop . /locations/lookupd/hosts LookupOrder FFAgent DNSAgent [hit enter]
top -l|grep lookupd [enter]to find out the PID for lookupd. Next kill the process with
kill -HUP nnnn [enter]where nnnn is the PID. Lookupd will restart automatically.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20010515062331512