DNS Resolver

Posted by Jason Noble on 08/19/2008 in dns, perl |

I had a list of domains that needed their MX records updated. I first wanted to make sure that our DNS servers were authoritative for those zones.

I used Perl and the Net::DNS CPAN module to figure out the NS records for each domain.

[text]
#!/usr/bin/perl

use Net::DNS;

my $resolver = Net::DNS::Resolver->new;
my $query = "";
my $domain = "";

open(FILE, "</tmp/domains.txt");
while(<file>) {
chomp;
$domain = $_;
$query = $resolver->query($domain, "NS");
print $domain;
if($query) {
foreach my $rr ($query->answer) {
next unless $rr->type eq "NS";
print ",", $rr->nsdname;
}
print "\n";
} else {
print ",DOES NOT RESOLVE\n";
}
}
[/text]

Copyright © 2008-2024 Jason Noble's Technical Adventures All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.