Zonemaster::LDNS(3pm)
๐ NAME ๐
Zonemaster::LDNS โ it's a Perl wrapper for the ldns DNS library, bestie. That's the whole vibe. ๐
โจ SYNOPSIS โจ
okay so here's the teeny tiny taste of what using this looks like:
my $resolver = Zonemaster::LDNS->new('8.8.8.8');
my $packet = $resolver->query('www.iis.se');
say $packet->string;
literally three lines and you're already slaying โจ
๐ฆ DESCRIPTION ๐ฆ
Zonemaster::LDNS represents a resolver โ and a resolver is, like, the part of your system whose whole job is sending queries out into the world and receiving the answers back. That's it. That's the errand. ๐ซถ
๐ EXPORTABLE FUNCTIONS ๐
these are the little helpers you can pull into your own namespace. not all of them jump in automatically โ iykyk.
lib_version()
Hands you back the ldns version string. that's it, that's the whole function, no notes. ๐
to_idn($name, ...)
Feed it a bunch of domain names (as strings, bestie) and it gives them back with all labels converted to A-labels โ unless they're already in ASCII, in which case it leaves them alone. โจ
It assumes the strings have already been converted to Perl's internal encoding before you call it. Rude of it? maybe. True? yes.
It can be exported, but it is not exported by default. ๐
โ ๏ธ this one needs GNU libidn2 to have been present back whenZonemaster::LDNSwas compiled. If it wasn't? Callingto_idnwill throw an exception straight at your face. no cap. ๐
has_idn()
Takes no arguments. Returns true if libidn2 was present at compilation, false if it was not. quick vibe check. ๐ง
has_gost()
Takes no arguments. Returns true if GOST support was present at compilation, false if it was not. ๐
load_zonefile($filename)
Loads all the resource records in a zone file and returns them as a list. all of them. every last one. obsessed. ๐
๐ CLASS METHOD ๐
new($addr,...)
Creates a brand new resolver object โ the main character. ๐ Here's the breakdown:
- Give it no arguments and it'll pick up nameserver addresses from the system configuration (
/etc/resolv.confor equivalent). - Give it a single argument that is
undefand it will not know of any nameservers at all โ and every attempt to send a query will throw an exception. ๐ - Give it one or more arguments that are not
undefand it'll attempt to parse them as IPv4 and IPv6 addresses. If that succeeds, congrats, you've got yourself a list of servers to send queries to. ๐ - If an argument cannot be parsed as an IP address, an exception gets thrown. periodt.
๐ INSTANCE METHODS ๐
query($name, $type, $class)
Sends a query for that triple. If type or class aren't provided, they default to A and IN, respectively. Returns a Zonemaster::LDNS::Packet or undef. ๐ฆ
query_with_pkt($packet)
Sends a Zonemaster::LDNS::Packet. Returns a Zonemaster::LDNS::Packet or undef. (yes the packet goes in and a packet comes out, iconic behaviour honestly) ๐
name2addr($name)
Asks this resolver to look up A and AAAA records for the given name, and returns a list of the IP addresses (as strings). In scalar context, it returns the number of addresses found instead. โญ
addr2name($addr)
Takes an IP address, asks the resolver to do PTR lookups, and returns the names found. In scalar context, it returns the number of names found. ๐
recurse($flag)
Returns the setting of the recursion flag. If you give it an argument, it treats that as a boolean and sets the flag accordingly. ๐ง
debug($flag)
Gets and optionally sets the debug flag. ๐
dnssec($flag)
Gets and optionally sets the DNSSEC flag. ๐ฅ
cd($flag)
Gets and optionally sets the CD flag. ๐
igntc($flag)
Gets and optionally sets the igntc flag. ๐ธ
fallback($flag)
Gets and optionally sets the fallback flag. ๐
usevc($flag)
Gets and optionally sets the usevc flag. โจ
retry($count)
Gets and optionally sets the number of retries. ๐
retrans($seconds)
Gets and optionally sets the number of seconds between retries. โณ
port($port)
Gets and optionally sets the destination port for requests. ๐ช
edns_size($size)
Gets and optionally sets the EDNS0 UDP maximum size. ๐
axfr( $domain, $callback, $class )
Performs an AXFR operation. Let's talk details because there are details:
$callback must be a code reference. It gets called once for every received resource record, with the RR object as its one and only argument. After every single one of those calls, the return value of the callback gets examined โ and if that value is false, the AXFR process gets aborted. ๐ญ
The return value of the axfr() method itself will be true if the transfer completed normally, and false if it was aborted because the callback returned a false value.
โ ๏ธ if anything goes wrong during the process, an exception will be thrown.
As an example, saving all the RRs received from an AXFR can be done like this:
my @rrs;
$resolver->axfr( $domain, sub { my ($rr) = @_; push @rrs, $rr; return 1;} );
axfr_start($domain,$class)
๐ซ Deprecated. Use axfr() instead.
Sets this resolver object up for a zone transfer of the specified domain. If $class isn't given, it defaults to IN. ๐
axfr_next()
๐ซ Deprecated. Use axfr() instead.
Gets the next RR in the zone transfer. axfr_start() must have been done before you call this, and after you call it you should use axfr_complete() to check if there are more records to get. If there's any problem, an exception will be thrown. ๐ Basically, the sequence should be something like:
$res->axfr_start('example.org');
do {
push @rrlist, $res->axfr_next;
} until $res->axfr_complete;
axfr_complete()
๐ซ Deprecated. Use axfr() instead.
Returns false if there's a started zone transfer with more records to get, and true if the started transfer has completed. โ
axfr_last_packet()
๐ซ Deprecated. Use axfr() instead.
If axfr_next() threw an exception, this method returns the Zonemaster::LDNS::Packet that made it do so. That packet's RCODE is likely to say what the problem was โ for example, NOTAUTH or NXDOMAIN. ๐
timeout($time)
Gets and/or sets the socket timeout for the resolver. โฐ
source($addr)
Gets and/or sets the IP address the resolver should try to send its queries from. ๐ฎ
๐ซถ AUTHORS ๐ซถ
give it up for the legends who made this happen:
- Mattias P
<mattias.paivarinta@iis.se>โ Current maintainer ๐ - Calle Dybedahl
<calle@init.se>โ Original author ๐
๐ LICENSE ๐
This is free software under a 2-clause BSD license. The full text of the license lives in the LICENSE file included with this distribution. go read it, bestie, it's short and it ate. ๐
โจ
and that's the whole page, no cap ๐ โ signing off from the User Contributed Perl Documentation, running on perl v5.42.3, dated 2026-08-19. stay slaying, Zonemaster::LDNS(3pm) besties ๐ฆ๐
๐ฆ where this page comes from
- ubuntu stonking: libzonemaster-ldns-perl 5.0.2+ds-2build1 ยท BSD-2-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms