一:安装依赖
- #Debian/Ubuntu系统
- apt install -y make git
-
- #CentOS系统
- yum install make git -y
二:安装WonderShaper
- git clone https://github.com/magnific0/wondershaper.git
- cd wondershaper
- make install
三:命令详细
- USAGE: wondershaper [-hcs] [-a <adapter>] [-d <rate>] [-u <rate>]
-
- OPTIONS:
- -h 显示此消息
- -a <adapter> 设置适配器
- -d <rate> 设置最大下载速率(单位:Kbps)
- -u <rate> 设置最大上传速率(单位:Kbps)
- -p 使用 /etc/conf.d/essenshaper.conf 中的预设
- -c 从适配器中清除限制
- -s 显示适配器的当前状态
- -v 显示当前版本
四:使用示例
首先使用ifconfig命令来查看网卡名称;
博主的网卡名称为enp1s0,下面使用以下命令来限制enp1s0网卡的宽带速率;
- #限制上传带宽为10Mbps
- wondershaper -a enp1s0 -u 10240
-
- #限制下载带宽为10Mbps
- wondershaper -a enp1s0 -d 10240
-
- #限制上传和上传均10Mbps
- wondershaper -a enp1s0 -d 10240 -u 10240
-
- #清除网卡限速规则
- wondershaper -c -a enp1s0
一:下载测试
- CacheFly 亚太 - 100MB
- wget -O /dev/null http://cachefly.cachefly.net/100mb.test
-
- Online 法国 - 1000MB
- wget -O /dev/null http://ping.online.net/1000Mo.dat
-
- Online 荷兰 - 1000MB
- wget -O /dev/null http://ping-ams1.online.net/1000Mo.dat
二:Speedtest.net
- wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
-
- chmod +x speedtest-cli
-
- ./speedtest-cli
-
- ## 如果出现错误
- /usr/bin/env: ‘python’: No such file or directory
-
- ## 输入以下命令安装python
- apt-get install python