RblFilterIsIPAddressInRbl Method
Checks if the given IP address is listed in the specified DNS RBL.

Namespace: MailBee.AntiSpam
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
public bool IsIPAddressInRbl(
	string ipString,
	string rblHost


Type: SystemString
The IPv4 address to check, as "" string.
Type: SystemString
The DNS RBL host name.

Return Value

Type: Boolean
true if this IP address is black-listed; othwerwise, false.
MailBeeInvalidArgumentExceptionipString or rblHost is a null reference (Nothing in Visual Basic) or an empty string, or ipString does not denote a valid IPv4 address.
MailBeeExceptionAnother error occurred (e.g. timeout from DNS server).

To check against multiple RBLs at once, use GetRblStatusesOfIPAddress(String, String) method (it can utilize multi-threading).

To fine-tune tradeoff between performance and accuracy, you can use different number of DNS servers (more servers tried - less performance but more accuracy), increase timeouts or retry count (the same effect), add option to try DNS via TCP, not just UDP (some DNS servers don't deliver meaningful replies via TCP although it's not common for DNS RBL servers).

Note Note
Be sure to specify the correct name for the RBL host. If you make a typo, it will have effect of RBL returning "not blacklisted" status for any IP address. No error will occur.

This sample checks an IP address against "zen.spamhaus.org" RBL. The most interesting line of code is the last one.

The sample also fine-tunes DNS checking routine for better performance (at cost of lower accuracy). You can remove "For performance sake" section to return to default DNS settings.

using System;
using MailBee;
using MailBee.DnsMX;
using MailBee.AntiSpam;

class Sample
    static void Main(string[] args)
        RblFilter rbl = new RblFilter();

        // Logging is helpful for debugging.
        rbl.Log.Enabled = true;
        rbl.Log.Filename = @"C:\Temp\log.txt";

        // RBL check needs DNS servers.

        // For performance sake, avoid making redundant TCP queries. UDP is enough with RBL.
        // Also, the default 5000ms timeout can be too long.
        foreach (DnsServer dns in rbl.DnsServers)
            dns.TryTcp = false;
            dns.UdpTimeout = 500;

            // Or you can leave UdpRetryCount=2 (default), it will end up in increased times to check against dead/slow RBLs
            // but the results will be more accurate.
            dns.UdpRetryCount = 1;

        Console.WriteLine("Is in RBL: " + rbl.IsIPAddressInRbl("", "zen.spamhaus.org").ToString());
See Also