Simple PHP Script for RBL Checking

Posted by Nessa | Posted in , | Posted on July 16, 2010

16

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)

<?php
require_once('Net/DNSBL.php');

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

foreach ($iplist as $ip){

$dnsbl = new Net_DNSBL();

$dnsbl->setBlacklists(array(
'sbl-xbl.spamhaus.org',
'dnsbl.sorbs.net',
'bl.spamcop.net',
'dnsbl-1.uceprotect.net',
'dnsbl-2.uceprotect.net',
'dnsbl-3.uceprotect.net',
'isps.spamblocked.com',
'zen.spamhaus.org'
));

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:

asiaspam.spamblocked.com
bl.deadbeef.com
bl.emailbasura.org
bl.spamcop.net
blackholes.five-ten-sg.com
blacklist.woody.ch
bogons.cymru.com
cbl.abuseat.org    cdl.anti-spam.org.cn
combined.abuse.ch
combined.rbl.msrbl.net
db.wpbl.info
dnsbl-1.uceprotect.net
dnsbl-2.uceprotect.net
dnsbl-3.uceprotect.net
dnsbl.abuse.ch
dnsbl.ahbl.org
dnsbl.cyberlogic.net
dnsbl.inps.de
dnsbl.njabl.org
dnsbl.sorbs.net
drone.abuse.ch
duinv.aupads.org
dul.dnsbl.sorbs.net
dul.ru
dyna.spamrats.com
dynip.rothen.com
eurospam.spamblocked.com
fl.chickenboner.biz
http.dnsbl.sorbs.net
images.rbl.msrbl.net
ips.backscatterer.org
isps.spamblocked.com
ix.dnsbl.manitu.net
korea.services.net
lacnic.spamblocked.com
misc.dnsbl.sorbs.net
noptr.spamrats.com
ohps.dnsbl.net.au
omrs.dnsbl.net.au
orvedb.aupads.org
osps.dnsbl.net.au
osrs.dnsbl.net.au
owfs.dnsbl.net.au
owps.dnsbl.net.au
pbl.spamhaus.org
phishing.rbl.msrbl.net
probes.dnsbl.net.au
proxy.bl.gweep.ca
proxy.block.transip.nl
psbl.surriel.com
rbl.interserver.net
rdts.dnsbl.net.au
relays.bl.gweep.ca
relays.bl.kundenserver.de
relays.nether.net
residential.block.transip.nl
ricn.dnsbl.net.au
rmst.dnsbl.net.au
sbl.spamhaus.org
short.rbl.jp
smtp.dnsbl.sorbs.net
socks.dnsbl.sorbs.net
spam.dnsbl.sorbs.net
spam.rbl.msrbl.net
spam.spamrats.com
spamlist.or.kr
spamrbl.imp.ch
t3direct.dnsbl.net.au
tor.ahbl.org
tor.dnsbl.sectoor.de
torserver.tor.dnsbl.sectoor.de
ubl.lashback.com
ubl.unsubscore.com
virbl.bit.nl
virus.rbl.jp
virus.rbl.msrbl.net
web.dnsbl.sorbs.net
wormrbl.imp.ch
xbl.spamhaus.org
zen.spamhaus.org

Be Sociable, Share!

Comments (16)

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 hexainfosoft.in and also business inquiry.

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 :)

[...] causing your email to bounce.  RBLmon.com is a good way to get started, or you can implement blacklist checking into your existing monitoring solution.  The goal is to know when your IPs are blacklisted as soon [...]

Is there a way which the script can return listed or not listed beside every server from the list?

Hi :)

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.

Hmmm the above doesn’t sound right.

Thanks for the code!
I really appreciate it.

(there that sounds better)

[...] » Simple PHP Script for RBL Checking :: v-nessa.net :: Programming is Sexy [...]

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….

Thanks!

Wow I didn’t know I needed this script until I came across your website. :)
Very sexy indeed.

Great! easy to follow and amazing tutorial.

tnx!.

Thanks

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.

[...] causing your email to bounce.  RBLmon.com is a good way to get started, or you can implement blacklist checking into your existing monitoring solution.  The goal is to know when your IPs are blacklisted as soon [...]

Hi Vanessa,

Nice blog, I have read couple of thread and found them amazing.

Nice, to see a girl writing such a technical blog :P

file(“…txt”,FILE_IGNORE_NEW_LINES);

was needed for it to work for me.

Thanks anyway.

Post a comment