Is it possible to deny range of IPs on Nginx

Igor Yavych picture Igor Yavych · Jun 23, 2013 · Viewed 20.5k times · Source

Is it possible to deny range like 43.249.64.0-43.249.85.255? Or only by mask like 43.249.64.0/19 which includes up to 43.249.95.255 which makes it not good decision.

Answer

djf picture djf · Jun 23, 2013

You can block IP ranges using the CIDR notation. Have a look at the article 'Nginx Block And Deny IP Address OR Network Subnets'

You can use IP range calculators like this one that do the math for you. For example your range '43.249.64.0-43.249.85.255' can be expressed as:

43.249.64.0/20
43.249.80.0/22
43.249.84.0/23