Recipe13.5.Viewing a DNS Server s Zones


Recipe 13.5. Viewing a DNS Server's Zones

Problem

You want to view the supported zones on a DNS Server.

Solution

Using a graphical user interface

  1. From the Administrative Tools, open the DNS snap-in (dnsmgmt.msc).

  2. Connect to the DNS Server you want to view. In the left pane, right-click on DNS and select Connect to DNS Server. Select The following computer and enter the target server name. Click OK.

  3. In the left pane, expand the target server and click Forward Lookup Zones or Reverse Lookup Zones to view the supported zones in the right pane.

Using a command-line interface

Run the following command to view the zones on a local DNS Server:

> dnscmd <ServerName> /enumzones

The following command enumerates the zones on server dns01:

> dnscmd dns01 /enumzones

Using VBScript
' This code lists the zones that are supported by the specified server. ' ------ SCRIPT CONFIGURATION ------ strServer = "<ServerName>"  ' e.g., dns01.rallencorp.com ' ------ END CONFIGURATION --------- set objDNS = GetObject("winMgmts:\\" & strServer & "\root\MicrosoftDNS") set objDNSServer = objDNS.Get("MicrosoftDNS_Server.Name="".""") set objZones = objDNS.ExecQuery("Select * from MicrosoftDNS_Zone " & _                                 "Where DnsServerName = '" & _                                 objDNSServer.Name & "'")  WScript.Echo "Zones on " & objDNSServer.Name for each objZone in objZones    WScript.Echo " " & objZOne.Name next

Discussion

Using a graphical user interface

When you click on either Forward Lookup Zones or Reverse Lookup Zones in the left pane, the right pane contains a Type column that displays each zone's type.

Using a command-line interface

Using the /enumzones switch without any additional parameters displays all zones on the server. However, you can specify additional filters that limit the types of zones returned. With the Windows 2000 version of dnscmd, you can specify up to two filters:

Filter1:     /Primary     /Secondary     /Cache     /Auto-Created Filter2:     /Forward     /Reverse

With the Windows Server 2003 version of dnscmd, the filter behavior has changed. Instead of having two levels of criteria, you can specify one or more of the following:

/Primary /Secondary /Forwarder /Stub /Cache /Auto-Created /Forward /Reverse /Ds /File /DomainDirectoryPartition /ForestDirectoryPartition /CustomDirectoryPartition /LegacyDirectoryPartition /DirectoryPartition <PartitionName>

For more information on what each of these filters mean, run dnscmd /enumzones /?.

Using VBScript

To get the list of zones, I used a WQL query to find all MicrosoftDNS_Zone objects. You can add additional criteria to the WQL Select statement to return a subset of zones supported by the server if you need to. Look up the properties of the MicrosoftDNS_Zone class in MSDN to see the additional properties you can add to the query.

See Also

MSDN: MicrosoftDNS_Zone



Windows Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net