2

I run an OpenVPN server with a 1 Gbps bandwidth and I need to limit it to 5 Mbps per user.

Searching the internet I've come up to this bash script:

$U32 = "tc filter add dev tun0 protocol ip parent 1:0 prio 1 u32"

tc qdisc add dev tun0 root handle 1: htb default 30
tc class add dev tun0 parent 1: classid 1:1 htb rate 5mbit
tc class add dev tun0 parent 1: classid 1:2 htb rate 5mbit
$U32 match ip dst 10.8.0.0/16 flowid 1:1
$U32 match ip src 10.8.0.0/16 flowid 1:2

I tried it, but it limits the entire interface down to 5Mbps and not the single IPs and since I don't know how to use tc, i couldn't go further.

Does any one of you know how to modify this to limit each ip in the range to 5Mbps max?

Bonus question: do you know of any good online resource to learn more about tc?

DomeWTF
  • 127
  • 2

1 Answers1

0

I'm pretty sure it's something like this:

tc qdisc add dev tun0 parent root handle 1: htb default 30
tc class add dev tun0 parent 1: classid 1:1 htb sc rate 1000mbit ul rate 1000mbit
tc class add dev tun0 parent 1:1 classid 1:11 htb sc rate 5mbit ul rate 5mbit

The reason I say this is I use a script for limiting everyone except a select set to 5mbit, and since you don't need the set, it should be fine. I however use hfsc so I may be incorrect about formatting, but the gist seems to be that the parent class has the maximum bandwidth and the child class has the actual limit per user. I do not claim to be an expert but since you haven't been answered in a year and a half, perhaps you've either found the answer and forgotten to update your post or you're still searching for a solution.

Tom K
  • 1