Thursday, May 19, 2016

linux - How does my DHCP server know my machine's hostname when I didn't define one in dhclient.conf?

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:




  1. 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...


  2. 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 ""



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?

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...