Exporting a DNS zone is easy. Use the dnscmd
.
1 2 3 4 5 |
C:\> dnscmd DNS-SERVER /zoneexport "blah.com" "blahexport.txt" DNS Server DNS-SERVER exported zone blah.com to file C:\Windows\system32\dns\blahexport.txt on the DNS server Command completed successfully. |
Importing too is easy but the commands aren’t so obvious. Again you use dnscmd
, with the /zoneadd
switch as though you are creating a new zone. The help page for this misses out on an important switch though – /load
– which lets you load the zone from an exported or pre-existing file.
You can find this switch in the dnscmd
help:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
C:\> dnscmd /zoneadd Usage: DnsCmd <ServerName> /ZoneAdd <ZoneName> <ZoneType> [<Options>] <ZoneName> -- FQDN of zone <ZoneType>: /DsPrimary [/dp <FQDN>] -- DS integrated primary zone /Primary /file <filename> -- standard file backed primary; MUST include filename. /Secondary <MasterIPAddress> [<MasterIPAddress>] ..] [/file <filename>] -- standard secondary, MUST include at least one master IP; filename is optional. /Stub <MasterIPAddress> [<MasterIPAddress>] ..] [/file <filename>] -- stub secondary, only replicates NS info from primary server /DsStub -- as /Stub but DS integrated - use same options /Forwarder <MasterIPAddress> [<MasterIPAddress>] ..] [/Timeout <Time>] [/Slave] -- forwarder zone, queries for names in zone forwarded to masters /DsForwarder -- as /Forwarder but DS integrated - use same options <Options>: [/file <filename>] -- filename, invalid for DS integrated zones [/load] -- load existing file; if not specified, non-DS primary creates default zone records [/a <AdminName>] -- zone admin email name; primary zones only [/DP <FQDN>] -- fully qualified domain name of directory partition where zone should be stored; or use one of: /DP /domain - domain directory partition /DP /forest - forest directory partition /DP /legacy - legacy directory partition |
So the way to import a zone is as follows: first, copy the exported file into the c:\windows\system32\dns
folder of the DNS server and preferably rename it so the extension is a .dns
(not required, just a nice thing to do). Then run a command similar to below:
1 |
dnscmd DNS-SERVER /zoneadd "blah.com" /primary /file blah.com.dns |
That’s it. This will create a primary zone called “blah.com” and use the zone file that’s already in the location.
Note that you can’t use this technique for AD integrated zones. But that’s no issue. Simply import as above and then convert the zone to AD integrated via the GUI.