I'm using the Resolver class from Net::DNS and it seems to take very long time to ask IP addresses for selected domain. Our DNS is working correctly and hosting six IP addresses for it's domain. It takes about 5 to 6 seconds for the script to return output, and this is not really desired since i was intending to output the answer through website.

Ignore the lame validity checks it performs, they are not meant to be included like that later on. I'm only curious if there's a way i can speed up things, maybe even change the module form Net::DNS to something other?


#!/usr/bin/perl -w use strict; use Net::DNS; my @domainIp = resolveDomainIp ('test.ad.local'); my $i=1; foreach (@domainIp) { print $i++ . ": $_\n"; } sub resolveDomainIp { my $adFqdn = shift; error ("i need to know the active directory domain name (eg. microsoft +.ad.local)", 'exit') unless ($adFqdn); error ("provided active directory domain doesn't look like a domain na +me", 'exit') unless ($adFqdn =~ /^([a-zA-Z0-9]+)\.([a-zA-Z0-9]+)/); my $res = Net::DNS::Resolver->new; my $query = $res->search($adFqdn); + my @dcIp; if ($query) { foreach my $rr ($query->answer) { next unless $rr->type eq "A"; push @dcIp, $rr->address . " (record type " . $rr->type . ")"; } return @dcIp; } else { my $errMsg = $res->errorstring; error ("dns server the platform is asking from doesn't know any ip a +ddresses for $adFqdn", 'exit') if @_ != 1; } }

In reply to Net::DNS::Resolver and very slow reply by mellin

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.