Development environment - use of ethtool

ethtool is a command used to query and set network card parameters.
You can use ethtool to check the status of many network cards and other information, and then analyze the current network problems.

 

  • Command format:
ethtool [参数] [网络设备] 
  • Command function:
ethtool  查询或控制网络驱动程序和硬件设置
  • Command parameters
ethtool version 3.15
Usage:
        ethtool DEVNAME	Display standard information about device
        ethtool -s|--change DEVNAME	Change generic options
		[ speed %d ]
		[ duplex half|full ]
		[ port tp|aui|bnc|mii|fibre ]
		[ mdix auto|on|off ]
		[ autoneg on|off ]
		[ advertise %x ]
		[ phyad %d ]
		[ xcvr internal|external ]
		[ wol p|u|m|b|a|g|s|d... ]
		[ sopass %x:%x:%x:%x:%x:%x ]
		[ msglvl %d | msglvl type on|off ... ]
        ethtool -a|--show-pause DEVNAME	Show pause options
        ethtool -A|--pause DEVNAME	Set pause options
		[ autoneg on|off ]
		[ rx on|off ]
		[ tx on|off ]
        ethtool -c|--show-coalesce DEVNAME	Show coalesce options
        ethtool -C|--coalesce DEVNAME	Set coalesce options
		[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-low N]
		[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|--show-ring DEVNAME	Query RX/TX ring parameters
        ethtool -G|--set-ring DEVNAME	Set RX/TX ring parameters
		[ rx N ]
		[ rx-mini N ]
		[ rx-jumbo N ]
		[ tx N ]
        ethtool -k|--show-features|--show-offload DEVNAME	Get state of protocol offload and other features
        ethtool -K|--features|--offload DEVNAME	Set protocol offload and other features
		FEATURE on|off ...
        ethtool -i|--driver DEVNAME	Show driver information
        ethtool -d|--register-dump DEVNAME	Do a register dump
		[ raw on|off ]
		[ file FILENAME ]
        ethtool -e|--eeprom-dump DEVNAME	Do a EEPROM dump
		[ raw on|off ]
		[ offset N ]
		[ length N ]
        ethtool -E|--change-eeprom DEVNAME	Change bytes in device EEPROM
		[ magic N ]
		[ offset N ]
		[ length N ]
		[ value N ]
        ethtool -r|--negotiate DEVNAME	Restart N-WAY negotiation
        ethtool -p|--identify DEVNAME	Show visible port identification (e.g. blinking)
               [ TIME-IN-SECONDS ]
        ethtool -t|--test DEVNAME	Execute adapter self test
               [ online | offline | external_lb ]
        ethtool -S|--statistics DEVNAME	Show adapter statistics
        ethtool -n|-u|--show-nfc|--show-ntuple DEVNAME	Show Rx network flow classification options or rules
		[ rx-flow-hash tcp4|udp4|ah4|esp4|sctp4|tcp6|udp6|ah6|esp6|sctp6 |
		  rule %d ]
        ethtool -N|-U|--config-nfc|--config-ntuple DEVNAME	Configure Rx network flow classification options or rules
		rx-flow-hash tcp4|udp4|ah4|esp4|sctp4|tcp6|udp6|ah6|esp6|sctp6 m|v|t|s|d|f|n|r... |
		flow-type ether|ip4|tcp4|udp4|sctp4|ah4|esp4
			[ src %x:%x:%x:%x:%x:%x [m %x:%x:%x:%x:%x:%x] ]
			[ dst %x:%x:%x:%x:%x:%x [m %x:%x:%x:%x:%x:%x] ]
			[ proto %d [m %x] ]
			[ src-ip %d.%d.%d.%d [m %d.%d.%d.%d] ]
			[ dst-ip %d.%d.%d.%d [m %d.%d.%d.%d] ]
			[ tos %d [m %x] ]
			[ l4proto %d [m %x] ]
			[ src-port %d [m %x] ]
			[ dst-port %d [m %x] ]
			[ spi %d [m %x] ]
			[ vlan-etype %x [m %x] ]
			[ vlan %x [m %x] ]
			[ user-def %x [m %x] ]
			[ dst-mac %x:%x:%x:%x:%x:%x [m %x:%x:%x:%x:%x:%x] ]
			[ action %d ]
			[ loc %d]] |
		delete %d
        ethtool -T|--show-time-stamping DEVNAME	Show time stamping capabilities
        ethtool -x|--show-rxfh-indir|--show-rxfh DEVNAME	Show Rx flow hash indirection and/or hash key
        ethtool -X|--set-rxfh-indir|--rxfh DEVNAME	Set Rx flow hash indirection and/or hash key
		[ equal N | weight W0 W1 ... ]
		[ hkey %x:%x:%x:%x:%x:.... ]
        ethtool -f|--flash DEVNAME	Flash firmware image from the specified file to a region on the device
               FILENAME [ REGION-NUMBER-TO-FLASH ]
        ethtool -P|--show-permaddr DEVNAME	Show permanent hardware address
        ethtool -w|--get-dump DEVNAME	Get dump flag, data
		[ data FILENAME ]
        ethtool -W|--set-dump DEVNAME	Set dump flag of the device
		N
        ethtool -l|--show-channels DEVNAME	Query Channels
        ethtool -L|--set-channels DEVNAME	Set Channels
               [ rx N ]
               [ tx N ]
               [ other N ]
               [ combined N ]
        ethtool --show-priv-flags DEVNAME	Query private flags
        ethtool --set-priv-flags DEVNAME	Set private flags
		FLAG on|off ...
        ethtool -m|--dump-module-eeprom|--module-info DEVNAME	Query/Decode Module EEPROM information and optical diagnostics if available
		[ raw on|off ]
		[ hex on|off ]
		[ offset N ]
		[ length N ]
        ethtool --show-eee DEVNAME	Show EEE settings
        ethtool --set-eee DEVNAME	Set EEE settings
		[ eee on|off ]
		[ advertise %x ]
		[ tx-lpi on|off ]
		[ tx-timer %d ]
        ethtool -h|--help 		Show this help
        ethtool --version 		Show version number

The corresponding parameter function introduction:

       ethtool devname    |--查询ethX网口基本设置

       ethtool -a    |--查看网卡中 接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off。

       ethtool -A    |--修改网卡中 接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off。

       ethtool -c    |--显示指定以太网卡的合并信息。

       ethtool -C    |--更改指定以太网卡的合并设置。

       ethtool -g    |--查看指定网卡的buffer size

       ethtool -G    |--更改指定网卡的buffer size

       ethtool -i    |--显示网卡驱动的信息,如驱动的名称、版本等。

       ethtool -d    |--显示register dump信息, 部分网卡驱动不支持该选项

       ethtool -e    |--显示EEPROM dump信息,部分网卡驱动不支持该选项

       ethtool -E    |--修改网卡EEPROM byte

       ethtool -k    |--显示网卡Offload参数的状态:on 或 off,包括rx-checksumming、tx-checksumming等。

       ethtool -K    |--修改网卡Offload参数的状态

       ethtool -p    |--用于区别不同ethX对应网卡的物理位置,常用的方法是使网卡port上的led不断的闪;N指示了网卡闪的持续时间,以秒为单位。

       ethtool -P    |--查看永久物理地址(mac地址)

       ethtool -r    |--如果auto-negotiation模块的状态为on,则restarts auto-negotiation

       ethtool -S    |--显示NIC- and driver-specific 的统计参数,如网卡接收/发送的字节数、接收/发送的广播包个数等。

       ethtool -t    |--让网卡执行自我检测,有两种模式:offline or online

       ethtool -s    |--修改网卡的部分配置,包括网卡速度、单工/全双工模式、mac地址、是否支持流控等
  • Examples of commonly used commands:
		1.查看当前 eth1 网卡基本信息(查看网速、全/半双工、自协商等):
			ethtool eth1
			
		2.查看当前 eth1 网卡驱动版本等信息:
			ethtool -i eth1
			
		3.修改当前 eth1 网卡的部分配置(修改网卡速度、单工/全双工模式、自协商等)
			ethtool -s eth1 [speed 10|100|1000] [duplex half|full] [autoneg on|off]
			
		4.查看当前 eth1 网卡某个寄存器设置:
			ethtool -d eth1 | grep 0xX
		
		5.查看当前 eth1 是哪个网卡(没插网线,板卡网卡比较多同时忘记是哪个网卡的情况下,使eth1闪烁10分钟):
			ethtool -p eth1 600
		
		6.查看/设置当前 eth1 网卡的描述符缓冲区大小(rx ring、tx ring)
			ethtool -g eth1
			ethtool -G eth1 rx 4096
			
		7.查看eth1网卡寄存器值
			ethtool -d eth0
  • How to permanently save ethtool settings on network devices

        Solution 1: The
        ethtool settings can be saved in the /etc/sysconfig/network-scripts/ifcfg-ethX file to activate the options when the device is started next time.
        For example: ethtool -s eth0 speed 100 duplex full autoneg off
        This command sets the eth0 device to full duplex autonegation, and the speed is 100Mbs. To set these parameters when eth0 is started, modify the file /etc/sysconfig/network-scripts/ifcfg-eth0 and add the following line:
        ETHTOOL_OPTS="speed 100 duplex full autoneg off"

 

ethtool is a powerful network management tool under Linux. There are countless articles introducing it. Some more detailed ethtool articles are listed as a supplement.
Linux network card driver support and implementation of ethtool: https://www.cnblogs.com/imapla/p/4575621.html

 

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/Ivan804638781/article/details/98885811