Freebsd – AH00526 – apache 2.4 require ip range

apache-2.4freebsdsubnet

I'm using FreeBSD 9.2-RELEASE-p5 w/ apache24-2.4.12 package:

[root@j ~]# uname -a
FreeBSD X 9.2-RELEASE-p5 FreeBSD 9.2-RELEASE-p5 #0 r265974: Wed May 14 07:57:04 PDT 2014     root@X:/usr/obj/usr/src/sys/R610  amd64
[root@j ~]# httpd -v
Server version: Apache/2.4.12 (FreeBSD)
Server built:   Feb  4 2015 19:03:59
[root@j ~]# 

I'd like to block certain network (118.168.0.0 – 118.171.255.255) from my Apache, using following configuration:

<RequireAll>
    Require not ip 118.168-171.0.0/16
    Require all granted
</RequireAll>

And while I'm running a syntax check, I'm getting following:

[root@j /usr/local/etc/apache24/Includes]# httpd -t
AH00526: Syntax error on line 4 of /usr/local/etc/apache24/Includes/_RequireAll.:
ip address '118.168-171.0.0/16' appears to be invalid
[root@j /usr/local/etc/apache24/Includes]# 

If I cannot use range as defined in whois, how would one properly determinate subnet mask, so it can be used in Apache's httpd? or maybe I'm writing it all wrong as I'm using range and subnet mask and there is proper way to define range as this.

* UPDATE *

[root@j /usr/local/etc/apache24/Includes]# grep 118 _RequireAll. 
    Require not ip 118.168 118.169 118.170 118.171
[root@j /usr/local/etc/apache24/Includes]# httpd  -t
Syntax OK
[root@j /usr/local/etc/apache24/Includes]# 

Best Answer

Try the following

Require not ip 118.168 118.169 118.170 118.171