Problem with new --physdev-out style
Hi,
with recent kernels, I have this problem:
kernel: physdev match: using --physdev-out in the OUTPUT, FORWARD and POSTROUTING chains for non-bridged traffic is not supported anymore.
What does "non-bridged" in this context mean?? If it means rules (or traffic) that goes over the INPUT our OUTPUT chain, I do not understand, why my rule set causes this message to appers a thousand times.
Here's all my rules with --physdev-out:
arthur: ~ # grep physdev-out /etc/init.d/firewall
$IPTABLES -A FORWARD -o $BR_INT -m physdev --physdev-out $IF_INT -i $IF_EXT -d $localnet -s $Any -m state --state ESTABLISHED,RELATED -j ACCEPT $IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_INT --physdev-out $IF_DMZ -s $ZAPHOD -j ACCEPT
$IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_INT --physdev-out $IF_DMZ -s $localnet -p tcp -d $MARVIN --dport 3389 -j ACCEPT $IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_DMZ --physdev-out $IF_INT -d $ZAPHOD -p tcp --dport 135:139 -j ACCEPT $IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_DMZ --physdev-out $IF_INT -d $ZAPHOD -p udp --dport 135:139 -j ACCEPT $IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_DMZ --physdev-out $IF_INT -d $ZAPHOD -p tcp --dport 445 -j ACCEPT $IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_DMZ --physdev-out $IF_INT -d $ZAPHOD -p udp --dport 445 -j ACCEPT $IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_INT --physdev-out $IF_DMZ -s $ZAPHOD -m state --state ESTABLISHED,RELATED -j ACCEPT $IPTABLES -A FORWARD -o $BR_INT -m physdev --physdev-out $IF_INT -i $BR_GUEST -m state --state ESTABLISHED,RELATED -j ACCEPT $IPTABLES -A FORWARD -i $BR_GUEST -o $BR_INT -m physdev --physdev-out $IF_DMZ -p tcp --dport 3389 -j ACCEPT
$IPTABLES -A FORWARD -i $BR_GUEST -o $BR_INT -m physdev --physdev-out $IF_INT -p tcp --dport ssh -j ACCEPT
$IPTABLES -A FORWARD -i $BR_GUEST -o $BR_INT -m physdev --physdev-out $IF_INT -p tcp --dport 30022 -j ACCEPT
$IPTABLES -A FORWARD -i $IF_EXT -o $BR_INT -m physdev --physdev-out $IF_DMZ -p tcp --sport 22 -m state --state ESTABLISHED,RELATED -j ACCEPT $IPTABLES -A FORWARD -i $IF_EXT -o $BR_INT -m physdev --physdev-out $IF_DMZ -s $i -p udp --sport 53 -m state --state ESTABLISHED,RELATED -j ACCEPT
Where:
BR_INT="br-intern"
BR_GUEST="br-guest"
IF_EXT="eth0"
IF_INT="eth1"
IF_DMZ="vlan3"
You see, I use --physdev-out only in the FORWARD with bridged traffic, because the Interfaces given with -i or -i in these rules are always bridges (br-intern or br-guest).
Why do I get thousands of these error messages?
Signature · 4 lines
Volker Sauer * Poststrasse 1/601 * 64293 Darmstadt * Germany E-Mail/Jabber: volker(at)volker-sauer.de * http://www.volker-sauer.de PGPKey-Fingerprint: DB26 11C7 B12E 0B27 3999 2E4F 7E35 4E4D 5DD5 D0E0 http://wwwkeys.de.pgp.net/pks/lookup?op=get&search=0x7E354E4D5DD5D0E0
Quoted 1 line · Volker Sauer
with recent kernels, I have this problem:
Bugreports to netfilter-devel please.
Quoted 34 lines
kernel: physdev match: using --physdev-out in the OUTPUT, FORWARD and POSTROUTING chains for non-bridged traffic is not supported anymore.
What does "non-bridged" in this context mean?? If it means rules (or traffic) that goes over the INPUT our OUTPUT chain, I do not understand, why my rule set causes this message to appers a thousand times.
Here's all my rules with --physdev-out:
arthur: ~ # grep physdev-out
/etc/init.d/firewall
$IPTABLES -A FORWARD -o $BR_INT -m physdev --physdev-out $IF_INT -i $IF_EXT -d $localnet -s $Any -m state --state ESTABLISHED,RELATED -j ACCEPT $IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_INT --physdev-out $IF_DMZ -s $ZAPHOD -j ACCEPT
$IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_INT --physdev-out $IF_DMZ -s $localnet -p tcp -d $MARVIN --dport 3389 -j ACCEPT $IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_DMZ --physdev-out $IF_INT -d $ZAPHOD -p tcp --dport 135:139 -j ACCEPT $IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_DMZ --physdev-out $IF_INT -d $ZAPHOD -p udp --dport 135:139 -j ACCEPT $IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_DMZ --physdev-out $IF_INT -d $ZAPHOD -p tcp --dport 445 -j ACCEPT $IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_DMZ --physdev-out $IF_INT -d $ZAPHOD -p udp --dport 445 -j ACCEPT $IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_INT --physdev-out $IF_DMZ -s $ZAPHOD -m state --state ESTABLISHED,RELATED -j ACCEPT $IPTABLES -A FORWARD -o $BR_INT -m physdev --physdev-out $IF_INT -i $BR_GUEST -m state --state ESTABLISHED,RELATED -j ACCEPT $IPTABLES -A FORWARD -i $BR_GUEST -o $BR_INT -m physdev --physdev-out $IF_DMZ -p tcp --dport 3389 -j ACCEPT
$IPTABLES -A FORWARD -i $BR_GUEST -o $BR_INT -m physdev --physdev-out $IF_INT -p tcp --dport ssh -j ACCEPT
$IPTABLES -A FORWARD -i $BR_GUEST -o $BR_INT -m physdev --physdev-out $IF_INT -p tcp --dport 30022 -j ACCEPT
$IPTABLES -A FORWARD -i $IF_EXT -o $BR_INT -m physdev --physdev-out $IF_DMZ -p tcp --sport 22 -m state --state ESTABLISHED,RELATED -j ACCEPT $IPTABLES -A FORWARD -i $IF_EXT -o $BR_INT -m physdev --physdev-out $IF_DMZ -s $i -p udp --sport 53 -m state --state ESTABLISHED,RELATED -j ACCEPTWhere:
BR_INT="br-intern"
BR_GUEST="br-guest"
IF_EXT="eth0"
IF_INT="eth1"
IF_DMZ="vlan3"
Quoted 3 lines
You see, I use --physdev-out only in the FORWARD with bridged traffic, because the Interfaces given with -i or -i in these rules are always bridges (br-intern or br-guest).
Why do I get thousands of these error messages?
Try adding "--physdev-is-bridged" to your rules. Without that the kernel is not able to tell whether they apply only to bridged packets or also to forwarded or locally generated ones.
Suggestions how to improve this are welcome.
Quoted 5 lines · Patrick McHardy
Quoted 1 line
$IPTABLES -A FORWARD -i $BR_GUEST -o $BR_INT -m physdev --physdev-out $IF_DMZ -p tcp --dport 3389 -j ACCEPT
Try adding "--physdev-is-bridged" to your rules. Without that the kernel is not able to tell whether they apply only to bridged packets or also to forwarded or locally generated ones.
That won't work for the above rule, for example, since the packet is being forwarded between two different bridges, so it is not bridged.
The only solution I am aware of is to stop bridging and use routing and arp proxy.
Quoted 8 lines · Philip Craig
Quoted 4 lines · Patrick McHardy
Quoted 1 line
$IPTABLES -A FORWARD -i $BR_GUEST -o $BR_INT -m physdev --physdev-out $IF_DMZ -p tcp --dport 3389 -j ACCEPT
Try adding "--physdev-is-bridged" to your rules. Without that the kernel is not able to tell whether they apply only to bridged packets or also to forwarded or locally generated ones.
That won't work for the above rule, for example, since the packet is being forwarded between two different bridges, so it is not bridged.
I see nothing indicating that it is being forwarded. bridge-netfilter passes packets though the iptables hooks by default.
Hello,
Quoted 7 lines · Volker Sauer
with recent kernels, I have this problem:
kernel: physdev match: using --physdev-out in the OUTPUT, FORWARD and POSTROUTING chains for non-bridged traffic is not supported anymore.
What does "non-bridged" in this context mean??
It means packets leaving the IP stack, I guess you could say "routed" as opposed to "bridged". A packet can traverse iptables chains either when it is routed or when it is bridged. At the time a routed packet traverses the iptables chains, the "bridging decision" (i.e. chosing the output port when the output interface is a bridge) has not been made yet, so the output port is unknown and --physdev-out is irrelevant.
Quoted 7 lines · Patrick McHardy
Quoted 5 lines · Philip Craig
Quoted 3 lines · Patrick McHardy
Quoted 2 lines
$IPTABLES -A FORWARD -i $BR_GUEST -o $BR_INT -m physdev --physdev-out $IF_DMZ -p tcp --dport 3389 -j ACCEPT
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Try adding "--physdev-is-bridged" to your rules. Without that the kernel is not able to tell whether they apply only to bridged packets or also to forwarded or locally generated ones.
That won't work for the above rule, for example, since the packet is being forwarded between two different bridges, so it is not bridged.
Do you mean that the "bridged" flag (or whatever way this is implemented) is not reset when the packet is routed ? Doesn't this sound like a bug ?
Quoted 1 line
I see nothing indicating that it is being forwarded
"-A FORWARD -i $BR_GUEST -o $BR_INT"
Quoted 11 lines · Patrick McHardy
Quoted 7 lines · Philip Craig
Quoted 4 lines · Patrick McHardy
Quoted 1 line
$IPTABLES -A FORWARD -i $BR_GUEST -o $BR_INT -m physdev --physdev-out $IF_DMZ -p tcp --dport 3389 -j ACCEPT
Try adding "--physdev-is-bridged" to your rules. Without that the kernel is not able to tell whether they apply only to bridged packets or also to forwarded or locally generated ones.
That won't work for the above rule, for example, since the packet is being forwarded between two different bridges, so it is not bridged.
I see nothing indicating that it is being forwarded.
They are different bridges, BR_GUEST and BR_INT, doesn't that mean it must be forwarded?
Quoted 2 lines
bridge-netfilter
passes packets though the iptables hooks by default.
Yes, but if the destination is a different bridge then isn't it passed up to the IP layer without going through NF_BR_FORWARD, and so BRNF_BRIDGED is never set? And more importantly, nf_bridge->physoutdev is never set until the output bridge processes it.
Quoted 3 lines · Pascal Hambourg
Do you mean that the "bridged" flag (or whatever way this is implemented) is not reset when the packet is routed ? Doesn't this sound like a bug ?
It's not set at all for routed packets, which is correct behaviour.
Quoted 5 lines · Philip Craig
Quoted 1 line · Pascal Hambourg
Do you mean that the "bridged" flag (or whatever way this is implemented) is not reset when the packet is routed ? Doesn't this sound like a bug ?
It's not set at all for routed packets, which is correct behaviour.
Sure, but what about packets that enter a bridged interface and then are routed ? -
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Philip Craig
The only solution I am aware of is to stop bridging and use routing and arp proxy.
Sorry, the above isn't the only solution. Other possibilities:
1. Filter on IP address instead of output interface.
2. Delay the decision by setting a mark in iptables and filtering again in ebtables. eg the mark could simply encode which port the packet is allowed for, and ebtables drops if it is bridged out a different port.
Quoted 2 lines · Pascal Hambourg
Sure, but what about packets that enter a bridged interface and then are routed ?
It's not set for them either, they are still just routed packets. Not sure I understand your question. My original comment was that because the packets are routed (even though they arrived on a bridge), the bridged flag is not set, and so the --physdev-is-bridged option would never match for that particular rule, and it simply isn't possible to fix that rule to get the --physdev-out to work.
Quoted 7 lines · Philip Craig
Quoted 6 lines · Patrick McHardy
Quoted 5 lines · Philip Craig
Quoted 4 lines · Patrick McHardy
Quoted 1 line
$IPTABLES -A FORWARD -i $BR_GUEST -o $BR_INT -m physdev --physdev-out $IF_DMZ -p tcp --dport 3389 -j ACCEPT
Try adding "--physdev-is-bridged" to your rules. Without that the kernel is not able to tell whether they apply only to bridged packets or also to forwarded or locally generated ones.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
That won't work for the above rule, for example, since the packet is being forwarded between two different bridges, so it is not bridged.
I see nothing indicating that it is being forwarded.
They are different bridges,
BR_GUESTandBR_INT, doesn't that mean it must be forwarded?
You're right.
Quoted 10 lines · Philip Craig
Quoted 1 line · Pascal Hambourg
Sure, but what about packets that enter a bridged interface and then are routed ?
It's not set for them either, they are still just routed packets. Not sure I understand your question. My original comment was that because the packets are routed (even though they arrived on a bridge), the bridged flag is not set, and so the --physdev-is-bridged option would never match for that particular rule, and it simply isn't possible to fix that rule to get the --physdev-out to work.
I misunderstood your original comment. I thought you meant that --physdev-is-bridged would not help distinguish between routed and bridged packets when the input and output interfaces are bridges. Thanks for taking the time to clarify.
Quoted 1 line · Patrick McHardy
You're right.
Yes, he's right but only for 5 of my rules which indeed bridge between bridges (-i $BR_GUEST -o $BR_INT).
Let me summarize the discussion so far:
The warning message means, that --physdev-out can not be used, if the packet is actually forwarded (instead of bridged) between two interfaces even if both interfaces are bridges. In this case you either need proxy-arp or you need to filter by other things than physdev or yo need some magic with marking the packets.
Okay, so far so good. I can live with that, since bridging between two bridges is only an exemption. Usually I have only one bridge inside the firewall with physin and physout rules. This is the case for all my firewalls except the one I took the example from and this can easily be fixed by removing --physdev-out and using -s or -d or something like this. It's just the firewall of my testing site.
Coming to the real point:
99% of my rules on all my firewalls are like that:
$IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_INT --physdev-out $IF_DMZ -s $ZAPHOD -j ACCEPT
IF_INT (eth1) and IF_DMZ (vlan3) are both members of BR_INT (br-intern):
fw1: ~ # brctl show
br-intern 8000.000d88cd28c1 yes eth1
vlan3
This means, that all rules like that are valid even with the new concept of netfilter, right?? But why do I get error messages like quoted in my first mail for these rules - it *is* bridged traffic inside *one* bridge!
And: I don't see how --physdev-is-bridged should help, since it's a match and not a command to the kernel saying: "this *is* bridged traffic". It the kernel does not see this by itself, --physdev-is-bridged doesn't help.
From all your answers, I still do not get, why this rule is supposed not to work anymore!!
If my arguments are correct, I suggest the following improvement:
In case someone is using physdev in OUTPUT, display the message like it is now: "using --physdev-out in the OUTPUT chains for non-bridged traffic is not supported anymore".
In case it is used inside FORWARD, check if all physdev interfaces are members of the same bridge. If yes, accept the rule, because then it is allowed to use it!!! (Which is the case all the thousands of rules in my firewalls except the 5 that I sent to this list :-().
If no, display a message like this:
"physdev match: using --physdev-out in the FORWARD chains is only allowed if all physical interfaces are members of the same bridge."
What do thing about that?
Regards
Volker
Signature · 4 lines
Volker Sauer * Poststrasse 1/601 * 64293 Darmstadt * Germany E-Mail/Jabber: volker(at)volker-sauer.de * http://www.volker-sauer.de PGPKey-Fingerprint: DB26 11C7 B12E 0B27 3999 2E4F 7E35 4E4D 5DD5 D0E0 http://wwwkeys.de.pgp.net/pks/lookup?op=get&search=0x7E354E4D5DD5D0E0
Quoted 11 lines · Volker Sauer
99% of my rules on all my firewalls are like that:
$IPTABLES -A FORWARD -i $BR_INT -m physdev --physdev-in $IF_INT --physdev-out $IF_DMZ -s $ZAPHOD -j ACCEPT
IF_INT(eth1) andIF_DMZ(vlan3) are both members ofBR_INT(br-intern):fw1: ~ # brctl show
br-intern 8000.000d88cd28c1 yes eth1
vlan3
Quoted 8 lines
This means, that all rules like that are valid even with the new concept of netfilter, right?? But why do I get error messages like quoted in my first mail for these rules - it *is* bridged traffic inside *one* bridge!
And: I don't see how --physdev-is-bridged should help, since it's a match and not a command to the kernel saying: "this *is* bridged traffic". It the kernel does not see this by itself, --physdev-is-bridged doesn't help.
Whether you believe it or not, this is the only way to tell the physdev match that the rule only affects purely bridged traffic.
Quoted 10 lines
If my arguments are correct, I suggest the following improvement:
In case someone is using physdev in OUTPUT, display the message like it is now: "using --physdev-out in the OUTPUT chains for non-bridged traffic is not supported anymore".
In case it is used inside FORWARD, check if all physdev interfaces are members of the same bridge. If yes, accept the rule, because then it is allowed to use it!!! (Which is the case all the thousands of rules in my firewalls except the 5 that I sent to this list :-().
Does not work since one of the devices might be put in a different bridge after you loaded the rules.
Quoted 3 lines
If no, display a message like this:
"physdev match: using --physdev-out in the FORWARD chains is only allowed if all physical interfaces are members of the same bridge."
Feel free to send a patch to improve the error messages.
Quoted 9 lines · Patrick McHardy
Quoted 8 lines
This means, that all rules like that are valid even with the new concept of netfilter, right?? But why do I get error messages like quoted in my first mail for these rules - it *is* bridged traffic inside *one* bridge!
And: I don't see how --physdev-is-bridged should help, since it's a match and not a command to the kernel saying: "this *is* bridged traffic". It the kernel does not see this by itself, --physdev-is-bridged doesn't help.
Quoted 3 lines
Whether you believe it or not, this is the only way to tell the physdev match that the rule only affects purely bridged traffic.
Aah, now I get it! This way I can avoid the error message.... Great, I'll test it as soon as I'm back to the lab.
Quoted 2 lines
Does not work since one of the devices might be put in a different bridge after you loaded the rules.
Yes, you're right.
Then the only solution is to improve the error messages.
Quoted 7 lines
Quoted 4 lines
If no, display a message like this:
"physdev match: using --physdev-out in the FORWARD chains is only allowed if all physical interfaces are members of the same bridge."
Feel free to send a patch to improve the error messages.
Oh, I'll see if I can patch kernel 2.6.23.1.
Regards
Volker
Signature · 4 lines
Volker Sauer * Poststrasse 1/601 * 64293 Darmstadt * Germany E-Mail/Jabber: volker(at)volker-sauer.de * http://www.volker-sauer.de PGPKey-Fingerprint: DB26 11C7 B12E 0B27 3999 2E4F 7E35 4E4D 5DD5 D0E0 http://wwwkeys.de.pgp.net/pks/lookup?op=get&search=0x7E354E4D5DD5D0E0
Quoted 4 lines · Volker Sauer
In case someone is using physdev in OUTPUT, display the message like it is now: "using --physdev-out in the OUTPUT chains for non-bridged traffic is not supported anymore".
Ok.
Quoted 2 lines
In case it is used inside FORWARD, check if all physdev interfaces are members of the same bridge.
As Patrick said, that condition may change over time. I like to have all my ruleset loaded before the network is configured, even before some interfaces exist. Your proposed change would prevent it. Besides, my opinion is that it is not the job of iptables to do such checks.
Quoted 6 lines
If yes, accept the rule, because then it is
allowed to use it!!! (Which is the case all the thousands of rules in my firewalls except the 5 that I sent to this list :-().
If no, display a message like this:"physdev match: using --physdev-out in the FORWARD chains is only allowed if all physical interfaces are members of the same bridge."
This is wrong and inacurate. Using --physdev-out in the FORWARD and POSTROUTING chains is supported for *bridged* traffic only, period. All physical interfaces being members of the same bridge is not a sufficient condition to make sure that only bridged traffic will be matched. Traffic can still be routed from a bridge to itself.
Quoted 4 lines · Pascal Hambourg
As Patrick said, that condition may change over time. I like to have all my ruleset loaded before the network is configured, even before some interfaces exist. Your proposed change would prevent it. Besides, my opinion is that it is not the job of iptables to do such checks.
Agreed.
Quoted 8 lines
Quoted 7 lines
If yes, accept the rule, because then it is
allowed to use it!!! (Which is the case all the thousands of rules in my firewalls except the 5 that I sent to this list :-().
If no, display a message like this:
"physdev match: using --physdev-out in the FORWARD chains is only allowed if all physical interfaces are members of the same bridge."
Quoted 5 lines
This is wrong and inacurate. Using --physdev-out in the FORWARD and POSTROUTING chains is supported for *bridged* traffic only, period. All physical interfaces being members of the same bridge is not a sufficient condition to make sure that only bridged traffic will be matched. Traffic can still be routed from a bridge to itself.
Yes, it is inacurate.
But I think one needs a better explenation. I'm a power-user but still a user, not a developer. Users think in different terms and speak another language.
Maybe an advice like "look for the option "--physdev-is-bridged" - it may help you" or so would be good.
Signature · 4 lines
Volker Sauer * Poststrasse 1/601 * 64293 Darmstadt * Germany E-Mail/Jabber: volker(at)volker-sauer.de * http://www.volker-sauer.de PGPKey-Fingerprint: DB26 11C7 B12E 0B27 3999 2E4F 7E35 4E4D 5DD5 D0E0 http://wwwkeys.de.pgp.net/pks/lookup?op=get&search=0x7E354E4D5DD5D0E0