Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x support forum
 Helicon Tech : ISAPI_Rewrite 2.x support forum
Subject Topic: Blocking IP addresses and ranges Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
damonw
Newbie
Newbie


Joined: 23 May 2008
Online Status: Offline
Posts: 4
Posted: 23 May 2008 at 7:38am | IP Logged Quote damonw

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 View damonw's Profile Search for other posts by damonw
 
damonw
Newbie
Newbie


Joined: 23 May 2008
Online Status: Offline
Posts: 4
Posted: 23 May 2008 at 8:24am | IP Logged Quote damonw

What I mean is instead of user agent names can ISAPI be used to block IP numbers?
Back to Top View damonw's Profile Search for other posts by damonw
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7389
Posted: 23 May 2008 at 8:30am | IP Logged Quote Lexey

Of course.

RewriteCond %REMOTE_ADDR 192\.168\..*|10\..*
RewriteRule (.*) $1 [F]
Back to Top View Lexey's Profile Search for other posts by Lexey
 
damonw
Newbie
Newbie


Joined: 23 May 2008
Online Status: Offline
Posts: 4
Posted: 23 May 2008 at 8:40am | IP Logged Quote damonw

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 View damonw's Profile Search for other posts by damonw
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7389
Posted: 23 May 2008 at 8:45am | IP Logged Quote Lexey

Quote:

Is this an IP address?


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 View Lexey's Profile Search for other posts by Lexey
 
damonw
Newbie
Newbie


Joined: 23 May 2008
Online Status: Offline
Posts: 4
Posted: 23 May 2008 at 8:52am | IP Logged Quote damonw

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 View damonw's Profile Search for other posts by damonw
 
alucas
Newbie
Newbie


Joined: 15 May 2008
Location: United States
Online Status: Offline
Posts: 6
Posted: 17 July 2008 at 7:50pm | IP Logged Quote alucas

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 View alucas's Profile Search for other posts by alucas
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7389
Posted: 28 July 2008 at 4:57pm | IP Logged Quote Lexey

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 View Lexey's Profile Search for other posts by Lexey
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum