I suppose most folks have avoided replying because there are simply too many questions with answers that are in the archives.
I implemented a bad bot blackhole, and left it running for two weeks. It has since blocked over 2k unique IPs.
It is my recollection of Key Master's 2002 script (
Ban malicious visitors with this Perl Script [webmasterworld.com]
) that these precise/unique IP blocks were ONLY active temporarily and were updated often by the same script.
I asked elsewhere on these forums, and was told I should be blocking IP ranges rather than individual ips.
That assumption is correct!
Does anyone have a script or php function to condense a list of IPs into a list of ip ranges?
I'm not aware that any such thing exists, however in order for it exist it would require a LOOKUP and COMPARE in one of two ways:
1) either an offline database of all IP's, registrants (such a thing does exist however it is very, very large and doing a comparison lookup would take forever even with today's computers).
2) a capability to lookup the known IP to multiple online Registrars and then extract the full-CIDR (or in the case mod-rewrite; convert to mod_rewrite IP syntax.
Additionally - if my bad bot script wants to block an IP, is it safe to go ahead and block that entire ip range? Seems like I might be blocking other people?
Each webamster must determine what is beneficial or detrimental to their own website (s) (another Webmaster World member previously advised you of same)
However, and generally speaking, most bots run rampant from commericial IP's (i.e., server farms and/or hosts) with the most exceptions being from corrupted machines (botnets).
If it is pretty safe, then how would I go about blocking an IP range rather than an individual IP?
There are many, many examples of methods in Webmaster World archives.
The
Close to Perfect htaccess [webmasterworld.com] thread provides methods (syntax) that is still function (despite most of the IP's and UA's being outdated.
Is there a whois lookup function or API that will return the range for me?
Each of the following offers their own WHOIS lookups:
ARIN
APNIC
AFRINIC
LACNIC
RIPE
Hope I've answered all your questions.