【Linux】一步一步学Linux——ethtool命令(155)

00. 目录

01. 命令概述

ethtool命令用于查询ethX网口基本设置、及设置网卡的参数。

命令比较复杂,功能特别多。

02. 命令格式

ethtool [ -a | -c | -g | -i | -d | -k | -r | -S |] ethX
ethtool [-A] ethX [autoneg on|off] [rx on|off] [tx on|off]
ethtool [-C] ethX [adaptive-rx on|off] [adaptive-tx on|off] [rx-usecs N] [rx-frames N] [rx-usecs-irq N] [rx-frames-irq N] [tx-usecs N] [tx-frames N] [tx-usecs-irq N] [tx-frames-irq N] [stats-block-usecs N][pkt-rate-low N][rx-usecs-low N] [rx-frames-low N] [tx-usecs-low N] [tx-frames-lowN] [pkt-rate-high N] [rx-usecs-high N] [rx-frames-high N] [tx-usecs-high N] [tx-frames-high N] [sample-interval N]
ethtool [-G] ethX [rx N] [rx-mini N] [rx-jumbo N] [tx N]
ethtool [-e] ethX [raw on|off] [offset N] [length N]
ethtool [-E] ethX [magic N] [offset N] [value N]
ethtool [-K] ethX [rx on|off] [tx on|off] [sg on|off] [tso on|off]
ethtool [-p] ethX [N]
ethtool [-t] ethX [offline|online]
ethtool [-s] ethX [speed 10|100|1000] [duplex half|full] [autoneg on|off] [port tp|aui|bnc|mii] [phyad N] [xcvr internal|external]
[wol p|u|m|b|a|g|s|d...] [sopass xx:yy:zz:aa:bb:cc] [msglvl N]

03. 常用选项

-a 查看网卡中 接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off。
-A 修改网卡中 接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off。
-c display the Coalesce information of the specified ethernet card。
-C Change the Coalesce setting of the specified ethernet card。
-g Display the rx/tx ring parameter information of the specified ethernet card。
-G change 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地址等。

04. 参考示例

4.1 查询网卡基本设置

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

4.2 查询网卡驱动相关信息

[deng@localhost ~]$ ethtool -i ens33
driver: e1000
version: 7.3.21-k8-NAPI
firmware-version: 
expansion-rom-version: 
bus-info: 0000:02:01.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: no
[deng@localhost ~]$ 

4.3 查询网卡收发包统计

[deng@localhost ~]$ ethtool -S ens33
NIC statistics:
     rx_packets: 15796742
     tx_packets: 31586
     rx_bytes: 4802989050
     tx_bytes: 5649128

4.4 查询网卡注册信息

[root@localhost ~]# ethtool -d ens33
MAC Registers
-------------
0x00000: CTRL (Device control register)  0x00C00249
      Endian mode (buffers):             little
      Link reset:                        reset
      Set link up:                       1
      Invert Loss-Of-Signal:             no

4.5 设置网卡自适应模式

[root@localhost ~]# ethtool -r ens33
[root@localhost ~]# 

4.6 设置网卡速率等信息

[root@localhost ~]# ethtool -s ens33 autoneg off speed 100 duplex full 

4.7 停止网卡的发送模块TX

[root@localhost ~]# ethtool -A tx off ens33 

4.8 设置网卡速率为100M

[root@localhost ~]# ethtool -s ens33 speed 100

4.9 使网卡灯闪烁10次

[root@localhost ~]# ethtool -p ens33 10
[root@localhost ~]# 

操作完毕后,看哪块网卡的led灯在闪,eth0就对应着哪块网卡。

4.10 显示网卡Offload参数的状态

[root@localhost ~]# ethtool -k ens33
Features for ens33:
rx-checksumming: off
tx-checksumming: on
        tx-checksum-ipv4: off [fixed]
        tx-checksum-ip-generic: on
        tx-checksum-ipv6: off [fixed]
        tx-checksum-fcoe-crc: off [fixed]
        tx-checksum-sctp: off [fixed]

4.11 关闭网卡对收到的数据包的校验功能

[root@localhost ~]# ethtool -K ens33 rx off 

4.12 显示EEPROM dump信息

[root@localhost ~]# ethtool -e ens33 
Offset          Values
------          ------
0x0000:         00 50 56 26 d8 88 20 04 ff ff ff ff ff ff ff ff 
0x0010:         00 00 00 00 0b 46 50 07 ad 15 0f 10 86 80 e8 01 
0x0020:         ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
0x0030:         ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
0x0040:         de df 61 78 0c 28 00 00 c8 00 ff ff ff ff ff ff 
0x0050:         ff ff ff ff ff ff ff ff ff ff ff ff ff ff 02 06 
0x0060:         ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
0x0070:         ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 3a 
0x0080:         ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
0x0090:         ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
[root@localhost ~]# 

05. 总结

在这里插入图片描述

06. 附录

参考:【Linux】一步一步学Linux系列教程汇总

  • 4
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值