ybiC has asked for the wisdom of the Perl Monks concerning the following question:

This may relate more to OO than Net::DNS...
I'm trying to confirm that DNS updates are being propagated to other nameservers. Net::DNS POD provides this example of lookup, which works fine :
use Net::DNS; $res = new Net::DNS::Resolver; $query = $res->search("foo.bar.com"); if ($query) { foreach $rr ($query->answer) { next unless $rr->type eq "A"; print $rr->address, "\n"; } } else { print "query failed: ", $res->errorstring, "\n"; }
and Net::DNS::Resolver provides this example of querying multiple nameservers :
$res->nameservers("192.168.1.1", "192.168.2.2", "192.168.3.3");
My humble question to the master monks - how do I inject the Net::DNS::Resolver snippet into the Net::DNS query ?
    cheers,
    ybiC

Replies are listed 'Best First'.
DNS Querying Multiple Resolvers in Series - Re: OO
by lhoward (Vicar) on Jun 30, 2000 at 02:05 UTC
    You are very close. To query each nameserver once, put your nameservers in a list and iterate through the list, assigning each nameserver once to a resolver and querying it. See the following:
    use Net::DNS; use strict; my @nameservers=("192.168.1.1", "192.168.2.2", "192.168.3.3"); my $nameserver; foreach $nameserver(@nameservers){ print "checking on $nameserver\n"; my $res = new Net::DNS::Resolver; $res->nameservers($nameserver); my $query = $res->search("www.perlmonks.com"); if ($query) { my $rr; foreach $rr ($query->answer) { next unless $rr->type eq "A"; print $rr->address, "\n"; } }else { print "query failed: ", $res->errorstring, "\n"; } }
    If you assign multiple nameservers to one resolver, it will use them as alternate nameservers in case it doesn't hear back from one of the others.
Re: OO (alternate, not multiple, nameservers)
by ybiC (Prior) on Jun 30, 2000 at 03:23 UTC
    Thanks lhoward, that's it to a tee. Alternate namesevers (same as resolv.conf) occured to me as soon as I posted the question. Wasn't as close as I thought.

    I've got MX record and authoritative nameserver query working. With a bit more tweaking (timestamp, reverse lookup, taint+strict cleanup), I'll be ready to post this marginally useful script on Code or Craft.