Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

UPDATE: Fixed. Problem was not Perl. Permissions were incorrect on /etc/nsswitch.conf which prevented Perl from using it.

Grettings,

Some code that uses Net::DNS works on RHEL5 hosts, (Net::DNS 0.59), but fails (query is undef) on RHEL6 (Net::DNS 0.65). What might the problem be?

Code sample:

#!/tool/pandora64/bin/perl5.8.8 use Net::DNS; use Data::Dumper; use strict; use warnings; my $host = $ARGV[0]; my @domains; open(RESOLV, "/etc/resolv.conf") or die("couldn't open /etc/resolv.con +f for reading!"); while(<RESOLV>) { next unless /^search\s+(.*)/; my $str = $1; @domains = split(/\s+/, $str); } close RESOLV; my $res = new Net::DNS::Resolver; $res->debug(1); # Remove all subdomain stuff $host =~ s/\..*//g; # Now figure out the FQDN by choosing from the entries in resolv.conf. my ( $fqhost, $query ); foreach(@domains) { print "query -> $host.$_\n"; $query = $res->query("$host.$_"); if($query) { $fqhost = $host . "." . $_; last; } } unless(defined $fqhost) { print Dumper( \@domains ); print Dumper( \$query ); # If we can't resolve the IP for a given hostname, # we skip that host completely. die "WARNING: Skipping host: $host, query: $query -- no DNS entry! +"; }

RHEL5 output:

$ dnscheck.pl atlrhel5cs query -> atlrhel5cs.example.com ;; query(atlrhel5cs.example.com) ;; setting up an AF_INET() family type UDP socket ;; send_udp(127.0.0.1:53) ;; answer from 127.0.0.1:53 : 52 bytes ;; HEADER SECTION ;; id = 32277 ;; qr = 1 opcode = QUERY aa = 0 tc = 0 rd = 1 ;; ra = 1 ad = 0 cd = 0 rcode = NOERROR ;; qdcount = 1 ancount = 1 nscount = 0 arcount = 0 ;; QUESTION SECTION (1 record) ;; atlrhel5cs.example.com. IN A ;; ANSWER SECTION (1 record) atlrhel5cs.example.com. 9270 IN A 10.180.10.46 ;; AUTHORITY SECTION (0 records) ;; ADDITIONAL SECTION (0 records) $VAR1 = \bless( { 'answer' => [ bless( { 'rdlength' => 4, 'ttl' => 9270, 'name' => 'atlrhel5cs.exampl +e.com', 'address' => '10.180.10.46', 'class' => 'IN', 'type' => 'A', 'rdata' => ' &#65533; .' }, 'Net::DNS::RR::A' ) ], 'buffer' => undef, 'question' => [ bless( { 'qclass' => 'IN', 'qname' => 'atlrhel5cs.exa +mple.com', 'qtype' => 'A' }, 'Net::DNS::Question' ) ], 'answerfrom' => '127.0.0.1', 'answersize' => 52, 'additional' => [], 'authority' => [], 'header' => bless( { 'nscount' => 0, 'cd' => 0, 'qdcount' => 1, 'ancount' => 1, 'rcode' => 'NOERROR', 'tc' => 0, 'opcode' => 'QUERY', 'ad' => 0, 'ra' => 1, 'qr' => 1, 'arcount' => 0, 'id' => 32277, 'aa' => 0, 'rd' => 1 }, 'Net::DNS::Header' ), 'offset' => undef }, 'Net::DNS::Packet' );

RHEL6 output:

~$ dnscheck.pl atlrhel5cs query -> atlrhel5cs.example.com ;; query(atlrhel5cs.example.com) ;; setting up an AF_INET() family type UDP socket query -> atlrhel5cs.to.example2.com ;; query(atlrhel5cs.to.example2.com) ;; setting up an AF_INET() family type UDP socket query -> atlrhel5cs.example2.com ;; query(atlrhel5cs.example2.com) ;; setting up an AF_INET() family type UDP socket $VAR1 = [ 'example.com', 'to.example2.com', 'example2.com' ]; $VAR1 = \undef; Use of uninitialized value in concatenation (.) or string at /home/new +atson/bin/dnscheck.pl line 39. WARNING: Skipping host: atlrhel5cs, query: -- no DNS entry! at /home/ +newatson/bin/dnscheck.pl line 39.
<

Neil Watson
watson-wilson.ca


In reply to Net::DNS failure on RHEL6 by neilwatson

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (11)
    As of 2014-11-26 20:29 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My preferred Perl binaries come from:














      Results (172 votes), past polls