Skip to contentSkip to conversation

Order of match extensions

DISCUSSION Andrew Beverley 2 participants 3 messages Oct 6, 2011

lore
Share & tools
lore
#0 lore raw

Hi,

Does the order of match extensions matter for iptables rules? Can someone explain why the following 2 rules produce different results:

1. Matches lots of packets as expected:

iptables -t mangle -A FORWARD -i eth0 -m mark ! --mark 99 \
	-m state --state NEW -m statistic --mode nth --every 1 -j LOG

2. Does not match any packets:

iptables -t mangle -A FORWARD -i eth0 -m state --state NEW \
	-m statistic --mode nth --every 1 -m mark ! --mark 99 -j LOG

The only difference is the place of the "mark" match (either at the end or the beginning).

(Debian iptables v1.4.8)

Andy

#1 lore raw
Quoted 3 lines · Andrew Beverley

Hi,

Does the order of match extensions matter for iptables rules?

Clearly.

#2 lore raw
Quoted 7 lines · Jan Engelhardt
Quoted 3 lines · Andrew Beverley

Hi,

Does the order of match extensions matter for iptables rules?

Clearly.

Okay... so why does this rule appear to not match anything?

iptables -t mangle -A FORWARD -i eth0 -m state --state NEW \
        -m statistic --mode nth --every 1 -m mark ! --mark 99 -j LOG

Is the importance of the order documented anywhere?

Thanks,

Andy