Wednesday, June 25, 2008

Enumerate all hosts in a dns domain using Perl

I had a need to search for a hostname at my company. I found the Net::DNS perl module to be useful. Here is an example of enumerating all hosts for a domain.


use strict;
use Net::DNS;

my $res = Net::DNS::Resolver->new;
$res->nameservers("nameserver ip address");

my @zone = $res->axfr("example.com");

foreach my $rr (@zone) {
print $rr->print;

No comments: