Link to home
Start Free TrialLog in
Avatar of plusign
plusign

asked on

DNS Information

How can i get DNS information from all server in domain?

Any suggestion on command line eithr batch file, vb script, utility, etc are welcomed!
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image


What kind of DNS information? AD Environment I assume? Windows DNS Servers? And all set to AD Integrated?

DNSCMD is likely to be the best tool here, it's part of the Windows Support Tools which can be downloaded here:

http://www.microsoft.com/downloads/details.aspx?FamilyId=49AE8576-9BB9-4126-9761-BA8011FABF38&displaylang=en

There are a number of commands that would seem to be immediately useful:

dnscmd <DNSServerName> /EnumZones
dnscmd <DNSServerName> /ZoneInfo <ZoneName>
dnscmd <DNSServerName> /ZoneExport <ZoneName> <FileName>

There are many more, but which are useful depends entirely on what you're looking for. It would be entirely possible to wrap a bit of VbScript around this to pull more specific details.

HTH

Chris
Avatar of plusign
plusign

ASKER

I mean DNS server IP address which we enter in TCP/IP Configuration

As in the existing TCP/IP configuration?

In that case it's exposed in WMI and can be retrieved like this:


On Error Resume Next

Const WBEM_RETURN_IMMEDIATELY = &h10
Const WBEM_FORWARD_ONLY = &h20

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", _
      "WQL", WBEM_RETURN_IMMEDIATELY + WBEM_FORWARD_ONLY)

For Each objItem In colItems
      strDNSServerSearchOrder = Join(objItem.DNSServerSearchOrder, ",")
      WScript.Echo "DNSServerSearchOrder: " & strDNSServerSearchOrder
Next


In the example above strComputer can be set to pretty much anything, it's just a matter of deciding exactly what you want to check and what you want to do with the information once you have it. So, how did you prefer to have it all? And is this just for Servers and not workstations within an AD Domain?

Chris
Use the Name Server Lookup (nsLookup)

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\>nslookup
Default Server:  <server>
                 <address>
> ?
Commands:   (identifiers are shown in uppercase, [] means optional)
NAME            - print info about the host/domain NAME using default server
NAME1 NAME2     - as above, but use NAME2 as server
help or ?       - print info on common commands
set OPTION      - set an option
    all                 - print options, current server and host
    [no]debug           - print debugging information
    [no]d2              - print exhaustive debugging information
    [no]defname         - append domain name to each query
    [no]recurse         - ask for recursive answer to query
    [no]search          - use domain search list
    [no]vc              - always use a virtual circuit
    domain=NAME         - set default domain name to NAME
    srchlist=N1[/N2/.../N6] - set domain to N1 and search list to N1,N2, etc.
    root=NAME           - set root server to NAME
    retry=X             - set number of retries to X
    timeout=X           - set initial time-out interval to X seconds
    type=X              - set query type (ex. A,ANY,CNAME,MX,NS,PTR,SOA,SRV)
    querytype=X         - same as type
    class=X             - set query class (ex. IN (Internet), ANY)
    [no]msxfr           - use MS fast zone transfer
    ixfrver=X           - current version to use in IXFR transfer request
server NAME     - set default server to NAME, using current default server
lserver NAME    - set default server to NAME, using initial server
finger [USER]   - finger the optional NAME at the current default host
root            - set current default server to the root
ls [opt] DOMAIN [> FILE] - list addresses in DOMAIN (optional: output to FILE)
    -a          -  list canonical names and aliases
    -d          -  list all records
    -t TYPE     -  list records of the given type (e.g. A,CNAME,MX,NS,PTR etc.)
view FILE           - sort an 'ls' output file and view it with pg
exit            - exit the program
Hi plusign,

Open a CMD window.
Type: nslookup
Then type: ls yourdomain.com
you will get a list of all the server names in yourdomain.com and their IP addresses.

Regards,
Peter
Hi plusign (again!),

You wanted to know how to batch process this...
Create a file named dom.cmd and put this in it:
nslookup <dom.txt

Create a 2nd file named dom.txt and put this in it:
ls yourdomain.com

the type: dom
and you'll get the list of servers and addresses.

Amend dom.cmd to:
nslookup <dom.txt >list.txt
and you'll get your list in list.txt instead of on screen.

Regards,
Peter
Avatar of plusign

ASKER

I guess some of you misunderstood my question. I am not looking for how to convert domain name to IP address, but I am trying to find out the DNS server IP address (preferred/alternate) which is configured in network settings.
Open a command prompt and type IPCONFIG /ALL  .Your DNS servers will be listed in the output.

Plusign, that's what the WMI query does above. If you're happy with that method then it can be expanded to automatically return that information for any PC or Server within the domain. Just let me know what you'd prefer.

Chris
Avatar of plusign

ASKER

Finally, my friend got the simple solution. I just run this command:

FOR /F %%i IN (serverlist.txt) DO psexec \\%%i ipconfig /all |FIND "DNS Servers" > result.txt

But the batch file can only capture the first line of DNS server (for my case, it's OK).

Chris-Dent,
Your script is cool!!! How can i custome to capture from all server from specific OU or any centralize serverlist?
ASKER CERTIFIED SOLUTION
Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial