D
D
Dmitry2013-11-30 14:59:46
iptables
Dmitry, 2013-11-30 14:59:46

How to use the "!" in iptables?

man iptables says the following:
A "!" argument before the address specification inverts the sense of the "parameter".
But when I try to write below rule -
iptables -A INPUT -p tcp -s ! 192.168.1.60 --dport 22 -j DROP
when I run the rules, I get the following error -
Bad argument `192.168.1.60'
Could you give me an example or point out where to write the "!" argument so that it is executed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThreeDHead, 2013-11-30
@imert

First, "-s ! 192.168.1.60" is stuck in the middle of another construct, don't do it like that.
Correct:
iptables -A INPUT ! -s 192.168.1.60 -p tcp --dport 22 -j DROP
Note that "!" before "-s", not after (it used to be possible, but now it's not).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question