Home > Computers > Export All DNS Zones

Export All DNS Zones

I was in the process of enabling DNS scavenging following the steps in this blog post. I’m used to it already being on but going into an existing environment with it disabled & enabling it could be bad. I was at the “enable” phase mentioned in the blog when I thought that it would be nice to have an export of all the zones just in case. While I’m sure there are other solutions, this is mine.

  • Browse to C:\Windows\System32\dns.
  • Create a folder called export.
  • Open a command prompt.
  • Browse to C:\Temp.
  • Run the following commands:

dnscmd /enumzones > AllZones.txt

for /f %a in (AllZones.txt) do dnscmd /ZoneExport %a export\%a.txt

  • In the export folder you will now have a text file with an export for every zone (forward & reverse) in your DNS server.
  • Now create a subfolder in the YYYYMMDD format under the export folder created earlier.
  • Move all the text files to that folder.
Categories: Computers Tags: , ,
  1. me
    July 30, 2013 at 9:22 am

    how can i make this go to a different directory

  2. patrickhoban
    August 7, 2013 at 12:49 pm

    I’m not aware of a way to export it to a folder outside of C:\Windows\System32\dns. The steps I use at least will get it into a subdirectory that you can then move wherever. I’m sure with a little scripting effort this could all be automated.

  3. Philip
    February 8, 2014 at 11:40 am

    Thank you! This helped us a lot.

  4. mike rose
    January 27, 2016 at 6:45 am

    in order to be able to do a CTRL-F inside a single document, merge all txt files with this cmd: “for %f in (*.txt) do type “%f” >> output.txt”

  5. Gellert Zoltan
    March 21, 2016 at 2:59 am


    What can I do, if I have Subzones under the DNS?

    • patrickhoban
      March 21, 2016 at 12:26 pm

      Doesn’t the command do subzones as well?

      • Jon Yong
        March 28, 2016 at 10:32 am

        The exported file generated by the /ZoneExport switch will also enumerate records from Nodes (“subzones”).

        I can confirm this as I have just used it less than two hours ago.

        As non-relevant note, I used PowerShell to parse the Zones using /enumzones (as recommended here), loop through those Zones to perform a /ZoneExport, and then output the text data into CSV format containing the entire environment (with columns for Zone, Hostname, IP, and IP in binary format).

        Many other resources on the internet only describe the use of /enumrecords, which forces you to check one Node at a time, and there does not seem to be a way to enumerate Nodes. Pointing /enumrecords to node “@” only enumerates the root and ignores child Nodes.

        Thus, thanks to Patrick Holban for writing this document, identifying how to use /ZoneExport correctly (which recursively enumerates records in all nodes).

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: