NAME
Net::DNS::Check::Check - OOP Perl module based on Net::DNS for domain name checking.
SYNOPSIS
use Net::DNS::Check;
my $dnscheck = new Net::DNS::Check(
domain => 'foo.com'
);
print ($dnscheck->check()?'OK':'FAILED');
use Net::DNS::Check;
use Net::DNS::Check::Config;
my $config = new Net::DNS::Check::Config();
$config->test_conf( test => 'soa_refresh_range', level => 'I');
my $dnscheck = new Net::DNS::Check(
domain => 'foo.com',
config => $config,
nserver => 'ns.acme.com;ns2.acme.com=1.2.3.4',
debug => 1
);
print ($dnscheck->check()?'OK':'FAILED');
DESCRIPTION
Net::DNS::Check is a collection of OOP Perl modules allowing easy implementation of applications for domain name checking.
The Net::DNS::Check was built to be as easy as possible to use and highly configurable and flexible: it allow easy implementation of your custom test and deeper configuration of what you want to check and how.
Config Objects
A Config object is an instance of the Net::DNS::Check::Config class. With this object you can configure how Net::DNS::Check operates. You can set, for example, which test will be executed during the check phase, set the debug level and several other options. For additional information see Net::DNS::Check::Config.
Test Object
Net::DNS::Check::Test is the base class for test objects. A test is the single analysis that you can execute during the checking phase of a domain name. You can create a subclass of Net::DNS::Check::Test class and generate your custom test. For additional information see Net::DNS::Check::Test. At present these are the supported tests:
-
Check if the IP addresses found during the hosts resolution do not belong to IP private classes.
-
Compare the IP addresses found during the hosts resolution with the IP addresses given with nserver argument (if exists) in method "new".
-
Check if the hosts found are CNAME or not.
-
Verify the correctness of the hosts syntax.
-
Compare the MX RR found.
-
Check if the MX RR is present or not.
-
Check if the NS RR are the same in all the authoritative nameservers.
-
Check if the number of NS RR are within the range set in the configuration object. For additional information see: Net::DNS::Check::Config.
-
Compare the NS RR found with the effectively delegated nameservers (NS RR in the parent zone of the domain name being checked).
-
Compare the expire time of all the authoritative nameservers.
-
Check if the expire time in the SOA RR is within the range set in the configuration object. For additional information see: Net::DNS::Check::Config.
-
Compare the value of the master nameserver specified in the SOA RR of all the authoritative nameservers.
-
Check if the NS RR exists for the master nameserver specified in the SOA RR.
-
Compare the refresh time in SOA RR of all authoritative nameservers.
-
Check if the refresh time in the SOA RR is within the range set in the configuration object. For additional information see: Net::DNS::Check::Config.
-
Compare the retry time in the SOA RR of all the authoritative nameservers.
-
Check if the retry time in the SOA RR is within the range set in the configuration object. For additional information see: Net::DNS::Check::Config.
-
Compare the serial number in the SOA RR of all the authoritative nameservers.
-
Check if the syntax of the serial number in the SOA RR are in the AAAAMMGGVV format.
METHODS
new
This method creates a new Net::DNS::Check object and returns a reference to it. Arguments are passed as hash. The method "new" gives origin to all necessary queries.
domain: mandatory argument corresponding to the domain name you want to check
config: a reference to a Net::DNS::Check::Config object. This argument is optional and, if not present, the default configuration is used.
nserver: a string containing the list of all the authoritative nameservers. This argument is mandatory if the domain name to be cheked has not yet been delegated. The nserver string has a specific format: nserver_name=IP1,IP2...;nserver2_name=IP1;nserver3_name=IP1,IP2,IP3;...
The IP addresses are mandatory only for the nameservers within a domain name which has not yet been delegated. As many nameservers as necessary cab be typed into the nserver string.
Examples:
ns.foo.com=10.0.0.1;ns2.foo.com=192.168.1.1,192.168.3.100
ns.amce.com;ns4.foo.com=10.1.1.1
debug: with this argument the required debug level can be set:
Level 0: no debug information
Level 1: print to STDOUT information about executed actions
Level 2: as for level 1, but information about query answers are also displayed
Level 3: as for previous levels, but debug option of Net::DNS module is also activated.
check
With this method the check of the domain name starts. You'll get a true value if the check succeded or false otherwise.
test_summary
This method returns an hash containing the status and number of executed tests in that status.
For example if you have 3 tests in Warning status, 2 in Error status and 5 in OK status an hash like this will be given:
'W' => 3, 'E' => 2, 'OK' => 5
At present 4 different status are supported: OK, Warning (W), Error (E), Ignore (I). For additional information about status see Net::DNS::Check::Conf.
If an argument containing a specific status is passed, this method returns only the number of executed test in that status.
Examples:
# $dnscheck is Net::DNS::Check object
$dnscheck->check();
# Print the number of test in OK status
print $dnscheck->test_summary('OK')
# Return the hash of all the status
# ********* ATTENZIONE attualmente riporta un hash reference,
# stabilire cosa e' meglio
my %hash_status = $dnscheck->test_summary();
foreach my $status ( keys %hash_status ) {
print "$status: ". $hash_status{$status}."\n";
}
check_status
This method returns "true" if the check succeede or otherwise "false".
nsauth
Returns the list (array) of the authoritative nameservers. Autoritative nameservers correspond to delegated nameservers (NS RR within the zone of the parent domain) or correspond to the nameservers passed with "nserver" argument in the method "new".
ns_status
This method returns status the information about the nameserver passed as argument. The nameserver must be one of the delegated nameservers. The status is "false" if no errors are found. If some problems to resolve the nameserver name are found or some errors are given during the query, this method returns an error string ("true" value):
NXDOMAIN: the domain name of the nameserver does not exist.
NOANSWER: some link problems (query time out)
error
This method return "false" if no errors are found during the check of the domain name. Otherwise it returns the error string ("true" value):
NXDOMAIN: the domain name or one of its parents have not yet been delegated (and the "nserver" argument of the method "new" is empty)
NOANSWER: some link problems (query time out)
Note that if this method returns an error ("true" value), the check (called with the "check" method) will never start.
test_list
This method returns an array containing the name of executed tests or, if the status argument is passed, it returns the array of the test in a specific status. At present 4 different status are supported: OK, Warning (W), Error (E), Ignore (I). For additional information about status see Net::DNS::Check::Conf.
test_object
This method returns the reference to Net::DNS::Check::Test object specified as argument.
test_status
This method returns the status information about the test name passed as argument. At present there 4 different status are supported: OK, Warning (W), Error (E), Ignore (I). An OK status is returned if the test succeedes. One of the possibile other values, according to the configuration, is returned otherwise. For additional information about status see Net::DNS::Check::Config.
test_detail
This method returns detailed information about a test name passed as argument. It returns an hash in which keys are nameserver names (delegated nserver) and values are an hash point whose keys are "desc" or "status" and values are: for "desc", a text string containing a description of result and for "status" a "true" or "false" value depending on the test results.
Example of returned hash for 'soa_serial_syntax' test:
%ret = (
'ns.foo.com' => {
'desc' => '2005041700',
'status' => 1
},
'ns.acme.net' => {
'desc' => '20050320',
'status' => 0
},
);
Example:
foreach my $test_name ( $dnscheck->test_list() ) {
$result .= "\n$test_name: ".$dnscheck->test_status($test_name) ."\n";
$result .= "==============================\n";
my %test_detail = $dnscheck->test_detail($test_name);
foreach my $ns_name ( keys %test_detail ) {
if ( defined $test_detail{$ns_name}->{desc} ) {
my $detail_status = $test_detail{$ns_name}->{status};
my $detail_desc = $test_detail{$ns_name}->{desc};
$result .= "$ns_name: Status: $detail_status Desc: $detail_desc\n";
}
}
}
domain
Returns the domain name passed as argument to the method "new".
COPYRIGHT
Copyright (c) 2005 Lorenzo Luconi Trombacchi - IIT-CNR
All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
4 POD Errors
The following errors were encountered while parsing the POD:
- Around line 1002:
'=item' outside of any '=over'
- Around line 1011:
You forgot a '=back' before '=head2'
- Around line 1015:
'=item' outside of any '=over'
- Around line 1026:
You forgot a '=back' before '=head2'