開発環境-ethtoolの使用

ethtoolは、ネットワークカードのパラメータを照会および設定するために使用されるコマンドです。
ethtoolを使用して、多くのネットワークカードのステータスやその他の情報を確認し、現在のネットワークの問題を分析できます。

 

  • コマンド形式:
ethtool [参数] [网络设备] 
  • コマンド機能:
ethtool  查询或控制网络驱动程序和硬件设置
  • コマンドパラメータ
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

対応するパラメータ関数の紹介:

       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地址、是否支持流控等
  • 一般的に使用されるコマンドの例:
		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
  • ネットワークデバイスにethtool設定を永続的に保存する方法

        解決策1:
        ethtool設定を/ etc / sysconfig / network-scripts / ifcfg-ethXファイルに保存して、次回デバイスを起動したときにオプションをアクティブ化できます。
        次に例を示します。ethtool-seth0speed 100duplex full autoneg off
        このコマンドは、eth0デバイスを全二重自動否定に設定します。速度は100Mbsです。eth0の開始時にこれらのパラメーターを設定するには、ファイル/ etc / sysconfig / network-scripts / ifcfg-eth0を変更し、次の行を追加します
        。ETHTOOL_OPTS= "speed 100duplex full autoneg off"

 

Ethtoolは、Linuxでの強力なネットワーク管理ツールです。Ethtoolに関する記事は無数にあります。補足として、より詳細なethtoolの記事がいくつかリストされています。
Linuxネットワークカードドライバーのサポートとethtoolの実装:https://www.cnblogs.com/imapla/p/4575621.html

 

 

 

 

 

 

 

 

おすすめ

転載: blog.csdn.net/Ivan804638781/article/details/98885811