Search code examples
limitbandwidth-throttlingtrafficshaping

How do I throttle bandwidth-speed for internal ip-addresses using tc command and cbq-only filter?


I want to limit bandwidth-speed of internal ip-addresses (like 10.8.0.1) and had been trying to use the following rules:

tc qdisc add dev tun1 root handle 1: cbq avpkt 1000 bandwidth 3000mbit
tc class add dev tun1 parent 1: classid 1:1 cbq rate 1mbit allot 1500 prio 1 bounded isolated
tc qdisc add dev tun1 parent 1: sfq perturb 10
tc filter add dev tun1 parent 1: protocol ip prio 16 u32 match ip src {IP_HERE} flowid 1:1

These rules work perfect with 'non-internal' ip-addresses but don't work with internals. I am unable to use htb filter because my VPS is based on OpenVZ and the kernel doesn't support it.

Thanks.


Solution

  • I solved the issue which is quite easy.

    Just had to change source to destination. So, the last command will be like this:

    tc filter add dev tun1 parent 1: protocol ip prio 16 u32 match ip dst {IP_HERE} flowid 1:1