Changing Solaris hostname (updated)
The traditional method of changing the hostname of a given solaris system was to use sys-unconfig utility. This command restores the system's configuration to an “as-manufactured” state, ready to be reconfigured again. This includes it's IP address, hostname, DNS, TZ, etc.
There is a simpler method and one I've used for many years :-)
Simply edit a couple of files and reboot the system to achieve this.
[updated for Solaris 11]
With the release of Solaris 11 came a change for the /etc/nodename file being replaced with the config/nodename property of the svc:/system/identity:node service. So in order to change hostname in Solaris 11, we need to change the property to the new hostname and restart the service.
- To list the current hostname (i.e. config/nodename property):
# svccfg -s system/identity:node listprop config config application config/enable_mapping boolean true config/ignore_dhcp_hostname boolean false config/loopback astring config/nodename astring smurf
- Change the hostname to schlumpf by setting the property config/nodename to schlumpf
# svccfg -s system/identity:node setprop config/nodename="schlumpf"
- Refresh and restart the system/identity:node service for the changes to take effect.
# svcadm refresh system/identity:node # svcadm restart system/identity:node
- Verify the changes
# svccfg -s system/identity:node listprop config config application config/enable_mapping boolean true config/ignore_dhcp_hostname boolean false config/nodename astring schlumpf config/loopback astring schlumpf # hostname schlumpf
- Simply edit a couple of files and reboot the system to achieve this.
Under Solaris 10, edit the following files and replace the old hostname and/or IP address wherever applicable.
/etc/inet/hosts /etc/nodename /etc/hostname.[interface]
For the last file, the interface is the primary interface that is being used in the system (for example hme0). If the file only contains an IP address you can leave the file unchanged, unless you want to change the IP address of the system too.
- (optional) If necessary, modify
dumpadm's savecore directory too:
dumpadm -s /var/crash/<new_hostname>
- For Solaris 9 and below, we need to also edit below files:
/etc/net/ticlts/hosts /etc/net/ticots/hosts /etc/net/ticotsord/hosts
- Reboot the system gracefully for the changes to take effect:
# init 6