Sullivan Beck
and 1 contributors


Data::Checker::DNS - check data to see if it is valid in DNS


   use Data::Checker;
   $obj = new Data::Checker;



This module is meant to be used by the Data::Checker module.

One set of checks that is often done on sets of hostnames or IPs is to check that they are defined in DNS. This module provides several DNS related checks that can be performed. It uses the Net::DNS module to actually do the checks.



This is the only function provided by this module, and it is intended to be used by the Data::Checker module.


The $check_opts hashref defines exactly what DNS checks to perform, and some options used by those checks. Known keys that specify the checks are:


If this keys is present, the hostname is tested to see if it is fully qualified or not. This check will fail on on IP.

This check does not actually do a DNS lookup. Instead, it looks at the hostname to see if is fully qualified or not.

If this is given, the host must be fully qualifed to pass (or unqualifed if the 'negate' option is given).


If this key is present, the hostname or IP is tested to see if it is in DNS. If it is defined in DNS, it passes.

This is the default check done, and if $check_opts is not passed in, this check will be performed.

expected_ip, expected_domain, expected_hostname

If any of these keys are present, the information in DNS is tested to make sure that the values are as expected.

The expected value should be stored in the description passed to the check function (see Data::Checker for more information), or in the 'value' option in $check_opts.

If the description is a hashref and there are keys 'ip', 'domain', or 'hostname' respectively, the values are either a string or a listref of strings, and the value in DNS must match one of those strings.

Alternately, if the description does not exist or does not contain those keys, the 'value' option in $check_opts will be used.

If the 'negate' option is included, the values are restricted value which cannot be used in DNS.

The following keys can also be present to specify additional options:


This is a whitespace separated list of nameservers to use.


All examples include the following lines:

   use Data::Checker;
   $obj = new Data::Checker;

   $data = ...
   $opts = ...

   ($pass,$fail,$info,$warn) = $obj->check($data,"DNS",$opts);

The value of $data and $opts is listed below in the examples.

To check if a hostname is fully qualified
   $data = [ 'foo', '' ];
   $opts = { 'qualified'  => undef };

This yields:

   $pass = [ '' ]
   $fail = { 'foo' => [ 'Host is not fully qualified' ] }
To check if a hostname is NOT fully qualified:
   $data = [ 'foo', '' ];
   $opts = { 'qualified' => { 'negate' => 1 } };

This yields:

   $pass = [ 'foo' ]
   $fail = { '' => [ 'Host is fully qualified' ] }
To check that a host is in DNS:
   $data = [ '', 'aaa.bbb.ccc' ];
   $opts = { 'dns' => undef };
To check that a host has the expected IP in DNS

Current DNS shows:        =  =

The test:

   $data = { ''       => { 'ip'  => '' },
             '' => { 'ip'  => '' }
   $opts = { 'dns' => undef,
             'expected_ip' => undef };


   $pass = { ''       => { 'ip'  => '' } }
   $fail = { '' => [ 'DNS IP value does not match expected value' ] }


None known.


Data::Checker, Net::DNS


This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Sullivan Beck (