更新 xs.sh
This commit is contained in:
parent
64e8d470fb
commit
7fde95d04f
18
xs.sh
18
xs.sh
@ -14,28 +14,24 @@ fi
|
||||
|
||||
# 添加限速规则
|
||||
add_limit() {
|
||||
echo "Adding bandwidth limit of $LIMIT_RATE on ports 8337 and 8338 for interface $INTERFACE..."
|
||||
echo "Applying new bandwidth limit..."
|
||||
|
||||
# 添加全局队列规则(上行限制)
|
||||
# 清理旧规则
|
||||
tc qdisc del dev "$INTERFACE" root 2>/dev/null
|
||||
tc qdisc del dev ifb0 root 2>/dev/null
|
||||
|
||||
# 添加上行规则
|
||||
tc qdisc add dev "$INTERFACE" root handle 1: htb default 11
|
||||
tc class add dev "$INTERFACE" parent 1: classid 1:1 htb rate "$LIMIT_RATE"
|
||||
tc class add dev "$INTERFACE" parent 1:1 classid 1:11 htb rate "$LIMIT_RATE"
|
||||
|
||||
# 针对端口 8337 上行流量添加过滤规则
|
||||
tc filter add dev "$INTERFACE" protocol ip parent 1:0 prio 1 u32 match ip dport 8337 0xffff flowid 1:11
|
||||
|
||||
# 针对端口 8338 上行流量添加过滤规则
|
||||
tc filter add dev "$INTERFACE" protocol ip parent 1:0 prio 1 u32 match ip dport 8338 0xffff flowid 1:11
|
||||
|
||||
# 添加全局队列规则(下行限制)
|
||||
# 添加下行规则
|
||||
tc qdisc add dev ifb0 root handle 1: htb default 11
|
||||
tc class add dev ifb0 parent 1: classid 1:1 htb rate "$LIMIT_RATE"
|
||||
tc class add dev ifb0 parent 1:1 classid 1:11 htb rate "$LIMIT_RATE"
|
||||
|
||||
# 针对端口 8337 下行流量添加过滤规则
|
||||
tc filter add dev ifb0 protocol ip parent 1:0 prio 1 u32 match ip sport 8337 0xffff flowid 1:11
|
||||
|
||||
# 针对端口 8338 下行流量添加过滤规则
|
||||
tc filter add dev ifb0 protocol ip parent 1:0 prio 1 u32 match ip sport 8338 0xffff flowid 1:11
|
||||
|
||||
echo "Bandwidth limit applied successfully."
|
||||
|
||||
Loading…
Reference in New Issue
Block a user