skip to content

System: Expanding IPv6 Addresses for DNSBL Checks

A DNSBL is a DNS-based spam blocking list which can be used, for example, to bock emails originating from known spam servers. There are a number of DNSBL in existence, with some of the more popular being SORBS, Spamhaus and SpamCop.

Use of DNSBL is sometimes controversial as it can result in legitimate emails being blocked through no fault of the sender. Also because removal from some lists requires up-front payment.

RBL check for IPv4 addresses

To query a DNSBL to check an IPv4 address (e.g. 74.XXX.254.254) we first reverse the address, and then append the DNSBL domain. For example, we want to check if the preceding address appears in the Spamhaus Zen DNSBL we end up with

To query the blacklist directly we can use any number of command-line tools, including host and dig.

If the address is ok to accept emails from you will receive a null response:

# host Host not found: 3(NXDOMAIN) # dig a ;; AUTHORITY SECTION: 10 IN SOA 1804051006 3600 600 432000 10

While if there is a problem you will receive one or more addresses in response indicating that the address is currently blacklisted:

# host has address has address has address # dig a ;; ANSWER SECTION: 23 IN A 23 IN A 23 IN A # dig txt ;; ANSWER SECTION: 60 IN TXT "" 60 IN TXT ""

Each 127.0.0.* address returned represents a different sub-list or reason that the ip address has been black-listed. To find the meaning of these return values you need to refer to the DNSBL website as they vary across services.

Querying the TXT record is often more useful as it can return more detailed information or a link, as shown above.

Here is the same ip address run through SORBS:

# host has address has address # dig txt ;; ANSWER SECTION: 3600 IN TXT "Currently Sending Spam See:" 3600 IN TXT "Exploitable Server See:"

And through SpamCop:

# host has address # dig txt ;; ANSWER SECTION: 2100 IN TXT "Blocked - see"

As you can see that this particular IPv4 address appears in all three of the DNSBL tested.

RBL check for IPv6 addresses

Working with IPv6 address is more difficult for two reasons. Firstly, because they are often abbreviated, and secondly, because all 32 digits of the address need to be reversed.

For example, starting with: 2600:XXXX::f03c:91ff:fe50:d2

We first need to expand the address to its full length:


Then reverse the individual digits, ignoring the colons, and append the DNSBL domain as before:

# host has address # dig txt ;; ANSWER SECTION: 60 IN TXT ""

In this case the IPv6 address appears in the Spamhaus CSS Component of the SBL meaning that it has been blocked for belonging to a larger network of addresses, some of which are sending spam.

Preparing IP addresses for DNSBL checking

Here we've created a couple of useful tools which take an IPv4 or IPv6 address and convert it into the required format for a DNSBL lookup. First for IPv4:

IPv4 DNSBL Converter

And this form will work for IPv6 addresses:

IPv6 DNSBL Converter

These forms are JavaScript-only so you don't need to worry about the input values being exposed.

See the link under References below for a more comprehensive list of available DNSBL.

Enabling DNSBL checks in sendmail

In sendmail you just need to add the following to your make/reload and restart:

FEATURE(dnsbl, `', `Your outgoing mail server $&{client_addr} has been blacklisted by SORBS - see Database Check -')dnl FEATURE(dnsbl, `', `Your outgoing mail server $&{client_addr} has been blacklisted by Spamhaus - see Blocklist Removal Center -')dnl FEATURE(dnsbl, `', `Your outgoing mail server $&{client_addr} has been blacklisted by SpamCop - see')dnl


< System

Post your comment or question