Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I currently deny IP addresses like this in the nginx.conf file:


But how would I deny

deny 42.22.*.*; <---- this obviously doesnt work, what is the correct syntax for nginx?

Ive seen:

deny <---- not sure what this means, but it made me try

deny 42.22.0/999.0/999 <---- which fails.

So whats the correct syntax?

share|improve this question

This isn't nginx specific, it's a lack of understanding subnets in network math; /24 is a class C and /16 is a class B.

42.22.*.* = =


share|improve this answer
Arrrhhh!! Classful networking! It burns!. – Tom O'Connor Dec 12 '10 at 18:55
You're right though. He wants to block a whole /16 network. Ouch. This is almost never the right thing to do. – Tom O'Connor Dec 12 '10 at 18:56
looks like he wants to block a whole bunch of Australia; - is all down under on the big island. – troyengel Dec 12 '10 at 20:16
Nope... the IP I used is made up for the example – Dennis Dec 12 '10 at 22:21

deny is the correct syntax.

More information on nginx blocking

/16 signifies Subnetwork. For further information click on the link to read.

share|improve this answer
Thats not enough though. I want the equivalent of: 42.22.0/24.0/24 but that fails – Dennis Dec 12 '10 at 14:48
this comment doesn't address his question and you gave him the wrong answer. – troyengel Dec 12 '10 at 16:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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