My question is I am trying to limit a users bandwidth on a server and wondering the best way to do this. Before I dive to far into the tc/iptables I was wondering if I could get any advice on this and if someone could give me a sample config that might be something I can play around with, it would be greatly appreciated.
From what I understand you can make rules with tc then apply the rules with iptables using the mark statement. Some people say to use the mangle postrouting or output, but not 100% sure which one is best or if it even matters. I believe with tc I will be using the htb (token bucket to limit bandwidth) however people say there are performance trade off's and I am looking for the lowest latency method. These users are not on the internal network, but connecting to a server.
I have two types of users, so there only needs to be two rules to limit them. So far what I can see is the tc/iptables combo to be what I want, but am open for suggestions for alternatives.
I think for iptables the command will look like
Bandwidth limit rule 1
iptables -A PREROUTING -s xxx.xxx.xxx.xxx -t mangle -j MARK --set-mark 0x1
Bandwidth limit rule 2
iptables -A PREROUTING -s xxx.xxx.xxx.xxx -t mangle -j MARK --set-mark 0x2
What I want to happen
- User comes in on eth0 (their IP will be known. Not random IP's)
- requests info from server
- server sends out info on eth0 back to user with rule applied