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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.