I'm trying to resolve some funky DNS issues related to DHCP on our network (I suspect we have more than one DHCP server running at the moment), and while trying to figure that out, I noticed something strange with a new server I just set up.
The server in question is a Xen virtual machine running Ubuntu 9.10 Server. The physical Xen server is also on our network, and when I booted up the VM for the first time in Xen (I imported it from a local Virtualbox VM running on my machine, where it was running on a different network), it got a DHCP lease from our office network and everything was good.
I checked the dhclient.eth0.leases
file to see what got configured, and saw that the old DHCP lease from the previous network the machine was on was still there, as well as the new DHCP lease for the office network it's currently connected to. There are two things I noticed right away:
The old DHCP lease information from the previous network doesn't have an
options host-name
line, which I take to mean the original VirtualBox version of the VM wasn't sending this option to the DHCP server. Or does this mean the old DHCP server didn't support the DHCP host name option? It was using VirualBox's internal DHCP server at the time...The new DHCP lease information does have an
options host-name
line, which includes the correct, current hostname for the server ("fozzie"). If I understand correctly, this means the server sent it's hostname to the DHCP server on our network.
There are a number of things I don't understand about all this.
First, I did not change dhclient.conf
for the server at any point; it's using the default configuration. In fact it contains the following line verbatim:
send host-name "<hostname>"
So my first question is, how in the heck did it know to send the server's real hostname if the configuration isn't set up to send it in the first place?
Second, why did the first DHCP lease (for the old network) not include option host-name
, but the second DHCP lease (on the new network) did include it, if I haven't touched any of the configuration files?
All I did was export the original VirtualBox machine as an OVF, and then import it into XenServer, so how did it magically configure my hostname via DHCP if it's not even configured with the actual hostname in dhclient.conf
?
Third: When I run hostname
, the server returns fozzie.our.domain
, but dhclient.eth0.leases
says the hostname option was set to fozzie
(no domain). How did it know to strip off the domain?
OK, after a long time trawling the Internet and trying to read through
man
pages, I mostly figured out what's going on:Apparently,
send host-name "<hostname>"
, and more specifically,<hostname>
, has special significance on Ubuntu. It tellsdhclient
to send your machine's current hostname to the DHCP server. Note that this is case-sensitive (i.e. if you type<HOSTNAME>
, dhclient will send the literal text<HOSTNAME>
to the DHCP server). As reported here and here, this works on Ubuntu Feisty and above, being part of a patch to (ironically) fix a problem withdhclient
not sending the machine's hostname by default.This just seems to be because not all DHCP servers will echo the hostname back to the client. Yesterday we still using a Linux-based ClarkConnect router as our DHCP server, which echoed the hostname back to each client. Today we disabled DHCP on that server, and switched to using the built-in DHCP server on our primary domain controller. Our DHCP leases from the PDC don't include
option host-name
either, but it doesn't seem to affect anything. The machines get updated in DNS, and they can all find each other by hostname.This is me not fully understanding the intricacies of DHCP. Our DHCP server was set to configure all of our clients with our domain. I'm guessing the DHCP server was smart enough to remove the domain name portion from the hostname sent by the client.
Anyone have any corrections or clarifications to add to this answer? It still seems a bit "hand-wavy", so I won't accept it as-is.