Send hostname to DHCP server on Ubuntu/XUbuntu
Default installation of Ubuntu and XUbuntu do not send the hostname to the DHCP server and this prevents other machines on the network from looking up your machine by using the FQDN (Fully Qualified Domain Name). This is easy to fix with a few tweaks to the DHCP configuration file.
Disclaimer: These steps have worked for me and have been tested on Compaq Evo N610c running Ubuntu 8.04 LTS (Hardy Heron) and Compaq Armada M300 running XUbuntu 8.04 LTS (Hardy Heron). YMMV. I am not responsible for loss of data or damage to computers.
1. Open Terminal Window
2. If you already know your hostname skip to step 4
3. To find your hostname run the following command
hostname
4. Make a copy of the existing dhclient configuration file
sudo cp /etc/dhcp3/dhclient.conf /etc/dhcp3/dhclient.original
5. Edit the dhclient configuration file
sudo vi /etc/dhcp3/dhclient.conf
6. Search for the line send host-name (On XUbuntu it is missing completely and you will need to add it in)
7. Uncomment the line and replace <hostname> with the hostname identified in step 3. The line should look similar to (don’t leave out the semi-colon at the end)
send host-name "ubuntu-laptop";
8. Save the file and exit gedit
9. Restart networking
sudo /etc/init.d/networking restart
That’s it … test if other machines on the network can now look up your machine by using the FQDN. If you notice something wrong you can always restore the original dhclient configuration file.
The above instructions should work for KUbuntu too although I have not validate it myself.
7 comments7 Comments so far
Leave a reply






This works on Debian 4 too.
Thanks for your tip!
One thing I noticed:
The send host-name command needed a semi-colon at the end of the line before it worked for me.
Thanks Tom good catch. I have updated the post to fix the error.
There’s a cleaner way to do this.
Ubuntu has a built in variable for the hostname. Instead of saying:
send host-name “ubuntu-laptop”;
you can say:
send host-name “”;
This way, if you decide to change your hostname, you only have to update one place.
HTH,
Brian
You wrote:
test if other machines on the network can now look up your machine by using the FQDN.
Here is my /etc/hosts:
bruparel@bcr-d810:/etc$ cat hosts
127.0.0.1 localhost
127.0.1.1 bcr-d810
If I try to ping bcr-d810 it does not find it. Here is the changed in /etc/dhcp3/dhclient.conf:
send host-name “bcr-d810″;
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
I restart the computer, but I can’t seem to be able to ping bcr-d810. What do I have to do to set a proper FQDN?
Thanks.
Bharat
Thanks for this!
When creating the backup, you have …/dhcp/… instead of …/dhcp3/… as the destination.
Also, Brian’s tip about using host-name “” didn’t work for me on Xubuntu Hardy.
Thanks Damian … I have updated the post.