Fix : No Hostname when using DHCP in Sun Solaris 8/9/10
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:
# hostname
unknown
or the /etc/hosts file has an entry as follows:
# cat /etc/hosts
#
# Internet host table
#
127.0.0.1 localhost
192.168.100.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
PARAM_REQUEST_LIST=1,3,6,12,15,28,43
and remove the Parameter “12″ from the above to look as follows:
PARAM_REQUEST_LIST=1,3,6,15,28,43
and save the file.
Now, add the hostname to the /etc/nodename & /etc/hosts as follows
Note : if /etc/nodename file does not exist then create the file and add the parameter
# vi /etc/nodename
and add the hostname you want it to have (solarisserver for me)
# cat /etc/nodename
solarisserver
and edit the /etc/hosts file
# vi /etc/hosts
and add the line similar to the following
192.168.100.3 globalzone
Now,reboot the server and you should be all fine with hostname set for the system.
# init 6
