I'd like to add a range of IPs to Apache httpd 2.2 where the third octet is in a range:


I can do this:

Allow from X.Y.192
Allow from X.Y.193
. . .
Allow from Y.Y.254

But, that's pretty verbose. I'm basically trying to add a list of partial IPs.

Is there a shortcut?


Allow can use a network address and mask, per https://httpd.apache.org/docs/2.2/mod/mod_authz_host.html#allow with either a mask or a number of bits.

192 to 254 (255 in fact) corresponds to the first two bits of the last (4th) byte to be set to 1.

So will match to

If you really need not to match the .255 then you will need multiple Allow statements. Or add deny from Result will then depend on the order setting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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