How-To Geek

How to Export Your Windows Server’s DNS Records to a Web Page

If you run a Windows Server which takes advantage of the built in DNS Server, you have a nice graphical interface for viewing and managing your DNS records. However, the vast majority of the time you probably just look at these records as opposed to updating them. This process is not difficult, but can be a hassle as you have to connect to the DNS Server machine through remote desktop, open DNS controls and locate the record. Wouldn’t it be easier if you could simply see this information over the web?

To make this functionality possible, we have a very simple script which exports your current DNS Server records to text files and makes them available via a simple indexed HTML file which can be accessed from any device with a web browser.


Overall, the script’s configuration options are very straight forward. You simply need to configure the output location where you would like the destination files to end up. This folder will be populated with a ‘default.htm’ and ‘[domain]’ files. These names can be customized in the script as needed.

The script makes the assumption that you have named your DNS files using the default naming convention the Windows DNS Server uses ([domain].dns). If you are not using the default naming convention, the script will not work properly.

As an additional function, the script can delete unused DNS record files which are no longer active in your DNS Server. If enabled (off by default), when the export procedure fails for a DNS record file, meaning the domain was not found in the DNS Server, it is deleted. These unlinked DNS record files do not do any harm or consume any resources, so it is safe to leave them alone.

If you update your DNS records often, you can configure the script to run regularly through a scheduled task so you know the information you are viewing is always current. The output of the script is read-only so any changes made to the resulting files will not be reflected in your DNS Server.

How it Works

The script simply reads your current DNS files from the default Windows location and then interfaces with the DNSCmd command line tool to produce the output files. The DNSCmd tool is included with Server 2008, but Server 2003 machines must install the Resource Kit Tools to put this utility on your system.


The ‘[domain]’ are the output produced by the ZoneExport command.


You can access the listing by viewing the output ‘default.htm’ file in a browser. If you have configured the script to export to a publically available location, you can view the output from anywhere.


By clicking on a domain, you can see all the DNS information from your DNS Server for that domain.


The Script

ECHO Written by: Jason Faulkner

SETLOCAL EnableDelayedExpansion

REM Directory where the HTML pages should be generated.
SET OutPath=C:inetpubwwwrootdns
SET HTMLPage=default.htm

REM HTML page title/header.
SET Title=DNS Records

REM Delete DNS record files which are not currently loaded in the DNS server (1=Yes, 0=No)
SET DeleteNotFound=0

DEL /Q "%OutPath%*"
SET OutFile="%OutPath%%HTMLPage%"

REM HTML header info. Customize as needed.
ECHO ^<HTML^> >> %OutFile%
ECHO ^<HEAD^> >> %OutFile%
ECHO ^<TITLE^>%Title%^</TITLE^> >> %OutFile%
ECHO ^</HEAD^> >> %OutFile%
ECHO ^<BODY^> >> %OutFile%
ECHO ^<H1^>%Title%^<H1^> >> %OutFile%
ECHO ^<H3^>Machine Name: %ComputerName%^</H3^> >> %OutFile%
ECHO ^<H5^>Generated on: %Date% %Time%^</H5^> >> %OutFile%

SET DNSDir=%WinDir%system32dns
FOR /F %%A IN ('DIR /A:-D /B /L %DNSDir%*.dns') DO (
    SET Zone=%%A
    SET Zone=!Zone:.dns=!
    SET ZoneFile=!Zone!
    ECHO Exporting: !Zone!
    DNSCmd . /ZoneExport !Zone! !ZoneFile!
    IF NOT EXIST %DNSDir%!ZoneFile! (
        ECHO !Zone! is not currently loaded in DNS Server.
        IF {%DeleteNotFound%}=={1} DEL /F /Q %DNSDir%%%A
    ) ELSE (
        ECHO ^<A HREF="!ZoneFile!"^>!Zone!^</A^>^<BR/^> >> %OutFile%
        REM Output is always to DNS directory, so move the file to the HTML dir.
        MOVE /Y %DNSDir%!ZoneFile! "%OutPath%!ZoneFile!"

ECHO ^<BR/^> >> %OutFile%
ECHO ^</BODY^> >> %OutFile%
ECHO ^</HTML^> >> %OutFile%



Download DNS Dump to HTML Script from

Download Windows Server 2003 Resource Kit Tools from Microsoft

Jason Faulkner is a developer and IT professional who never has a hot cup of coffee far away. Interact with him on Google+

  • Published 08/23/10

Comments (5)

  1. nike air force 1 low

    Following all your amazing weblog, I come across it is of the special information and absolute options.Believe that I will attain what exactly I want from your current blog.Greatest wishes to you!
    Prada Handbags and Prada Handbags 2010, Mens Prada Sunglasses with high quality, fashion style and competitive price.

  2. Peter Miller

    Finally the first step. Being a very small ISP I am looking for a solution to offer my customers a solution to edit their DNS settings via a web interface. So what I am looking for is:
    – webinterface to view the DNS entries (you’ve solved that part)
    – webinterface to edit the DNS entries (well, that’s just the next step)
    – and finally (and that might be the largest problem) a small database which domain belongs to whom and therefor who may edit which DNS entries

    Any idea?

    Peter Miller

  3. Jason Faulkner

    You need some sort of hosting control panel. Your needs are way outside the bounds of what this script is designed to do.

  4. Lady Gaga Games

    This is often a top notch website. I’ve been back repeatedly over the past few days and wish to subscribe to your rss feed utilizing Google but cannot ascertain the right way to do it precisly. Would you know of any sort of guides?

  5. CENG

    Your Script could only work on W2k8 R2 with Standalone (Primary) or Secondary Zones. My Server (ADS Integrated) has NO DNS Files on its Share (C:\Windows\System32\dns).

More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!