Skip to content

Read and write DNS Records in ActiveDirectory with perl.

Notifications You must be signed in to change notification settings

peterviskup/net-ad-dnsrecord

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a set of perl modules to allow for the editing of ActiveDirectory-backed-DNS.

documentation is lacking, code examples are in the t/ (tests) directory

Use this at your own peril. I do.

################################################################################
#

use Net::ActiveDirectory;
my $zone="example.org";
my $ad = Net::ActiveDirectory->new({
                                     'domain'   => $ENV{'WINDOWS_DOMAIN'},      # example.org
                                     'username' => $ENV{'WINDOWS_USERNAME'},    # joe (not joe@example.org or EXAMPLE\joe)
                                     'password' => $ENV{'WINDOWS_PASSWORD'},    # derp
                                   });

# Add some records to a zone
$ad->addrecord( $zone, "somehost IN A 192.168.2.225"                      # add an A record
$ad->addrecord( "2.168.192.in-addr.arpa", "225 IN PTR somehost.$zone." ); # add a PTR

$ad->addrecord( "$zone", "_ldap._tcp IN SRV 0 10 389 192.168.2.225"       # zone, entry form
$ad->addrecord( "_ldap._tcp.$zone. 86400 IN SRV 0 10 389 192.168.2.225"); # all-one-arguement form (w/optional ttl)


# Delete the same records from a zone with the same formats
$ad->delrecord( $zone, "somehost IN A 192.168.2.225" 
$ad->delrecord( "2.168.192.in-addr.arpa", "225 IN PTR somehost.$zone." ); 

$ad->delrecord( "$zone", "_ldap._tcp IN SRV 0 10 389 192.168.2.225"    
$ad->delrecord( "_ldap._tcp.$zone. 86400 IN SRV 0 10 389 192.168.2.225");

# or add a reciprocal pair (this will add / delete the A and PTR for both)
# (it needs the fqdn / full IP to detect the zone file)
$ad->addpair( "somehost.$zone", "192.168.2.225" );
$ad->delpair( "somehost.$zone", "192.168.2.225" );


# this will return if all NS servers have the record (this can take 15 minutes with mixed-mode domains)
# I use them to loop until all servers have the record before continuing an operation that depends on DNS
$ad->add_propagated("somehost.$zone IN A 192.168.2.225");
$ad->del_propagated("somehost.$zone IN A 192.168.2.225");

About

Read and write DNS Records in ActiveDirectory with perl.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Perl 98.9%
  • Shell 1.1%