Subject: | query() does not query all DNS servers in nameservers list |
- FreeBSD system with port p5-Net-DNS-0.48
- FreeBSD version: 4.10-RELEASE-p5
FreeBSD cvs.xyz.cz 4.10-RELEASE-p5 FreeBSD 4.10-RELEASE-p5 #0: Thu Jan 27 16:46:11 CET 2005 root@cvs.xyz.cz:/usr/src/sys/compile/cvs.xyz.cz i386
query() function does not query all DNS in nameservers list in case it receives REFUSED answer.
Consider following function:
sub dns_find_addrs {
my ($name) = @_;
my @addrs = ();
my $resolver = Net::DNS::Resolver->new;
# print $resolver->nameservers;
my $query = $resolver->query($name, 'ANY');
if ($query) {
foreach my $rec ($query->answer) {
if ($rec->type eq 'A' || $rec->type eq 'AAAA') {
push @addrs, $rec->address;
} elsif ($rec->type eq 'CNAME') {
my $query = $resolver->query($rec->rdatastr, 'ANY');
if ($query) {
foreach my $rec ($query->answer) {
$rec->type eq 'A' || $rec->type eq 'AAAA'
and push @addrs, $rec->address;
}
} else {
warn "DNS CNAME-based query failed: ", $resolver->errorstring, "\n";
}
}
}
} else {
warn "DNS query failed: ", $resolver->errorstring, "\n";
}
@addrs or warn "$name has no DNS records\n";
return @addrs;
}
When called on c12.xyz.cz and than on x3.xyz.cz,
it behaves like this:
13:48:02.037179 DNSCLIENT.4481 > DNSSERVER.53: 10432+ ANY? c12.xyz.cz. (32)
13:48:02.037448 DNSSERVER.53 > DNSCLIENT.4481: 10432* 1/2/2 CNAME lo0.c12.xyz.cz. (117)
13:48:02.050795 DNSCLIENT.1319 > DNSSERVER.53: 10433+ ANY? lo0.c12.xyz.cz. (36)
13:48:02.051161 DNSSERVER.53 > DNSCLIENT.1319: 10433* 1/2/2 A 195.1.2.2 (119)
13:48:02.056622 DNSCLIENT.3457 > DNSSERVER.53: 10434+ ANY? x3.xyz.cz. (40)
13:48:02.057163 DNSSERVER.53 > DNSCLIENT.3457: 10434 Refused 0/0/0 (40)
There are 3 DNS servers in the list, but after the first refuses to answer, the next 2 DNS servers are not queried.