How to configure DHCP client to request hostname (e.g., with DNS)? (SOLVED)

ascalonx's picture

I'm trying to figure out how to get my appliance to register its hostname with the dns server (much like windows does).  From what I've found online, it appears a standard Ubuntu install uses the dhcp-client3 package for its dhcp client and this has configurations that can be made via /etc/dhcp3/dhclient3.conf to send the hostname when requesting dhcp.

However, it seems that there is no /etc/dhcp3 folder on my appliance, so I can only assume that dhclient3 is not being used as the dhcp client.  Is there another place to make this kind of configuration?



Liraz Siri's picture

Sorry its taken this long to get back to you. We're in the middle of a new release (2009.02) and it's been a bit hectic.

Ubuntu comes with dhcp3-client by default, but we've decided to go with udhcpc as our default dhcp client because it is simpler and smaller while still providing most of dhcp3's functionality.

If you like you can remove udhcpc and install dhcp3-client instead:

$ apt-get remove udhcpc
$ apt-get install dhcp3-client
On the other hand, for the purpose of registering/requesting a hostname during dhcp, they are both configured in the same way - in /etc/network/interface. See section "The dhcp method" in the manual page:
$ man interfaces
In a nutshell, you just have to add the hostname parameter to your configuration like this:
$ cat /etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
   hostname myhostname # hostname to be requested

Hope this helps!
andenix's picture

I have a configuration where several hosts connected to the Internet through a router. Some are wired and some wireless. One of the hosts called "forum" runs Turnkey PHPBB appliance.


First time its name appeared blank in my router, so as Liraz Siri post suggests,

1) I added this line:

auto eth0
iface eth0 inet dhcp
   hostname forum # hostname to be requested




The name appeared at my router DHCP client list, but the host could not be pinged by its hostname (pinging by ip worked).

2) Once again like the post above suggested I did this:

$ apt-get remove udhcpc
$ apt-get install dhcp3-client

This did not fix the problem, but now I could install samba (next step) without warnings.


3) installing samba

$ apt-get install samba


reboot, no voila I could do:

$ ping forum

from any host in my network!


PS: I am no linux expert so the above could be not very secure and not the best practice either. The ideas are not mine, but a compilation of different posts I found on Turnkey and Ubuntu websites.



Jeremy Davis's picture

DHCP is handy for roaming computers, end-user environments (such as home networks) and developemnt/testing servers but for a static server farm (even if virtual) I prefer to hard code IPs and set those in my nameserver (DNS). Avoiding DHCP (where practical) is a great way of eliminating one potential problem.

andenix's picture

Actually I realized that you don't have to remove udhcpc to be able to lookup your hosts in a LAN, just make sure you configure your hostname through webmin and it matches the one you entered in /etc/network/interfaces.

The problem with DNS in small networks is that not all routers allow you to configure it. Then its a pain, because you will have to either establish DNS and DHCP on a side host, or really hardcode all IPs as you mentioned..

Linux User's picture

With Turnkey Linux Fileserver, I changed hostname in networking hostname. I then went to /etc/networking/interfaces and added the bit about hostname to to the ethernet device.

Post new comment