Skip to content

The joy of editing the Mac OS X hosts file

I have a G4 iMac on my desk. You know, one of the ones that looks like a desk lamp. It competes for space with my two XP boxes. I do my development under XP, the iLamp is for testing our web apps. The ilamp more or less sees our network, but it can’t resolve workstation WINS names to actual IP addresses. Since I know zip about configuring Mac OS X networking, I figured I would cheat and just add the workstation IP addresses to the hosts file on the iLamp. In a normal OS, you just edit the hosts file and be done with it, not with the iLamp. No sir, you have to mix the cutting edge of 1978 technology with arcane Mac OS X commands. After some googling, I found what I needed here at You have to run a unix/linix/whatever shell, edit or create the hosts file, then load it with niload. And that’s the simple way to do it. If you want to do it with the GUI tools, it’s pretty damn tedius.

Launch netinfo, located at /Applications/Utilities/NetInfoManager
Under the Domain menu, select Security, and Authenticate. Type a username and password with admin prividledges.

Select, in the Directory Browser, / and then ‘machines’.

Either press apple-n, the icon that looks like ‘new folder’ or go to the Directory menu, and select ‘new sub directory’.

This should insert a flag at /machines/net_directory

Unless you are creating an entry for a host named ‘new_directory’ you’ll want to rename it.

Select, in the ‘Directory: new_directory’ plane that has ‘property and Value(s)’ stuff the first, and only entry (“name | new_directory”).

Under the ‘Directory’ menu, select ‘Delete value’.

The entry should now read ‘name | ‘. Which is good.

Now, enter the hostname, which can be something simple like myfileserver or as ‘complex’ as or whatever.

So, select the name and line, and go to the directory menu, and select ‘insert value’. (option-apple-i)
Now type the hostname.

Next, we need to input an ip address.

First, insert a new property, called ‘ip_address’.
apple-shift-n or apple-shift-i (eye – look in the directory menu, you’ll see it).

where it says ‘new_property’, click and type ‘ip_address’.

Where it says ‘new_value’, type the ipaddress that goes with the host you inserted.

If you wish, you can enter more than one hostname, so if for example you wish and matrixbaby both to go to the same IP, just insert an additional value to the name property:

Select ‘name’ and under, the ‘directory’ menu, select ‘insert value’ (apple-option-i).

That should do it, close out of netinfo, and you’re set. If you wish to properly name your computer, either insert/modify the entry called ‘localhost’ and give it a name, in addition to localhost. I think thats what I did. you can also modify the /etc/hostconfig file, change the HOSTNAME= localhost to whatever you wish.

I guess it could be worse, at least Mac OS X has a command line.