The requirement is to be able to set the hostname for a Solaris server to something new.
To begin with, list the current hostname settings by typing (as root) the following command:
svccfg -s system/identity:node listprop config
That will return something like this:
$ svccfg -s system/identity:node listprop config config application config/enable_mapping boolean true config/ignore_dhcp_hostname boolean false config/nodename astring solaris config/loopback astring solaris
Here you see that both “config/nodename” and “config/loopback” are currently set to the same thing (probably “solaris” immediately after a fresh O/S install). So it’s both of those that need changing by typing (again, as root):
svccfg -s system/identity:node setprop config/nodename="dizsol" svccfg -s system/identity:node setprop config/loopback="dizsol"
Finish things off with a refresh of the relevant settings:
svccfg -s system/identity:node refresh
You should find that the host names change immediately:
However, even though the output from the earlier ‘listprop’ command has changed to reflect the new hostname in that screenshot, notice how the hostname in the prompt itself has not (i.e., the command line prompt still says “[email protected]”, which is the original name).
For the system as a whole to pick up the change, therefore, you can either reboot (a tad drastic, but effective!), or you can issue these commands to refresh and restart the identity service:
svcadm refresh system/identity:node svcadm restart system/identity:node
The prompt in your existing terminal won’t change in response to either of these commands, but new terminals that you open should now display the revised hostname.
You can then issue this command:
…to make sure the change has taken effect system-wide.
Finally, note that changing the hostname doesn’t alter the contents of /etc/hosts, so you may want to edit that file and add in some revised details. For example, my original /etc/hosts read:
# # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Internet host table # ::1 solaris localhost 127.0.0.1 solaris localhost loghost
…showing that ‘solaris’ was my original hostname. It would help some applications (such as Oracle!) to modify things slightly as follows:
# # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Internet host table # 192.168.137.5 dizsol ::1 solaris localhost 127.0.0.1 solaris localhost loghost
That is, put the new hostname (and its correct IP address) at the head of the file.