Thursday, November 15, 2012

Auto-register AD DNS host name from CentOS

You can get a Linux (CentOS 6.3) server installation to automatically appear in a Windows DNS and Active Directory configuration (vanilla Windows Server 2008 R2).

At the Windows end, you first need to tick “Dynamically update DNS A and PTR records for DHCP client that do not request updates (for example, clients running Windows NT 4.0)”. I did this via Start > Admin Tools > DHCP > [server] > IPv4 > Scope > Properties > DNS.

You can check what the Windows DHCP server is up to by examining the logs which are in c:\windows\system32\dhcp. This was happening by default on my test rig. It starts a new log each day and keeps a week of history and also writes the status codes at the top of each file. I’m looking for DNS Update Request (30) and DNS Update Successful (32). You should be able to see these for Windows 7 clients (for example) and can generate them by doing an ipconfig /release and ipconfig /renew.

We then installed CentOS 6.3 via the minimal network installer image, which then drags down the bits it needs from the internet. We first set the VM guest to use the legacy network adapter for this, as the image doesn’t have Hyper-V Integration Services installed so can’t use the default one. We also set the memory to 1GB. At 512MB the installer didn’t give us the graphical install user interface.

During the initial phase we told it to use IPv4 with DHCP and disabled IPv6. It then needed a URL for the phase 2 image and a bit later it started a graphical setup user interface. We gave it the FQDN for this new host (newhost.subdomain.domain.com for example). At the bottom of this screen is a Configure Network button. We pressed this and edited eth0. IPv4 was set to Automatic DHCP and we set the DHCP Client ID to match the hostname given above without the domain (so just “newhost”).

Do the rest of the install and then reboot.

Next, enable DNS through the firewall.

Then you need to add an entry to a config file:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

There should be some stuff in here already. You need to add:
DHCP_HOSTNAME=newhost

“newhost” again needs to match with what you did before. Then “<Esc>:wq” to write and quit vi.

Then ifdown eth0 followed by ifup eth0. This should release and renew via DHCP so checking the Windows DHCP Server log should show the expected DNS update messages.

Back on the Windows Server, the hostname (newhost) should appear in the Name column in DHCP Address Leases and an A record should also appear in the DNS forward lookup zone.

1 comment:

Anonymous said...

Thanks to you, I'm able to get my machines to resolve on the network!

Adding DHCP_HOSTNAME to /etc/sysconfig/network also works.