-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathcheck-nsservers-know
More file actions
29 lines (24 loc) · 832 Bytes
/
check-nsservers-know
File metadata and controls
29 lines (24 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl -w
use strict;
use warnings;
use Net::DNS;
# takes a single domain, retrieves the ns records for it and then
# queries each server to ensure it can answer for that domain
my $domain = shift;
my $res = Net::DNS::Resolver->new;
my $query = $res->query( $domain, "NS");
if ($query) {
foreach my $rr (grep { $_->type eq 'NS' } $query->answer) {
$res->nameservers( $rr->nsdname);
my $lookup = $res->query( $domain, "A");
if ($lookup) {
foreach my $record (grep { $_->type eq 'A' } $lookup->answer) {
print $domain, " ", $rr->nsdname, " ", $record->address, "\n";
}
} else {
warn "A record query for [$domain] against [", $rr->nsdname, "] failed: ", $res->errorstring, "\n";
}
}
} else {
warn "NS record query for [$domain] failed : ", $res->errorstring, "\n";
}