Everything In Between

If your project so much as pretends to have a profit motive, I will tell you to go fuck yourself and your project.

Changing the hostname on Mac OS X Server

5 comments

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 Preferences.app, 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 Preferences.app. 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 Admin.app 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 - 192.168.0.10 192.168.0.10 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.

Written by Meitar

September 19th, 2007 at 11:33 pm

5 Responses to 'Changing the hostname on Mac OS X Server'

Subscribe to comments with RSS or TrackBack to 'Changing the hostname on Mac OS X Server'.

  1. I found your blog on google, and read a few of your other posts. I just added you to my Google News Reader. Keep up the good work. Look forward to reading more from you in the future.

    Private

    20 Jun 09 at 1:47 PM

  2. This article is very useful to professionals in computer networking.

    change ip

    8 Jul 09 at 8:30 AM

  3. Many thanks!

    Angel

    19 Oct 10 at 9:28 AM

  4. The beauty of the web: Sometimes 4 year old information is still perfectly valid if you can find it. This solved my issue in under 30 seconds.

    Thank you.

    Laird

    4 Jun 11 at 9:21 AM

  5. Totally agree with Laird.
    Thanks a lot, you just saved me a whole bunch of time.
    ….Wait for it….

    4 years later!!!

    Mithran

    18 Apr 12 at 1:38 AM

Leave a Reply