dhclient-script ignores "option host-name" from DHCP-server

Bug #482313 reported by Friedrich Graeter
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
dhcp3 (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Binary package hint: dhcp-client

I have a set of machines running Ubuntu 9.10. These computers should receive their hostnames via DHCP from a DHCP server. For each host, the "option host-name" is set on the DHCP server and the lease file in "/var/lib/dhcp3" shows me, that the hostname was received.

However, the host name won't be set, even if /etc/hostname is deleted. It works this way with Debian.

I've figured out, that it can't work, since in /sbin/dhclient-script the following code is used to set the hostname:

set_hostname() {
    local current_hostname=$(hostname)
    if [ -z "$current_hostname" -o "$current_hostname" = "(none)" ]; then
        hostname "$new_host_name"
    fi
}

If I delete /etc/hostname or keep it empty, Ubuntu sets the hostname automatically to "localhost" - therefore the upper script will fail. It now works, after changing it to:

if [ -z "$current_hostname" -o "$current_hostname" = "localhost" ]; then

Probably the way, how Ubuntu deals with a missing /etc/hostname differs from the way how Debian does...

Related branches

Mathias Gug (mathiaz)
Changed in dhcp3 (Ubuntu):
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Valentijn Sessink (valentijn) wrote :

We have set /etc/hostname explicitly to '(none)'. Naturally, this is an illegal hostname, but since we use dhcp for our hostnames, the hostname is changed once the network is up.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package dhcp3 - 3.1.3-2ubuntu3

---------------
dhcp3 (3.1.3-2ubuntu3) lucid; urgency=low

  * debian/dhclient-script.linux: Fix regression in host_name option
    handling, so that it's always honored when /etc/hostname is not set,
    fixes LP: #537978, #482313, #90388, #476491
 -- Thierry Carrez <email address hidden> Thu, 01 Apr 2010 16:52:36 +0200

Changed in dhcp3 (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.