Subject: | Net::DNS appears to use only the last nameserver line from resolv.conf |
Date: | Sat, 13 Sep 2014 01:58:45 +0000 |
To: | "bug-Net-DNS [...] rt.cpan.org" <bug-Net-DNS [...] rt.cpan.org> |
From: | "Phil Hedrick (phhedric)" <phhedric [...] cisco.com> |
Most systems seem to have multiple nameserver lines in resolv.conf yet in Net/DNS/Resolver/Base.pm the code seems to only use the last nameserver line.
This causes problems if the last nameserver listed in resolve.conf happens to be further away or becomes unavailable.
Recommend this code or something like it:
5.14.1/x86_64-linux-thread-multi/Net/DNS/Resolver/Base.pm
249:
/^nameserver/ && do {
my @temp_ns;
( $keyword, @temp_ns ) = split;
foreach my $ns (@temp_ns) {
$ns = '0.0.0.0<http://0.0.0.0/> 'if $ns eq '0';
}
push @ns, @temp_ns;
next;
$ perl -v
This is perl 5, version 14, subversion 1 (v5.14.1) built for x86_64-linux-thread-multi
$ uname -a
Linux 2.6.32-358.6.1.el6.x86_64 #1 SMP Fri Mar 29 16:51:51 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
Here’s a diff
$ diff Base.pm NewBase.pm
248d247
<
250,252c249,252
< ( $keyword, @ns ) = split;
< foreach my $ns (@ns) {
< $ns = '0.0.0.0' if $ns eq '0';
---
Show quoted text
> my @temp_ns;
Show quoted text> ( $keyword, @temp_ns ) = split;
Show quoted text> foreach my $ns (@temp_ns) {
Show quoted text> $ns = '0.0.0.0 'if $ns eq '0';
253a254
Show quoted text> push @ns, @temp_ns;
Here’s a patch
$ diff -p Base.pm NewBase.pm
*** Base.pm 2014-09-12 21:40:56.351700071 -0400
--- NewBase.pm 2014-09-12 21:40:14.504700125 -0400
*************** sub read_config_file {
*** 245,256 ****
( $keyword, @searchlist ) = split;
next;
};
-
/^nameserver/ && do {
! ( $keyword, @ns ) = split;
! foreach my $ns (@ns) {
! $ns = '0.0.0.0' if $ns eq '0';
}
next;
};
}
--- 245,257 ----
( $keyword, @searchlist ) = split;
next;
};
/^nameserver/ && do {
! my @temp_ns;
! ( $keyword, @temp_ns ) = split;
! foreach my $ns (@temp_ns) {
! $ns = '0.0.0.0 'if $ns eq '0';
}
+ push @ns, @temp_ns;
next;
};
}
Regards,
Phil