Listing03_Create_A_Record_Net-DNS (Perl)
This code can be found in
Chapter 8 of Managing Enterprise Active Directory Services
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the Perl code from this site.
# From the book "Managing Enterprise Active Directory Services"
# ISBN: 0-672-32125-4
use strict;
use Net::DNS;
my $update = Net::DNS::Update->new("xyz.com.");
$update->push("pre", nxrrset("host1.xyz.com. A"));
$update->push("update", rr_add("host1.xyz.com. 5200 A 192.168.1.5"));
my $res = Net::DNS::Resolver->new;
$res->nameservers("dc1.xyz.com.");
my $reply = $res->send($update);
if ($reply) {
if ($reply->header->rcode eq "NOERROR") {
print "Update succeeded\n";
}
else {
print "Update failed: ", $reply->header->rcode, "\n";
}
}
else {
print "Update failed: ", $res->errorstring, "\n";
}
|
This code has been viewed 718 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|