-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-zone-transfer.pl
63 lines (42 loc) · 1.03 KB
/
check-zone-transfer.pl
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/perl -w
# Compruebo que este el modulo instalado
BEGIN {
eval "use Net::DNS";
if ( $@ ) {
warn "Error al cargar el modulo: Net::DNS\n"
. "Instalar Modulo:\n"
. "\t\tcpan\n"
. "\t\tcpan> install Net::DNS\n";
exit ();
}
}
# Compruebe que este el argumento pasado
if ( @ARGV != 1 ) {
die "\nUso: $0 <dominio> \n\n"
. " <dominio> Dominio [ej -> dominio.com]\n"
;
}
$dominio= $ARGV[0];
chomp $dominio;
use Net::DNS;
$addr = shift || "$dominio";
$res = Net::DNS::Resolver->new;
$query = $res->query($addr, "NS");
if ($query) {
foreach $rr (grep { $_->type eq 'NS' } $query->answer) {
push @archivos, $rr->nsdname;
}
}
else {
warn "query failed: ", $res->errorstring, "\n";
}
$res = Net::DNS::Resolver->new( nameservers => [ @archivos ] );
my @zone = $res->axfr("$dominio");
if (@zone) {
foreach my $rr (@zone) {
$rr->print;
}
}
else {
print 'Zone transfer failed: ', $res->errorstring, "\n";
}