Forum Moderators: phranque

Message Too Old, No Replies

Forbid a Certain Range of IPs via Class A

Denying a range of Class A IPs, does this look correct?

         

MickeyRoush

11:57 pm on Aug 26, 2011 (gmt 0)

10+ Year Member



I'm trying to forbid a certain range of IPs via Class A.

The Class A's are:

210.
211.
212.
213.
217.
218.
219.
220.
221.
222.


Does this look correct?

RewriteCond %{REMOTE_ADDR} ^2(1([0-3]|[7-9])|2[0-2])\.
RewriteRule .* - [F]

The pipe is needed between [0-3] and [7-9] and the grouping is needed correct? I want to exclude 214. 215. and 216.

Any help or a point in the right direction would be greatly appreciated.

wilderness

12:51 am on Aug 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



RewriteCond %{REMOTE_ADDR} ^2(1[0-3789]|2[012])\.
RewriteRule .* - [F]


Somewhere (either in the Apache for SSID forums) there's an explanation of the speediest use of sequences and groups (I may not be using the correct terminology).

two or three numbers in a set sequence are acceptable ([23] or [456], however more must sequential numbers (actually characters) must be defined with a hyphen [0-4] or [013-8]or [013-79] or [0125689] are all valid examples.

Your still allowed to include additional characters in the group that are outside the previous group ranges

lucy24

1:15 am on Aug 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



[012]


Does this form run faster than [0-2]? They obviously mean the same thing and take up the same number of bytes. Same for [789] vs. [7-9]. (I noticed you kept [0-3], at a savings of one byte ;))

wilderness

1:27 am on Aug 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



yes the examples of sequences that I provided run faster, however you'll need to locate the person whom has the capability to measure such minute-ms's.

It's certainly not me ;)

a sequence of 2 or 3 characters is acceptable, four or more, are not.

wilderness

6:58 am on Aug 27, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Lucy,
Here's a saved explanation from Jim in early 2007:

[789] is marginally faster, doing three discrete compares without having to call the (more complicated) range-processing routine for [7-9].

MickeyRoush

2:53 pm on Aug 27, 2011 (gmt 0)

10+ Year Member



@ wilderness

Your awesome. Thanks for solution and explanation. The explanation is what I really needed. It will help me with configuring other rules. Thanks again!