20

I've seen people use the exclamation mark (!) in multiple examples, but when I try to use it I get an error.

The rule I'm trying:

-A OUTPUT -m owner --gid-owner 1006 -d ! 192.168.1.0/24 -j DROP

The error:

Bad argument '192.168.1.0/24'

What is the correct syntax for this?

1 Answer 1

40

Just as the manpage states:

[!] -d, --destination address[/mask][,...]
       Destination  specification.   See  the  description  of  the  -s
       (source)  flag  for  a  detailed description of the syntax.  The
       flag --dst is an alias for this option.

That makes it

! -d 192.168.1.0/24
2
  • 5
    It has nothing to do with shady blogs, the syntax has changed for iptables and the exclamation mark went before the flag at some point.
    – Martin
    Jan 2, 2013 at 13:27
  • You can also use it like: ! -d <URL>.
    – another
    Nov 19, 2019 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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