I recently came across this information in an Apple PDF worksheet and couldn’t find anything via Google that really laid out the full situation, so I thought I would write this up for posterity.
In Mac OS X 10.4.x Server (and the client version I believe [and possibly earlier versions], by default your hostname is determined dynamically. This is controlled by the following line in the file
(note that in my Mac OS X 10.4.10 client this line is absent from
/etc/hostconfig so I assume that absence defaults to automatic as well). If you want to your hostname to be static, just change
-AUTOMATIC- to whatever fully qualified hostname you want like
When the hostname is determined automatically, the OS steps through this list of possibilities and goes with the first valid name found:
- The name provided by the DHCP or BootP server for the primary IP address
- The first name returned by a reverse DNS (address-to-name) query for the primary IP address
- The local hostname (set in the Sharing pane of System Preferences)
- The name
So this means if you get different IP addresses at home, work, and on the road you will see your hostname bounce around, which can be disconcerting if you aren’t expecting your shell prompt to change (wave to Philip :)).
Update: I changed the hostname of a Mac OS X 10.5 Server, but in certain places (such as the output of the
hostname command) I would still get the old hostname. Turns out that there is a preference file that didn’t get updated for some reason:
/Library/Preferences/SystemConfiguration/preferences.plist. I found a reference to the old hostname there, and after editing the file and rebooting, it appears that the last traces of the old hostname are gone.