My Malicious Mac
I have become to like my mac. The other day I spoke up spontaneously to by poor PC-coworkers saying that “I’ve started to like my Mac”. Today I was close to throw it out the window. I should do such an easy thing as over riding the DNS lookup to test some software. In windows that would be an easy task, just cd in to the sooooo logical path “c:/windows/system32/drivers/etc” and edit the hosts-file. As soon as you save it your local DNS cache will have the new entries and you can start browsing and nslookuping as a maniac.
In OS X on the other hand I changed the hosts file in /etc/hosts and, to be sure, /private/etc/hosts (they are symlinks) and started to browser on the new address… To no avail. I started googling ofcourse, and found these nice quotes:
“Making MacOS X consult /etc/hosts before the DNS server seems rather difficult. In fact, even making MacOS X consult /etc/hosts AT ALL seems rather difficult.” (Origin: http://www.netneurotic.net/mac/configuring.html)
I found a handful other tricks on the web aswell, for example this easy six steps rocket:
- Create (as root or using sudo) “/etc/hosts”.
- Read the file into NetInfo: “niload hosts . < /etc/hosts" [1]
- Create a directory “/etc/lookupd”.
- Create a file “hosts” in that directory.
- Make it contain this line: “LookupOrder FFAgent NIAgent DNSAgent” [2]
- Reboot the machine or HUP lookupd. [3]
After a good time (we are talking hours here, including terrorizing my good friend the-artist-formerly-known-as-theMacSupport-but-these-days-is-more-of-a-googlebot. I gave up and went home. Configuring the rest of the software I was about to try out on my wonderly beloved DELL PC.
After a good dish of cod, couscous and a wonderful lime/yoghurt/honey sause I started googling again…
I realized that Mac OS X seams to have changed the hosts/DNS thing between 10.1-10.2 and 10.3. No wonder there’s so many articles that completely contradicts each other. Ohhh wonderfully Microsoft that made a solution and stuck with it for years. Stop all development! :)
Anyway, the trick was just too easy. Do your hosts-thing and then simply:
lookupd -flushcache
Over and out.

Stumble It!