That is it!

#!/usr/bin/perl
use Net::DNS::Simple;
my $res = Net::DNS::Simple->new("www.google.com", "MX");
$res->print_domain();

I have been working with DNS for while using Perl and Net::DNS module. However something always annoyed me when I needed to write a new Perl tool, I had to spend too much time writing all the things that Net::DNS needs.

Given that I wrote a very simple module that is 100% based on Net::DNS module. I called it Net::DNS::Simple, previously named as MYResolver. There are other modules similar to Net::DNS usage easier such as Net::DNS::Resolver and  Net::DNS:Dig*.

Install

I always use ‘local::lib’/perlbrew strategy because I don’t want to mix my production server with crazy modules.

You need the Net::DNS module. Follow all ‘cpan’ procedure by default, just press enter.

$ cpan install Net::DNS

Assuming that you have Perl modules into your ~/perl5  (PERL_LOCAL_LIB_ROOT:

Cloning Net::DNS::Simple (It is not at CPAN yet)

$ git clone https://bitbucket.org/kaiorafael/net-dns-simple.git

Change for whatever place your PERL_LOCAL_LIB_ROOT is pointing to:

$ cd net-dns-simple; perl Makefile.PL INSTALL_BASE=/home/kaiorafael/perl5

Make and install it

$ make ; make install

I have this output

kaiorafael $ make
cp lib/Net/DNS/Simple.pm blib/lib/Net/DNS/Simple.pm
Manifying 1 pod document
kaiorafael $ make install
Manifying 1 pod document
Installing /home/kaiorafael/perl5/lib/perl5/Net/DNS/Simple.pm
Installing /home/kaiorafael/perl5/man/man3/Net::DNS::Simple.3pm
Appending installation info to /home/kaiorafael/perl5/lib/perl5/x86_64-kfreebsd-gnu-thread-multi/perllocal.pod

Please make sure that you have

$ ls  $PERL5LIB/Net/DNS/Simple.pm

Tested on Debian Jessie amd64/ Debian Wheezy kFreeBSD

Current Methods

*A word about About Net::DNS::Dig. It has a very week Query ID number generator and susceptible to Kaminsky’s DNS Bug. I have tried to tell the maintainer without success.

my $ID	= time % 65536;
print $ID;
[kaiorafael $] perl f.pl 
53953
[kaiorafael $] perl f.pl 
53954

http://cpansearch.perl.org/src/MIKER/Net-DNS-Dig-0.12/Dig.pm

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.