DNS::LDNS(3)
DNS::LDNS(3) π
NAME πΈ
DNS::LDNS β Perl extension for the ldns library π¦
SYNOPSIS β¨
use DNS::LDNS ':all'
DESCRIPTION π
okay so DNS::LDNS is a perl OO-wrapper for the ldns library. A complete list of object methods is found in the perldoc for each of the individual classes. You may also read the documentation of the ldns library at http://www.nlnetlabs.nl/projects/ldns. π
Brief examples of usage π
Here's a little taste, bestie. No cap, these are the exact vibes:
use DNS::LDNS ':all';
my $z = new DNS::LDNS::Zone(filename => '/path/to/myzone');
print DNS::LDNS::last_error;
my $rr = new DNS::LDNS::RR('mylabel 3600 IN A 168.10.10.10');
print $z->soa->to_string;
my $rrlist = $z->rrs->push($rr);
print $z->to_string;
my $kl = new DNS::LDNS::KeyList;
$kl->push(new DNS::LDNS::Key(filename => 'key');
$kl->key(0)->set_pubkey_owner(
new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'myzone.org'));
my $signedz = $z->sign($kl);
print $signedz->to_string;
my $r = new DNS::LDNS::Resolver(filename => '/my/resolv.conf');
my $p = $r->send(
new DNS::LDNS::RData(LDNS_RDF_TYPE_DNAME, 'www.google.com'),
LDNS_RR_TYPE_A, LDNS_RR_CLASS_IN, LDNS_RD);
print $p->answer->to_string;
print $p->authority->to_string;
Classes π§
A description of the classes included and how they map to the ldns library structures, bestie:
DNS::LDNSβ Base class with static functions and constants.DNS::LDNS::Zoneβ Represents a parsed zonefile (maps to theldns_zonestruct).DNS::LDNS::RRListβ Represents a list of RRs. This class is also used to represent an RRSet if all the dnames and types are equal, (maps to theldns_rr_liststruct).DNS::LDNS::RRβ Represents a resource record (RR), (maps to theldns_rrstruct).DNS::LDNS::RDataβ Represents an rdata field or a dname in an RR (maps to theldns_rdfstruct).DNS::LDNS::Resolverβ Represents a DNS resolver (maps to theldns_resolverstruct).DNS::LDNS::Packetβ Represents a DNS package (maps to theldns_pktstruct).DNS::LDNS::Keyβ Represents a DNSSec private key (maps to theldns_keystruct).DNS::LDNS::KeyListβ Represents a linked list of keys (maps to theldns_key_liststruct).DNS::LDNS::DNSSecZoneβ Represents a zone with dnssec data (maps to theldns_dnssec_zonestruct).DNS::LDNS::RBTreeβ Represents a tree of DNSSecName nodes (maps to theldns_rbtreestruct).DNS::LDNS::RBNodeβ Represents a node in the RBTree (maps to theldns_rbnodestruct).DNS::LDNS::DNSSecNameβ Represents a dname in a DNSSecZone and holds a DNSSecRRSets list for this dname, possibly with signatures (maps to theldns_dnssec_namestruct).DNS::LDNS::DNSSecRRSetsβ Represents a linked list of DNSSec RR sets, possibly with signatures (maps to theldns_dnssec_rrsetsstruct).DNS::LDNS::DNSSecRRsβ Represents a linked list of RRs (maps to theldns_dnssec_rrsstruct).DNS::LDNS::DNSSecDataChainβ Represents a chain of RR, DNSKEY, and DS data used for building a dnssec trust tree (maps to theldns_dnssec_data_chainstruct).DNS::LDNS::DNSSecTrustTreeβ Represents a tree of chained trust relationships from a signed RR to a set of trust anchors (maps to theldns_dnssec_trust_treestruct).DNS::LDNS::GCβ Garbage collector. Handles ownership dependencies and freeing data used by the other classes. Used internally only.
One thing to note is that some of the classes have a seemingly overlapping functionality. The Zone and RRList are used to represent a generic zone. It may contain dnssec data but treats it like any other dns data and does not have any knowledge of its structure. The DNSSec* and RB* classes are building blocks for representing a signed zone in a more structured way. π
Static functions β
str = rr_type2str(type)
str = rr_class2str(class)
type = rr_type_by_name(str)
class = rr_class_by_name(str)
str = pkt_opcode2str(opcode)
str = pkt_rcode2str(rcode)
error = errorstr_by_id(status)
str = DNS::LDNS::last_error
status = DNS::LDNS::last_status
rr = dnssec_create_nsec(from, to, type)
rr = dnssec_create_nsec3(from, to, algorithm, flags, iterations, salt)
rr = create_nsec(current, next, rrs)
rr = create_nsec3(cur_owner, cur_zone, algorithm, flags,
iterations, salt, empty_nonterminals)
algo = signing_algorithm_by_name(name)
bool = key_algorithm_supported(algorithm)
rr = read_anchor_file(filename)
Object references and cloning π¦
Since some of the objects are found as sub objects within other objects, it is important to know how the wrapper classes handle object references, dependencies and cloning. The general rule is that accessor methods just return a reference to the object while methods inserting data inserts a clone of the object. Most classes have a clone method which can be used if a cloned object is what you really want. π
Examples:
DNS::LDNS::Zone::rrs returns a reference to the DNS::LDNS::RRList within the zone, so if you make changes to the RRList you also changes the Zone object. π
DNS::LDNS::RRList::push(rr) clones the rr, then pushes the cloned rr to the list. Changing the rr afterwards will not change the list. β¨
An exception is the Key class which does not have a clone mechanism. In this case we allow a free Key to be added to only one KeyList. Adding it to multiple lists will provoke an error. π
The wrapper keeps track of allocated data structures and references. Whenever data is no longer referred to by a perl object, it will be freed.
ERROR HANDLING π¨
The purpose for writing this wrapper class has been to be able to process zone file data with good time performance. Data checking and error handling is a bit sparse. π¬
Most constructors will update the DNS::LDNS::last_status variable if they fail (return undef). Wrapper methods to ldns functions which would return a status will update the static DNS::LDNS::last_status variable. Most methods do not return a status and will not reset this variable even though they succeeds. π
EXPORT π¦
None by default.
Exportable constants π
Status
LDNS_STATUS_ADDRESS_ERRLDNS_STATUS_CERT_BAD_ALGORITHMLDNS_STATUS_CRYPTO_ALGO_NOT_IMPLLDNS_STATUS_CRYPTO_BOGUSLDNS_STATUS_CRYPTO_EXPIRATION_BEFORE_INCEPTIONLDNS_STATUS_CRYPTO_NO_DNSKEYLDNS_STATUS_CRYPTO_NO_DSLDNS_STATUS_CRYPTO_NO_MATCHING_KEYTAG_DNSKEYLDNS_STATUS_CRYPTO_NO_RRSIGLDNS_STATUS_CRYPTO_NO_TRUSTED_DNSKEYLDNS_STATUS_CRYPTO_NO_TRUSTED_DSLDNS_STATUS_CRYPTO_SIG_EXPIREDLDNS_STATUS_CRYPTO_SIG_NOT_INCEPTEDLDNS_STATUS_CRYPTO_TSIG_BOGUSLDNS_STATUS_CRYPTO_TSIG_ERRLDNS_STATUS_CRYPTO_TYPE_COVERED_ERRLDNS_STATUS_CRYPTO_UNKNOWN_ALGOLDNS_STATUS_CRYPTO_VALIDATEDLDNS_STATUS_DDD_OVERFLOWLDNS_STATUS_DNSSEC_EXISTENCE_DENIEDLDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUNDLDNS_STATUS_DNSSEC_NSEC_RR_NOT_COVEREDLDNS_STATUS_DNSSEC_NSEC_WILDCARD_NOT_COVEREDLDNS_STATUS_DOMAINNAME_OVERFLOWLDNS_STATUS_DOMAINNAME_UNDERFLOWLDNS_STATUS_EMPTY_LABELLDNS_STATUS_ENGINE_KEY_NOT_LOADEDLDNS_STATUS_ERRLDNS_STATUS_FILE_ERRLDNS_STATUS_INTERNAL_ERRLDNS_STATUS_INVALID_B32_EXTLDNS_STATUS_INVALID_B64LDNS_STATUS_INVALID_HEXLDNS_STATUS_INVALID_INTLDNS_STATUS_INVALID_IP4LDNS_STATUS_INVALID_IP6LDNS_STATUS_INVALID_POINTERLDNS_STATUS_INVALID_STRLDNS_STATUS_INVALID_TIMELDNS_STATUS_LABEL_OVERFLOWLDNS_STATUS_MEM_ERRLDNS_STATUS_MISSING_RDATA_FIELDS_KEYLDNS_STATUS_MISSING_RDATA_FIELDS_RRSIGLDNS_STATUS_NETWORK_ERRLDNS_STATUS_NOT_IMPLLDNS_STATUS_NO_DATALDNS_STATUS_NSEC3_ERRLDNS_STATUS_NULLLDNS_STATUS_OKLDNS_STATUS_PACKET_OVERFLOWLDNS_STATUS_RES_NO_NSLDNS_STATUS_RES_QUERYLDNS_STATUS_SOCKET_ERRORLDNS_STATUS_SSL_ERRLDNS_STATUS_SYNTAX_ALG_ERRLDNS_STATUS_SYNTAX_BAD_ESCAPELDNS_STATUS_SYNTAX_CLASS_ERRLDNS_STATUS_SYNTAX_DNAME_ERRLDNS_STATUS_SYNTAX_EMPTYLDNS_STATUS_SYNTAX_ERRLDNS_STATUS_SYNTAX_INCLUDELDNS_STATUS_SYNTAX_INCLUDE_ERR_NOTIMPLLDNS_STATUS_SYNTAX_INTEGER_OVERFLOWLDNS_STATUS_SYNTAX_ITERATIONS_OVERFLOWLDNS_STATUS_SYNTAX_KEYWORD_ERRLDNS_STATUS_SYNTAX_MISSING_VALUE_ERRLDNS_STATUS_SYNTAX_ORIGINLDNS_STATUS_SYNTAX_RDATA_ERRLDNS_STATUS_SYNTAX_TTLLDNS_STATUS_SYNTAX_TTL_ERRLDNS_STATUS_SYNTAX_TYPE_ERRLDNS_STATUS_SYNTAX_VERSION_ERRLDNS_STATUS_UNKNOWN_INETLDNS_STATUS_WIRE_INCOMPLETE_ADDITIONALLDNS_STATUS_WIRE_INCOMPLETE_ANSWERLDNS_STATUS_WIRE_INCOMPLETE_AUTHORITYLDNS_STATUS_WIRE_INCOMPLETE_HEADERLDNS_STATUS_WIRE_INCOMPLETE_QUESTION
Resolver flags and constants
LDNS_RESOLV_ANCHORLDNS_RESOLV_DEFDOMAINLDNS_RESOLV_INETLDNS_RESOLV_INET6LDNS_RESOLV_INETANYLDNS_RESOLV_KEYWORDLDNS_RESOLV_KEYWORDSLDNS_RESOLV_NAMESERVERLDNS_RESOLV_OPTIONSLDNS_RESOLV_RTT_INFLDNS_RESOLV_RTT_MINLDNS_RESOLV_SEARCHLDNS_RESOLV_SORTLIST
Resolver query flags
LDNS_AALDNS_ADLDNS_CDLDNS_QRLDNS_RALDNS_RDLDNS_TC
Resolver rcodes
LDNS_RCODE_FORMERRLDNS_RCODE_NOERRORLDNS_RCODE_NOTAUTHLDNS_RCODE_NOTIMPLLDNS_RCODE_NOTZONELDNS_RCODE_NXDOMAINLDNS_RCODE_NXRRSETLDNS_RCODE_REFUSEDLDNS_RCODE_SERVFAILLDNS_RCODE_YXDOMAINLDNS_RCODE_YXRRSET
Packet types
LDNS_PACKET_ANSWERLDNS_PACKET_NODATALDNS_PACKET_NXDOMAINLDNS_PACKET_QUESTIONLDNS_PACKET_REFERRALLDNS_PACKET_UNKNOWN
Packet opcodes
LDNS_PACKET_IQUERYLDNS_PACKET_NOTIFYLDNS_PACKET_QUERYLDNS_PACKET_STATUSLDNS_PACKET_UPDATE
Packet sections
LDNS_SECTION_ADDITIONALLDNS_SECTION_ANSWERLDNS_SECTION_ANYLDNS_SECTION_ANY_NOQUESTIONLDNS_SECTION_AUTHORITYLDNS_SECTION_QUESTION
DNSSec constants
okay so finishing up that last list, here are the last few constants, bestie:
LDNS_DEFAULT_EXP_TIMELDNS_MAX_KEYLENLDNS_DNSSEC_KEYPROTO
DNSSec sign policies π‘οΈβ¨
these are the policies for DNSSec signing, no cap. here's the whole vibe:
LDNS_SIGNATURE_LEAVE_ADD_NEWLDNS_SIGNATURE_LEAVE_NO_ADDLDNS_SIGNATURE_REMOVE_ADD_NEWLDNS_SIGNATURE_REMOVE_NO_ADDLDNS_NSEC3_MAX_ITERATIONS
Key flags π©π
flags for keys, periodt. here's the list:
LDNS_KEY_REVOKE_KEYLDNS_KEY_SEP_KEYLDNS_KEY_ZONE_KEY
Key algorithms ππ
all the key algorithms, slay. here they are:
LDNS_DHLDNS_DSALDNS_DSA_NSEC3LDNS_ECCLDNS_RSAMD5LDNS_RSASHA1LDNS_RSASHA1_NSEC3LDNS_RSASHA256LDNS_RSASHA512LDNS_ECC_GOSTLDNS_PRIVATEDNSLDNS_PRIVATEOID
Signing algorithms βοΈπ₯
signing algorithms, the main character energy. here's the list:
LDNS_SIGN_DSALDNS_SIGN_DSA_NSEC3LDNS_SIGN_ECC_GOSTLDNS_SIGN_HMACSHA1LDNS_SIGN_HMACSHA256LDNS_SIGN_RSAMD5LDNS_SIGN_RSASHA1LDNS_SIGN_RSASHA1_NSEC3LDNS_SIGN_RSASHA256LDNS_SIGN_RSASHA512
Hashing algorithm π§π
hashing algorithms, they're giving very much 'secure the bag' energy. here:
LDNS_SHA1LDNS_SHA256LDNS_HASH_GOST
Rdata constants π¦β¨
rdata constants, no cap. here's the whole set:
LDNS_MAX_RDFLENLDNS_NSEC3_VARS_OPTOUT_MASKLDNS_RDF_SIZE_16BYTESLDNS_RDF_SIZE_6BYTESLDNS_RDF_SIZE_BYTELDNS_RDF_SIZE_DOUBLEWORDLDNS_RDF_SIZE_WORD
Rdata types ππ¦
rdata types, the whole squad. here's the list:
LDNS_RDF_TYPE_ALDNS_RDF_TYPE_AAAALDNS_RDF_TYPE_ALGLDNS_RDF_TYPE_APLLDNS_RDF_TYPE_ATMALDNS_RDF_TYPE_B32_EXTLDNS_RDF_TYPE_B64LDNS_RDF_TYPE_CERT_ALGLDNS_RDF_TYPE_CLASSLDNS_RDF_TYPE_DNAMELDNS_RDF_TYPE_HEXLDNS_RDF_TYPE_INT16LDNS_RDF_TYPE_INT16_DATALDNS_RDF_TYPE_INT32LDNS_RDF_TYPE_INT8LDNS_RDF_TYPE_IPSECKEYLDNS_RDF_TYPE_LOCLDNS_RDF_TYPE_NONELDNS_RDF_TYPE_NSAPLDNS_RDF_TYPE_NSECLDNS_RDF_TYPE_NSEC3_NEXT_OWNERLDNS_RDF_TYPE_NSEC3_SALTLDNS_RDF_TYPE_PERIODLDNS_RDF_TYPE_SERVICELDNS_RDF_TYPE_STRLDNS_RDF_TYPE_TIMELDNS_RDF_TYPE_HIPLDNS_RDF_TYPE_TSIGTIMELDNS_RDF_TYPE_TYPELDNS_RDF_TYPE_UNKNOWNLDNS_RDF_TYPE_WKS
Algorithms used in CERT RRs. ππ
algorithms used in CERT RRs, periodt. here's the list:
LDNS_CERT_ACPKIXLDNS_CERT_IACPKIXLDNS_CERT_IPGPLDNS_CERT_IPKIXLDNS_CERT_ISPKILDNS_CERT_OIDLDNS_CERT_PGPLDNS_CERT_PKIXLDNS_CERT_SPKILDNS_CERT_URI
RR compress flag ποΈπΈ
RR compress flags, lowkey important. here:
LDNS_RR_COMPRESSLDNS_RR_NO_COMPRESS
RR classes π·οΈπ
RR classes, the whole hierarchy. here's the list:
LDNS_RR_CLASS_ANYLDNS_RR_CLASS_CHLDNS_RR_CLASS_COUNTLDNS_RR_CLASS_FIRSTLDNS_RR_CLASS_HSLDNS_RR_CLASS_INLDNS_RR_CLASS_LASTLDNS_RR_CLASS_NONE
RR types πβ
RR types, the main event. here's the whole list, no cap:
LDNS_RR_TYPE_ALDNS_RR_TYPE_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RR_TYPE_UIDLDNS_RR_TYPE_UINFOLDNS_RR_TYPE_UNSPECLDNS_RR_TYPE_WKSLDNS_RR_TYPE_X25
Various defaults and other constants πβ¨
various defaults and other constants, the final boss. here's the list:
LDNS_DEFAULT_TTLLDNS_PORTLDNS_IP4ADDRLENLDNS_IP6ADDRLENLDNS_MAX_DOMAINLENLDNS_MAX_LABELLENLDNS_MAX_PACKETLENLDNS_MAX_POINTERSLDNS_RR_OVERHEADLDNS_RDATA_FIELD_DESCRIPTORS_COMMON
π BUGS π
okay so this package is still in the beta stage of development. there are no known bugs, but like, parts of the code haven't been tested super well yet. bugreports would be greatly appreciated, bestie! π
π SEE ALSO π
the one and only:
π AUTHOR π
Erik Pihl Ostlyngen, <erik.ostlyngen@uninett.no>
π COPYRIGHT AND LICENSE π
Copyright (C) 2013 by UNINETT Norid AS This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.
this page is from perl v5.42.2, dated 2026-06-11, for DNS::LDNS(3). stay iconic, bestie! π β¨
π¦ where this page comes from
- fedora 43: perl-ldns 1.9.2-1.fc43 Β· BSD-3-Clause
- fedora 44: perl-ldns 1.9.2-1.fc44 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms