4

I want to limit the outgoing traffic to a specific bandwidth.

My Code:

tc qdisc add dev vif1.0 root handle 1: htb default 30
tc class add dev vif1.0 parent 1: classid 1:1 htb rate 1mbit
tc class add dev vif1.0 parent 1: classid 1:2 htb rate 1mbit
tc filter add dev vif1.0 protocol ip parent 1:0 prio 1 u32 match ip dst 91.214.170.249/32 flowid 1:1
tc filter add dev vif1.0 protocol ip parent 1:0 prio 1 u32 match ip src 91.214.170.249/32 flowid 1:2

But nothing happens.. I have uploaded a 1GB file and can download it with 4MB/s

vif1.0 is the interface name of my virtual machine

Vince
  • 371
  • 2
  • 12
  • Unclear on which interface `vif1.0` is. Is that on the host machine, or the guest? And is the guest the one sending the file? – derobert Oct 14 '13 at 15:36
  • @derobert Yes, the interface vif1.0 is on the host machine. i have a webserver on my guest machine. i download the file from it (--> outgoing) or upload a file to the guest machine (--> incoming) – Vince Oct 14 '13 at 20:27
  • 1
    the HTB needs to be on an interface where there is a packet queue. So that'd be the outgoing interface on the guest (assuming you're downloading to the VM host machine). [And assuming it works at all on a virtual interface, not sure.] – derobert Oct 14 '13 at 20:39
  • @derobert interface eth1 is the whole internet. and all other interfaces (vif1.0 too) goes over eth1 to the internet.. so what is the problem with my configuration? :/ – Vince Oct 15 '13 at 12:16
  • It sounds like the traffic is coming in to your host machine over vif1.0, but htb works on traffic going out of an interface. – derobert Oct 15 '13 at 13:23
  • I have added the interface peth1 to a class (peth1 is the bridge for eth1. so the traffic goes: vif1.0 --> peth1 --> eth1 --> internet). Then a new filter: `tc filter add dev peth1 parent 1: protocol ip prio 16 u32 match ip src xxx.xxx.xxx.xxx flowid 1:1` and it works :) – Vince Oct 16 '13 at 05:57

1 Answers1

1

Solved by OP in the comments:

I have added the interface peth1 to a class (peth1 is the bridge for eth1. so the traffic goes: vif1.0 --> peth1 --> eth1 --> internet). Then a new filter: tc filter add dev peth1 parent 1: protocol ip prio 16 u32 match ip src xxx.xxx.xxx.xxx flowid 1:1

M K
  • 161
  • 5