Subject: | Problem about TSIG in Net::DNS |
Dear Sir or Madam,
I have a simple perl program that uses Net::DNS to create packets and sign them with a TSIG key. When I send these packets to a DNS server that I have been using for several years, the server reports that the signatures are invalid. However, when I use dig -k <key> they work fine.
As you can see from the attached code, I am using an option code in the OPT record, and I don't
know if this has something to do with the problem. Can you please see if you have the same
problem with this code, or see if there is a programming mistake I have made? My Perl version is
5.8.9, and my OS is Mac OS X 10.6.4. Thanks a lot!
Regards!
Yingdi
Subject: | tsig.pl |
use Net::DNS;
use Net::IP;
#Set DNS server to query
$res = Net::DNS::Resolver->new();
$res->nameservers("jupiter.cs.brown.edu");
$res->port(7979);
#Set key for TSIG
$key_name = "yingdi-brown";
$key = "8bz86RaXjzxHioN3fKruQg==";
#Generate TSIG
$tsig = Net::DNS::RR->new("$key_name TSIG $key");
$tsig->fudge(300);
#Generate a Query
$query = Net::DNS::Packet->new("www.sjtu.edu.cn");
#Generate OPT
@iplist = qw(202 120 2 101);
my $opt = Net::DNS::RR->new(
name => "",
type => "OPT",
class => 1024,
extendedrcode => 0x00,
ednsflags => 0x0000,
optioncode => 0x51,
optiondata => pack("C4", @iplist)
);
#Push OPT into Query
$query->push(additional => $opt);
#Sign Query
$query->sign_tsig($tsig);
$query->print;
#Send Query
$response = $res->send($query);
if($response){
foreach $_ ($response->answer){
print $_->rdatastr."\n";
}
}
Subject: | Kyingdi-brown.+157+53254.key |
Message body not shown because it is not plain text.