Add tc example

This commit is contained in:
Super User
2024-03-25 10:27:36 +03:00
parent 3a65f588a5
commit efbae88b55

View File

@@ -15,3 +15,33 @@ iptables -L -vn
# Fix TTL for mobile network
iptables -t mangle -A POSTROUTING -j TTL --ttl-set 65
```
## TC
```bash
#!/bin/bash
interface=veth0
interface_limit=100mbit
download_limit=40mbit
upload_limit=40mbit
# tc -s -d qdisc show dev veth0
tc qdisc show dev $interface | grep -q "qdisc pfifo_fast 0"
[ "$?" -gt "0" ] && tc qdisc del dev $interface root; sleep 1
tc qdisc add dev $interface root handle 1: htb default 30
tc class add dev $interface parent 1: classid 1:1 htb rate $interface_limit burst 15k
tc class add dev $interface parent 1:1 classid 1:10 htb rate $download_limit burst 15k
tc class add dev $interface parent 1:1 classid 1:20 htb rate $upload_limit burst 15k
tc qdisc add dev $interface parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $interface parent 1:20 handle 20: sfq perturb 10
tc filter add dev $interface protocol ip parent 1: prio 1 u32 match ip dst 0.0.0.0/0 flowid 1:10
tc filter add dev $interface protocol ip parent 1: prio 1 u32 match ip src 0.0.0.0/0 flowid 1:20
```