TurnKey Linux Virtual Appliance Library

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

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?

Thanks,

Dusty

Liraz Siri's picture

Configuring DHCP to request hostname via /etc/network/interfaces

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!

Sumamry - I hope you will find it helpful

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

to:

/etc/network/interfaces

 

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.

--andenix

 

Jeremy's picture

Another way to go

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.

a remark

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..

How I got it to work

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

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)