Subject: | Net::DNS appears to round-robin nameservers and/or domains listed in resolv.conf when multiple are listed |
Date: | Mon, 25 Apr 2011 16:08:18 -0700 |
To: | <bug-Net-DNS [...] rt.cpan.org> |
From: | <Greg.Webster [...] westfraser.com> |
$ perl -v
This is perl, v5.8.8 built for i386-linux-thread-multi
$ perl
use Net::DNS;
print Net::DNS->version, "\n";
0.59
$ uname -a
Linux redacted.domain.ca 2.6.18-194.32.1.el5PAE #1 SMP Wed Jan 5 18:43:13
EST 2011 i686 i686 i386 GNU/Linux
Report:
Net::DNS appears to round-robin nameservers and/or domains listed in
resolv.conf when multiple are listed. Hopefully this bug is not already
fixed in a later version...I searched but could not see anything
applicable.
For example, my resolv.conf contains two domains and three nameservers,
like this:
$ cat /etc/resolv.conf
search wft.ca wwd.com
nameserver 10.0.228.1001
nameserver 10.10.228.1002
nameserver 10.0.228.1003
(Domains and IPs changed for privacy reasons)
Nameservers 1 and 2 correspond DNS servers on the first domain and
nameserver 3 for the second domain.
When I do a query of an hostname which only exists in the second domain, it
only resolves sporadically (about half the time).
Here is the code I am using which gives this result:
#!/usr/bin/perl
use Net::DNS;
my $res = Net::DNS::Resolver->new;
my $infile = "/tmp/gwk_hosts.txt";
open (INFILE, $infile) || die "Could not open $infile for reading";
while (<INFILE>) {
my $hostip = "";
($thishost,$thisip) = split(/\t/,$_);
next if ($thishost eq "name");
chomp $thisip;
#print "Host: $thishost - IP: $thisip\n";
my $query = $res->search("$thishost");
if ($query) {
foreach my $rr ($query->answer) {
next unless $rr->type eq "A";
$hostip = $rr->address;
}
} else {
warn "query failed: ", $res->errorstring, "\n";
}
if ($hostip ne $thisip) {
print "Error: $thishost resolves to $hostip not $thisip\n";
}
}