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.

We have a Windows Server 2k8 server running DNS services for our domain. Some of the forward looks up don't have reverse lookups and some of the reverse lookups don't have forward lookups. DNS has been poorly managed (pre-me) and this seems to be a situation of too many cooks and a problem we had with a runaway script a couple years ago (also pre-me). Does anyone have a quick way (hopefully scripted) that we can verify and fix these?

share|improve this question

2 Answers 2

This is a script that I had lying around for other reasons, very simple and not a full match, but in a pinch it will do. You will need a Unix-like box (Linux or OS X) that knows about the Windows DNS server.

Step 1: Dump your DNS records to a text file called dns.txt, with each record's name or IP being the only entry, one per line. Put this text file in the same directory as the PHP script, open a terminal, and "cd" to that directory. Step 2: Run this script against it and pipe the results to a file. ("php ./dnscount.php > results.txt") Step 3: Take the result file and dice it (probably using Excel's import text feature) so that you have a text file containing only the resolved entries. Save THAT file as dns.txt. Step 4: Run the script again. The negative results will be the ones you want to fix.

Again, I just happened to have this lying around so your mileage will vary, but I know it will work well enough to do what you need in about half an hour (most of that time spent getting your Linux box and dicing various text files for the input). Also, you may want to strip out the pre and br tags.

<?php
$dnsfile = fopen('dnslist.txt', 'r');
$whilenot = 1;
echo "<PRE>";
while($whilenot){
    $whilenot = 0;
    $hostname = fgetss($dnsfile);
    if($hostname){
        //$hostcommand =  "host -la -t any " .$hostname. "";
        $hostcommand =  "host " .$hostname. "";
        passthru($hostcommand);
        $whilenot = 1;
        print('<br>');
    }
}
echo "</PRE>";
fclose($dnsfile);
?>
share|improve this answer

Sorry, I don't have any thing already written, but I can point you towards a great built-in tool. The utility dnscmd.exe is the Windows command line tool for managing a DNS server. If you are handy with Windows shell scripting this should be a great starting point. This way you won't need PHP and Linux/Unix as shown in another answer. If you don't already have this infrastructure it could be very time consuming to get that setup.

This was a great site I used to get more familiar: How can I easily administer DNS servers by using the command prompt?

share|improve this answer

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.