Author image Marcin Cieślak


Net::DNS::DomainController::Discovery - Discover Microsoft Active Directory domain controllers via DNS queries


Version 1.00


Issues DNS requests to provide a list of hostnames and IP addresses of the Microsoft Active Directory domain controllers.

    use Net::DNS::DomainController::Discovery;

    my $foo = Net::DNS::DomainController::Discovery::domain_controllers('');

Multiple domain names can be specified:

    my $foo = Net::DNS::DomainController::Discovery::domain_controllers('', '');

This module works only if the Active Directory domain controllers are registed with the domain name system (DNS).


Use this function to obtain a list of Active Domain controllers registered in the DNS for the domain names given as arguments.

Returns a nested array of (domain name, hostname, ip address) tuples that contain all the Active Directory domain controllers serving the domain name if registered in the DNS.

If the domain does not contain any Active Domain domain controller service records, no entries for the domain are returned.

No records are returned for the domain controller names which do resolve neither to an IPv4 nor IPv6 address.



Extract server name from the SRV response.


Query SRV records and return server names if any.


Extract IP addresses from the resolver response.


Resolver server names using the appropriate record for the address family requested. $type parameter should be set A for IPv4, AAAA for IPv6).


Validate the domain name and add the magic string for the Active Directory domain controllers.


Marcin CIESLAK, <saperski at>


Please report any bugs or feature requests to bug-net-dns-domaincontroller-discovery at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


Microsoft has a documentation how the Active Directory domain controllers should register themselves in the DNS:

Microsoft Active Directory Technical Specifications [MS-ADTS] Section SRV Records Published 14 February 2019 at

Archived on 23 March 2020:

You can find documentation for this module with the perldoc command.

    perldoc Net::DNS::DomainController::Discovery

You can also look for information at:


This software is Copyright (c) 2020 by Marcin CIESLAK.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)