From: Aleksandar Milivojevic <amilivojevic@pbl.ca>
To: netfilter@lists.netfilter.org
Subject: Re: two negatived parameters
Date: Tue, 07 Sep 2004 11:10:05 -0500 [thread overview]
Message-ID: <413DDD5D.1000006@pbl.ca> (raw)
In-Reply-To: <5943.1094471335@www56.gmx.net>
Akolinare@gmx.net wrote:
>>iptables -A FORWARD -s host1 -d host2 -j DROP
>
> well sorry it is not that easy as it seems. The rule should forward pakets
> to a user-chain only if host1 ist not the source and host2 are is not the
> destination.
Actually, it is... Let draw things out, so that you can see clearly
where you made mistake...
What you have is !A AND !B, which is the same thing as !(A OR B), which
gives you following table:
A B T
0 0 1
0 1 0
1 0 0
1 1 0
This obviously is not what you wanted. It matches only when both source
and destination of the packet are not as specified.
What you want is logical operation that will result in this table:
A B T
0 0 1
0 1 1
1 0 1
1 1 0
Translated from table to formula, this would be !(A AND B) (it is
trivial to see that above is negated AND operator table), which could
also be written as !A OR !B (if you preffer this form). Now, AFAIK,
neither of those can be acomplished directly in Netfilter as one liner.
You can only use and operator, and you can negate arguments only
directly, and somehow I doubt you can specify -s or -d multiple times on
same line. But as a workaround, what somebody (you ommited who when
quoting) suggested will do exactly what you want:
iptables -A FORWARD -s host1 -d host2 -j DROP
iptables -A FORWARD -j ACCEPT
The first line will drop what you wanted to drop. The second will
accept all the rest. Unless there were more rules to follow and more
checks to be done for host1 and host2 (in which case, you can do them in
user defined chain, and change first line to jump there instead of
dropping packet right away). Something along the lines of:
iptables -A FORWARD -s host1 -d host2 -j SOMETHING
iptables -A FORWARD -j ACCEPT
iptables -N SOMETHING
iptables -A SOMETHING -p tcp --dport 80 -j ACCEPT
iptables -A SOMETHING -j DROP
--
Aleksandar Milivojevic <amilivojevic@pbl.ca> Pollard Banknote Limited
Systems Administrator 1499 Buffalo Place
Tel: (204) 474-2323 ext 276 Winnipeg, MB R3T 1L7
next prev parent reply other threads:[~2004-09-07 16:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-06 11:48 two negatived parameters Akolinare
2004-09-07 16:10 ` Aleksandar Milivojevic [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-09-06 8:28 Akolinare
2004-09-06 8:49 ` Alistair Tonner
2004-09-06 9:00 ` Cedric Blancher
2004-09-06 20:16 ` Jason Opperisano
2004-09-07 15:43 ` Aleksandar Milivojevic
2004-09-07 16:36 ` Jason Opperisano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=413DDD5D.1000006@pbl.ca \
--to=amilivojevic@pbl.ca \
--cc=netfilter@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.