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 when Zonemaster::LDNS was compiled. If it wasn't? Calling to_idn will 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.conf or equivalent).
  • Give it a single argument that is undef and 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 undef and 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