VPS 限制网速带宽 Linux网卡限速
Wondershaper介绍: WonderShaper 是一个限制网络带宽的脚本, 可用于对特定网卡进行带宽限速, 它封装了linux的tc命令, 但是使用起来更加简单和方便.
安装 wondershaper
curl -Lo /usr/sbin/wondershaper https://raw.githubusercontent.com/magnific0/wondershaper/master/wondershaper
chmod +x /usr/sbin/wondershaper查询网卡
ifconfig # 大多数为 eth0对网卡设置限速
wondershaper -a eth0 -d 5000 -u 2000 # 限制 下载 5Mbps, 上传 2Mbps
# wondershaper -a eth0 -d 90000 -u 90000 # 限制 下载 90Mbps, 上传 90Mbps
-a 网卡名(这里设了 eth0)
-d 下载速度 (单位为 Kbps)
-u 上传速度 (单位为 Kbps)
速度单位为 Kbps(Kbit/s) (100000 Kbps = 100Mbps = 12.5 MB/s)取消网卡限速
wondershaper -a eth0 -c # eth0 为网卡名查看状态
wondershaper -a eth0 -s # eth0 为网卡名安装服务:
curl -Lo /etc/systemd/system/wondershaper.service https://raw.githubusercontent.com/magnific0/wondershaper/master/wondershaper.service
systemctl daemon-reload创建配置文件
curl -Lo /etc/systemd/wondershaper.conf https://raw.githubusercontent.com/magnific0/wondershaper/master/wondershaper.conf编辑 配置文件
vim /etc/systemd/wondershaper.conf
# 根据需要, 修改 IFACE, DSPEED, USPEED 的值即可启动服务
systemctl enable --now wondershaper.service限速的用途
某些VPS商家的带宽限速规则较严格, 比如多少分钟内, 占用过高(比如超过多少Mbps) 就限速或者黑洞.
自己手动限速, 可以避免 触发限速规则.
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
小菜鸡
评论已关闭