Windows – Create PTR Records from Existing A Records (Windows DNS)

domain-name-systemreverse-dnswindowszones

I am migrating DNS zones (both forward and reverse) from Bind to Windows DNS. The reverse entries in the existing Bind server have not been maintained all that well for the static zones and I would rather not just import all the records.

I have however moved all the A records over to the Windows setup and made sure they are cleaned up. Now I have empty reverse zones.

What I am wondering is if there is a relatively easy way to tell the DNS server (Windows 2008 R2, Active Directory integrated), either via GUI or cmd line, to go ahead and create PTR records for all of the A records.

Best Answer

How are your PowerShell skills? It could be a fairly straightforward matter of using

$hosts = Get-WmiObject -ComputerName $DomainController -Namespace 'root\MicrosoftDNS' -Class MicrosoftDNS_AType 

And then using the CreateInstanceFromPropertyData method:

foreach ($record in $hosts)  {
  $PTRRecord = [wmiclass]"\\$DomainController\root\MicrosoftDNS:MicrosoftDNS_PTRType
  $PTRRecord.createInstanceFromPropertydata("foo","bar","baz")
}

My example above is an excerpted (and sanitized) bit of a script I use to add CNAME records for existing A records. Doing PTRs should be quite similar; fix my foo-bar-baz handwave. There are more ideas and pointers in this Scripting Guys article.