Unknown hostname for Solaris 10 DHCP client
When I installed Solaris 10 x86, my computer thought its hostname was unknown. Aside from being annoying, this seemed to be causing a few issues, so I set about trying to set it to a name of my choice.
Using the uname -S hostname
command set the hostname for me but this information didn’t persist on reboot. A bit of googling turned up various references to editing /etc/init.d/network so that it read /etc/nodename and set the hostname accordingly (as well as a script to set the hostname), but my system didn’t have an /etc/nodename file.
I understood that /etc/nodename should contain my computer’s name, but didn’t know if any other settings were required (I later found Jeff Hunter’s TCP/IP quick configuration guide, which confirmed that the file just contains the computer’s name - in my case laptop3).
It turns out that these hacks are for Solaris 8/9 - Solaris 10 is quite happy to set the hostname based on the contents of /etc/nodename. Once I had created /etc/nodename and rebooted, /etc/hosts read:
#
# Internet host table
#
127.0.0.1 localhost
192.168.7.106 laptop3 # Added by DHCP
and the computer was no longer anonymous!
Method 2:
http://docs.sun.com/app/docs/doc/816-4554/dhcp-admin-1058sm?a=view
How to Enable a Solaris DHCPv4 Client to Request a Specific Host Name
-
On the client system, edit the /etc/default/dhcpagent file as superuser.
-
Find the REQUEST_HOSTNAME keyword in the /etc/default/dhcpagent file and modify the keyword as follows:
REQUEST_HOSTNAME=yes
If a comment sign (#) is in front of REQUEST_HOSTNAME, remove the #. If the REQUEST_HOSTNAME keyword is not present, insert the keyword.
-
Edit the /etc/hostname.interface file on the client system to add the following line:
inet hostname
hostname is the name that you want the client to use.
-
Type the following commands to have the client perform a full DHCP negotiation upon rebooting:
# ifconfig interface dhcp release
# rebootThe DHCP data that is cached on the client is removed. The client restarts the protocol to request new configuration information, including a new host name. The DHCP server first makes sure that the host name is not in use by another system on the network. The server then assigns the host name to the client. If configured to do so, the DHCP server can update name services with the client's host name.
If you want to change the host name later, repeat Step 3 and Step 4.