From: "U.Mutlu" <for-gmane@mutluit.com>
To: netfilter@vger.kernel.org
Subject: Re: [iptables] Effect of negating multiple source or dest IPs (-s or -d)
Date: Tue, 08 Nov 2011 22:59:37 +0100 [thread overview]
Message-ID: <j9c8o9$3rp$1@dough.gmane.org> (raw)
In-Reply-To: <alpine.DEB.2.00.1111082112340.31624@blackhole.kfki.hu>
Jozsef Kadlecsik wrote, On 2011-11-08 21:22:
> On Tue, 8 Nov 2011, U.Mutlu wrote:
>
>> Jan Engelhardt wrote, On 2011-11-08 17:44:
>>> On Tuesday 2011-11-08 17:19, U.Mutlu wrote:
>>>
>>>> sim@netmess.org wrote, On 2011-11-08 17:16:
>>>>>> What's the effect of this rule on a multihomed box
>>>>>> (the IPs below are just some examples, not real):
>>>>>>
>>>>>> iptables -A INPUT ! -d 1.2.3.4,2.3.4.5 -p all -j DROP
>>>>>>
>>>>>
>>>>> the newest version of iptables says:
>>>>>
>>>>> iptables v1.4.12.1: ! not allowed with multiple source or destination IP
>>>>> addresses
>>>>
>>>> Oh, one wonders why they did so...
>>>
>>> Because it leads to a confusing result.
>>>
>>> ! -d a,b,c
>>>
>>> could be reasonably interpreted as
>>>
>>> ! -d a&& ! -d b&& ! -d c
>>>
>>> but because using "," in -s/-d means a simple rule expansion, it
>>> actually generates an equivalent of
>>>
>>> ! -d a || ! -d b || ! -d c
>>
>> But OR'ing them IMHO doesn't make much sense, just think about it.
>> I would suggest to AND them.
>> Look, a normal rule like this one
>> iptables -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
>> matches only if every single part of it matches (ie. AND).
>> Then in our negation case above it should behave similar,
>> and not switch to OR.
>
> The matches are AND-ed. However the individual matches may generate OR
> conditions, like multiport.
>
> What you suggest means that while
>
> -d a,b
>
> is interpreted as "a" OR "b", then
>
> ! -d a,b
>
> should be interpeted as NOT "a" AND NOT "b".
>
> I think that'd be pretty confusing.
My problem was this: my eth0 has to accept packets for 2 IPs,
but then I saw that there comes in also much other unwanted
garbage like broadcast and multicast, so I wanted right in the
beginning of my script DROP all packets not destined to the 2 IP.
Ok, I think as an alternative I can realize this with an
own chain and with 'convential' methods.
Too bad, I just wanted avoid that extra work of restructuring my script... :-)
next prev parent reply other threads:[~2011-11-08 21:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-08 15:56 [iptables] Effect of negating multiple source or dest IPs (-s or -d) U.Mutlu
2011-11-08 16:16 ` sim
2011-11-08 16:19 ` U.Mutlu
2011-11-08 16:44 ` Jan Engelhardt
2011-11-08 17:11 ` U.Mutlu
2011-11-08 19:23 ` Jan Engelhardt
2011-11-08 20:22 ` Jozsef Kadlecsik
2011-11-08 21:59 ` U.Mutlu [this message]
2011-11-08 22:18 ` Amos Jeffries
2011-11-08 23:40 ` Jozsef Kadlecsik
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='j9c8o9$3rp$1@dough.gmane.org' \
--to=for-gmane@mutluit.com \
--cc=netfilter@vger.kernel.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.