Forum Moderators: open

Message Too Old, No Replies

Colorado Internet Cooperative Association

199.45.128.0 - 199.45.255.255

         

wilderness

4:16 am on Nov 23, 2002 (gmt 0)

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



Is it possible Jim or perahps another might provide me one of those range numbers for excluding 128.-255 above.

RewriteCond %{REMOTE_ADDR} ^199\.45\.(12[8-9]¦25[0-5])\.

Is the above correct?
Thanks in advance.

I've lost my patience for this portion of Colorado and anybdoy connected to it :-(

jdMorgan

6:16 am on Nov 23, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



wilderness,


Is it possible Jim or perahps another might provide me one of those range numbers for excluding 128.-255 above.

RewriteCond %{REMOTE_ADDR} ^199\.45\.(12[8-9]¦25[0-5])\.

OK, if I understand the question, you want to cover 199.45.128.0 through 199.45.255.255, which would be something like:


RewriteCond %{REMOTE_ADDR} ^199\.45\.(12[89]¦1[3-9][0-9]¦2[0-4][0-9]¦25[0-5])\.

These regular expressions are always messy because they are lexical (text) compares, not numeric-range compares, and the digit ranges are derived from hexadecimal bytes translated to decimal, not decimal counts, i.e. the range of each IP address "field" is 0-255 instead of 0-999

I suppose you might just as well use:


RewriteCond %{REMOTE_ADDR} ^199\.45\.(12[89]¦1[3-9][0-9]¦2[0-5][0-9])\.

since it's slightly shorter, and you'll never get a request in the range of 199.45.256.x through 199.45.299.x anyway. I guess you'll never see a request for xx.xx.xx.0 or xx.xx.xx.255 either, come to think of it...

Warning to cut-n-pasters: The WebmasterWorld forum software seems to modify the pipe symbols "¦" as shown above to an alternative character that won't work in mod_rewrite, PERL, etc. Always replace any broken-vertical-line pipe symbol copied from posts here with solid-vertical-line pipe symbols, or you may get a 500-Server Error or the dreaded "Premature end of script headers" error if you try to use it as-is. :(

wilderness: If I didn't get the question right, let me know!

Jim

wilderness

11:55 am on Nov 23, 2002 (gmt 0)

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



Many thanks Jim.
You understood the range correctly.

I used a previous explanation of yours to derive the numbers I provided.
Is it possible you have realized since then that specific ranges would never be addressed?

Also I'd like to be able to grasp this in an effort to obtain my own ranges in the future.
The final numbers you provided and specifically the middle range have confused me.
Is it possible you could expand on what they do?

RewriteCond %{REMOTE_ADDR} ^199\.45\.(12[89]¦
1[3-9][0-9]-----------------midddle range?
¦2[0-5][0-9])\.

Many thanks for your assitance.

The following also bears reposting, altthough I'm not sure why when I made the error the 500 (which makes me grit my teeth) didn't appear.

Warning to cut-n-pasters: The WebmasterWorld forum software seems to modify the pipe symbols "¦" as shown above to an alternative character that won't work in mod_rewrite, PERL, etc. Always replace any broken-vertical-line pipe symbol copied from posts here with solid-vertical-line pipe symbols, or you may get a 500-Server Error or the dreaded "Premature end of script headers" error if you try to use it as-is.

jdMorgan

6:19 pm on Nov 23, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wilderness,

Sure, here goes...

Starting with


RewriteCond %{REMOTE_ADDR} ^199\.45\.(12[89]¦1[3-9][0-9]¦2[0-4][0-9]¦25[0-5])\.
and breaking it down:

^199\.45\.(12[89]
Match 199.45.128 - 199.45.129

¦1[3-9][0-9]
or 199.45.130 - 199.45.199

¦2[0-4][0-9]
or 199.45.200 - 199.45.249

¦25[0-5])
or 199.45.250 - 199.45.255

\.
followed by a dot and another unspecified group of characters, which would be the final digits of the IP address, 0-255. The reason they can be anything is that the pattern does not have an end anchor ($) on it.

This all comes down to a matter of style at some point; The shortest-form that would work to cover the whole range, while allowing some non-existent IP address values in the range of 256-299 to be matched would be:


RewriteCond %{REMOTE_ADDR} ^199\.45\.(12[89]¦1[3-9][0-9]¦2[0-9]{2})\.

In the above examples, I've used groups [89] and ranges [1-9]. The ranges are just a special form of group and are not mathematical in nature, they are character-code-range in nature. You can have [0-9a-z] if you want to match all digits and lowercase characters. Or [0-9A-Za-z] to include uppercase if you want. Or a random group instead of a range [1357ace]. Or, exclude some characters from matching [^abc] (in this case the "^" means "not"). Special characters like "." can also be included, but must be escaped with the preceding backslash, as usual.

I've also used the "occurrence count" which is in the form, {min,max}, and affects the previous character or the previous group of characters enclosed in () or []. Actually, I used the short form {count} to specify an exact count.

All of this is covered in this nice, short regular expressions tutorial [etext.lib.virginia.edu].

An easy way to read these multi-[] pattern groups is to read the left digits in the brackets first, then the right. For example, the pattern
1[1-9][0-9] can be read:
1[1-9][0-9] reading the left digits gives "110", then say "through" and read the right-side digits
1[1-9][0-9] giving "199".
So, it's "110 through 199"

I hope that clarifies the issue.
Jim

wilderness

1:05 am on Nov 24, 2002 (gmt 0)

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



Many thanks Jim for the extensive time and explanation.

Hopefully your insight has prodded me into some testing :-)