Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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

2 Answers 2

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.