Is it possible to deny range of IPs on Nginx
Asked Answered
J

1

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.

Joshi answered 23/6, 2013 at 20:26 Comment(4)
or you could use multiple ranges?Lesotho
I'm really bad with networking so I can't calculate which ranges I need to add to cover one mentioned above. If you could calculate them for me, I would be more than gratefulJoshi
write out the octets in binary format ,e.g. 43 -> 00101011. that'll make visualizing the masks much easier.Lesotho
Would that be 43.249.64.0/20, 43.249.80.0/22 and 43.249.84.0/23?Joshi
M
33

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

Mastermind answered 23/6, 2013 at 20:35 Comment(4)
@Flyer yeah I noticed. And the numbers add up - isn't that comforting : )Mastermind
haha, I guess. thanks again. Have no clue why I haven't though of combining ranges myself.Joshi
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?Iatric
@CraigHicks That's correct. Here's the access module documentationMastermind

© 2022 - 2024 — McMap. All rights reserved.