Changing the hostname on Mac OS X Server

Due to my new computer purchase and subsequent data transfers, I had an extra Power Mac G4 lying about the floor. Finally, I had a dedicated machine with which to experiment with the copy of Mac OS X Server I have. I had already installed Mac OS X Server on a drive in another machine, but then moved this drive to a new machine, with a new IP address and a new hostname.

I thought that changing the hostname for my server would be easy, no more complicated than changing the Computer Name setting in the Sharing pane of System, but evidently this is not the case. In the Apple world, every computer actually has three names:

  • The Apple Computer Name
  • The UNIX hostname (often, but not always, as part of the DNS name)
  • The Bonjour name.

In Mac OS X client, all three of these names are changed in the Sharing Pane of System In Mac OS X Server, however, things are not so straight-forward. Since the machine is a server and is sensitive to its network settings such as these, there are a number of places that include both files on the filesystem and directories (such as LDAP or NetInfo databases) that need to be modified in order for the hostname or IP address (if set manually) to change.

This issue manifested itself for me when I tried simply changing the Computer Name in the Sharing pane of System Preferences and noted that, while Server and a number of other places had correctly picked up this change, the hostname command and my bash shell prompt had not. They still read “Proteus,” the old hostname even after I had changed it to “Minotaur,” the new hostname I wanted to use.

Reviewing the /var/log/system.log file showed that during boot, configd was explicitly setting the hostname to this old value (Proteus.local), though I could not find out where this value was coming from. After futzing with innumerable files and GUI tools, I finally got the solution I needed: use the Apple-supplied changeip command line tool to update all the necessary places at once.

In my case, since only the hostname needed to change and not the IP address, and because my Mac OS X Server machine was a standalone server which used only its own local NetInfo database as a directory store, the command I needed was the following:

sudo changeip - Proteus.local Minotaur.local

Note that the IP addresses for both the old-ip and the new-ip parameters are the same, thus denoting “no change” in IP address.

Finally, this can be checked with:

sudo changeip -checkhostname

So, a simple thing really, that took me almost two days to solve. This is the wonder of vendor-specific tools. They give you increadible ease-of-use, if you already know about them.

The following is a list of related resources that I discovered while trying to learn more about this issue.

5 replies on “Changing the hostname on Mac OS X Server”

Comments are closed.