I am trying to log all my outbound connections to a file using iptables.
This is my rule:
-A OUTPUT ! -o lo ! --destination 127.0.0.1 -m state --state NEW -j LOG --log-prefix "new_connection " --log-level 7
However, if I add another IP destination (multicast) so my rule becomes this:
-A OUTPUT ! -o lo ! --destination 127.0.0.1 ! --destination 220.127.116.11 -m state --state NEW -j LOG --log-prefix "new_connection " --log-level 7
I get the following error:
multiple -d flags not allowed
My question is not what does the error mean, but rather how can I exclude multiple IP addresses in my rule? The two conditions
! --destination 127.0.0.1
! --destination 18.104.22.168
are mutually exclusive so having two rules would effectively be like not having them at all (only worse, as I would get nearly twice the logs)
So is there an "and" operator?