Wondershaper在Ubuntu中限制网卡速度带宽

2,731 阅读1分钟

Wondershaper在Ubuntu中限制网卡速度带宽

Wondershaper是Ubuntu系统下对网卡进行限速、控制带宽的命令,原理是基于系统TC命令的轻量脚本封装,具有简单,轻量的特点。

局域网内下载测试时千兆网卡太快了,不利于调试。所以使用该命令限制带宽。

安装:

sudo apt install wondershaper

使用:

添加限速规则:

sudo wondershaper ens33 1024 2048

参数:

  • sudo wondershaper:命令
  • ens33:网卡名,可以用ip a查看,常见的有eth0等,ubbuntu下默认为ens33
  • 1024:下载速率限制 kbit/s
  • 2048:下载速率限制 kbit/s

解除限速:

sudo wondershaper clear ens33

参数:

  • sudo wondershaper:命令
  • clear:清除规则
  • ens33:网卡名,可以用ip a查看,常见的有eth0等,ubbuntu下默认为ens33

官方文档

WONDERSHAPER(8)                          System Manager's Manual                         WONDERSHAPER(8)

NAME
       wondershaper - simple traffic shaping script

SYNOPSIS
       wondershaper [interface]
       wondershaper clear [interface]
       wondershaper [interface] [downlink] [uplink]

DESCRIPTION
       This manual page documents briefly the wondershaper script.  This manual page was written for the
       Debian distribution because the original script does not have a manual page.

       wondershaper is a traffic shaping script that provides low latency,  prioritizes  bulk  transfers
       below  normal  web traffic, prioritizes interactive shells above normal web traffic, and attempts
       to prevent upload and download traffic from affecting each other's ack packets.  Put simply,  the
       wondershaper makes your internet connection more "responsive"

SYNTAX
       A summary of wondershaper syntax is included below.  For a complete description, see the files in
       /usr/share/doc/wondershaper.

       wondershaper [ interface ]
              Shows the status of traffic shaping on that interface.

       wondershaper clear [ interface ]
              Removes all traffic shaping from that interface.

       wondershaper [ interface ] [ downlink ] [ uplink ]
              Configures the wondershaper on the specified interface, given the specified downlink speed
              in kilobits per second, and the specified uplink speed in kilobits per second.

总结:

简单使用了Wondershaper在Ubuntu中限制网卡速度带宽,注意单位是kbit/s,就是平常生活中用的宽带带宽。实际下载速度转化kB/s要除以8。