I'm having some trouble finding a way to query a specific dns server 
for the text record of a given name purely in perl. I'm trying to do 
this with Net::DNS, but it's proving difficult as I'm not very 
experienced with objects. 

I'm running rbldnsd (a daemon for running dnsbls: 
http://www.corpit.ru/mjt/rbldnsd.html) 
on a box on my local NAT network. If the hostname queried for is listed 
(in whatever zone I'm using, be it DSBL, SBL,etc  or one of my own), 
rbldnsd returns '127.0.0.2'. If that is returned, I want to fetch the text 
(TXT) record for the hostname as well, which includes further information 
about the listing. 

The code which finds the 'A' record here is pretty much straight from the 
example that the author of Net::DNS included:


###/snip

use Net::DNS;

$IP=shift;

($a,$b,$c,$d) = split (/\./,$IP);

$host="$d\.$c\.$b\.$a\.rbl\.foo\.com";

my $res  = Net::DNS::Resolver->new;

$res->nameservers("192.168.0.72");

my $query=$res->search("$host");

if ($query) {
      foreach my $rr ($query->answer) {
          next unless $rr->type eq "A";
          $addy=$rr->address;
      }

        if ($addy=~/127\.0\.0\.2/) {

        #how the fsck do you find txt records with Net::DNS???
        $txt=`host -t txt $host 192.168.0.72|sed -e 's/\"//g' -ne '6p'|awk \'\{print 
\$3\}\'`;

        print "$IP -> $txt";
        }


} else {
      print "NULL\n";
  }


###/snip

...I've also looked at Tie::DNS, which seems to provide a simpler 
interface for this module, but I don't immediately see a way to point 
the code at a specific nameserver, which is absolutely necessary for 
me. (I can't just throw 192.168.0.72 in my /etc/hosts file, 
because it's not a "real" DNS server, it just performs lookups on one specific 
zonefile that I've specified). If anyone can point me in the right 
direction, it would be most appreciated.

TIA,

Bob 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to