DNS-TinyDNS reviews

RSS | Module Info | Add a review of DNS-TinyDNS

DNS-TinyDNS (0.22) *****

Over the years, a number of printers at work have been retired, and/or replaced by different printers or multi-purpose copiers. I had to go through my printer hosts as defined in my DNS server, to see which ones were still alive.

I started to write a program to parse the tinydns data file (I had got as far as 'use strict;'...) when I thought to check CPAN, to see if anyone had already uploaded a module to take care of the fiddly details. In general, djb datafiles are dead simple to parse, but if someone's already gone to the trouble to do so, well, take it.

I installed the module without a hitch, and wrote my program in about two minutes flat.

My only gripe with the module as it stands is that you have to specify the directory of the tinydns configuration. If you have drunk the DJB kool-aid down to the last dregs and/or you haven't bothered to set it up to use a different directory, there is only one place you'll find it, and that's in /etc/tinydns (or /usr/local/etc/tinydns if you're running a BSD ports system).

Therefore, the module should try the usual locations to find the data files it wants to operate on if the user fails to supply the "dir" parameter to the new() constructor. This makes for less work, and would make the module Do The Right Thing.

Anyway, the program came out short, sharp and sweet (view source to get the indented view):

#! /usr/bin/perl -w

use strict;
use DNS::TinyDNS;
use Net::IP::Match::XS;
use IO::Socket;
use Socket 'inet_aton';

my $dns = DNS::TinyDNS->new(type => 'dnsserver', dir => '/etc/tinydns');

peek($_->{ip}) or print "$_->{host}($_->{ip}) dead\n"


sort {inet_aton($a->{ip}) cmp inet_aton($b->{ip})}

grep {match_ip($_->{ip}, '')}

$dns->list( type=>'host', zone => 'example.com' );

sub peek {

my $s = IO::Socket::INET->new(

Timeout => 2,

PeerHost => $_[0],

Proto => 'tcp',

PeerPort => 9100,

) or return 0;

close $s;

return 1;

And now I know I have 38 obsolete DNS records that may be removed! The ease in writing this code came about in large part due to DNS::TinyDNS. Having to parse the file myself would have added a proportionally large amount of make-work code. Thanks Anarion.