Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

According to several comments in the web most DHCP clients simply ignore the hostname provided by the DHCP server. Does Ubuntu use the provided hostname? If not, how can Ubuntu be persuaded to use the provided hostname?

share|improve this question

It seems you can do that with /etc/dhcp3/dhclient.conf's option:

request host-name;

See the example at the end of dhclient.conf(5)

share|improve this answer
Ubuntu enables this by default, but it seems no one cares about the hostname returned by the DHCP server. – Andreas Roth Apr 11 '11 at 9:44

Setting an empty hostname (which is contained in /etc/hostname) works for at least Ubuntu 14.04 (just be sure to renew your DHCP-lease or restart of course).

Then as an optional step - if you care about messages like unable to resolve host <hostname> - you would have to change /etc/hosts dynamically to point your loopback address to the acquired hostname.

Using Ubuntu 14.04 you could place a script in /etc/dhcp/dhclient-enter-hooks.d containing the following to accomplish that optional step:

if [ -n "${new_host_name}" ]; then
  sed -i "/\ ${new_host_name}" /etc/hosts

Then of course make it executable by means of chmod +x my-custom-script.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.