Netzfetz wrote:For each lan port I have set up a different vlan (=Interface), so the lan ports are totally independent from each other.
What I need to do: regulate the traffic for each lan port SEPARATELY, so e.g.: 100k UP 1000k DOWN for lan port 1, 200k UP 1200k DOWN for lan port 2, etc.
Since each lan port is virtually a different interface this should work with TC and TBF.
Ok. This is clear, but I never done this exact setup before. I'll take a stab at it anyway. :-)
Netzfetz wrote:When I write "upload bandwidth" I mean traffic going out of a PC to one lan port of the WRT. From the WRT's point of view that is INcoming traffic (coming IN through a lan port / Interface).
"Download" is vice versa = OUTgoing traffic from the lan-interface's point of view.
Ok, I understand the point you're making, but iptables doesn't "know" which interface is connected to the Internet. iptables simply cares about inbound and outbound traffic on an interface, and what you want to do with it. So you can still shape traffic on each of the vlans with the same concepts I listed in the other thread, only it gets a little more complicated. The reason being because I assume you want to throttle traffic going between any given vlan and the Internet, but not throttle traffic between two internal vlans (i.e. what's the point in having 100Mbit full duplex if you throttle it? :-)
So, I'd say you can do ingress filtering on each vlan port to 100kbps (controlling upstream traffic), and egress filtering on each vlan port to 1000kbps (controlling downstream traffic) but only where the source or destination isn't within your private address range. So to fit that last statement in, you'd have to do part of it on the PREROUTING chain of the mangle table. This rules out using the classify module, because classify only works on the POSTROUTING chain. This means you need to do marks with iptables and use tc to pick up those marks. (or do it all with tc and fight through the arcane sentax) A bit more cumbersome, but it works as shown in the lartc guide. Something like this might work:
iptables -t mangle -A PREROUTING -i vlan0 -p tcp -m tcp -d ! 192.168.0.0/16 --sport 22 -j MARK --set-mark 0x1
so this would set marks on all packets not bound for this class B private address range coming in on vlan0. You'd do similar things with the other vlans. You'd obviously need to have classes set up with tc and check for the marks with tc.
outbound postrouting on vlan0 you could probably use the classify module if you want, or stick with tc if you want to be consistent.
And of course, you can include using the ipp2p modules into the logic to pick up bittorrent traffic and whatnot since that seems to be what you're after.
I think this would work, but like I said I'm just brainstorming here, because I never done this kind of setup on a WRT, but the theory still applies. It just need to be thought out more. It gets complicated when you've created all the vlans. Maybe someone else can think of a more elegant way to do it?
Greg