ethtool 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

ethtool 命令安装:


-bash/zsh: ethtool: command not found

# Windows (WSL2)
sudo apt-get update sudo apt-get install ethtool

# Debian
apt-get install ethtool

# Ubuntu
apt-get install ethtool

# Alpine
apk add ethtool

# Arch Linux
pacman -S ethtool

# Kali Linux
apt-get install ethtool

# CentOS
yum install ethtool

# Fedora
dnf install ethtool

# Raspbian
apt-get install ethtool

# Dockerfile
dockerfile.run/ethtool

# Docker
docker run cmd.cat/ethtool ethtool

ethtool 命令补充说明:


ethtool 命令查询或控制网络驱动程序和硬件设置。


ethtool

ethtool 是标准 Linux 实用程序,用于控制网络驱动程序和硬件,特别是有线以太网设备。 它可用于:

  • 获取识别和诊断信息
  • 获取扩展设备统计信息
  • 控制以太网设备的速度、双工、自动协商和流量控制
  • 控制校验和卸载和其他硬件卸载功能
  • 控制 DMA 环大小和中断调节
  • 控制多队列设备的接收队列选择
  • 升级闪存中的固件

ethtool 命令语法:


ethtool devname

ethtool -h|--help
ethtool --version
ethtool -a|--show-pause devname
ethtool -A|--pause devname [autoneg on|off] [rx on|off] [tx on|off]
ethtool -c|--show-coalesce devname
ethtool -C|--coalesce devname [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
ethtool -G|--set-ring devname [rx N] [rx-mini N] [rx-jumbo N] [tx N]
ethtool -i|--driver devname
ethtool -d|--register-dump devname [raw on|off] [hex on|off] [file name]
ethtool -e|--eeprom-dump devname [raw on|off] [offset N] [length N]
ethtool -E|--change-eeprom devname [magic N] [offset N] [length N] [value N]
ethtool -k|--show-features|--show-offload devname
ethtool -K|--features|--offload devname feature on|off ...
ethtool -p|--identify devname [N]
ethtool -P|--show-permaddr devname
ethtool -r|--negotiate devname
ethtool -S|--statistics devname
ethtool -t|--test devname [offline|online|external_lb]
ethtool -s devname speed N [duplex half|full] [port tp|aui|bnc|mii] [autoneg on|off] [advertise N] [phyad N] [xcvr internal|external] [wol p|u|m|b|a|g|s|d...] [sopass xx:yy:zz:aa:bb:cc] [msglvl N | msglvl type on|off ...]
ethtool -n|-u|--show-nfc|--show-ntuple devname [ rx-flow-hash tcp4|udp4|ah4|esp4|sctp4|tcp6|udp6|ah6|esp6|sctp6 |
rule N ]
ethtool -N|-U|--config-nfc|--config-ntuple devname 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 xx:yy:zz:aa:bb:cc [m xx:yy:zz:aa:bb:cc]] [dst xx:yy:zz:aa:bb:cc [m xx:yy:zz:aa:bb:cc]] [proto N [m N]] [src-ip x.x.x.x [m x.x.x.x]] [dst-ip x.x.x.x [m x.x.x.x]] [tos N [m N]] [l4proto N [m N]] [src-port N [m N]] [dst-port N [m N]] [spi N [m N]] [l4data N [m N]] [vlan-etype N [m N]] [vlan N [m N]] [user-def N [m N]] [action N] [loc N] |
delete N
ethtool -w|--get-dump devname [data filename]
ethtool -W|--set-dump devname N
ethtool -T|--show-time-stamping devname
ethtool -x|--show-rxfh-indir devname
ethtool -X|--set-rxfh-indir devname [ equal N | weight W0 W1 ... ]
ethtool -f|--flash devname FILE [N]
ethtool -l|--show-channels devname
ethtool -L|--set-channels devname [rx N] [tx N] [other N] [combined N]
ethtool -m|--dump-module-eeprom devname [raw on|off] [hex on|off] [offset N] [length N]
ethtool --show-priv-flags devname
ethtool --set-priv-flags devname flag on|off ...
ethtool --show-eee devname
ethtool --set-eee devname [eee on|off] [tx-lpi on|off] [tx-timer N] [advertise N]

ethtool 命令选项:


-h --help
Shows a short help message.

--version
Shows the ethtool version number.

-a --show-pause
Queries the specified Ethernet device for pause parameter information.

-A --pause
Changes the pause parameters of the specified Ethernet device.
autoneg on|off

Specifies whether pause autonegotiation should be enabled.
rx on|off

Specifies whether RX pause should be enabled.
tx on|off

Specifies whether TX pause should be enabled.

-c --show-coalesce
Queries the specified network device for coalescing information.

-C --coalesce
Changes the coalescing settings of the specified network device.

-g --show-ring
Queries the specified network device for rx/tx ring parameter information.

-G --set-ring
Changes the rx/tx ring parameters of the specified network device.

rx N
Changes the number of ring entries for the Rx ring.

rx-mini N
Changes the number of ring entries for the Rx Mini ring.

rx-jumbo N
Changes the number of ring entries for the Rx Jumbo ring.

tx N
Changes the number of ring entries for the Tx ring.

-i --driver
Queries the specified network device for associated driver information.

-d --register-dump
Retrieves and prints a register dump for the specified network device. The register format for some devices is known and decoded others are printed in hex. When raw is enabled, then ethtool dumps the raw register data to stdout. If file is specified, then use contents of previous raw register dump, rather than reading from the device.

-e --eeprom-dump
Retrieves and prints an EEPROM dump for the specified network device. When raw is enabled, then it dumps the raw EEPROM data to stdout. The length and offset parameters allow dumping certain portions of the EEPROM. Default is to dump the entire EEPROM.

-E --change-eeprom
If value is specified, changes EEPROM byte for the specified network device. offset and value specify which byte and it's new value. If value is not specified, stdin is read and written to the EEPROM. The length and offset parameters allow writing to certain portions of the EEPROM. Because of the persistent nature of writing to the EEPROM, a device-specific magic key must be specified to prevent the accidental writing to the EEPROM.

-k --show-features --show-offload
Queries the specified network device for the state of protocol offload and other features.

-K --features --offload
Changes the offload parameters and other features of the specified network device. The following feature names are built-in and others may be defined by the kernel.

rx on|off
Specifies whether RX checksumming should be enabled.

tx on|off
Specifies whether TX checksumming should be enabled.

sg on|off
Specifies whether scatter-gather should be enabled.

tso on|off
Specifies whether TCP segmentation offload should be enabled.

ufo on|off
Specifies whether UDP fragmentation offload should be enabled

gso on|off
Specifies whether generic segmentation offload should be enabled

gro on|off
Specifies whether generic receive offload should be enabled

lro on|off
Specifies whether large receive offload should be enabled

rxvlan on|off
Specifies whether RX VLAN acceleration should be enabled

txvlan on|off
Specifies whether TX VLAN acceleration should be enabled

ntuple on|off
Specifies whether Rx ntuple filters and actions should be enabled

rxhash on|off
Specifies whether receive hashing offload should be enabled

-p --identify
Initiates adapter-specific action intended to enable an operator to easily identify the adapter by sight. Typically this involves blinking one or more LEDs on the specific network port.

N
Length of time to perform phys-id, in seconds.

-P --show-permaddr
Queries the specified network device for permanent hardware address.

-r --negotiate
Restarts auto-negotiation on the specified Ethernet device, if auto-negotiation is enabled.

-S --statistics
Queries the specified network device for NIC- and driver-specific statistics.

-t --test
Executes adapter selftest on the specified network device. Possible test modes are:

offline|online|external_lb
defines test type: offline (default) means to perform full set of tests possibly causing normal operation interruption during the tests, online means to perform limited set of tests do not interrupting normal adapter operation, external_lb means to perform external-loopback test in addition to other offline tests.

-s --change
Allows changing some or all settings of the specified network device. All following options only apply if -s was specified.

speed N
Set speed in Mb/s. ethtool with just the device name as an argument will show you the supported device speeds.

duplex half|full
Sets full or half duplex mode.

port tp|aui|bnc|mii
Selects device port.

autoneg on|off
Specifies whether autonegotiation should be enabled. Autonegotiation is enabled by default, but in some network devices may have trouble with it, so you can disable it if really necessary.

advertise N
Sets the speed and duplex advertised by autonegotiation. The argument is a hexadecimal value using one or a combination of the following values:
phyad N

PHY address.

xcvr internal|external
Selects transceiver type. Currently only internal and external can be specified, in the future further types might be added.

wol p|u|m|b|a|g|s|d...
Sets Wake-on-LAN options. Not all devices support this. The argument to this option is a string of characters specifying which options to enable.

sopass xx:yy:zz:aa:bb:cc
Sets the SecureOn鈩� password. The argument to this option must be 6 bytes in Ethernet MAC hex format (xx:yy:zz:aa:bb:cc).

msglvl N
msglvl type on|off ...

Sets the driver message type flags by name or number. type names the type of message to enable or disable; N specifies the new flags numerically. The defined type names and numbers are:

The precise meanings of these type flags differ between drivers.

-n -u --show-nfc --show-ntuple
Retrieves receive network flow classification options or rules.

rx-flow-hash tcp4|udp4|ah4|esp4|sctp4|tcp6|udp6|ah6|esp6|sctp6
Retrieves the hash options for the specified flow type.

rule N
Retrieves the RX classification rule with the given ID.

-N -U --config-nfc --config-ntuple
Configures receive 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...
Configures the hash options for the specified flow type.

flow-type ether|ip4|tcp4|udp4|sctp4|ah4|esp4
Inserts or updates a classification rule for the specified flow type.

All fields below that include a mask option may either use "m" to indicate a mask, or may use the full name of the field with a "-mask" appended to indicate that this is the mask for a given field.

src xx:yy:zz:aa:bb:cc [m xx:yy:zz:aa:bb:cc]
Includes the source MAC address, specified as 6 bytes in hexadecimal separated by colons, along with an optional mask. Valid only for flow-type ether.

dst xx:yy:zz:aa:bb:cc [m xx:yy:zz:aa:bb:cc]
Includes the destination MAC address, specified as 6 bytes in hexadecimal separated by colons, along with an optional mask. Valid only for flow-type ether.

proto N [m N]
Includes the Ethernet protocol number (ethertype) and an optional mask. Valid only for flow-type ether.

src-ip x.x.x.x [m x.x.x.x]
Specify the source IP address of the incoming packet to match along with an optional mask. Valid for all IPv4 based flow-types.

dst-ip x.x.x.x [m x.x.x.x]
Specify the destination IP address of the incoming packet to match along with an optional mask. Valid for all IPv4 based flow-types.

tos N [m N]
Specify the value of the Type of Service field in the incoming packet to match along with an optional mask. Applies to all IPv4 based flow-types.

l4proto N [l4m N]
Includes the layer 4 protocol number and optional mask. Valid only for flow-type ip4.

src-port N [m N]
Specify the value of the source port field (applicable to TCP/UDP packets) in the incoming packet to match along with an optional mask. Valid for flow-types ip4, tcp4, udp4, and sctp4.

dst-port N [m N]
Specify the value of the destination port field (applicable to TCP/UDP packets)in the incoming packet to match along with an optional mask. Valid for flow-types ip4, tcp4, udp4, and sctp4.

spi N [m N]
Specify the value of the security parameter index field (applicable to AH/ESP packets)in the incoming packet to match along with an optional mask. Valid for flow-types ip4, ah4, and esp4.

l4data N [m N]
Specify the value of the first 4 Bytes of Layer 4 in the incoming packet to match along with an optional mask. Valid for ip4 flow-type.

vlan-etype N [m N]
Includes the VLAN tag Ethertype and an optional mask.

vlan N [m N]
Includes the VLAN tag and an optional mask.

user-def N [m N]
Includes 64-bits of user-specific data and an optional mask.

action N
Specifies the Rx queue to send packets to, or some other action.

loc N
Specify the location/ID to insert the rule. This will overwrite any rule present in that location and will not go through any of the rule ordering process.

delete N
Deletes the RX classification rule with the given ID.

-w --get-dump
Retrieves and prints firmware dump for the specified network device. By default, it prints out the dump flag, version and length of the dump data. When data is indicated, then ethtool fetches the dump data and directs it to a file.

-W --set-dump
Sets the dump flag for the device.

-T --show-time-stamping
Show the device's time stamping capabilities and associated PTP hardware clock.

-x --show-rxfh-indir
Retrieves the receive flow hash indirection table.

-X --set-rxfh-indir
Configures the receive flow hash indirection table.

equal N
Sets the receive flow hash indirection table to spread flows evenly between the first N receive queues.

weight W0 W1 ...
Sets the receive flow hash indirection table to spread flows between receive queues according to the given weights. The sum of the weights must be non-zero and must not exceed the size of the indirection table.

-f --flash FILE
Flash firmware image from the specified file to a region on the adapter. By default this will flash all the regions on the adapter.

N
A number to identify flash region where the image should be flashed. Default region is 0 which denotes all regions in the flash.

-l --show-channels
Queries the specified network device for the numbers of channels it has. A channel is an IRQ and the set of queues that can trigger that IRQ.

-L --set-channels
Changes the numbers of channels of the specified network device.

rx N
Changes the number of channels with only receive queues.

tx N
Changes the number of channels with only transmit queues.

other N
Changes the number of channels used only for other purposes e.g. link interrupts or SR-IOV co-ordination.

combined N
Changes the number of multi-purpose channels.

-m --dump-module-eeprom
Retrieves and if possible decodes the EEPROM from plugin modules, e.g SFP+, QSFP

--show-priv-flags
Queries the specified network device for its private flags. The names and meanings of private flags (if any) are defined by each network device driver.

--set-priv-flags
Sets the device's private flags as specified.

flag on|off Sets the state of the named private flag.

--show-eee
Queries the specified network device for its support of Energy-Efficient Ethernet (according to the IEEE 802.3az specifications)

--set-eee
Sets the device EEE behaviour.

eee on|off
Enables/disables the device support of EEE.

tx-lpi on|off
Determines whether the device should assert its Tx LPI.

advertise N
Sets the speeds for which the device should advertise EEE capabiliities. Values are as for --change advertise

tx-timer N
Sets the amount of time the device should stay in idle mode prior to asserting its Tx LPI (in microseconds). This has meaning only when Tx LPI is enabled.

ethtool 命令实例:


ethtool 显示接口的当前设置:

ethtool eth0


Settings for eth0:
        Link detected: yes

ethtool 显示接口的驱动程序信息:

ethtool --driver eth0


driver: virtio_net
version: 1.0.0
firmware-version: 
expansion-rom-version: 
bus-info: 0000:00:06.0
supports-statistics: no
supports-test: no
supports-eeprom-access: no
supports-register-dump: no
supports-priv-flags: no

ethtool 显示接口所有支持的功能:

ethtool --show-features eth0


Features for eth0:
rx-checksumming: on [fixed]
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]
scatter-gather: on
        tx-scatter-gather: on
        tx-scatter-gather-fraglist: off [fixed]
tcp-segmentation-offload: on
        tx-tcp-segmentation: on
        tx-tcp-ecn-segmentation: on
        tx-tcp6-segmentation: on
        tx-tcp-mangleid-segmentation: off
udp-fragmentation-offload: on
generic-segmentation-offload: on
generic-receive-offload: on
large-receive-offload: off [fixed]
rx-vlan-offload: off [fixed]
tx-vlan-offload: off [fixed]
ntuple-filters: off [fixed]
receive-hashing: off [fixed]
highdma: on [fixed]
rx-vlan-filter: off [fixed]
vlan-challenged: off [fixed]
tx-lockless: off [fixed]
netns-local: off [fixed]
tx-gso-robust: off [fixed]
tx-fcoe-segmentation: off [fixed]
tx-gre-segmentation: off [fixed]
tx-ipip-segmentation: off [fixed]
tx-sit-segmentation: off [fixed]
tx-udp_tnl-segmentation: off [fixed]
fcoe-mtu: off [fixed]
tx-nocache-copy: off
loopback: off [fixed]
rx-fcs: off [fixed]
rx-all: off [fixed]
tx-vlan-stag-hw-insert: off [fixed]
rx-vlan-stag-hw-parse: off [fixed]
rx-vlan-stag-filter: off [fixed]
busy-poll: off [fixed]
tx-gre-csum-segmentation: off [fixed]
tx-udp_tnl-csum-segmentation: off [fixed]
tx-gso-partial: off [fixed]
tx-sctp-segmentation: off [fixed]
rx-gro-hw: off [fixed]
l2-fwd-offload: off [fixed]
hw-tc-offload: off [fixed]
rx-udp_tunnel-port-offload: off [fixed]

ethtool 扩展阅读:




ethtool 命令评论