Solved

DNS Information

Posted on 2006-11-07
11
288 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
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 70

Expert Comment

by:Chris Dent
Comment Utility

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
Comment Utility
I mean DNS server IP address which we enter in TCP/IP Configuration
0
 
LVL 70

Expert Comment

by:Chris Dent
Comment Utility

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
 
LVL 24

Expert Comment

by:SunBow
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 6

Expert Comment

by:1peterx
Comment Utility
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
Comment Utility
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
Comment Utility
Open a command prompt and type IPCONFIG /ALL  .Your DNS servers will be listed in the output.
0
 
LVL 70

Expert Comment

by:Chris Dent
Comment Utility

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
Comment Utility
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 70

Accepted Solution

by:
Chris Dent earned 125 total points
Comment Utility

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
remove ie 11 and recover ie 10 8 24
Android: Contixo LA703 rooting 4 251
Staging desktop / laptop tools 5 90
PXE question 7 76
Introduction How to create multiboot configuration with XP\Vista and Windows 7 on it? And most important question - how to do this correctly so not to have any kind of nightmares we get when system gets screwed? First of all one should realize t…
Windows 10 is here and for most admins this means frustration and challenges getting that first working Windows 10 image. As in my previous sysprep articles, I've put together a simple help guide to get you through this process. The aim is to achiev…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now