Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm about to switch a mail server. I'd like to be able to search Microsoft DNS where

MX Server == 'mail.foo.com'

Or, perhaps

CNAME.name == 'mail' OR CNAME.value == 'mail.foo.com'

Does anyone know of a tool that will permit to accomplish something like this?

share|improve this question
4  
It is very hard to understand what it is you're asking. My instinct says you're looking for something like nslookup -type=MX mail.foo.com –  Jeff Ferland Feb 21 '12 at 16:57
    
No. I have a Microsoft DNS server, it has 150,000 domains. I want to find domains that have the MX server already set to mail.foo.com so I know what the change I want to make will effect. –  Evan Carroll Feb 21 '12 at 17:15
    
Anything wrong with a perl / python / ruby / whatever script that looks up the MX record for all 150,000 domains? That's the simplest method as far as human time is concerned. –  Jeff Ferland Feb 21 '12 at 18:35
    
How would I get the list of domains the DNS server provides, in the end grepping through the folder as mentioned in my answer was by far the best solution for me. –  Evan Carroll Feb 21 '12 at 18:53
1  
If you don't know the list of domain you're authoritative for, then yes I'd get grepping. –  Jeff Ferland Feb 21 '12 at 19:11
add comment

4 Answers

Here are a few ideas:

  • If you're using zone files to store the zones (i.e. not Active Directory integrated zones) then you can just use find, findstr, or your favorite grep port to search the zone files (stored in %SystemRoot%\system32\dns by default).

  • You could use nslookup or dig and perform queries against the DNS server

  • You can use the command-line dnscmd tool to dump zones and search them with find, findstr, grep, etc.

  • You could sort the columns in the DNS management console snap-in to cause the data you're looking for to appear in a known location

I'm not exactly sure I understand what you're looking for, but I'd lean toward the first two ideas as being the best ways. I do find myself, from time to time, sorting the columns in the DNS management console to quickly see if I've created a given record.

Edit:

150,000 domains. Zow.

You could probably hack the script in this answer I wrote to loop thru your zones looking for the records you want. It shouldn't be too bad.

share|improve this answer
    
Where do I get dnscmd, for Windows Server 2008? –  Evan Carroll Feb 21 '12 at 18:02
    
It's part of the Windows Support Tools. They're in the "SUPPORT\TOOLS" folder on the installation media. –  Evan Anderson Feb 21 '12 at 18:07
    
gha. I don't have the installation media it's on a cloud server. –  Evan Carroll Feb 21 '12 at 18:14
    
Download an evaluation version of Windows Server 2008 R2, if nothing else. –  Evan Anderson Feb 21 '12 at 18:14
1  
@EvanCarroll: If the zones are stored in files then grepping them is fine. Active Directory integrated zones won't be stored in files. –  Evan Anderson Feb 22 '12 at 17:45
show 1 more comment

nslookup

    set type=mx
    domain.com

when you press enter, the dns will resolve all the mail type records regarding that specific domain.

share|improve this answer
    
but, I want to query the local DNS server for where the mail record equals something -- I do not want to dump the MX record for a single domain. –  Evan Carroll Feb 21 '12 at 17:13
add comment

Okay, so this is probably going off the reservation as far as the "official method" but this is what I've always done. As long as the zone files are being stored on disk (external domains, not AD), you can use the following Powershell script to search the text zone files for specific IP addresses/host names/record types.

Param ([String]$searchPattern)

      $resultsFormat = @{Expression={$_.Filename};Label="File"},
                       @{Expression={$_.LineNumber};Label="Line"},
                       @{Expression={$_.Line};Label="Text"}

      $searchResults = Get-ChildItem -Filter "*.dns" | Select-String -Pattern $searchPattern | ft $resultsFormat -AutoSize

If ($searchResults) {$searchResults} Else {Write-Host "`nNo search results`n"}

Save this script to the "C:\Windows\System32\DNS" folder and name it "query.ps1". Then run it from Powershell by changing to that directory and typing "query.ps1 ".

I share this folder on all my DNS servers (for admins only) and then map a drive to it. This way I can run the script from my workstation by executing it from the mapped drive. Easy Peasy.

Examples:

Find all the DNS entries with "192.168.1.1" in them

.\query.ps1 192.168.1.1

Find all the DNS entries with "www" in them

.\query.ps1 www

Find all the DNS entries with "mx" in them

.\query.ps1 mx
share|improve this answer
add comment
up vote -5 down vote accepted
  1. Install cygwin.
  2. Browse to C:\Windows\System32\dns
  3. Use grep.

Like any Microsoft Problem, it's most easily solved with the Cygwin port of the Linux toolset.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.