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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |