Forum Moderators: phranque

Message Too Old, No Replies

IP range access restriction

         

peter_budo

9:27 am on Nov 11, 2007 (gmt 0)

10+ Year Member



How do I setup allowed IP range for virtual hosting? I know I can do address by address (140.87.7.1 140.87.7.2 etc) or puting like 140.87.7. Problem is I need to allow access for range 140.87.7.1 - 140.87.7.20 for one intranet site and another range 140.87.7.21 140.87.7.50 for another intranet site.

jdMorgan

4:36 pm on Nov 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure which Apache module and directives you intend to use, and the implementation varies between them, so the first step is to review the Apache mod_access and mod_rewrite documentation.

With mod_access, it is much easier to implement access controls on address ranges which start at and are sized to powers of two, rather than powers of ten. So controlling .0 through .31 (32 addresses, or two raised to the fifth power) is much simpler and more efficient than controlling .1 through .30, for example.

With mod_rewrite, you'll need to define one or more regular-expressions patterns that encompasses the characters that make up the various IP address ranges -- Don't lose sight of the fact that mod_rewrite does a character compare, not a numeric compare. However, this method can support any range or size, regardless of the number base of the range start address and size.

Jim