Using NetInfo as replacement for /etc/hosts

Mar 28, '01 11:45:10PM

Contributed by: paulsomm

I've been searching the net now since installing OSX Final for a way to use my hosts file in my /etc folder like I do under Linux for developing websites (i.e. in the hosts file I create "127.0.0.1 somesite.me" and then use apache and http headers so that somesite.me in a browser returns a locally created website).

Looking in the /etc/hosts file you are told that the file isn't consulted unless you change your lookupd configuration. Lookupd is handled by NetInfo. And hence my problem: I had no idea how to change the order in NetInfo to look at the flat file /etc/hosts before going to DNS.

Read the rest of this article if you'd like more info on using NetInfo as at hosts file...

After realizing I was overcomplicating things I found a better way to achieve the exact same result in a way I actually like better than editing a /etc/hosts file: using NetInfo!

I went into the "Utilities" folder in "Applications" and double-clicked the "Netinfo Manager", then clicked the lock and provided my password. The next thing I did was I noticed that / Machines (clicking the "/" in the left pane then the "Machines" in the middle pane) showed me the same listing of 127.0.0.1 and localhost as the hosts file did. So, I clicked in the right pane the entry "Localhost" and then clicked the double-folder icon to duplicate this entry. I duplicated the entry as many times as I needed, then double-clicked the value "localhost" in the bottom window for each duplicated entry and changed it to what I wanted, i.e. "site1.me"

This has the same effect as having "127.0.0.1 site1.me" in the /etc/hosts file under linux.

Just thought I'd pass this along.

Comments (10)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20010328234510985