Linux网络限速,网卡限速使用场景
今年黑五入手了一款德国VPS,性能不错,还带L4 L7防护,但是L4防御非常激进,测速下载超过1000Mbit就会被认定是DDOS攻击从而切断网络,所以我们这里使用wondershaper控制网卡网速限制,从而不激发它过于激进的DDOS防护。
安装使用wondershaper
项目地址:https://github.com/magnific0/wondershaper
安装依赖git
apt install git -y
使用 git 拉去最新版本,当然也可以使用 yum/apt 仓库里面的,推荐使用 git 的方法, 因为git拉取通常是最新版本
git clone https://github.com/magnific0/wondershaper.git cd wondershaper make install

启动服务并设置开机启动
systemctl start wondershaper.service systemctl enable wondershaper.service
使用命令查看wondershaper功能
wondershaper -h

使用限速功能(网卡eth0,下载100M,上传100M)
wondershaper -a eth0 -d 102400 -u 102400
清除限速格则(必须指定网卡)
wondershaper -a eth0 -c
到此基本功能就完成了,最后不要忘记在/etc/rc.local添加开机自动生效