about cache nonexist record

Hauke Lampe list+bindusers at hauke-lampe.de
Tue Jul 21 10:42:03 UTC 2009


Tech W. wrote:

> Can I ask how to call nsupdate in Perl language?
> I know some Perl but not good at it.

The documentation for Net::DNS::Update should get you started. Here's
one example:


use Net::DNS;

my $zone = "ixhash.bl.openchaos.org";
my $master = "nsig3.hauke-lampe.de.";

my $key_name = "update-bl.";
my $key = "XXX";

my $update = Net::DNS::Update->new($zone);
my $res = Net::DNS::Resolver->new(
    nameservers     => [$master],
    persistent_udp  => 1,
    persistent_tcp  => 1,
    recurse         => 0,
);

# send update, reset $update object
sub send {
    $res->tsig($key_name, $key) if ($key_name);
    my $reply = $res->send($update);
    if ($reply) {
        if ($reply->header->rcode eq 'NOERROR') {
            print "Update succeeded\n" if $debug > 0;
        } else {
            print 'Update failed: ', $reply->header->rcode, "\n";
        }
    } else {
        print 'Update failed: ', $res->errorstring, "\n";
    }
    $update = Net::DNS::Update->new($zone);
}



$update->push(pre => nxrrset("$hash.$zone A"));
$update->push(update => rr_add("$hash.$zone 42 A 127.0.0.1"));
$update->push(update => rr_add("$hash.$zone 42 TXT \"timestamp $^T\""));
&send;



Hauke.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
URL: <https://lists.isc.org/pipermail/bind-users/attachments/20090721/47e24be7/attachment.bin>


More information about the bind-users mailing list