If you are using DHCP to receive IP Address for your Sun Solaris system, you may end up with no hostname assigned to the system. This can be confirmed when there is no hostname at the prompt or if the output for the command “hostname” is as follows:
or the /etc/hosts file has an entry as follows:
# cat /etc/hosts
# Internet host table
192.168.0.3 unknown # Added by DHCP
This happens when the DHCP server doesn’t provide a hostname for your server. Most of the DHCP Servers or routers acting as a DHCP Server doesn’t provide a hostname and Solaris DHCP agent relies on the DHCP server for its hostname.
To fix this problem, edit the dhcpagent config and set it not to request a Hostname from the DHCP server and then add a hostname to the /etc/hosts & /etc/nodename file.
Edit DHCPAGENT config
[For Solaris 10, this is not required as setting the hostname in /etc/nodename overrides the hostname provided by the DHCP Server. Move onto the next step]
Edit the dhcpagent config file /etc/default/dhcpagent with your favorite editor
# vi /etc/default/dhcpagent
and look for
and remove the Parameter “12” from the above to look as follows:
and save the file.
Now, add the hostname to the /etc/nodename & /etc/hosts as follows
# vi /etc/nodename
and add the hostname you want it to have (solarisserver for me)
# cat /etc/nodename
and edit the /etc/hosts file
# vi /etc/hosts
and add the line similar to the following
192.168.0.3 solarisserver loghost
Now,reboot the server and you should be all fine with hostname set for the system.
# init 6