Changing the Hostname in Solaris (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 hostname, IP address, DNS, timezone, etc.
There is a simpler method and one I've used for many years. Which require a simple edit of a couple of files and reboot the system.
Under Solaris 10 and earlier follow these steps. For Solaris 11, click here:
- Edit the following files and replace the old hostname and/or IP address wherever applicable:
/etc/hostname.<interface>. This is the primary interface that is being used in the system (for example
/etc/hostnme.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.
- (optionally) Modify
dumpadm's savecore directory too:
# dumpadm -s /var/crash/<new_hostname>
- Under Solaris 9, we also need to edit the following files:
/etc/net/ticlts/hosts /etc/net/ticots/hosts /etc/net/ticotsord/hosts
- Reboot the system gracefully for the changes to take effect:
# init 6or
# shutdown -i6 -g0 -y
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