Ubuntu 20针对除特定端口外的全局上行自动限速脚本
一、方案概述 二、安装必要软件包 Ubuntu 20.04 默认已安装 iproute2(提供 tc)和 iptables,但为了确保环境完整,执行: bash sudo apt update sudo apt install -y iproute2 iptables 三、部署限速脚本 1. 创建脚本目录并编写主脚本 bash sudo mkdir -p /usr/local/bin sudo nano /usr/local/bin/speedlimit.sh 将以下完整脚本内容粘贴进去(已修复 Illegal “match” 错误,使用 fw 分类器): bash #!/bin/bash # ============================================ # Ubuntu 20.04 上行带宽限速脚本 # 功能:对指定网卡上行总带宽进行限速,支持排除端口 # 用法:speedlimit.sh {start|stop|status|restart} # ============================================ # ========== 用户配置区域 ========== INTERFACE=”eth0″ # 你的出口网卡,用 ip link show 查看 LIMIT_RATE=”10mbit” … Read more