hostname from dhcp STILL not set, despite multiple ubuntu fixes and bug reports
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
dhcp3 (Ubuntu) |
Fix Released
|
Low
|
Unassigned |
Bug Description
Despite multiple bug reports and attempts at fixes, ubuntu versions maverick and natty do NOT set their hostname from dhcp. See: #537978, #482313, #90388, #476491
Releases:
---------------
maverick: lsb_release -rd
Release: 10.10
natty: lsb_release -rd
Release: 11.04
Versions of dhcp and hostname packages:
-------
maverick:dpkg -l | grep -E dhcp\|hostname
ii dhcp3-client 3.1.3-2ubuntu6.3 DHCP client
ii dhcp3-common 3.1.3-2ubuntu6.3 common files used by all the dhcp3* packages
ii hostname 3.04ubuntu1 utility to set/show the host name or domain name
natty: dpkg -l | grep -E dhcp\|hostname
ii hostname 3.05ubuntu1 utility to set/show the host name or domain name
ii isc-dhcp-client 4.1.1-P1-
ii isc-dhcp-common 4.1.1-P1-
What I expect to happen:
-------
With client configured with empty /etc/hostname, and main network interface configured for dhcp, I expect the hostname to be set during boot.
What happened instead:
-------
With empty /etc/hostname, the machine comes up with (none) as hostname, with /etc/hostname missing entirily, the hostname is set to `localhost´
Elaboration:
-------------------
In networks with lots (dozens or hundreds) of linux workstations I keep the /etc/hostname on each of them empty. They get the hostname from dhcp at boot-time and set it. Managing lots of clients or a HPC cluster becomes impractical if I have to set all hostnames on them by hand. Installation in such a situation typically happens from an imaging host, where one or maybe a few images is used to install on hundreds of clients.
So there must be NO host-specific configuration in these images. Hostnames are set by the dhcp client with information provided by the dhcp server. UUID's are NOT used in /etc/fstab, /boot/grub/
root=UUID=
I want to be able to configure in /etc/default/
Unfortunately Canonical gives me no such configuration options at this time, and this is not good for sysadmins like me who need tools to administrate lots of workstations.
Also note that dhcp clients can push a client side provided hostname to a dhcp or dns server, which is useful if you have a laptop that the user has root-access to. My situation is the other way around: the users have NO root-access on the workstations or the HPC cluster, and hostnames are centrally pushed to the clients.
For this latest dhcp host-setting regression I suspect two reasons.
I suspect two reasons:
1) upstart sets the hostname in recent ubuntu distros, and it simply does:
exec hostname -b -F /etc/hostname
This will not work if /etc/hostname is empty!
2) dhclient does not set the hostname despite being so configured in /etc/dhcp3/
Apparantly it is possible to write an exit hook script that sets the hostname like this:
# ===== /etc/dhcp/
if [[ -n $new_host_name ]]
then
echo "$new_host_name" > /etc/hostname
/bin/hostname $new_host_name
fi
Apparantly $new_host_name is the internal variable that dhclient uses for the hostname info that it got from the dhcp server.
The correctly configured dhcp server has stanzas for the clients like this:
host maris007 {
fixed-address 10.0.0.7;
hardware ethernet 00:30:48:58:df:14;
option host-name "maris007";}
Changed in dhcp3 (Ubuntu): | |
importance: | Undecided → Low |
So, adding a file `hostname´ to /etc/dhcp/ dhclient- exit-hooks. d/ with this in it: dhclient- exit-hooks. d/hostname ====== dhclient- exit-hooks. d/hostname ======
# ===== begin /etc/dhcp/
if [ -n $new_host_name ]
then
echo "$new_host_name" > /etc/hostname
/bin/hostname $new_host_name
fi
# ===== end /etc/dhcp/
_kind of_ works to fix this problem. But on text consoles it still reads `localhost login´,
and only after actually login is the hostname there on the prompt. Ugly. So it is not a
complete fix.
Why is it that the hostname gets set so late when I set it up like this? Is the upstart /etc/init/ hostname. conf script executed _before_ the upbringing of the network? That could explain this.