.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Net::DNS::Resolver 3" .TH Net::DNS::Resolver 3 "2015-02-26" "perl v5.20.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::DNS::Resolver \- DNS resolver class .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Net::DNS; \& \& $resolver = new Net::DNS::Resolver(); \& \& # Perform a lookup, using the searchlist if appropriate. \& $reply = $resolver\->search( \*(Aqexample.com\*(Aq ); \& \& # Perform a lookup, without the searchlist \& $reply = $resolver\->query( \*(Aqexample.com\*(Aq, \*(AqMX\*(Aq ); \& \& # Perform a lookup, without pre or post\-processing \& $reply = $resolver\->send( \*(Aqexample.com\*(Aq, \*(AqMX\*(Aq, \*(AqCH\*(Aq ); \& \& # Send a prebuilt query packet \& $query = new Net::DNS::Packet( ... ); \& $reply = $resolver\->send( $packet ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Instances of the \f(CW\*(C`Net::DNS::Resolver\*(C'\fR class represent resolver objects. A program can have multiple resolver objects, each maintaining its own state information such as the nameservers to be queried, whether recursion is desired, etc. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" .Vb 2 \& # Use the default configuration \& $resolver = new Net::DNS::Resolver(); \& \& # Use my own configuration file \& $resolver = new Net::DNS::Resolver( config_file => \*(Aq/my/dns.conf\*(Aq ); \& \& # Set options in the constructor \& $resolver = new Net::DNS::Resolver( \& nameservers => [ \*(Aq10.1.1.128\*(Aq, \*(Aq10.1.2.128\*(Aq ], \& recurse => 0, \& debug => 1 \& ); .Ve .PP Returns a resolver object. If no arguments are supplied, \fInew()\fR returns an object having the default configuration. .PP On Unix and Linux systems, the default values are read from the following files, in the order indicated: .PP .Vb 3 \& /etc/resolv.conf \& $HOME/.resolv.conf \& ./.resolv.conf .Ve .PP The following keywords are recognised in resolver configuration files: .IP "domain" 4 .IX Item "domain" The default domain. .IP "search" 4 .IX Item "search" A space-separated list of domains to put in the search list. .IP "nameserver" 4 .IX Item "nameserver" A space-separated list of nameservers to query. .PP Except for \fI/etc/resolv.conf\fR, files will only be read if owned by the effective userid running the program. In addition, several environment variables may contain configuration information; see \*(L"\s-1ENVIRONMENT\*(R"\s0. .PP On Windows systems, an attempt is made to determine the system defaults using the registry. Systems with many dynamically configured network interfaces may confuse Net::DNS. .PP You can include a configuration file of your own when creating a resolver object: .PP .Vb 2 \& # Use my own configuration file \& $resolver = new Net::DNS::Resolver( config_file => \*(Aq/my/dns.conf\*(Aq ); .Ve .PP This is supported on both Unix and Windows. .PP If a custom configuration file is specified at first instantiation, both the system configuration and environment variables are ignored. .PP Explicit arguments to \fInew()\fR override the corresponding configuration variables. The following arguments are supported: .IP "nameservers" 4 .IX Item "nameservers" A reference to an array of nameservers to query. .IP "searchlist" 4 .IX Item "searchlist" A reference to an array of domains to search for unqualified names. .IP "domain" 4 .IX Item "domain" Domain name suffix to be appended to queries of unqualified names. .IP "recurse" 4 .IX Item "recurse" .PD 0 .IP "debug" 4 .IX Item "debug" .IP "port" 4 .IX Item "port" .IP "srcaddr" 4 .IX Item "srcaddr" .IP "srcport" 4 .IX Item "srcport" .IP "tcp_timeout" 4 .IX Item "tcp_timeout" .IP "udp_timeout" 4 .IX Item "udp_timeout" .IP "retrans" 4 .IX Item "retrans" .IP "retry" 4 .IX Item "retry" .IP "usevc" 4 .IX Item "usevc" .IP "stayopen" 4 .IX Item "stayopen" .IP "igntc" 4 .IX Item "igntc" .IP "defnames" 4 .IX Item "defnames" .IP "dnsrch" 4 .IX Item "dnsrch" .IP "persistent_tcp" 4 .IX Item "persistent_tcp" .IP "persistent_udp" 4 .IX Item "persistent_udp" .IP "dnssec" 4 .IX Item "dnssec" .PD .PP For more information on any of these options, please consult the method of the same name. .SS "search" .IX Subsection "search" .Vb 5 \& $packet = $resolver\->search( \*(Aqmailhost\*(Aq ); \& $packet = $resolver\->search( \*(Aqmailhost.example.com\*(Aq ); \& $packet = $resolver\->search( \*(Aq192.0.2.1\*(Aq ); \& $packet = $resolver\->search( \*(Aqexample.com\*(Aq, \*(AqMX\*(Aq ); \& $packet = $resolver\->search( \*(Aqannotation.example.com\*(Aq, \*(AqTXT\*(Aq, \*(AqHS\*(Aq ); .Ve .PP Performs a \s-1DNS\s0 query for the given name, applying the searchlist if appropriate. The search algorithm is as follows: .IP "1." 4 If the name contains at least one dot, try it as is. .IP "2." 4 If the name does not end in a dot, try appending each item in the search list to the name. This is only done if \f(CW\*(C`dnsrch\*(C'\fR is true. .IP "3." 4 If the name does not contain any dots, try it as is. .PP The record type and class can be omitted; they default to A and \s-1IN.\s0 If the name looks like an \s-1IP\s0 address (IPv4 or IPv6), then an appropriate \s-1PTR\s0 query will be performed. .PP Returns a \f(CW\*(C`Net::DNS::Packet\*(C'\fR object, or \f(CW\*(C`undef\*(C'\fR if no answers were found. If you need to examine the response packet, whether it contains any answers or not, use the \fIsend()\fR method instead. .SS "query" .IX Subsection "query" .Vb 5 \& $packet = $resolver\->query( \*(Aqmailhost\*(Aq ); \& $packet = $resolver\->query( \*(Aqmailhost.example.com\*(Aq ); \& $packet = $resolver\->query( \*(Aq192.0.2.1\*(Aq ); \& $packet = $resolver\->query( \*(Aqexample.com\*(Aq, \*(AqMX\*(Aq ); \& $packet = $resolver\->query( \*(Aqannotation.example.com\*(Aq, \*(AqTXT\*(Aq, \*(AqHS\*(Aq ); .Ve .PP Performs a \s-1DNS\s0 query for the given name; the search list is not applied. If the name does not contain any dots and \f(CW\*(C`defnames\*(C'\fR is true, the default domain will be appended. .PP The record type and class can be omitted; they default to A and \s-1IN.\s0 If the name looks like an \s-1IP\s0 address (IPv4 or IPv6), an appropriate \s-1PTR\s0 query will be performed. .PP Returns a \f(CW\*(C`Net::DNS::Packet\*(C'\fR object, or \f(CW\*(C`undef\*(C'\fR if no answers were found. If you need to examine the response packet, whether it contains any answers or not, use the \fIsend()\fR method instead. .SS "send" .IX Subsection "send" .Vb 4 \& $packet = $resolver\->send( $packet ); \& $packet = $resolver\->send( \*(Aqmailhost.example.com\*(Aq ); \& $packet = $resolver\->send( \*(Aqexample.com\*(Aq, \*(AqMX\*(Aq ); \& $packet = $resolver\->send( \*(Aqannotation.example.com\*(Aq, \*(AqTXT\*(Aq, \*(AqHS\*(Aq ); .Ve .PP Performs a \s-1DNS\s0 query for the given name. Neither the searchlist nor the default domain will be appended. .PP The argument list can be either a \f(CW\*(C`Net::DNS::Packet\*(C'\fR object or a list of strings. The record type and class can be omitted; they default to A and \s-1IN. \s0 If the name looks like an \s-1IP\s0 address (IPv4 or IPv6), an appropriate \s-1PTR\s0 query will be performed. .PP Returns a \f(CW\*(C`Net::DNS::Packet\*(C'\fR object whether there were any answers or not. Use \f(CW\*(C`$packet\->header\->ancount\*(C'\fR or \f(CW\*(C`$packet\->answer\*(C'\fR to find out if there were any records in the answer section. Returns \f(CW\*(C`undef\*(C'\fR if no response was received. .SS "axfr" .IX Subsection "axfr" .Vb 3 \& @zone = $resolver\->axfr(); \& @zone = $resolver\->axfr( \*(Aqexample.com\*(Aq ); \& @zone = $resolver\->axfr( \*(Aqexample.com\*(Aq, \*(AqHS\*(Aq ); \& \& $iterator = $resolver\->axfr(); \& $iterator = $resolver\->axfr( \*(Aqexample.com\*(Aq ); \& $iterator = $resolver\->axfr( \*(Aqexample.com\*(Aq, \*(AqHS\*(Aq ); \& \& $rr = $iterator\->(); .Ve .PP Performs a zone transfer using the resolver nameservers list, attempted in the order listed. .PP If the zone is omitted, it defaults to the first zone listed in the resolver search list. .PP If the class is omitted, it defaults to \s-1IN.\s0 .PP When called in list context, \fIaxfr()\fR returns a list of \f(CW\*(C`Net::DNS::RR\*(C'\fR objects or an empty list if the zone transfer failed. The redundant \s-1SOA\s0 record that terminates the zone transfer is not returned to the caller. .PP Here is an example that uses a timeout and \s-1TSIG\s0 verification: .PP .Vb 3 \& $resolver\->tcp_timeout( 10 ); \& $resolver\->tsig( \*(AqKhmac\-sha1.example.+161+24053.private\*(Aq ); \& @zone = $resolver\->axfr( \*(Aqexample.com\*(Aq ); \& \& die \*(AqZone transfer failed: \*(Aq, $resolver\->errorstring unless @zone; \& \& foreach $rr (@zone) { \& $rr\->print; \& } .Ve .PP When called in scalar context, \fIaxfr()\fR returns an iterator object. Each invocation of the iterator returns a single \f(CW\*(C`Net::DNS::RR\*(C'\fR or \f(CW\*(C`undef\*(C'\fR when the zone is exhausted. The redundant \s-1SOA\s0 record that terminates the zone transfer is not returned to the caller. .PP Here is the example above, implemented using an iterator: .PP .Vb 3 \& $resolver\->tcp_timeout( 10 ); \& $resolver\->tsig( \*(AqKhmac\-sha1.example.+161+24053.private\*(Aq ); \& $iterator = $resolver\->axfr( \*(Aqexample.com\*(Aq ); \& \& die \*(AqZone transfer failed: \*(Aq, $resolver\->errorstring unless $iterator; \& \& while ( $rr = $iterator\->() ) { \& $rr\->print; \& } .Ve .SS "nameservers" .IX Subsection "nameservers" .Vb 2 \& @nameservers = $resolver\->nameservers(); \& $resolver\->nameservers( \*(Aq192.0.2.1\*(Aq, \*(Aq192.0.2.2\*(Aq, \*(Aq2001:DB8::3\*(Aq ); .Ve .PP Gets or sets the nameservers to be queried. .PP Also see the IPv6 transport notes below .SS "empty_nameservers" .IX Subsection "empty_nameservers" .Vb 1 \& $resolver\->empty_nameservers(); .Ve .PP Empties the list of nameservers. .SS "print" .IX Subsection "print" .Vb 1 \& $resolver\->print; .Ve .PP Prints the resolver state on the standard output. .SS "string" .IX Subsection "string" .Vb 1 \& print $resolver\->string; .Ve .PP Returns a string representation of the resolver state. .SS "searchlist" .IX Subsection "searchlist" .Vb 2 \& @searchlist = $resolver\->searchlist; \& $resolver\->searchlist( \*(Aqa.example\*(Aq, \*(Aqb.example\*(Aq, \*(Aqc.example\*(Aq ); .Ve .PP Gets or sets the resolver search list. .SS "empty_searchlist" .IX Subsection "empty_searchlist" .Vb 1 \& $resolver\->empty_searchlist(); .Ve .PP Empties the searchlist. .SS "port" .IX Subsection "port" .Vb 2 \& print \*(Aqsending queries to port \*(Aq, $resolver\->port, "\en"; \& $resolver\->port(9732); .Ve .PP Gets or sets the port to which queries are sent. Convenient for nameserver testing using a non-standard port. The default is port 53. .SS "srcport" .IX Subsection "srcport" .Vb 2 \& print \*(Aqsending queries from port \*(Aq, $resolver\->srcport, "\en"; \& $resolver\->srcport(5353); .Ve .PP Gets or sets the port from which queries are sent. The default is 0, meaning any port. .SS "srcaddr" .IX Subsection "srcaddr" .Vb 2 \& print \*(Aqsending queries from address \*(Aq, $resolver\->srcaddr, "\en"; \& $resolver\->srcaddr(\*(Aq192.0.2.1\*(Aq); .Ve .PP Gets or sets the source address from which queries are sent. Convenient for forcing queries from a specific interface on a multi-homed host. The default is 0.0.0.0, meaning any local address. .SS "bgsend" .IX Subsection "bgsend" .Vb 1 \& $socket = $resolver\->bgsend( $packet ) || die $resolver\->errorstring; \& \& $socket = $resolver\->bgsend( \*(Aqmailhost.example.com\*(Aq ); \& $socket = $resolver\->bgsend( \*(Aqexample.com\*(Aq, \*(AqMX\*(Aq ); \& $socket = $resolver\->bgsend( \*(Aqannotation.example.com\*(Aq, \*(AqTXT\*(Aq, \*(AqHS\*(Aq ); .Ve .PP Performs a background \s-1DNS\s0 query for the given name, i.e., sends a query packet to the first destination in the \f(CW\*(C`nameservers\*(C'\fR list and returns immediately without waiting for a response. The program can then perform other tasks while awaiting the response from the nameserver. .PP The argument list can be either a \f(CW\*(C`Net::DNS::Packet\*(C'\fR object or a list of strings. The record type and class can be omitted; they default to A and \s-1IN. \s0 If the name looks like an \s-1IP\s0 address (IPv4 or IPv6), an appropriate \s-1PTR\s0 query will be performed. .PP Returns an \f(CW\*(C`IO::Socket::INET\*(C'\fR object or \f(CW\*(C`undef\*(C'\fR on error in which case the reason for failure can be found through a call to the errorstring method. .PP The program must determine when the socket is ready for reading and call \f(CW\*(C`bgread\*(C'\fR to get the response packet. Either \f(CW\*(C`bgisready\*(C'\fR or \&\f(CW\*(C`IO::Select\*(C'\fR may be used to find out if the socket is ready. .PP \&\f(CW\*(C`bgsend\*(C'\fR does not support persistent sockets. .PP \&\fB\s-1BEWARE\s0\fR: \&\f(CW\*(C`bgsend\*(C'\fR does not support the usevc option (\s-1TCP\s0) and operates on \s-1UDP\s0 only. Answers may not fit in an \s-1UDP\s0 packet and might be truncated. Truncated packets will \fBnot\fR be retried over \s-1TCP\s0 automatically and should be handled by the caller. .SS "bgread" .IX Subsection "bgread" .Vb 5 \& $packet = $resolver\->bgread($socket); \& if ($packet\->header\->tc) { \& # Retry over TCP (blocking). \& } \& undef $socket; .Ve .PP Reads the answer from a background query (see \*(L"bgsend\*(R"). The argument is an \f(CW\*(C`IO::Socket\*(C'\fR object returned by \f(CW\*(C`bgsend\*(C'\fR. .PP Returns a \f(CW\*(C`Net::DNS::Packet\*(C'\fR object or \f(CW\*(C`undef\*(C'\fR on error. .PP The programmer should close or destroy the socket object after reading it. .SS "bgisready" .IX Subsection "bgisready" .Vb 9 \& $socket = $resolver\->bgsend( \*(Aqfoo.example.com\*(Aq ); \& until ($resolver\->bgisready($socket)) { \& # do some other processing \& } \& $packet = $resolver\->bgread($socket); \& if ($packet\->header\->tc) { \& # Retry over TCP (blocking). \& } \& $socket = undef; .Ve .PP Determines whether a socket is ready for reading. The argument is an \f(CW\*(C`IO::Socket\*(C'\fR object returned by \f(CW\*(C`bgsend\*(C'\fR. .PP Returns true if the socket is ready, false if not. .SS "tsig" .IX Subsection "tsig" .Vb 2 \& $tsig = $resolver\->tsig; \& $resolver\->tsig( $tsig ); \& \& $resolver\->tsig( \*(AqKhmac\-sha1.example.+161+24053.private\*(Aq ); \& \& $resolver\->tsig( \*(AqKhmac\-sha1.example.+161+24053.key\*(Aq ); \& \& $resolver\->tsig( \*(AqKhmac\-sha1.example.+161+24053.key\*(Aq, \& fudge => 60 \& ); \& \& $resolver\->tsig( $key_name, $key ); \& \& $resolver\->tsig( undef ); .Ve .PP Get or set the \s-1TSIG\s0 record used to automatically sign outgoing queries and updates. Call with an undefined argument, 0 or '' to turn off automatic signing. .PP The default resolver behavior is not to sign any packets. You must call this method to set the key if you would like the resolver to sign packets automatically. .PP Packets can also be signed manually; see the Net::DNS::Packet and Net::DNS::Update manual pages for examples. \s-1TSIG\s0 records in manually-signed packets take precedence over those that the resolver would add automatically. .SS "retrans" .IX Subsection "retrans" .Vb 2 \& print \*(Aqretrans interval: \*(Aq, $resolver\->retrans, "\en"; \& $resolver\->retrans(3); .Ve .PP Get or set the retransmission interval The default is 5 seconds. .SS "retry" .IX Subsection "retry" .Vb 2 \& print \*(Aqnumber of tries: \*(Aq, $resolver\->retry, "\en"; \& $resolver\->retry(2); .Ve .PP Get or set the number of times to try the query. The default is 4. .SS "recurse" .IX Subsection "recurse" .Vb 2 \& print \*(Aqrecursion flag: \*(Aq, $resolver\->recurse, "\en"; \& $resolver\->recurse(0); .Ve .PP Get or set the recursion flag. If true, this will direct nameservers to perform a recursive query. The default is true. .SS "defnames" .IX Subsection "defnames" .Vb 2 \& print \*(Aqdefnames flag: \*(Aq, $resolver\->defnames, "\en"; \& $resolver\->defnames(0); .Ve .PP Get or set the defnames flag. If true, calls to \f(CW\*(C`query\*(C'\fR will append the default domain to names that contain no dots. The default is true. .SS "dnsrch" .IX Subsection "dnsrch" .Vb 2 \& print \*(Aqdnsrch flag: \*(Aq, $resolver\->dnsrch, "\en"; \& $resolver\->dnsrch(0); .Ve .PP Get or set the dnsrch flag. If true, calls to \f(CW\*(C`search\*(C'\fR will apply the search list to resolve names that are not fully qualified. The default is true. .SS "debug" .IX Subsection "debug" .Vb 2 \& print \*(Aqdebug flag: \*(Aq, $resolver\->debug, "\en"; \& $resolver\->debug(1); .Ve .PP Get or set the debug flag. If set, calls to \f(CW\*(C`search\*(C'\fR, \f(CW\*(C`query\*(C'\fR, and \f(CW\*(C`send\*(C'\fR will print debugging information on the standard output. The default is false. .SS "usevc" .IX Subsection "usevc" .Vb 2 \& print \*(Aqusevc flag: \*(Aq, $resolver\->usevc, "\en"; \& $resolver\->usevc(1); .Ve .PP Get or set the usevc flag. If true, queries will be performed using virtual circuits (\s-1TCP\s0) instead of datagrams (\s-1UDP\s0). The default is false. .SS "tcp_timeout" .IX Subsection "tcp_timeout" .Vb 2 \& print \*(AqTCP timeout: \*(Aq, $resolver\->tcp_timeout, "\en"; \& $resolver\->tcp_timeout(10); .Ve .PP Get or set the \s-1TCP\s0 timeout in seconds. The default is 120 seconds (2 minutes). A timeout of \f(CW\*(C`undef\*(C'\fR means indefinite. .SS "udp_timeout" .IX Subsection "udp_timeout" .Vb 2 \& print \*(AqUDP timeout: \*(Aq, $resolver\->udp_timeout, "\en"; \& $resolver\->udp_timeout(10); .Ve .PP Get or set the \s-1UDP\s0 timeout in seconds. The default is \f(CW\*(C`undef\*(C'\fR, which means that the retry and retrans settings will be used to perform the retries until they exhausted. .SS "persistent_tcp" .IX Subsection "persistent_tcp" .Vb 2 \& print \*(AqPersistent TCP flag: \*(Aq, $resolver\->persistent_tcp, "\en"; \& $resolver\->persistent_tcp(1); .Ve .PP Get or set the persistent \s-1TCP\s0 setting. If true, Net::DNS will keep a \s-1TCP\s0 socket open for each host:port to which it connects. This is useful if you are using \s-1TCP\s0 and need to make a lot of queries or updates to the same nameserver. .PP The default is false unless you are running a SOCKSified Perl, in which case the default is true. .SS "persistent_udp" .IX Subsection "persistent_udp" .Vb 2 \& print \*(AqPersistent UDP flag: \*(Aq, $resolver\->persistent_udp, "\en"; \& $resolver\->persistent_udp(1); .Ve .PP Get or set the persistent \s-1UDP\s0 setting. If true, Net::DNS will keep a single \s-1UDP\s0 socket open for all queries. This is useful if you are using \s-1UDP\s0 and need to make a lot of queries or updates. .SS "igntc" .IX Subsection "igntc" .Vb 2 \& print \*(Aqigntc flag: \*(Aq, $resolver\->igntc, "\en"; \& $resolver\->igntc(1); .Ve .PP Get or set the igntc flag. If true, truncated packets will be ignored. If false, the query will be retried using \s-1TCP.\s0 The default is false. .SS "errorstring" .IX Subsection "errorstring" .Vb 1 \& print \*(Aqquery status: \*(Aq, $resolver\->errorstring, "\en"; .Ve .PP Returns a string containing the status of the most recent query. .SS "answerfrom" .IX Subsection "answerfrom" .Vb 1 \& print \*(Aqlast answer was from: \*(Aq, $resolver\->answerfrom, "\en"; .Ve .PP Returns the \s-1IP\s0 address from which the most recent packet was received in response to a query. .SS "answersize" .IX Subsection "answersize" .Vb 1 \& print \*(Aqsize of last answer: \*(Aq, $resolver\->answersize, "\en"; .Ve .PP Returns the size in bytes of the most recent packet received in response to a query. .SS "dnssec" .IX Subsection "dnssec" .Vb 2 \& print "dnssec flag: ", $resolver\->dnssec, "\en"; \& $resolver\->dnssec(0); .Ve .PP The dnssec flag causes the resolver to transmit \s-1DNSSEC\s0 queries and to add a \s-1EDNS0\s0 record as required by \s-1RFC2671\s0 and \s-1RFC3225.\s0 The actions of, and response from, the remote nameserver is determined by the settings of the \s-1AD\s0 and \s-1CD\s0 flags. .PP Calling the \fIdnssec()\fR method with a non-zero value will also set the \&\s-1UDP\s0 packet size to the default value of 2048. If that is too small or too big for your environment, you should call the \fIudppacketsize()\fR method immediately after. .PP .Vb 2 \& $resolver\->dnssec(1); # DNSSEC using default packetsize \& $resolver\->udppacketsize(1250); # lower the UDP packet size .Ve .PP A fatal exception will be raised if the \fIdnssec()\fR method is called but the Net::DNS::SEC library has not been installed. .SS "adflag" .IX Subsection "adflag" .Vb 3 \& $resolver\->dnssec(1); \& $resolver\->adflag(1); \& print "authentication desired flag: ", $resolver\->adflag, "\en"; .Ve .PP Gets or sets the \s-1AD\s0 bit for dnssec queries. This bit indicates that the caller is interested in the returned \s-1AD \s0(authentic data) bit but does not require any dnssec RRs to be included in the response. The default value is 0. .SS "cdflag" .IX Subsection "cdflag" .Vb 3 \& $resolver\->dnssec(1); \& $resolver\->cdflag(1); \& print "checking disabled flag: ", $resolver\->cdflag, "\en"; .Ve .PP Gets or sets the \s-1CD\s0 bit for dnssec queries. This bit indicates that authentication by upstream nameservers should be suppressed. Any dnssec RRs required to execute the authentication procedure should be included in the response. The default value is 0. .SS "udppacketsize" .IX Subsection "udppacketsize" .Vb 2 \& print "udppacketsize: ", $resolver\->udppacketsize, "\en"; \& $resolver\->udppacketsize(2048); .Ve .PP udppacketsize will set or get the packet size. If set to a value greater than the default \s-1DNS\s0 packet size, an \s-1EDNS\s0 extension will be added indicating support for \s-1UDP\s0 fragment reassembly. .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" The following environment variables can also be used to configure the resolver: .SS "\s-1RES_NAMESERVERS\s0" .IX Subsection "RES_NAMESERVERS" .Vb 3 \& # Bourne Shell \& RES_NAMESERVERS="192.0.2.1 192.0.2.2 2001:DB8::3" \& export RES_NAMESERVERS \& \& # C Shell \& setenv RES_NAMESERVERS "192.0.2.1 192.0.2.2 2001:DB8::3" .Ve .PP A space-separated list of nameservers to query. .SS "\s-1RES_SEARCHLIST\s0" .IX Subsection "RES_SEARCHLIST" .Vb 3 \& # Bourne Shell \& RES_SEARCHLIST="a.example.com b.example.com c.example.com" \& export RES_SEARCHLIST \& \& # C Shell \& setenv RES_SEARCHLIST "a.example.com b.example.com c.example.com" .Ve .PP A space-separated list of domains to put in the search list. .SS "\s-1LOCALDOMAIN\s0" .IX Subsection "LOCALDOMAIN" .Vb 3 \& # Bourne Shell \& LOCALDOMAIN=example.com \& export LOCALDOMAIN \& \& # C Shell \& setenv LOCALDOMAIN example.com .Ve .PP The default domain. .SS "\s-1RES_OPTIONS\s0" .IX Subsection "RES_OPTIONS" .Vb 3 \& # Bourne Shell \& RES_OPTIONS="retrans:3 retry:2 debug" \& export RES_OPTIONS \& \& # C Shell \& setenv RES_OPTIONS "retrans:3 retry:2 debug" .Ve .PP A space-separated list of resolver options to set. Options that take values are specified as \f(CW\*(C`option:value\*(C'\fR. .SH "IPv6 TRANSPORT" .IX Header "IPv6 TRANSPORT" The Net::DNS::Resolver library will enable IPv6 transport if the appropriate libraries (Socket6 and IO::Socket::INET6) are available and the destination nameserver has at least one IPv6 address. .PP The \fIforce_v4()\fR, \fIforce_v6()\fR and \fIprefer_v6()\fR methods with a non-zero argument may be used to configure transport selection. .PP The behaviour of the \fInameserver()\fR method illustrates the transport selection mechanism. If, for example, IPv6 is not available or IPv4 transport has been forced, the \fInameserver()\fR method will only return IPv4 addresses: .PP .Vb 3 \& $resolver\->nameservers( \*(Aq192.0.2.1\*(Aq, \*(Aq192.0.2.2\*(Aq, \*(Aq2001:DB8::3\*(Aq ); \& $resolver\->force_v4(1); \& print join \*(Aq \*(Aq, $resolver\->nameservers(); .Ve .PP will print .PP .Vb 1 \& 192.0.2.1 192.0.2.2 .Ve .SH "CUSTOMISED RESOLVERS" .IX Header "CUSTOMISED RESOLVERS" Net::DNS::Resolver is actually an empty subclass. At compile time a super class is chosen based on the current platform. A side benefit of this allows for easy modification of the methods in Net::DNS::Resolver. You can simply add a method to the namespace! .PP For example, if we wanted to cache lookups: .PP .Vb 1 \& package Net::DNS::Resolver; \& \& my %cache; \& \& sub search { \& $self = shift; \& \& $cache{"@_"} ||= $self\->SUPER::search(@_); \& } .Ve .SH "BUGS" .IX Header "BUGS" \&\fIbgsend()\fR does not honour the usevc flag and only uses \s-1UDP\s0 for transport. .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c)1997\-2002 Michael Fuhr. .PP Portions Copyright (c)2002\-2004 Chris Reinhardt. .PP Portions Copyright (c)2005 Olaf M. Kolkman, NLnet Labs. .PP Portions Copyright (c)2014 Dick Franks. .PP All rights reserved. This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself. .SH "SEE ALSO" .IX Header "SEE ALSO" perl, Net::DNS, Net::DNS::Packet, Net::DNS::Update, Net::DNS::Header, Net::DNS::Question, Net::DNS::RR, \&\fIresolver\fR\|(5), \s-1RFC 1035, RFC 1034\s0 Section 4.3.5