1、项目介绍
“Wonder Shaper is a script that allows the user to limit the bandwidth of one or more network adapters.”
译:Wonder Shaper是一个脚本,允许用户限制一个或多个网络适配器的带宽。
项目地址:https://github.com/magnific0/wondershaper
根据介绍,我们可以借助这个脚本程序来实现对VPS上传&下载速度的限制。
2、脚本的使用
首先需要安装必要的依赖。
#CentOS
yum install make git -y
#Debian/Ubuntu
apt install make git -y拉取Wonder Shaper
#克隆存储库
git clone https://github.com/magnific0/wondershaper.git
#进入文件夹
cd wondershaper显示Wonder Shaper说明
./wondershaper -h得到输出结果
USAGE: ./wondershaper [-hcs] [-a <adapter>] [-d <rate>] [-u <rate>]Limit the bandwidth of an adapter
OPTIONS:   
-h           Show this message   
-a <adapter> Set the adapter   
-d <rate>   Set maximum download rate (in Kbps) and/or   
-u <rate>    Set maximum upload rate (in Kbps)   
-p           Use presets in "/etc/systemd/wondershaper.conf"   
-c           Clear the limits from adapter   
-s           Show the current status of adapter   
-v           Show the current version   查看需要限制的网卡。这里可以选择三个命令,我们选择使用ifconfig。
#查看网卡
ifconfig
ip addr show
route使用实例:
#限制上传10Mbps和限制下载10Mbps
./wondershaper -a eth0 -d 10240 -u 10240speedtest 测速
wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
chmod +x speedtest-cli 
./speedtest-cli