My client needed to transfer DNS zones from one network to another. Unfortunately, we couldn’t integrate the DNS zones with AD (Public Facing DNS) and two networks couldn’t talk to each other. So there was no way of doing this completely automated.
Here is how the new DNS infrastructure was configured:
dnsservername1 – Primary DNS Server
dnsservername2 – Secondary DNS Server
Both DNS server have been configured to disable recursion which disables forwarders. This prohibits the DNS server from resolving to other zones it doesn’t have added to it. For example, if someone was using dnsservername1 to resolve www.yahoo.com, it would fail.
Here is how I added the new DNS zones from the old DNS server.
1. Copied all .dns records from c:\windows\system32\dns to dnsservername1 (to same location)
2. Exported registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DNS Server\Zones from “olddnsserver”. Within the REG key I deleted all of the reverse lookup zones and secondary servers and imported into dnsservername1.
3. Restarted DNS service on dnsservername1, this allowed the zones to show up in DNS.
4. Changed all zone SOA and Name Server to dnsservername1 as well as adding dnsservername2 as a Name Server. Configured Zone Transfers to only Name Servers listed.
5. Exported the list of zones from dnsservername1 using the following command.
a. Get-WmiObject -ComputerName dnsservername1 -Namespace "root\MicrosoftDNS" -Class "MicrosoftDNS_Zone" | foreach {$_.name} | out-file –FilePath c:\temp\dnszones.txt
6. Copy dnszones.txt to dnsservername2 (c:\temp)
7. Imported secondary DNS zones to dnsservername2 using following script.
##Change $ServerName and IP Address
$ServerName = "dnsservername2 fqdn"
$ZoneList = "c:\temp\dnszones.txt"
$zones = Get-Content $zonelist
foreach ($zone in $zones) {
$NewZone=([WMIClass]"\\$ServerName\root\MicrosoftDNS:MicrosoftDNS_Zone").CreateZone($zone , 1, $False, "", @("IP Address"))
}
8. Restarted DNS service on dnsservername2 and allowed waited for zones to transfer.
