Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Net::DNS-> About setting more than one nameserver to lookup.

Reply
Thread Tools

Net::DNS-> About setting more than one nameserver to lookup.

 
 
eloelo
Guest
Posts: n/a
 
      08-07-2004
I want to use four nameserver to look up a domain's IP.
But why the code below can lookup domain's IP only using one nameserver.


#!/usr/bin/perl
use Net:NS;
@ns=('222.33.11.2','223.55.4.3','223.55.4.2','223. 55.4.7');

for($i=0;$i<4;$i++)
{
my $res = Net:NS::Resolver->new;
$res->nameservers($ns[i]);
my $query = $res->search("www.bdchina.com");

if ($query)
{
foreach my $rr ($query->answer)
{
next unless $rr->type eq "A";
print "$ns[i]---->",$rr->address, "\n";
}
}
else
{
warn "$ns[i]---->query failed: ", $res->errorstring, "\n";
}
}


 
Reply With Quote
 
 
 
 
Michael Fuhr
Guest
Posts: n/a
 
      08-07-2004
eloelo <(E-Mail Removed)> writes:

> I want to use four nameserver to look up a domain's IP.
> But why the code below can lookup domain's IP only using one nameserver.


Add "use warnings" to your script and let Perl tell you. Many
programmers consider "use strict" to be good practice as well.

> #!/usr/bin/perl
> use Net:NS;
> @ns=('222.33.11.2','223.55.4.3','223.55.4.2','223. 55.4.7');
>
> for($i=0;$i<4;$i++)
> {
> my $res = Net:NS::Resolver->new;
> $res->nameservers($ns[i]);
> my $query = $res->search("www.bdchina.com");
>
> if ($query)
> {
> foreach my $rr ($query->answer)
> {
> next unless $rr->type eq "A";
> print "$ns[i]---->",$rr->address, "\n";
> }
> }
> else
> {
> warn "$ns[i]---->query failed: ", $res->errorstring, "\n";
> }
> }


--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Pyro "could not find NameServer" Chuckk Hubbard Python 0 11-10-2008 10:52 AM
Pyro "could not find NameServer" Chuckk Hubbard Python 0 11-10-2008 08:49 AM
SOHO 7 and nameserver problems HC Cisco 0 11-23-2003 10:04 AM
host lookup on specific nameserver Thilo Rusche Java 3 07-29-2003 02:22 PM
Returned mail - nameserver error report MAILER-DAEMON@mta2.service.uci.edu Python 0 07-04-2003 01:07 PM



Advertisments