Solved

DNS Information

Posted on 2006-11-07
11
298 Views
Last Modified: 2012-06-21
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!
0
Comment
Question by:plusign
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 71

Expert Comment

by:Chris Dent
ID: 17887880

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
0
 

Author Comment

by:plusign
ID: 17889736
I mean DNS server IP address which we enter in TCP/IP Configuration
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 17889831

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
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Expert Comment

by:SunBow
ID: 17890059
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
0
 
LVL 6

Expert Comment

by:1peterx
ID: 17897347
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
0
 
LVL 6

Expert Comment

by:1peterx
ID: 17897455
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
0
 

Author Comment

by:plusign
ID: 17897971
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.
0
 
LVL 3

Expert Comment

by:superiz
ID: 17898289
Open a command prompt and type IPCONFIG /ALL  .Your DNS servers will be listed in the output.
0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 17899924

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
0
 

Author Comment

by:plusign
ID: 17928152
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?
0
 
LVL 71

Accepted Solution

by:
Chris Dent earned 125 total points
ID: 17960763

Sorry for the delay, lost track of a few recently.

If it's a list you can do it like this:



On Error Resume Next

Const SERVER_LIST = "ServerList.txt"

Const WBEM_RETURN_IMMEDIATELY = &h10
Const WBEM_FORWARD_ONLY = &h20

Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objFile = objFileSystem.GetFile(SERVER_LIST)
Set objStream = objFile.OpenAsTextStream(1, 0)

Do While Not objStream.AtEndOfStream
     strComputer = objStream.ReadLine

     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
     Set colItems = Nothing
     Set objWMIService = Nothing
Loop


For a specific OU you could bind to the OU and run for every computer in there:



On Error Resume Next

Const WBEM_RETURN_IMMEDIATELY = &h10
Const WBEM_FORWARD_ONLY = &h20

Set objOU = GetObject("LDAP://OU=SomeOU,OU=SomeWhere,DC=YourDomain,DC=local")
objOU.Filter = Array("computer")

For Each objComputer in objOU
     strComputer = objComputer.Get("name")

     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
     Set colItems = Nothing
     Set objWMIService = Nothing
Next
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello I read in a discussion about a person who configured a very simple mirror RAID with two hard drives; the system and data were on the same partition. He asked how to repair the system as it was not booting up anymore. In his case running …
Just about everyone has an old PC laying around.  Ask anyone in the IT industry, whether they are a professional or play in it as a hobby.  From outdated Desktops to cheap "throwaway" laptops, they are all around and not as hard to "fix up" as you m…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question