What it is
ethtool is a command-line utility for configuring and displaying information about network interface controllers (NICs) on Linux systems. You reach for it when you need to inspect or modify low-level network adapter settings like speed, duplex, or offloads.
Installation
Linux:
ethtool is typically pre-installed on most Linux distributions. If not, you can install it using your distribution’s package manager:
- Debian/Ubuntu:
sudo apt update sudo apt install ethtool - Fedora/CentOS/RHEL:
sudo yum install ethtool # or sudo dnf install ethtool - Arch Linux:
sudo pacman -S ethtool
macOS:
ethtool is not available on macOS. Use ifconfig and networksetup for similar tasks.
Windows:
ethtool is not available on Windows. Use the Network Connections control panel or PowerShell cmdlets like Get-NetAdapter and Set-NetAdapter.
Core Concepts
- NIC (Network Interface Controller): The hardware component that connects your computer to a network.
ethtoolinteracts directly with the driver for this hardware. - Driver: Software that allows the operating system to communicate with the NIC hardware.
ethtoolsettings are often dictated by what the NIC’s driver supports. - Link State: Refers to whether a physical connection exists between the NIC and another network device (e.g., a switch port).
- Speed: The data transfer rate of the network connection (e.g., 1000Mb/s, 10Gb/s).
- Duplex: Refers to whether the connection can send and receive data simultaneously (Full-duplex) or only one at a time (Half-duplex).
- Offloads: Hardware capabilities where the NIC performs tasks that would otherwise be handled by the CPU, such as checksum calculation or packet segmentation.
Commands / Usage
Inspecting NIC Information
-
Display general settings for
eth0:sudo ethtool eth0Shows speed, duplex, link status, and supported/advertised modes.
-
Check if the network link is up:
sudo ethtool eth0 | grep "Link status"Output like
Link status: yesindicates a physical connection. -
Display supported and advertised link modes for
eth0:sudo ethtool eth0 | grep SpeedShows what speeds the NIC supports and what it’s currently trying to negotiate.
-
Display Wake-on-LAN (WoL) settings for
eth0:sudo ethtool eth0 | grep Wake-onShows if WoL is enabled and on which events.
-
Display all offload settings for
eth0:sudo ethtool -k eth0Lists all configurable offload features and their current status (on/off).
-
Display specific offload settings (e.g., checksumming) for
eth0:sudo ethtool -k eth0 | grep checksumFilters the output for lines containing "checksum".
-
Display driver information for
eth0:sudo ethtool -i eth0Shows driver name, version, firmware version, and bus info.
-
Display EEPROM (or ROM) data for
eth0:sudo ethtool -e eth0Reads raw data from the NIC’s non-volatile memory. Useful for deep hardware inspection.
-
Display statistics for
eth0:sudo ethtool -S eth0Shows detailed hardware and driver statistics, including packet counts, errors, and drops.
Configuring NIC Settings
-
Set
eth0to 1000Mb/s, Full-duplex, and auto-negotiation:sudo ethtool -s eth0 speed 1000 duplex full autoneg onThis command attempts to set the specified speed and duplex mode.
autoneg ontells the NIC to negotiate with the other end of the link. -
Force
eth0to 100Mb/s, Half-duplex (disable auto-negotiation):sudo ethtool -s eth0 speed 100 duplex half autoneg offForces a specific link setting, disabling negotiation.
-
Enable auto-negotiation for
eth0:sudo ethtool -s eth0 autoneg onRe-enables automatic negotiation of speed and duplex.
-
Enable Wake-on-LAN (WoL) for
eth0(e.g., wake on magic packet):sudo ethtool -s eth0 wol gThe
gflag enables Wake-on-LAN for MagicPacket. Other flags exist for different wake events. -
Disable Wake-on-LAN (WoL) for
eth0:sudo ethtool -s eth0 wol 0Disables all Wake-on-LAN features.
-
Enable a specific offload feature (e.g.,
tx-checksumming) foreth0:sudo ethtool -K eth0 tx-checksumming onTurns on a specific hardware offload feature.
-
Disable a specific offload feature (e.g.,
rx-checksumming) foreth0:sudo ethtool -K eth0 rx-checksumming offTurns off a specific hardware offload feature.
-
Enable all offload features for
eth0:sudo ethtool -K eth0 tso on gso on gro on rx on tx onEnables common TCP/IP offload features.
-
Disable all offload features for
eth0:sudo ethtool -K eth0 tso off gso off gro off rx off tx offDisables common TCP/IP offload features.
-
Reset
eth0’s offload settings to driver defaults:sudo ethtool -K eth0 rx on tx on sg on tso on gso on gro off lro off(Note: This is an example of common defaults; actual defaults may vary.)
-
Load EEPROM/ROM data from a file into
eth0(use with extreme caution):sudo ethtool -E eth0 -f /path/to/eeprom_backup.binWARNING: This is a destructive operation and can brick your NIC if done incorrectly. Always back up first.
Other Useful Options
-
List all available network interfaces:
ip link show # or ls /sys/class/net/ethtoolrequires the interface name (e.g.,eth0,enp3s0,wlan0). -
Test link integrity for
eth0:sudo ethtool --test eth0Performs a series of tests on the NIC, including loopback tests.
-
Set the NIC’s MAC address for
eth0(requires interface down):sudo ip link set eth0 down sudo ip link set eth0 address 00:11:22:33:44:55 sudo ip link set eth0 upNote: This requires root privileges and the interface to be down.
ethtoolitself doesn’t directly set the MAC address butip linkdoes.
Common Patterns
-
Check link status and speed for all interfaces:
for iface in $(ls /sys/class/net/ | grep -v lo); do echo -n "$iface: "; sudo ethtool $iface | grep -E 'Speed:|Link status:'; doneIterates through non-loopback interfaces and shows their speed and link status.
-
Disable offloads to troubleshoot network issues:
sudo ethtool -K eth0 tso off gso off gro off rx off tx offIf you suspect hardware offloads are causing problems (e.g., dropped packets, slow transfers), disabling them is a common troubleshooting step. Remember to re-enable them if they don’t solve the issue.
-
Enable Wake-on-LAN globally (if supported):
for iface in $(ls /sys/class/net/ | grep -v lo); do sudo ethtool -s $iface wol g; doneAttempts to enable WoL on all non-loopback interfaces.
-
Check for specific errors in NIC statistics:
sudo ethtool -S eth0 | grep -E 'error|drop|fail'Filters NIC statistics for lines indicating potential problems.
-
Permanently configure settings (distro dependent):
ethtoolsettings are often lost on reboot. To make them persistent:- Debian/Ubuntu: Edit
/etc/network/interfacesand addethtool-optsdirectives or use/etc/network/if-up.d/scripts. - RHEL/CentOS/Fedora: Use
NetworkManagerconfiguration files (/etc/NetworkManager/system-connections/) or scripts in/etc/sysconfig/network-scripts/ifcfg-<interface>. - systemd-networkd: Use
.networkfiles in/etc/systemd/network/with[Link]options likeWakeOnLan=magic.
Example for
/etc/network/interfaces(Debian/Ubuntu):auto eth0 iface eth0 inet dhcp pre-up ethtool -s eth0 wol g pre-up ethtool -s eth0 autoneg off speed 1000 duplex full - Debian/Ubuntu: Edit
Gotchas
- Settings are not persistent: Most
ethtoolsettings are temporary and will be lost upon reboot or network service restart. You need to configure your distribution’s network management system to apply them persistently. - Driver limitations: Not all NICs or drivers support all
ethtooloptions. If a command fails or a setting doesn’t seem to apply, check the NIC’s documentation and driver capabilities. sudorequired: Modifying NIC settings requires root privileges.- Interface names: Ensure you are using the correct interface name (e.g.,
eth0,enp3s0,wlp2s0). Useip linkorls /sys/class/net/to find them. - Auto-negotiation: Forcing speed and duplex (
autoneg off) can cause link failures if the settings don’t match the connected device (e.g., switch port). It’s generally best to leaveautoneg onunless you have a specific reason not to. - Offload implications: Disabling offloads can increase CPU usage as the system takes over tasks previously handled by the NIC. While useful for troubleshooting, it may impact performance.
ethtool -eandethtool -Edangers: Reading EEPROM data (-e) is generally safe, but writing (-E) is extremely dangerous and can render your NIC unusable. Always back up your EEPROM data before attempting any writes.