We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Batch File: Monitor DNS activities

Medium Priority
563 Views
Last Modified: 2012-08-14
Hi there,

I need to create a batch file to monitor our Windows Server 2003 DNS server, and all changes are to be displayed within the DOS window.

Thanks for your help,
Rene
Comment
Watch Question

Chris DentPowerShell Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
Do you have any flexibility in that? What you ask is hard enough in a decent scripting language, the batch requirement (if it is a requirement) makes it obscene.

And if you get that far, what kind of changes? Changes to server settings? Record additions / removals?

Chris

Author

Commented:
Hey Chris,

Monitor Record additions / removals is what I need.

Well, my preference is batch file since I understand it. I do not know VB script (near future learning project).

I'd be happy if, I would get just a command line that will connect to the remote DNS server and give me the list of all DNS records. I'll script the rest, unless you have something.

Thanks,
Rene


Chris DentPowerShell Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
Hmm well if you enable Zone Transfers to whatever server you want to run the script from this will give you a full list:

nslookup
ls -d domain.com

You might find it easier to grab dig:

http://members.shaw.ca/nicholas.fong/dig/

Then use:

dig domain.com axfr

Both perform a zone transfer, and both will give you the full list (SOA repeated twice). Does that help scripting it in batch?

If not, both AD (if AD is involved) and WMI can tell you information about records in zones, useful for the more advanced scripting languages.

Chris

Author

Commented:
You you mind giving me the WMIC command line?
Chris DentPowerShell Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:

It's complex, you have to loop through, one class per record type and you really really need a filter (because that's how you target zones, and avoid the cached records).

So you'd at least want:

MicrosoftDNS_AType
MicrosoftDNS_CNAMEType
MicrosoftDNS_NSType
MicrosoftDNS_SOAType

Then if you use anything beyond the basic, one for each (SRV, MX, and so on).

I'm afraid I can't give you an example, I'm at home, no MS DNS servers here to test against. All are in the Root\MicrosoftDNS namespace if it helps and you want to GET OwnerName and ContainerName (if I remember correctly).

Documentation for the classes is here:

http://msdn.microsoft.com/en-us/library/ms682123%28v=VS.85%29.aspx

Sorry it's not more helpful. If I can convert you to PowerShell you can use my DNS module ;)

Chris

Author

Commented:
I'll give it a try with PowerShell
PowerShell Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks Chris,

FYI, I currently have another question for monitoring the DHCP server.

https://www.experts-exchange.com/Networking/Protocols/DHCP/Q_26983728.html

Thanks again and cheers,
Rene
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.