Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 98851
Status: rejected
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: phhedric [...] cisco.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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
From: rwfranks [...] acm.org
Bug in 0.75 only cd /tmp echo nameserver 192.0.2.1 > .resolv.conf echo nameserver 192.0.2.2 >> .resolv.conf echo nameserver 192.0.2.3 >> .resolv.conf perl -e 'use Net::DNS; print Net::DNS->version, "\n"' perl -e 'use Net::DNS; Net::DNS::Resolver->new()->print' 0.79 ;; RESOLVER state: ;; domain = ;; searchlist = ;; nameservers = 192.0.2.1 192.0.2.2 192.0.2.3 ;; port = 53 ;; srcport = 0 ;; srcaddr = 0.0.0.0 ;; tcp_timeout = 120 ;; retrans = 5 retry = 4 ;; usevc = 0 stayopen = 0 ;; defnames = 1 dnsrch = 1 ;; recurse = 1 igntc = 0 ;; force_v4 = 0 prefer_v6 = 0 ;; debug = 0