I have a XenServer installation with Debian (lenny) machines created on a daily basis using a script which creates the machine from a template and assigns it with a new hostname.
Our network has a Fortinet 60B appliance which servers as the DHCP server and a Microsoft Windows 2008 DC which also serves as a DNS server. I'd like to configure the VM template to send its hostname to the DNS server when it gets a leased IP from DHCP.
Currently, Fortinet assigns the DC as the DNS server along with the IP lease. I tried adding a 'send host-name "my-host-name"' line to /etc/dhcp3/dhclient.conf, but nothing gets updated in the DC.
So basically you want your client to send their hostname to your DNS server ?
This works great with Windows clients, but for Linux machines, I would go the other way around : set your clients to ask the DHCP server for an IP and a hostname. Using the "request host-name" option, dhclient asks the DHCP server to send a hostname along with the IP address, then sets the hostname of the VM.
Of course you'll need to prepare, in your DNS, a hostname for each IP address in the DHCP range.
This way you don't have the DNS cache / propagation delay problem, and you may have a central place with all the IP and hostnames - your DNS server.
I don't know wether your appliance's DHCP server supports sending hostnames - most does, but I think that's the easiest way for Linux clients.
Note: If you configured your DHCP server so that the same machine always get the same IP address (e.g. using mac address) then it will, obviously, always get the same hostname too. On some DHCP server, you can use directly hostname instead of IP address in the config files.
I Ended up using a script which runs nsupdate after VM is created from template and upon each boot.
This is somewhat similar to my own question. Have a look at my final comment to the one and only answer I received, where I refer to dhclient.conf.
Two things I've found that were required to get a non-domain joined machine to register and update it's DNS records on a Windows DC\DNS server:
Configure the DC\DNS server to allow both secure and unsecure dynamic DNS updates.
Configure the FQDN of the non-domain joined host to match your AD\DNS name: as in host.domain.com
Hmm. Never tried this exact config - I've had this working with Linux clients to Windows DHCP servers, but in that setup the DHCP server does the update. Not sure if the Fortinet box does the same thing.
You could try making the client talk to the DNS server directly; something like:
in /etc/dhcp3/dhclient.conf. Check
man dhclient.conf
for more info. I had to set at leastsend fqdn.fqdn
to get it working in my setup.You'll have to enable insecure updates to your DNS zones as well.
Many may consider this blatantly obvious, but be sure to specify your own request directive in
dhclient.conf
which does not request a hostname or domain-name. The default on my distro was:Note that this requests both host and domain names from the server which nullifies a
send host-name ...
directive. My request and send-host directives look like this: