So i have taken the advise of using Net::DNS. For simplicity, I have located code on the web and modified it. For the most part I get what i need. I have figured out how to do the name servers, but unfortunately, i don't think it it meets my needs. But I could be missing something. I have specified 2x nameservers. the x.x.50.50 is not online currently. Is there a way using Net:DNS, it would attempt to query the name server, and produce an "error" to the fact of no response, then go to the next nameserver, so on and so forth? If the name server is responding, I would want to display "Name Server - <IP> - followed by all the results". Below is the code I attempted. The "query failed", currently never get executed because the other nameserver is responding
use warnings; use strict; use Net::DNS; use Data::Dumper::Simple; my $dnsserver; my @resolver; #@resolver=qw[192.168.50.50, 192.168.10.98]; #foreach $dnsserver (@resolver) { #print "Validating Entries against $dnsserver\n"; my $resolver = Net::DNS::Resolver->new( nameservers =>[qw(192.168.50.50 192.168.10.98)], recurse => 0, debug => 1, ); my $ip = "192.168.50.70"; print " ##### Resolver State ##### \n"; $resolver->print; print "\n\n ##### End Resolver State ##### \n"; my $target_ip = join('.', reverse split(/\./, $ip)).".in-addr.arpa +"; my $query = $resolver->query($target_ip, 'PTR'); my $reply = $resolver->search("garytest.fedlab.local"); #warn Dumper(\$query, \$reply); if ($query) { foreach my $answer ($query->answer) { next unless $answer->type eq 'PTR'; print $answer->rdatastr, "\n"; } } else { print "query failed: ", $resolver->errorstring, "\n"; } if ($reply) { foreach my $rr ($reply->answer) { next unless $rr->type eq "A"; print $rr->address, "\n"; } } else { warn "query failed: ", $resolver->errorstring, "\n"; } #}
In reply to Re: Specifying a DNS resolver
by g_speran
in thread Specifying a DNS resolver
by g_speran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |