Simple PHP Script for RBL Checking

It’s useful for ISP’s and email service providers to run occasional RBL checks against their IPs to know when they are being blacklisted by populate CBL services. I’ve written a simple script that utilizes the DNSBL pear library to check against common blacklists, when given a list of IPs in a file.

First, you need to download or install the NET_DNSBL pear module. (Command: pear install NET_DNSBL)


$iplist = file("/path/to/iplist");

foreach ($iplist as $ip){

$dnsbl = new Net_DNSBL();


if ($dnsbl->isListed($ip)) {

echo "IP $ip is blacklisted!\n";


else {
echo "IP $ip not listed\n";


Of course, this script can be very easily modified to pull IPs from a database, or assign the $ip variable from a GET or POST request (like from a form or API).  Here’s an exclusive list of some RBL’s you can check against using this script, by adding them to the array shown:

Be Sociable, Share!

16 thoughts on “Simple PHP Script for RBL Checking

  1. Hi good information related when for the Internet service provider and email service provider check the list with their ip and they know when it service blocked with this function get the know when your service is blocked. Thanks.
    Feel free and give suggestion about and also business inquiry.

  2. Hi,

    That’s really useful scripts for hosting provider like us to monitor our IP status, so we can take the proper action earlier before the IP blocked permanently :)

    thanks you Vanessa :)

  3. Hey, cute geek girl.
    Your code works great.
    With one caveat….
    if you put a RBL in the list that is down for whatever reason, an error is returned by php (for code in dns_rbl).

    I banged my head against this for a while.

    Thanks for the code. I had wasted nearly a day before this.

  4. WHen I check a few IP’s or just one IP it say:

    IP xx.xx.xx.xx not listed IP is blacklisted!

    Why does it say both ?
    And if it’s blacklisted, will it show which RBL it’s listed on ?

    Anyone can show how to use a Form / Post instead to use ?
    Not a programmer, but learning….


  5. great, but i hate pear, install one thing then you have 50 dependences which leads piles of garbage, so i’ll go look for something else.

Leave a Reply

Your email address will not be published. Required fields are marked *