# From the book "Managing Enterprise Active Directory Services"
# ISBN: 0-672-32125-4
use strict;
use DnsCmd;
# Create new dnscmd object and specify primary server
my $dnscmd = DnsCmd->new('dc1.xyz.com');
# Delete old A record
$dnscmd->RecordDelete('xyz.com', # Forward zone name
'foobar', # Host name
'A', # RR Type
'10.5.1.1', # IP addr
'/f'); # No prompt
if ($dnscmd->error) {
die "Error deleting A: ",$dnscmd->output;
}
else {
print "Successfully deleted A: ",$dnscmd->output;
}
# Delete old PTR record
$dnscmd->RecordDelete('1.5.10.in-addr.arpa', # Reverse zone name
'1', # PTR owner name
'PTR', # RR type
'foobar.xyz.com', # FQDN of host
'/f'); # No prompt
if ($dnscmd->error) {
die "Error deleting PTR: ",$dnscmd->output;
}
else {
print "Successfully deleted PTR: ",$dnscmd->output;
}
# Add new A record
$dnscmd->RecordAdd('xyz.com', # Forward zone name
'foobar', # Host name
'A', # RR type
'10.5.2.1'); # IP addr
if ($dnscmd->error) {
die "Error adding A: ",$dnscmd->output;
}
else {
print "Successfully added A: ",$dnscmd->output;
}
# Add new PTR record
$dnscmd->RecordAdd('2.5.10.in-addr.arpa', # Reverse zone name
'1', # PTR owner name
'PTR', # RR type
'foobar.xyz.com'); # FQDN of host name
if ($dnscmd->error) {
die "Error adding PTR: ",$dnscmd->output;
}
else {
print "Successfully added PTR: ",$dnscmd->output;
}
|