Net::DNSBL::Client(3)
π Net::DNSBL::Client β the manual, but make it make sense π
okay bestie, so <pink>Net::DNSBL::Client</pink> is a Perl module that lives in the User Contributed Perl Documentation section, and it's literally your little group-chat manager for talking to a whole squad of DNSBLs at once. Multiple blocklists, one query, no drama. Let's get into it π¦
β¨ NAME β¨
Net::DNSBL::Client β client code for querying multiple DNSBLs. that's it, that's the whole vibe. π
πΈ SYNOPSIS πΈ
here's the whole thing in action, no cap:
use Net::DNSBL::Client;
my $c = Net::DNSBL::Client->new({ timeout => 3 });
$c->query_ip('127.0.0.2', [
{ domain => 'simple.dnsbl.tld' },
{ domain => 'masked.dnsbl.tld', type => 'mask', data => '0.0.0.255' },
{ domain => 'txt.dnsbl.tld', type => 'txt' },
{ domain => 'need-a-key.example.net' }],
{ lookup_keys => { 'need-a-key.example.net' => 'my_secret_key' }});
# And later...
my $answers = $c->get_answers();
see how it just slays? four DNSBLs, one call, and the keyed one gets its secret handed over separately so the results stay readable. iconic. β¨
π METHODS π
π Class Methods
new ( $args )
hands you back a brand-new Net::DNSBL::Client object. fresh out the box, ready to go π«Ά
$args is a hash reference and may contain the following key-value pairs:
resolverβ (optional) aNet::DNS::Resolverobject. if you don't hand one over, a new resolver gets created for you. no biggie.timeoutβ (optional) an integer number of seconds to use as the upper time limit for the query. if you don't provide it, the default is 10 seconds. and if you do provide it, it must be a positive integer, bestie. no zero, no negatives, no vibes-based timeouts. π
π Instance Methods
get_resolver ( )
returns the Net::DNS::Resolver object being used for DNS queries. it's giving "who's on aux". π§
get_timeout ( )
returns the timeout, in seconds, for queries.
set_timeout ( $secs )
sets the timeout, in seconds, for queries. glow-up for your patience levels. β¨
query_is_in_flight ( )
returns non-zero if query has been called but get_answers hasn't been called yet. returns zero otherwise. it's basically the "are we waiting on someone rn" check. π
query_ip ( $ipaddr, $dnsbls [, $options])
issues a whole set of DNS queries. and here's the thing you need to know: query_ip() returns as soon as the DNS queries have been issued. it does not wait around for the DNS responses to come back. it's not a waiter, it's a sender. π
once query_ip() has been called, the Net::DNSBL::Client object is said to have a query in flight. and query_ip() may not be called again while a query is in flight. one at a time, bestie, we're not chaos gremlins (today).
$ipaddris the text representation of an IPv4 or IPv6 address.$dnsblsis a reference to a list of DNSBL entries; each DNSBL entry is a hash with the following members:domainβ (required) the domain to query. for example,zen.spamhaus.org. this one's mandatory, no skipping it. π¨typeβ (optional) the type of DNSBL. possible values are:normalβ meaning any returned A record indicates a hit,matchβ meaning one of the returned A records must exactly match a given IP address,maskβ meaning one of the returned A records must evaluate to non-zero when bitwise-ANDed against a given IP address,- or
txtβ meaning TXT records should be looked up and returned (rather than A records).
if omitted, type defaults to normal.
dataβ (optional) for thematchandmasktypes, this data specifies the required match or the bitwise-AND mask. in the case of amasktype, the data can be something like"0.0.0.4", or an integer like"8". in that latter case, the integer n must range from 1 to 255 and is equivalent to0.0.0.n.
for match-type lookups, one or more of the octets can be specified as "x" or "X". for example, specifying a match against 127.0.X.3 will match a return code whose first octet is 127, second is zero, third is anything, and fourth is 3. wildcard energy. π¦
userdataβ (optional) this element can be any scalar or reference that you like. it is simply returned back to you unchanged in the list of hits. it's the "hold my stuff" pocket of this module. π
$options, if supplied, is a hash of options. currently, three options are defined:
early_exitβ if set to1, querying will stop after the first positive result is received, even if other DNSBLs are being queried. default is0.return_allβ if set to1, then the return value fromget_answers()will contain all DNSBLs that were supplied toquery_ip(), even if the DNSBL did not hit. if set to0(the default), then the return value fromget_answers()only returns entries for those DNSBLs that actually hit.lookup_keysβ this is a hashref ofdomain_name => key. some domains require a secret key to be inserted just before the domain name; rather than including the key in the domain, you can separate it out with thelookup_keyshash, making the returned results more readable. keep it cute, keep it clean. π
query_domain ( $domain, $dnsbls [, $options])
similar to query_ip, but it considers $domain to be a domain name rather than an IP address, and it does not reverse the domain. same energy, different input. π
get_answers ( )
this method may only be called while a query is in flight. it waits for DNS replies to come back and returns a reference to a list of hits. once get_answers() returns, a query is no longer in flight. so like, don't call it when nothing's happening, it will not be cute. π
note that the list of hits is not necessarily returned in the same order as the original list of DNSBLs supplied to query_ip(). do not count on ordering, bestie. seriously.
each hit in the returned list is a hash reference containing the following elements:
domainβ the domain of the DNSBL.hitβ set to1if the DNSBL was hit or0if it was not. (you will only get entries withhitset to0if you used thereturn_alloption toquery_ip().)typeβ the type of the DNSBL (normal,matchormask).dataβ the data supplied (fornormalandmasktypes).userdataβ the userdata as supplied in thequery_ip()call.actual_hitsβ reference to array containing actual A or TXT records returned by the lookup that caused a hit.replycodeβ the reply code from the DNS server (as a string). likely to be one ofNOERROR,NXDOMAIN,SERVFAILorTIMEOUT. (TIMEOUTis not a real DNS reply code; it is synthesized by this Perl module if the lookup times out. it's the module's own little invention π )
the hit may contain other elements not documented here; you should count on only the elements documented above. no peeking at undocumented fields and building your whole personality on them. π
if no DNSBLs were hit, then a reference to a zero-element list is returned. empty list, zero notes, moving on. β¨
π DEPENDENCIES π
Net::DNS::ResolverIO::Select
π AUTHOR π
- Dianne Skoll
<dianne@skoll.ca> - Dave O'Neill
<dmo@dmo.ca>
π COPYRIGHT AND LICENSE π
- Copyright (c) 2010 Roaring Penguin Software
- Copyright (c) 2022 Dianne Skoll
this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay, legally speaking. π
and that's the whole manual, bestie!! πβ¨π
this iconic little page came from perl v5.42.2 and it's dated 2025-12-14 β Net::DNSBL::Client(3), signing off π
π¦πΈ
π¦ where this page comes from
- fedora 43: perl-Net-DNSBL-Client 0.207-1.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- fedora 44: perl-Net-DNSBL-Client 0.207-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms