Steve
Steve

Reputation: 1765

Block IP address range with .htaccess

How would I block the IP range 103.4.8.0 - 103.4.15.255 using .htaccess?

By this I mean I want to block

Upvotes: 0

Views: 307

Answers (2)

Steve
Steve

Reputation: 1765

I ended up using:

<Limit GET HEAD POST>
order allow,deny
allow from all
deny from 103.4.8.
deny from 103.4.9.
..
deny from 103.4.15.
</Limit>

Upvotes: 0

Amit Verma
Amit Verma

Reputation: 41209

You can give an address range using ip/netmask pair :

deny from 127.0.55.0/24

However, since range 55 - 75 are not power of two, I don't see how to make a range out of them. I'd add several rules.

order allow,deny
deny from 127.0.55.0/24  // Matches 55
deny from 127.0.56.0/21  // Matches 56 to 64
deny from 127.0.64.0/21  // Matches 64 to 71
deny from 127.0.72.0/22  // Matches 72 to 75

deny from 127.0.235.0/24 // Matches 235
deny from 127.0.236.0/22 // Matches 236 to 239
deny from 127.0.240.0/21 // Matches 240 to 255
allow from all

Upvotes: 2

Related Questions