命令描述:
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