Skip to content

网络链路测速

查看当前网络链路带宽

需 安装 ethtool

sudo apt install ethtool

查看

ethtool <网卡名称>

输出样例

其中 当前 Speed: 10000Mb/s 就是 当前链路速度

:~$ ethtool eno1
Settings for eno1:
        Supported ports: [ TP ]
        Supported link modes:   100baseT/Full 
                                1000baseT/Full 
                                10000baseT/Full 
                                2500baseT/Full 
                                5000baseT/Full 
        Supported pause frame use: Symmetric
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  100baseT/Full 
                                1000baseT/Full 
                                10000baseT/Full 
        Advertised pause frame use: Symmetric
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Speed: 10000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: Unknown
Cannot get wake-on-lan settings: Operation not permitted
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes
user@node13:~$ 

网卡名称可以通过以下方式获取

ip addr

如下 在输出中找到 带有 UP 的 网卡,此时 eth1 就是网卡名称

|550

测试实际速度

上文链路速度是机器和 交换机 或路由器 协议速度,实际上的连接速度还需要 端到端 来测试

使用 iperf3 这个 工具,这是一个 BS 架构的测速工具,需要至少 AB 两台机器,一台做服务端,一台做客户端

服务端

iperf3 -s -p 5000  # -p 5000 是使用 5000 端口,可自行选择,客户端对应即可

目前 192.168.0.10 (或 192.168.1.25 已经开启一个服务端可用于直接测试)

客户端

iperf3 -c 192.168.0.10 -p 5000  # 192.168.1.1 是服务端IP 地址

硬件网卡

lshw -class network