I have Debian 11 server with installed Wireguard with wg0
interface and 3 peers. Server bandwidth speed is 100 MBit and traffic is around 500 GB per month.
What I need is: these 3 peers can use 100 GB/month traffic at top speed (meaning no bandwidth limit which is 100 MBit), and when peer reaches 100 GB traffic it's bandwidth speed needs to be lowered to around 2 MBit.
Let's assume I solved the problem with monitoring how much traffic used peer. So in next step, how to actually limit speed?
After some googling, I know that I can use tc
(traffic control) like that:
tc qdisc add dev wg0 root handle 1:0 htb default 30
tc class add dev wg0 parent 1:0 classid 1:1 htb rate 2mbit
These lines will limit traffic for wg0
interface, that means all three peers will have 2 MBit speed limit
But I need to limit not whole interface but peers.
So my question is: How to limit speed for peers with passed 100 GB limit? Maybe I need second interface wg1
which have speed limit and I must transfer peer (that pass the 100 GB limit) from wg0
interface to wg1
? Or is there another way let's say limit by peer? If there is a solution with monitoring peer traffic that will help me to.
Thanks a lot for any help!