DNS::Unbound - A Perl interface to NLNetLabs’s Unbound recursive DNS resolver
my $dns = DNS::Unbound->new()->set_option( verbosity => 2 ); my $verbosity = $dns->get_option( 'verbosity' ); $dns->set_option( verbosity => 1 + $verbosity ); my $res_hr = $dns->resolve( 'cpan.org', 'NS' ); # See below about encodings in “data”. my @ns = map { $dns->decode_name($_) } @{ $res_hr->{'data'} };
Instantiates this class.
Runs a synchronous query for a given $NAME and $TYPE. $TYPE may be expressed numerically or, for convenience, as a string. $CLASS is optional and defaults to 1 (IN), which is probably what you want.
IN
Returns a reference to a hash that corresponds to a libunbound struct ub_result (cf. libunbound(3)), excluding len, answer_packet, and answer_len.
struct ub_result
len
answer_packet
answer_len
NOTE: Members of data are in their DNS-native RDATA encodings. (libunbound doesn’t track which record type uses which encoding, so neither does DNS::Unbound.) To decode some common record types, see "CONVENIENCE FUNCTIONS" below.
data
Sets a configuration option. Returns OBJ.
Gets a configuration option’s value.
Gives the libunbound version string.
Note that Socket provides the inet_ntoa() and inet_ntop() functions for decoding A and AAAA records.
inet_ntoa()
inet_ntop()
A
AAAA
The following may be called either as object methods or as static functions (but not as class methods):
Decodes a DNS name. Useful for, e.g., NS query results.
NS
Note that this will normally include a trailing . because of the trailing NUL byte in an encoded DNS name.
.
Decodes a list of character-strings into component strings, returned as an array reference. Useful for TXT query results.
TXT
https://github.com/FGasper/p5-DNS-Unbound
Special thanks to ATOOMIC for making some helpful review notes.
To install DNS::Unbound, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DNS::Unbound
CPAN shell
perl -MCPAN -e shell install DNS::Unbound
For more information on module installation, please visit the detailed CPAN module installation guide.