linux下ethtool命令详解

接触这个命令感觉最大的一个特色就是可以判断网口位置,然后对这个命令的其它参数也一一的过了一遍,顺便学习记录下来

Ethtool命令用于获取以太网卡的配置信息,或者修改这些配置。

ethX是以太网卡的名称,Linux系统将检测到的第一块以太网卡命名为eth0, 第二块为eth1,以此类推

参数如下:

-a查看网卡中 接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off
-A修改网卡中 接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off
-cdisplay the Coalesce information of the specified ethernet card
-CChange the Coalesce setting of the specified ethernet card
-gDisplay the rx/tx ring parameter information of the specified ethernet card
-Gchange the rx/tx ring setting of the specified ethernet card
-i显示网卡驱动的信息,如驱动的名称、版本等
-d显示register dump信息, 部分网卡驱动不支持该选项
-e显示EEPROM dump信息,部分网卡驱动不支持该选项
-E修改网卡EEPROM byte
-k显示网卡Offload参数的状态:on 或 off,包括rx-checksumming、tx-checksumming等。
-K修改网卡Offload参数的状态
-p用于区别不同ethX对应网卡的物理位置,常用的方法是使网卡port上的led不断的闪;N指示了网卡闪的持续时间,以秒为单位。
-r如果auto-negotiation模块的状态为on,则restarts auto-negotiation
-S显示NIC- and driver-specific 的统计参数,如网卡接收/发送的字节数、接收/发送的广播包个数等。
-t让网卡执行自我检测,有两种模式:offline or online
-s修改网卡的部分配置,包括网卡速度、单工/全双工模式、mac地址等

使用ifconfig命令查看网卡列表

#ifconfig -s
Iface   MTU Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0       1500   0 88320957      0      0      0 102168173      0      0      0 BMRU
lo        65536   0 167399923      0      0      0 167399923      0      0      0 LRU

然后使用ethtool命令查看该网卡设备信息

#ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: Symmetric
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: Symmetric
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 1
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: on (auto)
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes

显示了eth0的接口类型,连接模式,速率等等信息。
如果是网卡上连接的是网线Supported ports内容就是TP(Twisted Paired),如果是光纤则显示Fiber

我们可以使网口等闪烁这个方法来确认网卡,非常方便

ethtool -p eth0 10

回车后与eth0 相对应的网卡接口旁边的指示灯就会闪烁10秒,之后自动停止闪烁

其它参数功能请自行测试学习

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://sulao.cn/post/220.html

我要评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。