Changing hostname

To change the hostname on a Solaris system:

1. Change the hostname in /etc/nodename. Replace the information in this file; commenting out the previous value will cause problems during a reboot.

2. Run uname -S new_hostname to change the nodename and hostname for your current session.

3. Change the hostname in /etc/hostname.network_interface (e.g., /etc/hostname.hme0). Replace the information in this file; commenting out the previous value will cause problems during a reboot.

4. Change the hostname in /etc/hosts

5. Change the hostname in /etc/net/*/hosts (/etc/net/ticlts/hosts, /etc/net/ticots/hosts, /etc/net/ticotsord/hosts), if applicable. More information on these files is available here.

# for FILE in `find /etc/net -name hosts` ; do
>
fgrep -l old_hostname $FILE > /dev/null 2>&1 && sed 's/old_hostname/new_hostname/g' $FILE > $FILE.new && mv $FILE.new $FILE
> done

6. Change the savecore-dir (Solaris 7 or later)

# [ ! -d /var/crash/`uname -n` ] && mkdir /var/crash/`uname -n` && chmod 700 /var/crash/`uname -n`
# dumpadm -s /var/crash/`uname -n`

7. Change the hostname in /etc/inet/ipnodes (Solaris 10 or later)

I recommend rebooting the system after making the above changes. Services may perform unexpectedly after a "live" hostname change.

If you cannot reboot the system, you may want to restart the syslog service to log messages using the new hostname.

The sys-unconfig(1M) command can also be used to change a system's hostname, but it requires reconfiguring much more than just the system's hostname.

More information:
http://www.princeton.edu/~unix/Solaris/troubleshoot/hostname-change.html

Back to brandonhutchinson.com.

Last modified: 2009/06/25