Lucid Tips

Easily understood tips that make your computing experience easier

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.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Google
  • Slashdot
  • StumbleUpon
  • Technorati
7 comments

7 Comments so far

  1. morten December 14th, 2008 2:47 pm

    This works on Debian 4 too.

  2. Tom Chapin February 2nd, 2009 1:56 pm

    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.

  3. lucidTipster February 5th, 2009 11:57 pm

    Thanks Tom good catch. I have updated the post to fix the error.

  4. Brian Stempin March 13th, 2009 4:22 pm

    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

  5. Bharat April 23rd, 2009 11:41 am

    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

  6. Damian April 26th, 2009 11:35 pm

    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.

  7. lucidTipster April 27th, 2009 11:11 am

    Thanks Damian … I have updated the post.