Scroll to navigation

Zonemaster::Engine::Nameserver(3pm) User Contributed Perl Documentation Zonemaster::Engine::Nameserver(3pm)

NAME

Zonemaster::Engine::Nameserver - object representing a DNS nameserver

SYNOPSIS

    my $ns = Zonemaster::Engine::Nameserver->new({ name => 'ns.nic.se', address => '212.247.7.228' });
    my $p = $ns->query('www.iis.se', 'AAAA');

DESCRIPTION

This is a very central object in the Zonemaster::Engine framework. All DNS communications with the outside world pass through here, so we can do things like synthezising and recording traffic. All the objects are also unique per name/IP pair, and creating a new one with an already existing pair will return the existing object instead of creating a new one. Queries and their responses are cached by IP address, so that a specific query will only be sent once to each address (even if there are multiple objects for that address with different names).

Class methods on this class allows saving and loading cache contents.

ATTRIBUTES

A Zonemaster::Engine::DNSName object holding the nameserver's name.
A Net::IP::XS object holding the nameserver's address.
The Zonemaster::LDNS object used to actually send and receive DNS queries.
A reference to a Zonemaster::Engine::Nameserver::Cache object holding the cache of sent queries. Not meant for external use.
The source address all resolver objects should use when sending queries. Depends on the IP version used to send the queries.
The IPv4 source address all resolver objects should use when sending queries over IPv4.
The IPv6 source address all resolver objects should use when sending queries over IPv6.
A reference to a list with elapsed time values for the queries made through this nameserver.

CLASS METHODS

Construct a new object.
Save the entire object cache to the given filename, using the byte-order-independent Storable format.
Replace the entire object cache with the contents of the named file.
Class method that returns a list of all nameserver objects in the global cache.
Remove all cached nameserver objects and queries.

INSTANCE METHODS

Send a DNS query to the nameserver the object represents. $name and $type are the name and type that will be queried for ($type defaults to 'A' if it's left undefined). $flagref is a reference to a hash, the keys of which are flags and the values are their corresponding values. The available flags are as follows. All but 'class' and 'edns_details' directly correspond to methods in the Zonemaster::LDNS::Resolver object.
Defaults to 'IN' if not set.
Send the query via TCP (only).
The retransmission interval.
Set the DO flag in the query. Defaults to false.

If set to true, it becomes an EDNS query. Value overridden by 'edns_details->do' (if also given). More details in 'edns_details' below.

Set the debug flag in the resolver, producing output on STDERR as the query process proceeds.
Set the RD flag in the query.
Set the timeout for the outgoing sockets. May or may not be observed by the underlying network stack.
Set the number of times the query is tried.
If set to true, incoming response packets with the TC flag set are not automatically retried over TCP.
If set to true, incoming response packets with the TC flag set fall back to EDNS and/or TCP.
If set to true, prevents a server to be black-listed on a query in case there is no answer OR rcode is REFUSED.
Set the EDNS0 UDP maximum size. Defaults to 512.

Used only when the query is an EDNS query. Does not enable on its own the query to be an EDNS query. Value overridden by 'edns_details->size' (if also given). More details in 'edns_details' below.

A hash. An empty hash or a hash with any keys below will enable the query to be an EDNS query.

The currently supported keys are 'version', 'z', 'do', 'rcode', 'size' and 'data'. See Zonemaster::LDNS::Packet for more details (key names prefixed with 'edns_').

Note that flag 'edns_size' also exists (see above) and has the same effect as 'edns_details->size', although the value of the latter will take precedence if both are given.

Similarly, note that flag 'dnssec' also exists (see above) and has the same effect as 'edns_details->do', although the value of the latter will take precedence if both are given.

Returns a string representation of the object. Normally this is just the name and IP address separated by a slash.
Used for overloading comparison operators.
Returns the total time spent sending queries and waiting for responses.
Returns the shortest time spent on a query.
Returns the longest time spent on a query.
Returns the average time spent on queries.
Returns the median query time.
Returns the standard deviation for the whole set of query times.
Adds fake delegation information to this specific nameserver object. Takes the same arguments as the similarly named method in Zonemaster::Engine. This is primarily used for internal information, and using it directly will likely give confusing results (but may be useful to model certain kinds of misconfigurations).
Adds fake DS information to this nameserver object. Takes the same arguments as the similarly named method in Zonemaster::Engine.
Does an AXFR for the requested domain from the nameserver. The callback function will be called once for each received RR, with that RR as its only argument. To continue getting more RRs, the callback must return a true value. If it returns a true value, the AXFR will be aborted. See Zonemaster::LDNS::axfr for more details.
2024-04-22 perl v5.38.2