12

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.

Igor Yavych
  • 4,166
  • 3
  • 21
  • 42

1 Answers1

31

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

djf
  • 6,592
  • 6
  • 44
  • 62
  • @Flyer yeah I noticed. And the numbers add up - isn't that comforting : ) – djf Jun 23 '13 at 20:45
  • haha, I guess. thanks again. Have no clue why I haven't though of combining ranges myself. – Igor Yavych Jun 23 '13 at 20:50
  • do you put a separate "deny" at the beginning of every line and a ";" at the end, or can you use one "deny", ";" pair for the whole block? – Craig Hicks Mar 03 '18 at 01:54
  • @CraigHicks That's correct. [Here's the access module documentation](http://nginx.org/en/docs/http/ngx_http_access_module.html) – djf Mar 03 '18 at 07:37