Jump to content

An Application of the checkdnsrr() Function


iwato

Recommended Posts

BACKGROUND: The following code takes an ordinary domain name, reverses it, concatenates it to another domain name via a dot, and performs a domain name record check. Apparently it is suppose to tell you whether or not a particular IP address has been black-listed. PROBLEM: What I find troubling is the length of time that it takes to process the code -- more than a half-minute. As I am hardly familiar with blacklisting, I am hoping that someone can explain the very long delay.

<?php	function check_dnsbl($ip) {		$dnsbl_check=array("bl.spamcop.net","list.dsbl.org",			"sbl.spamhaus.org",'xbl.spamhaus.org');		if($ip){			$rip=implode('.',array_reverse(explode(".",$ip)));			foreach($dnsbl_check as $val){				if(checkdnsrr($rip.'.'.$val.'.','A'))					return $rip.'.'.$val;			}		}		return false;	}?>

Roddy

Link to comment
Share on other sites

If you want to avoid the delay, you'd have to build a custom DNS cache - a list of IPs residing locally that you check before resolving the domains and updating the IP list regularly, or better yet, use dns_get_record(), keep the TTL and refresh the cache based on it (like real DNS caches do). Why doesn't PHP have a built in DNS cache is beyond me.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...