ethtool Command Explained: Linux NIC Diagnostics Guide - 夜莺博客

ethtool Command Explained: Linux NIC Diagnostics Guide

When a Linux server has slow, flaky or dead networking, ethtool is the tool that separates software problems from hardware ones - it reads settings and statistics straight from the NIC driver. This guide explains the core ethtool invocations every sysadmin needs: checking link state, driver and firmware versions, ring buffers, offload features, and the error counters that point to bad cables, dirty optics or overruns.

Basic Link and Driver Checks

ethtool eth0            # speed, duplex, auto-negotiation, link detected
ethtool -i eth0         # driver, version, firmware-version, bus-info
ethtool eth0 | grep -i speed

An outdated or mismatched driver is a classic hidden cause of packet loss; ethtool -i shows exactly which driver and firmware the NIC is running so you can compare with the vendor's recommended version.

Diagnosing with Statistics and Self-Tests

ethtool -S eth0 | grep -i error   # rx/tx errors, drops, CRC
ethtool -t eth0                   # NIC self-test
ethtool -g eth0                   # ring buffer sizes
ethtool -d eth0                   # register dump

Interpreting common counters: rx_dropped/tx_dropped often mean ring buffer overflow, rx_crc_errors point at physical-layer problems (cable or optics), and rx_fifo_errors suggest interrupt handling lag. If the self-test passes but errors persist, suspect the cable or the switch port instead of the NIC.

Checking and Tuning Offload Features

ethtool -k eth0        # offload features: TSO, GRO, GSO, checksum offload
ethtool -K eth0 tso on # enable TCP segmentation offload
ethtool -c eth0        # coalescing settings
ethtool -a eth0        # pause frame settings

Offloading lets the NIC do work the CPU would otherwise do. Verify the offload features are actually on with -k before blaming CPU for slow throughput, and remember that changing settings with -s or -K can disrupt the connection if done on the interface you are using.

Optics and Advanced Checks

ethtool -m eth0        # SFP/SFP+ module diagnostics (DOM)
ethtool --show-priv-flags eth0   # vendor private flags
ethtool -e eth0        # EEPROM dump

On fiber links, ethtool -m reads the optical module's Digital Optical Monitoring data - transmit and receive power levels that immediately reveal a dirty connector or a failing optics.

Common Errors and Fixes

  • No such device - wrong interface name; list interfaces with ip link show.
  • Operation not permitted - settings changes require root; re-run with sudo.
  • Setting changes lost after reboot - ethtool changes are runtime only; persist them via udev rules, systemd or your network manager config.

Related Reading on This Site

Pair this with Linux network troubleshooting with ss, netstat and tcpdump for the full toolchain, and optical module link maintenance for the fiber side of link problems.

原文链接:https://ioflood.com/blog/ethtool-linux-command