Dnscmd


Applies To: Windows Server 2008,Windows Server 2008 R2,Windows Server 2003 with SP1,Windows Server 2003 R2,Windows Server 2003

A command-line interface for managing DNS servers. This utility is useful in scripting batch files to help automate routine DNS management tasks, or to perform simple unattended setup and configuration of new DNS servers on your network.

Syntax


Copy Code

dnscmd <ServerName> <command> [<command parameters>]

Parameters

Parameter

Description

<ServerName>

The IP address or host name of a remote or local DNS server.

Commands

Command

Description

dnscmd /ageallrecords

Sets the current time on all time stamps in a zone or node.

dnscmd /clearcache

Clears the DNS server cache.

dnscmd /config

Resets the DNS server or zone configuration.

dnscmd /createbuiltindirectorypartitions

Creates the built-in DNS application directory partitions.

dnscmd /createdirectorypartition

Creates a DNS application directory partition.

dnscmd /deletedirectorypartition

Deletes a DNS application directory partition.

dnscmd /directorypartitioninfo

Lists information about a DNS application directory partition.

dnscmd /enlistdirectorypartition

Adds a DNS server to the replication set of a DNS application directory partition.

dnscmd /enumdirectorypartitions

Lists the DNS application directory partitions for a server.

dnscmd /enumrecords

Lists the resource records in a zone.

dnscmd /enumzones

Lists the zones hosted by the specified server.

dnscmd /exportsettings

Writes server configuration information to a text file.

dnscmd /info

Gets server information.

dnscmd /ipvalidate

Validates remote DNS servers.

dnscmd /nodedelete

Deletes all records for a node in a zone.

dnscmd /recordadd

Adds a resource record to a zone.

dnscmd /recorddelete

Removes a resource record from a zone.

dnscmd /resetforwarders

Sets DNS servers to forward recursive queries.

dnscmd /resetlistenaddresses

Sets server IP addresses to serve DNS requests.

dnscmd /startscavenging

Initiates server scavenging.

dnscmd /statistics

Queries or clears server statistics data.

dnscmd /unenlistdirectorypartition

Removes a DNS server from the replication set of a DNS application directory partition.

dnscmd /writebackfiles

Saves all zone or root-hint data to a file.

dnscmd /zoneadd

Creates a new zone on the DNS server.

dnscmd /zonechangedirectorypartition

Changes the directory partition on which a zone resides.

dnscmd /zonedelete

Deletes a zone from the DNS server.

dnscmd /zoneexport

Writes the resource records of a zone to a text file.

dnscmd /zoneinfo

Displays zone information.

dnscmd /zonepause

Pauses a zone.

dnscmd /zoneprint

Displays all records in the zone.

dnscmd /zonerefresh

Forces a refresh of the secondary zone from the master zone.

dnscmd /zonereload

Reloads a zone from its database.

dnscmd /zoneresetmasters

Changes the master servers that provide zone transfer information to a secondary zone.

dnscmd /zoneresetscavengeservers

Changes the servers that can scavenge a zone.

dnscmd /zoneresetsecondaries

Resets secondary information for a zone.

dnscmd /zoneresettype

Changes the zone type.

dnscmd /zoneresume

Resumes a zone.

dnscmd /zoneupdatefromds

Updates an Active Directory–integrated zone with data from Active Directory Domain Services (AD DS).

dnscmd /zonewriteback

Saves zone data to a file.

dnscmd /ageallrecords

Sets the current time on a time stamp on resource records at a specified zone or node on a DNS server.

Syntax


Copy Code

dnscmd [<ServerName>] /ageallrecords <ZoneName>[<NodeName>] | [/tree]|[/f]

Parameters






Remarks

Example

See Example 1: Set the current time on a time stamp to resource records.

dnscmd /clearcache

Clears the DNS cache memory of resource records on the specified DNS server.

Syntax


Copy Code

dnscmd [<ServerName>] /clearcache

Parameters


Sample usage

dnscmd dnssvr1.contoso.com /clearcache

dnscmd /config

Changes values in the registry for the DNS server and individual zones. Accepts server-level settings and zone-level settings.

Caution

Do not edit the registry directly unless you have no alternative. The registry editor bypasses standard safeguards, allowing settings that can degrade performance, damage your system, or even require you to reinstall Windows. You can safely alter most registry settings by using the programs in Control Panel or Microsoft Management Console (MMC). If you must edit the registry directly, back it up first. Read the Registry Editor Help for more information.

Server-level syntax


Copy Code

dnscmd [<ServerName>] /config <Parameter>

dnscmd /config

Modifies the configuration of the specified server.

Parameters



The following parameter values are described in the remainder of this section:

















































The DNS Server service can remove either or both of these names when it starts the first time, if it finds these names in an existing zone.












































































Zone-level syntax


Copy Code

dnscmd /config <Parameters>

dnscmd /config

Modifies the configuration of the specified zone.

Parameters


The following parameter values are documented in the remainder of this section:









Remarks

dnscmd /createbuiltindirectorypartitions

Creates a DNS application directory partition. When DNS is installed, an application directory partition for the service is created at the forest and domain levels. Use this command to create DNS application directory partitions that were deleted or never created. With no parameter, this command creates a built-in DNS directory partition for the domain.

Syntax


Copy Code

dnscmd [<ServerName>] /createbuiltindirectorypartitions [/forest] [/alldomains]

Parameters




dnscmd /createdirectorypartition

Creates a DNS application directory partition. When DNS is installed, an application directory partition for the service is created at the forest and domain levels. This operation creates additional DNS application directory partitions.

Syntax


Copy Code

dnscmd [<ServerName>] /createdirectorypartition <PartitionFQDN>

Parameters



dnscmd /deletedirectorypartition

Removes an existing DNS application directory partition.

Syntax


Copy Code

dnscmd [<ServerName>] /deletedirectorypartition <PartitionFQDN>

Parameters



dnscmd /directorypartitioninfo

Lists information about a specified DNS application directory partition.

Syntax


Copy Code

dnscmd [<ServerName>] /directorypartitioninfo <PartitionFQDN> [/detail]

Parameters




dnscmd /enlistdirectorypartition

Adds the DNS server to the specified directory partition's replica set.

Syntax


Copy Code

dnscmd [<ServerName>] /enlistdirectorypartition <PartitionFQDN>

Parameters



dnscmd /enumdirectorypartitions

Lists the DNS application directory partitions for the specified server.

Syntax


Copy Code

dnscmd [<ServerName>] /enumdirectorypartitions [/custom]

Parameters



dnscmd /enumrecords

Lists the resource records of a specified node in a DNS zone.

Syntax


Copy Code

dnscmd [<ServerName>] /enumrecords <ZoneName> <NodeName> [/type <RRType> <RRData>] [/authority] [/glue] [/additional] [/node | /child | /startchild<ChildName>] [/continue | /detail]

Parameters


















Sample usage

dnscmd /enumrecords test.contoso.com test /additional

dnscmd /enumzones

Lists the zones that exist on the specified DNS server.

Syntax


Copy Code

dnscmd [<ServerName>] /enumzones [/primary | /secondary | /forwarder | /stub | /cache | /auto-created] [/forward | /reverse | /ds | /file] [/domaindirectorypartition | /forestdirectorypartition | /customdirectorypartition | /legacydirectorypartition | /directorypartition <PartitionFQDN>]

Parameters



















Remarks

Example

See Example 2: Display a complete list of zones on a DNS server or Example 3: Display a list of autocreated zones on a DNS server.

dnscmd /exportsettings

Creates a text file that lists the configuration details of a DNS server. The text file is named DnsSettings.txt. It is located in the %systemroot%\system32\dns directory of the server.

Syntax


Copy Code

dnscmd [<ServerName>] /exportsettings

Parameters


Remarks

dnscmd /info

Displays settings from the DNS section of the registry of the specified server: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DNS\Parameters

Syntax


Copy Code

dnscmd [<ServerName>] /info [<Setting>]

Parameters



Remarks

Example

See Example 4: Display the IsSlave setting from a DNS server or Example 5: Display the RecursionTimeout setting from a DNS server.

dnscmd /ipvalidate

Tests whether an IP address identifies a functioning DNS server or whether the DNS server can act as a forwarder, a root hint server, or a master server for a specific zone.

Syntax


Copy Code

dnscmd [<ServerName>] /ipvalidate <Context> [<ZoneName>] [[<IPAddress>]…]

Parameters





Sample usage

dnscmd dnssvr1.contoso.com /ipvalidate /dnsservers 10.0.0.1 10.0.0.2

dnscmd dnssvr1.contoso.com /ipvalidate /zonemasters corp.contoso.com 10.0.0.2

dnscmd /nodedelete

Deletes all records for a specified host.

Syntax


Copy Code

dnscmd [<ServerName>] /nodedelete <ZoneName> <NodeName> [/tree] [/f]

Parameters






Example

See Example 6: Delete the records from a node.

dnscmd /recordadd

Adds a record to a specified zone in a DNS server.

Syntax


Copy Code

dnscmd [<ServerName>] /recordadd <ZoneName> <NodeName> <RRType> <RRData>

Parameters






Note

When you add a record, make sure that you use the correct data type and data format. For a list of resource record types and the appropriate data types, see Resource records reference.

Sample usage

dnscmd dnssvr1.contoso.com /recordadd test A 10.0.0.5

dnscmd /recordadd test.contoso.com test MX 10 mailserver.test.contoso.com

dnscmd /recorddelete

Deletes a resource record from a specified zone.

Syntax


Copy Code

dnscmd <ServerName> /recorddelete <ZoneName> <NodeName> <RRType> <RRData>[/f]

Parameters







Sample usage

dnscmd /recorddelete test.contoso.com test MX 10 mailserver.test.contoso.com

dnscmd /resetforwarders

Selects or resets the IP addresses to which the DNS server forwards DNS queries when it cannot resolve them locally.

Syntax


Copy Code

dnscmd [<ServerName>] /resetforwarders [<IPAddress> [,<IPAddress>]...][/timeout <TimeOut>] [/slave|/noslave]

Parameters







Remarks

Sample usage

dnscmd dnssvr1.contoso.com /resetforwarders 10.0.0.1 /timeout 7 /slave

dnscmd dnssvr1.contoso.com /resetforwarders /noslave

dnscmd /resetlistenaddresses

Specifies the IP addresses on a server that listens for DNS client requests.

Syntax


Copy Code

dnscmd [<ServerName>] /resetlistenaddresses [<ListenAddress>]

Parameters



Remarks

Sample usage

dnscmd dnssvr1.contoso.com /resetlistenaddresses 10.0.0.1

dnscmd /startscavenging

Tells a DNS server to attempt an immediate search for stale resource records in a specified DNS server.

Syntax


Copy Code

dnscmd [<ServerName>] /startscavenging

Parameter


Remarks

Sample usage

dnscmd dnssvr1.contoso.com /startscavenging

dnscmd /statistics

Displays or clears data for a specified DNS server.

Syntax


Copy Code

dnscmd [<ServerName>] /statistics [<StatID>] [/clear]

Parameters



The following is a list of numbers that can be specified and the corresponding statistic that displays:

















Remarks

Examples

See Example 7: Display time statistics for a DNS server or Example 8: Display NbstatMem statistics for a DNS server.

dnscmd /unenlistdirectorypartition

Removes the DNS server from the specified directory partition's replica set.

Syntax


Copy Code

dnscmd [<ServerName>] /unenlistdirectorypartition <PartitionFQDN>

Parameters



dnscmd /writebackfiles

Checks the DNS server memory for changes, and writes them to persistent storage.

Syntax


Copy Code

dnscmd [<ServerName>] /writebackfiles [<ZoneName>]

Parameters



Remarks

Sample usage

dnscmd dnssvr1.contoso.com /writebackfiles

dnscmd /zoneadd

Adds a zone to the DNS server.

Syntax


Copy Code

dnscmd [<ServerName>] /zoneadd <ZoneName> <ZoneType> [/dp <FQDN>| {/domain|/enterprise|/legacy}]

Parameters
















Remarks

Sample usage

dnscmd dnssvr1.contoso.com /zoneadd test.contoso.com /dsprimary

dnscmd dnssvr1.contoso.com /zoneadd secondtest.contoso.com /secondary 10.0.0.2

dnscmd /zonechangedirectorypartition

Changes the directory partition on which the specified zone resides.

Syntax


Copy Code

dnscmd [<ServerName>] /zonechangedirectorypartition <ZoneName>] {[<NewPartitionName>] | [<ZoneType>] }

Parameters








dnscmd /zonedelete

Deletes a specified zone.

Syntax


Copy Code

dnscmd [<ServerName>] /zonedelete <ZoneName> [/dsdel] [/f]

Parameters





Example

See Example 9: Delete a zone from a DNS server.

dnscmd /zoneexport

Creates a text file that lists the resource records of a specified zone.

Syntax

Art Imagednscmd [<ServerName>] /zoneexport <ZoneName> <ZoneExportFile>

Parameters




Remarks

Example

See Example 10: Export zone resource records list to a file.

dnscmd /zoneinfo

Displays settings from the section of the registry of the specified zone: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DNS\Parameters\Zones\<ZoneName>

Syntax


Copy Code

dnscmd [<ServerName>] /zoneinfo <ZoneName>  [<Setting>]

Parameters




Remarks

Example

See Example 11: Display RefreshInterval setting from the registry or Example 12: Display Aging setting from the registry.

dnscmd /zonepause

Pauses the specified zone, which then ignores query requests.

Syntax


Copy Code

dnscmd [<ServerName>] /zonepause <ZoneName>

Parameters



Remarks

Sample usage

dnscmd dnssvr1.contoso.com /zonepause test.contoso.com

dnscmd /zoneprint

Lists the records in a zone.

Syntax


Copy Code

dnscmd [<ServerName>] /zoneprint <ZoneName>

Parameters



dnscmd /zonerefresh

Forces a secondary DNS zone to update from the master zone.

Syntax


Copy Code

dnscmd <ServerName> /zonerefresh <ZoneName>

Parameters



Remarks

Sample usage

dnscmd dnssvr1.contoso.com /zonerefresh test.contoso.com

dnscmd /zonereload

Copies zone information from its source.

Syntax


Copy Code

dnscmd <ServerName> /zonereload <ZoneName>

Parameters



Remarks

Sample usage

dnscmd dnssvr1.contoso.com /zonereload test.contoso.com

dnscmd /zoneresetmasters

Resets the IP addresses of the master server that provides zone transfer information to a secondary zone.

Syntax


Copy Code

dnscmd <ServerName> /zoneresetmasters <ZoneName> [/local] [<IPAddress> [<IPAddress>]...]

Parameters





Remarks

Sample usage

dnscmd dnssvr1.contoso.com /zoneresetmasters test.contoso.com 10.0.0.1

dnscmd dnssvr1.contoso.com /zoneresetmasters test.contoso.com /local

dnscmd /zoneresetscavengeservers

Changes the IP addresses of the servers that can scavenge the specified zone.

Syntax


Copy Code

dnscmd [<ServerName>] /zoneresetscavengeservers <ZoneName> [<IPAddress> [<IPAddress>]...]

Parameters




Remarks

Sample usage

dnscmd dnssvr1.contoso.com /zoneresetscavengeservers test.contoso.com 10.0.0.1 10.0.0.2

dnscmd /zoneresetsecondaries

Specifies a list of IP addresses of secondary servers to which a master server responds when it is asked for a zone transfer.

Syntax


Copy Code

dnscmd [<ServerName>] /zoneresetsecondaries <ZoneName> {/noxfr | /nonsecure | /securens | /securelist <SecurityIPAddresses>} {/nonotify | /notify | /notifylist <NotifyIPAddresses>}

Parameters














Remarks

Sample usage

dnscmd dnssvr1.contoso.com /zoneresetsecondaries test.contoso.com /noxfr /nonotify

dnscmd dnssvr1.contoso.com /zoneresetsecondaries test.contoso.com /securelist 11.0.0.2

dnscmd /zoneresettype

Changes the type of the zone.

Syntax


Copy Code

dnscmd [<ServerName>] /zoneresettype <ZoneName> <ZoneType> [/overwrite_mem | /overwrite_ds]

Parameters














Remarks

Sample usage

dnscmd dnssvr1.contoso.com /zoneresettype test.contoso.com /primary /file test.contoso.com.dns

dnscmd dnssvr1.contoso.com /zoneresettype second.contoso.com /secondary 10.0.0.2

dnscmd /zoneresume

Starts a specified zone that was previously paused.

Syntax


Copy Code

dnscmd <ServerName> /zoneresume <ZoneName>

Parameters



Remarks

Sample usage

dnscmd dnssvr1.contoso.com /zoneresume test.contoso.com

dnscmd /zoneupdatefromds

Updates the specified Active Directory–integrated zone from AD DS.

Syntax


Copy Code

dnscmd <ServerName> /zoneupdatefromds <ZoneName>

Parameters



Remarks

Sample usage

dnscmd dnssvr1.contoso.com /zoneupdatefromds

dnscmd /zonewriteback

Checks DNS server memory for changes that are relevant to a specified zone, and writes them to persistent storage.

Syntax


Copy Code

dnscmd <ServerName> /zonewriteback <ZoneName>

Parameters



Remarks

Sample usage

dnscmd dnssvr1.contoso.com /zonewriteback test.contoso.com