linux命令--ethtool

本文介绍如何利用ethtool工具查询及调整网卡设置,包括查看支持的端口类型、连接模式、速率等,并提供了禁用自协商功能、降低网卡速度的具体命令实例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

命令描述:
ethtool – 用来显示或者修改网卡的设置

使用详述:
举例一
[root@linux /]# ethtool eth1
Supported ports: [ TP ]
(注:TP is for twisted pair, MII is for media independent interface and Fibre is for fiber cable.)
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
注:网口速率 10 / 100 / 1000
Duplex: Full
注:网口半/全双工 half / full
Port: Twisted Pair
注:tp|aui|bnc|mii
PHYAD: 0
注:physical address 物理地址
Transceiver: internal
Auto-negotiation: on
注:网口是否自协商
Supports Wake-on: umbg
Wake-on: d
Link detected: yes
注:eth1已经激活,插拔网线link状态才会改变

举例二
root@IMMV2-DEV4:~# ethtool -s eth4 autoneg off
root@IMMV2-DEV4:~# ethtool eth4
Settings for eth4:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: Not reported
Advertised auto-negotiation: No
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: g
Wake-on: g
Link detected: yes

举例三
看哪块网卡的led灯在闪,eth0就对应着哪块网卡
ethtool -p eth0 10

举例四
将千兆网卡的速度降为百兆
ethtool -s eth0 speed 100

检测是否有网线连接到网卡插槽(和ethtool的 Link detected: yes 一样):
~#cat /sys/class/net/eth0/carrier
1

如果有网线接到网卡插槽,检车是否被激活:
~# cat /sys/class/net/eth1/operstate
down

参考资料:
1.https://linuxconfig.org/how-to-detect-whether-a-physical-cable-is-connected-to-network-card-slot-on-linux
2.https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/s1-ethtool.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值