mellin has asked for the wisdom of the Perl Monks concerning the following question:
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; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::DNS::Resolver and very slow reply
by McDarren (Abbot) on Sep 04, 2006 at 10:29 UTC | |
by mellin (Scribe) on Sep 04, 2006 at 11:19 UTC | |
by McDarren (Abbot) on Sep 04, 2006 at 14:18 UTC | |
by mellin (Scribe) on Sep 04, 2006 at 14:37 UTC | |
by mda2 (Hermit) on Sep 04, 2006 at 14:38 UTC |