| Author |
|
damonw Newbie

Joined: 23 May 2008
Online Status: Offline Posts: 4
|
| Posted: 23 May 2008 at 7:38am | IP Logged
|
|
|
Hi!
I saw a post a few days ago asking how to block spambots and followed the link.
I was wondering if its possible though to block specific IP addresses and IP ranges?
DW
|
| Back to Top |
|
| |
damonw Newbie

Joined: 23 May 2008
Online Status: Offline Posts: 4
|
| Posted: 23 May 2008 at 8:24am | IP Logged
|
|
|
What I mean is instead of user agent names can ISAPI be used to block IP numbers?
|
| Back to Top |
|
| |
Lexey Moderator Group

Joined: 15 August 2002 Location: Russian Federation
Online Status: Offline Posts: 7389
|
| Posted: 23 May 2008 at 8:30am | IP Logged
|
|
|
Of course.
RewriteCond %REMOTE_ADDR 192\.168\..*|10\..*
RewriteRule (.*) $1 [F]
|
| Back to Top |
|
| |
damonw Newbie

Joined: 23 May 2008
Online Status: Offline Posts: 4
|
| Posted: 23 May 2008 at 8:40am | IP Logged
|
|
|
Hi Lexey,
hmmm....can you help break this down for me?
192\.168\..*|10\..*
Is this an IP address?
What I mean is say example you wanted to block the ip 202.71.138.26 how would you write this?
And if you wanted to block several IP's such as
202.71.138.26, 80.203.142.68, 201.45.35.98 etc., how would I achieve this? Does this redirect to a 404 or does a block simply block and not forward the user anywhere?
|
| Back to Top |
|
| |
Lexey Moderator Group

Joined: 15 August 2002 Location: Russian Federation
Online Status: Offline Posts: 7389
|
| Posted: 23 May 2008 at 8:45am | IP Logged
|
|
|
No, this sample pattern mathces 192.168.* and 10.* subnets.
Quote:
| What I mean is say example you wanted to block the ip 202.71.138.26 how would you write this? |
|
|
RewriteCond %REMOTE_ADDR 202\.71\.138\.26
RewriteRule (.*) $1 [F]
Quote:
And if you wanted to block several IP's such as
202.71.138.26, 80.203.142.68, 201.45.35.98 etc., how would I achieve this?
|
|
|
RewriteCond %REMOTE_ADDR 202\.71\.138\.26|80\.203\.142\.68|201\.45\.35\.98
RewriteRule (.*) $1 [F]
Quote:
Does this redirect to a 404 or does a block simply block and not forward the user anywhere? |
|
|
These rules will result in 404 without forwarding. If you want to "redirect" a client to your own 404 handler replace the 2nd line with something like this:
RewriteRule .* /404.asp [L]
|
| Back to Top |
|
| |
damonw Newbie

Joined: 23 May 2008
Online Status: Offline Posts: 4
|
| Posted: 23 May 2008 at 8:52am | IP Logged
|
|
|
Lexey...you're great! Many many many thanks!!!! :)))
I love this product...seriously one of the best softwares I have ever purchased.
DW
|
| Back to Top |
|
| |
alucas Newbie

Joined: 15 May 2008 Location: United States
Online Status: Offline Posts: 6
|
| Posted: 17 July 2008 at 7:50pm | IP Logged
|
|
|
I have an add-on question, not sure if this is possible in ISAPI, but... is it possible to be more fine-grained with the IP ranges you're blocking? For instance, instead of blocking 212.96.*.*, I'd like to block 212.96.0.0 - 212.96.31.255
So anything 212.96.x.y is okay for x >= 32, and blocked for x < 32. The .* doesn't quite work in this particular situation, and I've got a few such ranges that need blocking.
Is this something that can be done cleanly with ISAPI_REWRITE, or is it the wrong approach in this particular case?
Much appreciated.
|
| Back to Top |
|
| |
Lexey Moderator Group

Joined: 15 August 2002 Location: Russian Federation
Online Status: Offline Posts: 7389
|
| Posted: 28 July 2008 at 4:57pm | IP Logged
|
|
|
RewriteCond %REMOTE_ADDR 212\.96\.(?:[12]?\d|3[01])\..*
RewriteRule (.*) $1 [F]
Quote:
| Is this something that can be done cleanly with ISAPI_REWRITE, or is it the wrong approach in this particular case? |
|
|
This could be done quite easily but a match pattern could be quite complex since there are no bit operations in the regular expressions.
|
| Back to Top |
|
| |