博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
导出dns解析记录_如何将Windows Server的DNS记录导出到网页
阅读量:2506 次
发布时间:2019-05-11

本文共 6382 字,大约阅读时间需要 21 分钟。

导出dns解析记录

导出dns解析记录

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?

如果您运行的Windows Server利用了内置的DNS服务器,则您将拥有一个漂亮的图形界面来查看和管理DNS记录。 但是,绝大多数时候您可能只看这些记录而不是更新它们。 这个过程并不困难,但是很麻烦,因为您必须通过远程桌面连接到DNS服务器计算机,打开DNS控件并找到记录。 如果您可以简单地通过网络查看此信息,会不会更容易?

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.

为使此功能成为可能,我们有一个非常简单的脚本,该脚本可将您当前的DNS服务器记录导出到文本文件,并通过简单的索引HTML文件使它们可用,该文件可通过Web浏览器从任何设备进行访问。

组态 (Configuration)

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].dns.zone.txt’ files. These names can be customized in the script as needed.

总体而言,脚本的配置选项非常简单。 您只需要配置输出位置,即可使目标文件结束。 该文件夹将填充“ default.htm”和“ [domain] .dns.zone.txt”文件。 这些名称可以根据需要在脚本中自定义。

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.

该脚本假定您已使用Windows DNS服务器使用的默认命名约定([domain] .dns)为DNS文件命名。 如果您没有使用默认的命名约定,则该脚本将无法正常工作。

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.

作为一项附加功能,脚本可以删除未使用的DNS记录文件,这些文件在您的DNS服务器中不再活动。 如果启用(默认情况下为关闭),则当DNS记录文件的导出过程失败时,意味着在DNS服务器中找不到该域,则将其删除。 这些未链接的DNS记录文件不会造成任何危害或消耗任何资源,因此可以放心使用。

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.

如果您经常更新DNS记录,则可以将脚本配置为通过计划任务定期运行,以使您知道所查看的信息始终是最新的。 脚本的输出是只读的,因此对结果文件所做的任何更改都不会反映在DNS服务器中。

这个怎么运作 (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.

该脚本仅从默认的Windows位置读取当前的DNS文件,然后与DNSCmd命令行工具对接以生成输出文件。 DNSCmd工具包含在Server 2008中,但是Server 2003计算机必须安装Resource Kit Tools才能将该实用程序放到系统上。

image

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

“ [domain] .dns.zone.txt”是ZoneExport命令产生的输出。

image

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.

您可以通过在浏览器中查看输出的“ default.htm”文件来访问列表。 如果已将脚本配置为导出到公共可用位置,则可以从任何位置查看输出。

image

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

通过单击一个域,您可以从该域的DNS服务器中查看所有DNS信息。

image

剧本 (The Script)

@ECHO OFFTITLE DNS Dump to HTMLECHO DNS Dump to HTMLECHO Written by: Jason FaulknerECHO SysadminGeek.comECHO.ECHO.

@ECHO OFFTITLE DNS转储到HTMLECHO DNS转储到HTMLECHO撰写者:Jason FaulknerECHO SysadminGeek.comECHO.ECHO。

SETLOCAL EnableDelayedExpansion

SETLOCAL EnableDelayedExpansion

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

应当在其中生成HTML页面的REM目录。SET OutPath = C:inetpubwwwrootdnsSET HTMLPage = default.htm

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

REM HTML页面标题/标题SET标题= DNS记录

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

REM删除当前未加载到DNS服务器中的DNS记录文件(1 =是,0 =否)SET DeleteNotFound = 0

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

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%

REM HTML标头信息。 ECHO ^ <HTML ^> >>%OutFile%ECHO ^ <HEAD ^> >>%OutFile%ECHO ^ <TITLE ^>%Title%^ </ TITLE ^> >>%OutFile%ECHO ^ </ HEAD ^> >>%OutFile%ECHO ^ <BODY ^> >>%OutFile%ECHO ^ <H1 ^>%Title%^ <H1 ^> >>%OutFile%ECHO ^ <H3 ^>机器名称:%ComputerName% ^ </ H3 ^> >>%OutFile%ECHO ^ <H5 ^>生成于:%Date%%Time%^ </ H5 ^> >>%OutFile%

SET DNSDir=%WinDir%system32dnsFOR /F %%A IN ('DIR /A:-D /B /L %DNSDir%*.dns') DO (    SET Zone=%%A    SET Zone=!Zone:.dns=!    SET ZoneFile=!Zone!.dns.zone.txt    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.)

SET DNSDir =%WinDir%system32dnsFOR / F %% A IN('DIR / A:-D / B / L%DNSDir%*。dns')DO(SET Zone = %% A SET Zone =!Zone:.dns = !SET ZoneFile =!Zone!.dns.zone.txt ECHO导出:!Zone!DNSCmd。/ ZoneExport!Zone!!ZoneFile!如果不存在%DNSDir%!ZoneFile!(ECHO!Zone!当前不在DNS服务器中加载) 。IF {%DeleteNotFound%} == {1} DEL / F / Q%DNSDir %%% A)ELSE(ECHO ^ <A HREF="!ZoneFile!"^>!Zone!^ </ A ^> ^ < BR / ^> >>%OutFile%REM输出始终输出到DNS目录,因此将文件移至HTML目录。MOVE / Y%DNSDir%!ZoneFile!“%OutPath%!ZoneFile!”)ECHO。)

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

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

ENDLOCAL

本地

翻译自:

导出dns解析记录

转载地址:http://vczwd.baihongyu.com/

你可能感兴趣的文章
unity3d 射弹基础案例代码分析
查看>>
thinksns 分页数据
查看>>
os模块
查看>>
Python 约瑟夫圈问题
查看>>
如何在IntelliJ IDEA中配置Maven
查看>>
WPF RadioButton的探究,为啥选中一个其他都自动不选中了呢?
查看>>
C# 上传文件到指定路径
查看>>
LINQ to SQL vs. NHibernate
查看>>
基于Angular5和WebAPI的增删改查(一)
查看>>
windows 10 & Office 2016 安装
查看>>
最短路径(SP)问题相关算法与模板
查看>>
js算法之最常用的排序
查看>>
Python——交互式图形编程
查看>>
经典排序——希尔排序
查看>>
团队编程项目作业2-团队编程项目代码设计规范
查看>>
英特尔公司将停止910GL、915GL和915PL芯片组的生产
查看>>
团队编程项目作业2-团队编程项目开发环境搭建过程
查看>>
Stax解析XML示例代码
查看>>
cookie
查看>>
对顶堆学习笔记
查看>>