0

I want do deny the access to my Website for IP-Adresses from a certain IP range. (e.g. 143.56.122.127-143.56.122.255). I have found 4 different methods to do this on a Apache-Server:

  • Use a Deny from ###.###.###.### for each IP-address. This can be lots of work,...
  • Deny from ###.###.###.###/XX. I could not find out how I have to determine the number XX so that it does what I want.
  • Deny from ###.###.###.###/255.255.255.126. This is what I think could work for my specific example. I think it means that the difference to 255 of each part of the second IP-address is added to the first IP-address.
  • The fourth is one with pattern-matching, but this was not very intuitive and thus probably not the easiest way for most cases.

I think the second and third seem to be most straight forward, so can anybody explain them to me. do these methods have a name or are use in a standard?

1 Answer 1

2

I think, you can use second method.

Order allow,deny
//0.0.0.0 - 0.255.255.255.255
Allow from 0.0.0.0/8

//1.0.0.0 - 1.1.255.255
Allow from 1.0.0.0/15

//1.2.0.0 - 1.2.1.255
Allow from 1.2.0.0/23

//1.2.2.0 - 1.2.2.255
Allow from 1.2.2.0/24

//1.2.3.0 - 1.2.3.3
Allow from 1.2.3.0/30

This way, you can write

//143.56.122.127-143.56.122.255
Deny from 143.56.122.0/24
Allow from 143.56.122.0/25

You can also refer this. Though, i would like to make it pristine that i have never used in my project yet. This is suggestion. I would also like to read from others on this.

2
  • 1
    +1 But, according to whois the NetRange for that address is 143.56.0.0 to 143.56.255.255 and the CIDR is 143.56.0.0/16, so I guess the OP should ban that whole range, instead of part of it only. Jan 17, 2013 at 8:47
  • This was an IP that I made up as an example. +1 for the whois-link.
    – R_User
    Jan 18, 2013 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.