Wednesday, 25 July 2018

Solaris 11: Change host name using svccfg


When Solaris 11 was released more configurations were moved into the service management framework, and moved out of configuration files, one of these changes was the hostname/nodename.

View Hostname in SMF

This will read back the configuration out of the SMF.
 
# svccfg -s system/identity:node listprop config
config           application
config/nodename astring     solaris11box
config/loopback astring     solaris11box
 
Change Hostname in SMF

We have two separate settings, which need to be updated.
 
# svccfg -s system/identity:node setprop config/nodename = astring: newname
# svccfg -s system/identity:node setprop config/loopback = astring: newname
 
Review the Changes
 
# svccfg -s system/identity:node listprop config
config           application
config/nodename astring     newname
config/loopback astring     newname
 
Restart the Service to Reflect Changes

The system is now aware of the change, however it doesn’t use the change until the next reboot.  We can accelerate this by restarting the system/identity:node service.
 
# svccfg -s system/identity:node refresh
# svcadm restart system/identity:node
 
This will then show a system message reflecting the new hostname, to see the change in your shell prompt, you can spin off a child bash shell.  You can also use the hostname command to view the current hostname.