Changing hostname


Peter van der Linden, July 2003

Two names

MacOS (like Windows) has several hostnames that are used for different purposes.
  • DNS hostname - this is the name that other systems use to reach your system. DNS maps it to an IP address.
  • hostname name - this is the value retrieved by the hostname command.
  • Appleshare name - this is the name that Appleshare uses to find your system

    Counter-intuitively, none of these names have to match any of the others.

    Changing hostname name
    Change the file /etc/hostconfig. It has a line saying:

            HOSTNAME=-AUTOMATIC-
    
    Change the "-AUTOMATIC-" to be the name you want. If it is kept as "-AUTOMATIC-" the system gets its hostname while booting either from bootp or dhcp. The file is included by /etc/rc.common which is read by various shell scripts during bootup. It sets sh variables that are used by the scripts to determine how the system is to be setup.

    Changing DNS hostname
    Set the hostname like this

        sudo hostname -s yournewhostname.your.domain
    

    Changing Appleshare name
    Use the "Sharing" pane of the System Preferences -> Network panel.