Forum Moderators: phranque

Message Too Old, No Replies

Blocking range of IPs in htaccess

Will this IP block work?

         

grandma genie

6:05 pm on Aug 18, 2010 (gmt 0)

10+ Year Member



Hello everyone,
I have been using this to block a range of IPs in htaccess. Is this the correct way to do so:

deny from 112.224.0.0/112.255.255.255

Jeannie

SevenCubed

6:30 pm on Aug 18, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is what you would be looking for:

112.224.0.0/11

That blocks a range of 2,097,150 IP addresses from China

grandma genie

11:10 pm on Aug 18, 2010 (gmt 0)

10+ Year Member



Hi SC,
Thank you. That is very helpful.
Jeannie

grandma genie

12:05 am on Aug 22, 2010 (gmt 0)

10+ Year Member



I notice most people use this format in htaccess:

order allow,deny
deny from 24.00.00.00
allow from all

Why can't you do the same thing like this:

order allow/deny
allow from 24.00.00.00
deny from all

If you just want to allow USA and Canada visitors by only allowing USA and Canada IP addresses. Wouldn't this block everyone else? I only sell to American and Canadian customers and most of the others are just taking my pictures.

Will this work?

Jeannie

jdMorgan

12:38 pm on Aug 22, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In theory, it could work. But IP addresses are not assigned by geographic regions. In fact, they are assigned in fairly small "chunks" to whoever requests them. So to explicitly allow US and Canada would likely require several hundred lines of Allows, and you have to consider the consequences of "forgetting a range."

Take a look at IP2country for more info about the mess that is IP-address-to-country-mapping.

Jim