Checking range of IP addresses
- From: "tim@xxxxxxxxxxxxxxxxxxxx" <tim@xxxxxxxxxxxxxxxxxxxx>
- Date: 23 Jul 2005 14:22:42 -0700
A Perl script I wrote for a CGI is getting spammed. So I'm identifying
and blocking ranges of IP addresses.
At first I used IF statements like this:
# 218.73.64.0 - 218.73.79.255 banned
@ip = split(/\./, $ENV{'REMOTE_ADDR'});
if ($ip[0] == 218 && $ip[1] == 73 && ($ip[2] >= 64 && $ip[2] <= 79)) {
$banned = 1;
}
I know that's probably horrible programming and not very elegant. But
it worked.
Now the list I want to block is getting longer. I could continue to add
IF statements but I feel that's probably stupid.
Any suggestions how I might try to more elegantly process a list of
banned IP's?
Thanks!
--Tim
.
- Follow-Ups:
- Re: Checking range of IP addresses
- From: Gunnar Hjalmarsson
- Re: Checking range of IP addresses
- From: Gunnar Hjalmarsson
- Re: Checking range of IP addresses
- Prev by Date: Re: copy contructor
- Next by Date: Re: Checking range of IP addresses
- Previous by thread: posting an array
- Next by thread: Re: Checking range of IP addresses
- Index(es):