title: Linux设置网口速率
date: 2022-03-15 18:05:25.0
updated: 2022-03-15 18:25:35.0
url: https://liumou.site/doc/287
categories:
tags:
1、查看当前网口速率
1.1、查询网卡名称
执行下面的命令
nmcli device
然后找到已连接
的设备名称
gxxc@TD-ZW:~$ nmcli device
DEVICE TYPE STATE CONNECTION
enp125s0f1 ethernet 已连接 zb
enp125s0f0 ethernet 不可用 --
ip6tnl0 iptunnel 未托管 --
lo loopback 未托管 --
gxxc@TD-ZW:~$
例如这里是: enp125s0f1
1.2、查询网口速率
获取到网卡名称之后,通过查询语法可以查询该网卡的速率
1.2.1、查询语法
然后使用下面的语法进行查询
ethtool <网卡名>
1.2.2、实践
gxxc@TD-ZW:~$ ethtool enp125s0f1
Settings for enp125s0f1:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 100baseT/Full
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: No
Advertised FEC modes: Not reported
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 1
Transceiver: internal
Auto-negotiation: off
Cannot get wake-on-lan settings: Operation not permitted
Current message level: 0x00000036 (54)
probe link ifdown ifup
Link detected: yes
gxxc@TD-ZW:~$
此时可以看到,在Speed
值那里显示: 100Mb/s
,也就是目前是百兆网络
2、修改速率
2.1、自协商
自协商的意思就是系统自动根据硬件信息进行配置,这个模式也是系统的默认模式
设置语法
sudo ethtool -s <网卡> autoneg on
实践
sudo ethtool -s enp125s0f1 autoneg on