|
Packit Service |
f6e53a |
package Net::DNS::Resolver;
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
#
|
|
Packit Service |
f6e53a |
# $Id: Resolver.pm 1598 2017-10-03 09:48:30Z willem $
|
|
Packit Service |
f6e53a |
#
|
|
Packit Service |
f6e53a |
our $VERSION = (qw$LastChangedRevision: 1598 $)[1];
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head1 NAME
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Net::DNS::Resolver - DNS resolver class
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=cut
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
use strict;
|
|
Packit Service |
f6e53a |
use warnings;
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
use constant CONFIG => defined eval "require Net::DNS::Resolver::$^O";
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
use constant OS_CONF => join '::', __PACKAGE__, CONFIG ? $^O : 'UNIX';
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
use base OS_CONF;
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
1;
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
__END__
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head1 SYNOPSIS
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
use Net::DNS;
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver = new Net::DNS::Resolver();
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# Perform a lookup, using the searchlist if appropriate.
|
|
Packit Service |
f6e53a |
$reply = $resolver->search( 'example.com' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# Perform a lookup, without the searchlist
|
|
Packit Service |
f6e53a |
$reply = $resolver->query( 'example.com', 'MX' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# Perform a lookup, without pre or post-processing
|
|
Packit Service |
f6e53a |
$reply = $resolver->send( 'example.com', 'MX', 'IN' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# Send a prebuilt query packet
|
|
Packit Service |
f6e53a |
$query = new Net::DNS::Packet( ... );
|
|
Packit Service |
f6e53a |
$reply = $resolver->send( $query );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head1 DESCRIPTION
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Instances of the Net::DNS::Resolver class represent resolver objects.
|
|
Packit Service |
f6e53a |
A program can have multiple resolver objects, each maintaining its
|
|
Packit Service |
f6e53a |
own state information such as the nameservers to be queried, whether
|
|
Packit Service |
f6e53a |
recursion is desired, etc.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head1 METHODS
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 new
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# Use the default configuration
|
|
Packit Service |
f6e53a |
$resolver = new Net::DNS::Resolver();
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# Use my own configuration file
|
|
Packit Service |
f6e53a |
$resolver = new Net::DNS::Resolver( config_file => '/my/dns.conf' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# Set options in the constructor
|
|
Packit Service |
f6e53a |
$resolver = new Net::DNS::Resolver(
|
|
Packit Service |
f6e53a |
nameservers => [ '10.1.1.128', '10.1.2.128' ],
|
|
Packit Service |
f6e53a |
recurse => 0,
|
|
Packit Service |
f6e53a |
debug => 1
|
|
Packit Service |
f6e53a |
);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Returns a resolver object. If no arguments are supplied, C<new()>
|
|
Packit Service |
f6e53a |
returns an object having the default configuration.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
On Unix and Linux systems,
|
|
Packit Service |
f6e53a |
the default values are read from the following files,
|
|
Packit Service |
f6e53a |
in the order indicated:
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=over
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
F</etc/resolv.conf>,
|
|
Packit Service |
f6e53a |
F<$HOME/.resolv.conf>,
|
|
Packit Service |
f6e53a |
F<./.resolv.conf>
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=back
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The following keywords are recognised in resolver configuration files:
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=over
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
B<nameserver> address
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
IP address of a name server that the resolver should query.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
B<domain> localdomain
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The domain suffix to be appended to a short non-absolute name.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
B<search> domain ...
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
A space-separated list of domains in the desired search path.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
B<options> option:value ...
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
A space-separated list of key:value items.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=back
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Except for F</etc/resolv.conf>, files will only be read if owned by the
|
|
Packit Service |
f6e53a |
effective userid running the program. In addition, several environment
|
|
Packit Service |
f6e53a |
variables may contain configuration information; see L</ENVIRONMENT>.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Note that the domain and searchlist keywords are mutually exclusive.
|
|
Packit Service |
f6e53a |
If both are present, the resulting behaviour is unspecified.
|
|
Packit Service |
f6e53a |
If neither is present, the domain is determined from the local hostname.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
On Windows systems, an attempt is made to determine the system defaults
|
|
Packit Service |
f6e53a |
using the registry. Systems with many dynamically configured network
|
|
Packit Service |
f6e53a |
interfaces may confuse L<Net::DNS>.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# Use my own configuration file
|
|
Packit Service |
f6e53a |
$resolver = new Net::DNS::Resolver( config_file => '/my/dns.conf' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
You can include a configuration file of your own when creating a
|
|
Packit Service |
f6e53a |
resolver object. This is supported on both Unix and Windows.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
If a custom configuration file is specified at first instantiation,
|
|
Packit Service |
f6e53a |
all other configuration files and environment variables are ignored.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# Set options in the constructor
|
|
Packit Service |
f6e53a |
$resolver = new Net::DNS::Resolver(
|
|
Packit Service |
f6e53a |
nameservers => [ '10.1.1.128', '10.1.2.128' ],
|
|
Packit Service |
f6e53a |
recurse => 0
|
|
Packit Service |
f6e53a |
);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Explicit arguments to C<new()> override the corresponding configuration
|
|
Packit Service |
f6e53a |
variables. The argument list consists of a sequence of (name=>value)
|
|
Packit Service |
f6e53a |
pairs, each interpreted as an invocation of the corresponding method.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 print
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->print;
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Prints the resolver state on the standard output.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 query
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$packet = $resolver->query( 'mailhost' );
|
|
Packit Service |
f6e53a |
$packet = $resolver->query( 'mailhost.example.com' );
|
|
Packit Service |
f6e53a |
$packet = $resolver->query( '192.0.2.1' );
|
|
Packit Service |
f6e53a |
$packet = $resolver->query( 'example.com', 'MX' );
|
|
Packit Service |
f6e53a |
$packet = $resolver->query( 'annotation.example.com', 'TXT', 'IN' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Performs a DNS query for the given name; the search list is not applied.
|
|
Packit Service |
f6e53a |
If C<defnames> is true, and the number of dots is less than C<ndots>,
|
|
Packit Service |
f6e53a |
the default domain will be appended unless name is absolute.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The record type and class can be omitted; they default to A and IN.
|
|
Packit Service |
f6e53a |
If the name looks like an IP address (IPv4 or IPv6),
|
|
Packit Service |
f6e53a |
then a query within in-addr.arpa or ip6.arpa will be performed.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Returns a L<Net::DNS::Packet> object, or C<undef> if no answers were found.
|
|
Packit Service |
f6e53a |
The reason for failure may be determined using C<errorstring()>.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
If you need to examine the response packet, whether it contains
|
|
Packit Service |
f6e53a |
any answers or not, use the C<send()> method instead.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 search
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$packet = $resolver->search( 'mailhost' );
|
|
Packit Service |
f6e53a |
$packet = $resolver->search( 'mailhost.example.com' );
|
|
Packit Service |
f6e53a |
$packet = $resolver->search( '192.0.2.1' );
|
|
Packit Service |
f6e53a |
$packet = $resolver->search( 'example.com', 'MX' );
|
|
Packit Service |
f6e53a |
$packet = $resolver->search( 'annotation.example.com', 'TXT', 'IN' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Performs a DNS query for the given name, applying the searchlist if
|
|
Packit Service |
f6e53a |
appropriate. The search algorithm is as follows:
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Unless the number of dots is less than C<ndots>,
|
|
Packit Service |
f6e53a |
perform an initial query using the unmodified name.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
If C<dnsrch> is true and the name has no terminal dot,
|
|
Packit Service |
f6e53a |
try appending each suffix in the search list.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The record type and class can be omitted; they default to A and IN.
|
|
Packit Service |
f6e53a |
If the name looks like an IP address (IPv4 or IPv6),
|
|
Packit Service |
f6e53a |
then a query within in-addr.arpa or ip6.arpa will be performed.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Returns a L<Net::DNS::Packet> object, or C<undef> if no answers were found.
|
|
Packit Service |
f6e53a |
The reason for failure may be determined using C<errorstring()>.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
If you need to examine the response packet, whether it contains
|
|
Packit Service |
f6e53a |
any answers or not, use the C<send()> method instead.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 send
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$packet = $resolver->send( $query );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$packet = $resolver->send( 'mailhost.example.com' );
|
|
Packit Service |
f6e53a |
$packet = $resolver->query( '192.0.2.1' );
|
|
Packit Service |
f6e53a |
$packet = $resolver->send( 'example.com', 'MX' );
|
|
Packit Service |
f6e53a |
$packet = $resolver->send( 'annotation.example.com', 'TXT', 'IN' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Performs a DNS query for the given name.
|
|
Packit Service |
f6e53a |
Neither the searchlist nor the default domain will be appended.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The argument list can be either a pre-built query L<Net::DNS::Packet>
|
|
Packit Service |
f6e53a |
or a list of strings.
|
|
Packit Service |
f6e53a |
The record type and class can be omitted; they default to A and IN.
|
|
Packit Service |
f6e53a |
If the name looks like an IP address (IPv4 or IPv6),
|
|
Packit Service |
f6e53a |
then a query within in-addr.arpa or ip6.arpa will be performed.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Returns a L<Net::DNS::Packet> object whether there were any answers or not.
|
|
Packit Service |
f6e53a |
Use C<< $packet->header->ancount >> or C<< $packet->answer >> to find out
|
|
Packit Service |
f6e53a |
if there were any records in the answer section.
|
|
Packit Service |
f6e53a |
Returns C<undef> if no response was received.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 axfr
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
@zone = $resolver->axfr();
|
|
Packit Service |
f6e53a |
@zone = $resolver->axfr( 'example.com' );
|
|
Packit Service |
f6e53a |
@zone = $resolver->axfr( 'example.com', 'IN' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$iterator = $resolver->axfr();
|
|
Packit Service |
f6e53a |
$iterator = $resolver->axfr( 'example.com' );
|
|
Packit Service |
f6e53a |
$iterator = $resolver->axfr( 'example.com', 'IN' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$rr = $iterator->();
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Performs a zone transfer using the resolver nameservers list,
|
|
Packit Service |
f6e53a |
attempted in the order listed.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
If the zone is omitted, it defaults to the first zone listed
|
|
Packit Service |
f6e53a |
in the resolver search list.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
If the class is omitted, it defaults to IN.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
When called in list context, C<axfr()> returns a list of L<Net::DNS::RR>
|
|
Packit Service |
f6e53a |
objects. The redundant SOA record that terminates the zone transfer
|
|
Packit Service |
f6e53a |
is not returned to the caller.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
In deferrence to RFC1035(6.3), a complete zone transfer is expected
|
|
Packit Service |
f6e53a |
to return all records in the zone or nothing at all.
|
|
Packit Service |
f6e53a |
When no resource records are returned by C<axfr()>,
|
|
Packit Service |
f6e53a |
the reason for failure may be determined using C<errorstring()>.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Here is an example that uses a timeout and TSIG verification:
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->tcp_timeout( 10 );
|
|
Packit Service |
f6e53a |
$resolver->tsig( 'Khmac-sha1.example.+161+24053.private' );
|
|
Packit Service |
f6e53a |
@zone = $resolver->axfr( 'example.com' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
foreach $rr (@zone) {
|
|
Packit Service |
f6e53a |
$rr->print;
|
|
Packit Service |
f6e53a |
}
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
When called in scalar context, C<axfr()> returns an iterator object.
|
|
Packit Service |
f6e53a |
Each invocation of the iterator returns a single L<Net::DNS::RR>
|
|
Packit Service |
f6e53a |
or C<undef> when the zone is exhausted.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
An exception is raised if the zone transfer can not be completed.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The redundant SOA record that terminates the zone transfer is not
|
|
Packit Service |
f6e53a |
returned to the caller.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Here is the example above, implemented using an iterator:
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->tcp_timeout( 10 );
|
|
Packit Service |
f6e53a |
$resolver->tsig( 'Khmac-sha1.example.+161+24053.private' );
|
|
Packit Service |
f6e53a |
$iterator = $resolver->axfr( 'example.com' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
while ( $rr = $iterator->() ) {
|
|
Packit Service |
f6e53a |
$rr->print;
|
|
Packit Service |
f6e53a |
}
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 bgsend
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$handle = $resolver->bgsend( $packet ) || die $resolver->errorstring;
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$handle = $resolver->bgsend( 'mailhost.example.com' );
|
|
Packit Service |
f6e53a |
$handle = $resolver->bgsend( '192.0.2.1' );
|
|
Packit Service |
f6e53a |
$handle = $resolver->bgsend( 'example.com', 'MX' );
|
|
Packit Service |
f6e53a |
$handle = $resolver->bgsend( 'annotation.example.com', 'TXT', 'IN' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Performs a background DNS query for the given name and returns immediately
|
|
Packit Service |
f6e53a |
without waiting for the response. The program can then perform other tasks
|
|
Packit Service |
f6e53a |
while awaiting the response from the nameserver.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The argument list can be either a L<Net::DNS::Packet> object or a list
|
|
Packit Service |
f6e53a |
of strings. The record type and class can be omitted; they default to
|
|
Packit Service |
f6e53a |
A and IN. If the name looks like an IP address (IPv4 or IPv6),
|
|
Packit Service |
f6e53a |
then a query within in-addr.arpa or ip6.arpa will be performed.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Returns an opaque handle which is passed to subsequent invocations of
|
|
Packit Service |
f6e53a |
the C<bgbusy()> and C<bgread()> methods.
|
|
Packit Service |
f6e53a |
Errors are indicated by returning C<undef> in which case
|
|
Packit Service |
f6e53a |
the reason for failure may be determined using C<errorstring()>.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The response L<Net::DNS::Packet> object is obtained by calling C<bgread()>.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
B<BEWARE>:
|
|
Packit Service |
f6e53a |
Programs should make no assumptions about the nature of the handles
|
|
Packit Service |
f6e53a |
returned by C<bgsend()> which should be used strictly as described here.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 bgread
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$handle = $resolver->bgsend( 'www.example.com' );
|
|
Packit Service |
f6e53a |
$packet = $resolver->bgread($handle);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Reads the answer from a background query.
|
|
Packit Service |
f6e53a |
The argument is the handle returned by C<bgsend()>.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Returns a L<Net::DNS::Packet> object or C<undef> if no response was
|
|
Packit Service |
f6e53a |
received before the timeout interval expired.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 bgbusy
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$handle = $resolver->bgsend( 'foo.example.com' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
while ($resolver->bgbusy($handle)) {
|
|
Packit Service |
f6e53a |
...
|
|
Packit Service |
f6e53a |
}
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$packet = $resolver->bgread($handle);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Returns true while awaiting the response or for the transaction to time out.
|
|
Packit Service |
f6e53a |
The argument is the handle returned by C<bgsend()>.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Truncated UDP packets will be retried transparently using TCP while
|
|
Packit Service |
f6e53a |
continuing to assert busy to the caller.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 bgisready
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
until ($resolver->bgisready($handle)) {
|
|
Packit Service |
f6e53a |
...
|
|
Packit Service |
f6e53a |
}
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
C<bgisready()> is the logical complement of C<bgbusy()> which is retained
|
|
Packit Service |
f6e53a |
for backward compatibility.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 debug
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'debug flag: ', $resolver->debug, "\n";
|
|
Packit Service |
f6e53a |
$resolver->debug(1);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Get or set the debug flag.
|
|
Packit Service |
f6e53a |
If set, calls to C<search()>, C<query()>, and C<send()> will print
|
|
Packit Service |
f6e53a |
debugging information on the standard output.
|
|
Packit Service |
f6e53a |
The default is false.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 defnames
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'defnames flag: ', $resolver->defnames, "\n";
|
|
Packit Service |
f6e53a |
$resolver->defnames(0);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Get or set the defnames flag.
|
|
Packit Service |
f6e53a |
If true, calls to C<query()> will append the default domain to
|
|
Packit Service |
f6e53a |
resolve names that are not fully qualified.
|
|
Packit Service |
f6e53a |
The default is true.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 dnsrch
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'dnsrch flag: ', $resolver->dnsrch, "\n";
|
|
Packit Service |
f6e53a |
$resolver->dnsrch(0);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Get or set the dnsrch flag.
|
|
Packit Service |
f6e53a |
If true, calls to C<search()> will apply the search list to resolve
|
|
Packit Service |
f6e53a |
names that are not fully qualified.
|
|
Packit Service |
f6e53a |
The default is true.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 domain
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$domain = $resolver->domain;
|
|
Packit Service |
f6e53a |
$resolver->domain( 'domain.example' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Gets or sets the resolver default domain.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 igntc
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'igntc flag: ', $resolver->igntc, "\n";
|
|
Packit Service |
f6e53a |
$resolver->igntc(1);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Get or set the igntc flag.
|
|
Packit Service |
f6e53a |
If true, truncated packets will be ignored.
|
|
Packit Service |
f6e53a |
If false, the query will be retried using TCP.
|
|
Packit Service |
f6e53a |
The default is false.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 nameserver, nameservers
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
@nameservers = $resolver->nameservers();
|
|
Packit Service |
f6e53a |
$resolver->nameservers( '192.0.2.1', '192.0.2.2', '2001:DB8::3' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Gets or sets the nameservers to be queried.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Also see the IPv6 transport notes below
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 persistent_tcp
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'Persistent TCP flag: ', $resolver->persistent_tcp, "\n";
|
|
Packit Service |
f6e53a |
$resolver->persistent_tcp(1);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Get or set the persistent TCP setting.
|
|
Packit Service |
f6e53a |
If true, L<Net::DNS> will keep a TCP socket open for each host:port
|
|
Packit Service |
f6e53a |
to which it connects.
|
|
Packit Service |
f6e53a |
This is useful if you are using TCP and need to make a lot of queries
|
|
Packit Service |
f6e53a |
or updates to the same nameserver.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The default is false unless you are running a SOCKSified Perl,
|
|
Packit Service |
f6e53a |
in which case the default is true.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 persistent_udp
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'Persistent UDP flag: ', $resolver->persistent_udp, "\n";
|
|
Packit Service |
f6e53a |
$resolver->persistent_udp(1);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Get or set the persistent UDP setting.
|
|
Packit Service |
f6e53a |
If true, a L<Net::DNS> resolver will use the same UDP socket
|
|
Packit Service |
f6e53a |
for all queries within each address family.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
This avoids the cost of creating and tearing down UDP sockets,
|
|
Packit Service |
f6e53a |
but also defeats source port randomisation.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 port
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'sending queries to port ', $resolver->port, "\n";
|
|
Packit Service |
f6e53a |
$resolver->port(9732);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Gets or sets the port to which queries are sent.
|
|
Packit Service |
f6e53a |
Convenient for nameserver testing using a non-standard port.
|
|
Packit Service |
f6e53a |
The default is port 53.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 recurse
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'recursion flag: ', $resolver->recurse, "\n";
|
|
Packit Service |
f6e53a |
$resolver->recurse(0);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Get or set the recursion flag.
|
|
Packit Service |
f6e53a |
If true, this will direct nameservers to perform a recursive query.
|
|
Packit Service |
f6e53a |
The default is true.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 retrans
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'retrans interval: ', $resolver->retrans, "\n";
|
|
Packit Service |
f6e53a |
$resolver->retrans(3);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Get or set the retransmission interval
|
|
Packit Service |
f6e53a |
The default is 5 seconds.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 retry
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'number of tries: ', $resolver->retry, "\n";
|
|
Packit Service |
f6e53a |
$resolver->retry(2);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Get or set the number of times to try the query.
|
|
Packit Service |
f6e53a |
The default is 4.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 searchlist
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
@searchlist = $resolver->searchlist;
|
|
Packit Service |
f6e53a |
$resolver->searchlist( 'a.example', 'b.example', 'c.example' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Gets or sets the resolver search list.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 srcaddr
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->srcaddr('192.0.2.1');
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Sets the source address from which queries are sent.
|
|
Packit Service |
f6e53a |
Convenient for forcing queries from a specific interface on a
|
|
Packit Service |
f6e53a |
multi-homed host. The default is to use any local address.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 srcport
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->srcport(5353);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Sets the port from which queries are sent.
|
|
Packit Service |
f6e53a |
The default is 0, meaning any port.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 tcp_timeout
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'TCP timeout: ', $resolver->tcp_timeout, "\n";
|
|
Packit Service |
f6e53a |
$resolver->tcp_timeout(10);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Get or set the TCP timeout in seconds.
|
|
Packit Service |
f6e53a |
The default is 120 seconds (2 minutes).
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 udp_timeout
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'UDP timeout: ', $resolver->udp_timeout, "\n";
|
|
Packit Service |
f6e53a |
$resolver->udp_timeout(10);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Get or set the bgsend() UDP timeout in seconds.
|
|
Packit Service |
f6e53a |
The default is 30 seconds.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 udppacketsize
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print "udppacketsize: ", $resolver->udppacketsize, "\n";
|
|
Packit Service |
f6e53a |
$resolver->udppacketsize(2048);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Get or set the UDP packet size.
|
|
Packit Service |
f6e53a |
If set to a value not less than the default DNS packet size,
|
|
Packit Service |
f6e53a |
an EDNS extension will be added indicating support for
|
|
Packit Service |
f6e53a |
large UDP datagrams.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 usevc
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'usevc flag: ', $resolver->usevc, "\n";
|
|
Packit Service |
f6e53a |
$resolver->usevc(1);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Get or set the usevc flag.
|
|
Packit Service |
f6e53a |
If true, queries will be performed using virtual circuits (TCP)
|
|
Packit Service |
f6e53a |
instead of datagrams (UDP).
|
|
Packit Service |
f6e53a |
The default is false.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 answerfrom
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'last answer was from: ', $resolver->answerfrom, "\n";
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Returns the IP address from which the most recent packet was
|
|
Packit Service |
f6e53a |
received in response to a query.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 errorstring
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print 'query status: ', $resolver->errorstring, "\n";
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Returns a string containing error information from the most recent
|
|
Packit Service |
f6e53a |
DNS protocol interaction.
|
|
Packit Service |
f6e53a |
C<errorstring()> is meaningful only when interrogated immediately
|
|
Packit Service |
f6e53a |
after the corresponding method call.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 dnssec
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
print "dnssec flag: ", $resolver->dnssec, "\n";
|
|
Packit Service |
f6e53a |
$resolver->dnssec(0);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The dnssec flag causes the resolver to transmit DNSSEC queries
|
|
Packit Service |
f6e53a |
and to add a EDNS0 record as required by RFC2671 and RFC3225.
|
|
Packit Service |
f6e53a |
The actions of, and response from, the remote nameserver is
|
|
Packit Service |
f6e53a |
determined by the settings of the AD and CD flags.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Calling the C<dnssec()> method with a non-zero value will also set the
|
|
Packit Service |
f6e53a |
UDP packet size to the default value of 2048. If that is too small or
|
|
Packit Service |
f6e53a |
too big for your environment, you should call the C<udppacketsize()>
|
|
Packit Service |
f6e53a |
method immediately after.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->dnssec(1); # DNSSEC using default packetsize
|
|
Packit Service |
f6e53a |
$resolver->udppacketsize(1250); # lower the UDP packet size
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
A fatal exception will be raised if the C<dnssec()> method is called
|
|
Packit Service |
f6e53a |
but the L<Net::DNS::SEC> library has not been installed.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 adflag
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->dnssec(1);
|
|
Packit Service |
f6e53a |
$resolver->adflag(1);
|
|
Packit Service |
f6e53a |
print "authentication desired flag: ", $resolver->adflag, "\n";
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Gets or sets the AD bit for dnssec queries. This bit indicates that
|
|
Packit Service |
f6e53a |
the caller is interested in the returned AD (authentic data) bit but
|
|
Packit Service |
f6e53a |
does not require any dnssec RRs to be included in the response.
|
|
Packit Service |
f6e53a |
The default value is false.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 cdflag
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->dnssec(1);
|
|
Packit Service |
f6e53a |
$resolver->cdflag(1);
|
|
Packit Service |
f6e53a |
print "checking disabled flag: ", $resolver->cdflag, "\n";
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Gets or sets the CD bit for dnssec queries. This bit indicates that
|
|
Packit Service |
f6e53a |
authentication by upstream nameservers should be suppressed.
|
|
Packit Service |
f6e53a |
Any dnssec RRs required to execute the authentication procedure
|
|
Packit Service |
f6e53a |
should be included in the response.
|
|
Packit Service |
f6e53a |
The default value is false.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 tsig
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->tsig( $tsig );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->tsig( 'Khmac-sha1.example.+161+24053.private' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->tsig( 'Khmac-sha1.example.+161+24053.key' );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->tsig( 'Khmac-sha1.example.+161+24053.key',
|
|
Packit Service |
f6e53a |
fudge => 60
|
|
Packit Service |
f6e53a |
);
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->tsig( $key_name, $key );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->tsig( undef );
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Set the TSIG record used to automatically sign outgoing queries, zone
|
|
Packit Service |
f6e53a |
transfers and updates. Automatic signing is disabled if called with
|
|
Packit Service |
f6e53a |
undefined arguments.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The default resolver behaviour is not to sign any packets. You must
|
|
Packit Service |
f6e53a |
call this method to set the key if you would like the resolver to
|
|
Packit Service |
f6e53a |
sign and verify packets automatically.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Packets can also be signed manually; see the L<Net::DNS::Packet>
|
|
Packit Service |
f6e53a |
and L<Net::DNS::Update> manual pages for examples. TSIG records
|
|
Packit Service |
f6e53a |
in manually-signed packets take precedence over those that the
|
|
Packit Service |
f6e53a |
resolver would add automatically.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head1 ENVIRONMENT
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The following environment variables can also be used to configure
|
|
Packit Service |
f6e53a |
the resolver:
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 RES_NAMESERVERS
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# Bourne Shell
|
|
Packit Service |
f6e53a |
RES_NAMESERVERS="192.0.2.1 192.0.2.2 2001:DB8::3"
|
|
Packit Service |
f6e53a |
export RES_NAMESERVERS
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# C Shell
|
|
Packit Service |
f6e53a |
setenv RES_NAMESERVERS "192.0.2.1 192.0.2.2 2001:DB8::3"
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
A space-separated list of nameservers to query.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 RES_SEARCHLIST
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# Bourne Shell
|
|
Packit Service |
f6e53a |
RES_SEARCHLIST="a.example.com b.example.com c.example.com"
|
|
Packit Service |
f6e53a |
export RES_SEARCHLIST
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# C Shell
|
|
Packit Service |
f6e53a |
setenv RES_SEARCHLIST "a.example.com b.example.com c.example.com"
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
A space-separated list of domains to put in the search list.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 LOCALDOMAIN
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# Bourne Shell
|
|
Packit Service |
f6e53a |
LOCALDOMAIN=example.com
|
|
Packit Service |
f6e53a |
export LOCALDOMAIN
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# C Shell
|
|
Packit Service |
f6e53a |
setenv LOCALDOMAIN example.com
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The default domain.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head2 RES_OPTIONS
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# Bourne Shell
|
|
Packit Service |
f6e53a |
RES_OPTIONS="retrans:3 retry:2 inet6"
|
|
Packit Service |
f6e53a |
export RES_OPTIONS
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
# C Shell
|
|
Packit Service |
f6e53a |
setenv RES_OPTIONS "retrans:3 retry:2 inet6"
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
A space-separated list of resolver options to set. Options that
|
|
Packit Service |
f6e53a |
take values are specified as C<option:value>.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head1 IPv6 TRANSPORT
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The Net::DNS::Resolver library will enable IPv6 transport if the
|
|
Packit Service |
f6e53a |
L<IO::Socket::IP> library package is available.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The C<force_v4()>, C<force_v6()>, C<prefer_v4()>, and C<prefer_v6()> methods
|
|
Packit Service |
f6e53a |
with non-zero argument may be used to configure transport selection.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
The behaviour of the C<nameserver()> method illustrates the transport
|
|
Packit Service |
f6e53a |
selection mechanism. If, for example, IPv6 is not available or IPv4
|
|
Packit Service |
f6e53a |
transport has been forced, the C<nameserver()> method will only return
|
|
Packit Service |
f6e53a |
IPv4 addresses:
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$resolver->nameservers( '192.0.2.1', '192.0.2.2', '2001:DB8::3' );
|
|
Packit Service |
f6e53a |
$resolver->force_v4(1);
|
|
Packit Service |
f6e53a |
print join ' ', $resolver->nameservers();
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
will print
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
192.0.2.1 192.0.2.2
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head1 CUSTOMISED RESOLVERS
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Net::DNS::Resolver is actually an empty subclass. At compile time a
|
|
Packit Service |
f6e53a |
super class is chosen based on the current platform. A side benefit of
|
|
Packit Service |
f6e53a |
this allows for easy modification of the methods in Net::DNS::Resolver.
|
|
Packit Service |
f6e53a |
You can simply add a method to the namespace!
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
For example, if we wanted to cache lookups:
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
package Net::DNS::Resolver;
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
my %cache;
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
sub search {
|
|
Packit Service |
f6e53a |
$self = shift;
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
$cache{"@_"} ||= $self->SUPER::search(@_);
|
|
Packit Service |
f6e53a |
}
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head1 COPYRIGHT
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Copyright (c)1997-2000 Michael Fuhr.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Portions Copyright (c)2002-2004 Chris Reinhardt.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Portions Copyright (c)2005 Olaf M. Kolkman, NLnet Labs.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Portions Copyright (c)2014,2015 Dick Franks.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
All rights reserved.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head1 LICENSE
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
Permission to use, copy, modify, and distribute this software and its
|
|
Packit Service |
f6e53a |
documentation for any purpose and without fee is hereby granted, provided
|
|
Packit Service |
f6e53a |
that the above copyright notice appear in all copies and that both that
|
|
Packit Service |
f6e53a |
copyright notice and this permission notice appear in supporting
|
|
Packit Service |
f6e53a |
documentation, and that the name of the author not be used in advertising
|
|
Packit Service |
f6e53a |
or publicity pertaining to distribution of the software without specific
|
|
Packit Service |
f6e53a |
prior written permission.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit Service |
f6e53a |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit Service |
f6e53a |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
Packit Service |
f6e53a |
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
Packit Service |
f6e53a |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
Packit Service |
f6e53a |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
Packit Service |
f6e53a |
DEALINGS IN THE SOFTWARE.
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=head1 SEE ALSO
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
L<perl>, L<Net::DNS>, L<Net::DNS::Packet>, L<Net::DNS::Update>,
|
|
Packit Service |
f6e53a |
L<Net::DNS::Header>, L<Net::DNS::Question>, L<Net::DNS::RR>,
|
|
Packit Service |
f6e53a |
L<resolver(5)>, RFC 1034, RFC 1035
|
|
Packit Service |
f6e53a |
|
|
Packit Service |
f6e53a |
=cut
|
|
Packit Service |
f6e53a |
|