How to have a stable hostname in OS X Tiger

I’ve got DHCP at home and at work. Its definitely a lot easier than the early days of network administration, where everyone had their own static IP.

There is a problem though: with DHCP, my hostname keeps changing whenever I get a new IP address, specifically when I reconnect to a network. This is not that big a deal, except for apps like Perforce, which want you to have a specific hostname.

So how can you have a stable hostname on OS X Tiger? (Note this will work on Panther as well.) Well, it turns out that you have to get into the Terminal and edit a system configuration file: /etc/hostconfig

I personally like to use vi: sudo vi /etc/hostconfig

Then you need to either edit a line that looks like HOSTNAME=-AUTOMATIC- or if that line doesn’t exist, then just add something that looks like:

HOSTNAME=myHostName

I believe you have to reboot to get this setting to stick, but I think you can execute this command to tide you over if you don’t want to reboot right away:

sudo hostname myHostName

Check out more about this in the OpenDarwin FAQ.

One Reply to “How to have a stable hostname in OS X Tiger”

  1. Thanks, Louie! I had forgotten where to do this, but Google turned this up this helpful blog entry.

Comments are closed.