1.2 KiB
1.2 KiB
Network
ipset
# Create ip-list with timeout
ipset create ipl-name hash:ip timeout 3600
iptables
# Show current rules
iptables -L -vn
# Fix TTL for mobile network
iptables -t mangle -A POSTROUTING -j TTL --ttl-set 65
TC
#!/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