ETHTOOL - Base Documentation
Common Commands
Display Information
To display detailed information about a network interface:
ethtool eth0
This command outputs various statistics and properties such as speed, duplex mode, supported features, and driver information.
Display Driver Information
To display the driver details for a specific interface:
ethtool -i eth0
This provides the driver version, firmware version, and supported features.
Check Link Status
To check if the link is up or down on a specific interface:
ethtool eth0 | grep "Link detected"
This outputs whether the link is up or down.
Change Speed and Duplex Mode
To set a specific speed and duplex mode for an interface:
ethtool -s eth0 speed 1000 duplex full autoneg off
This command sets the speed to 1000Mbps, full duplex, and disables auto-negotiation.
Enable/Disable Auto-Negotiation
To disable or enable auto-negotiation:
ethtool -s eth0 autoneg off
To enable auto-negotiation:
ethtool -s eth0 autoneg on
Set Wake-on-LAN Options
To configure Wake-on-LAN (WoL) settings:
ethtool -s eth0 wol g
This enables WoL for magic packets. To disable WoL:
ethtool -s eth0 wol d
Set Ring Buffer Size
To adjust the ring buffer size (useful for high throughput environments):
ethtool -G eth0 rx 4096 tx 4096
This sets the receive and transmit ring buffer sizes to 4096.
Display Interface Statistics
To display statistics such as packet errors, drops, and other counters:
ethtool -S eth0
This shows statistics such as `rx_dropped`, `tx_dropped`, `rx_errors`, `tx_errors`, etc.
Advanced Configuration
Change MAC Address
To display the current MAC address of an interface:
ethtool -P eth0
To change the MAC address temporarily:
ethtool -s eth0 hw ether XX:XX:XX:XX:XX:XX
Replace `XX:XX:XX:XX:XX:XX` with the desired MAC address.
Enable/Disable Offload Features
To disable TX and RX checksum offload:
ethtool -K eth0 tx off rx off
This command disables the offloading of checksum calculations for transmitted and received packets.
Display and Modify Driver Settings
To display the driver settings for an interface:
ethtool -d eth0
This command shows the detailed driver settings for debugging purposes.
Interrupt Coalescing
To adjust interrupt coalescing settings (to improve performance or reduce CPU usage):
ethtool -C eth0 rx-usecs 1000 tx-usecs 1000
This sets the coalescing time for both receive and transmit interrupts.
View Supported Features
To view the supported features of the network interface:
ethtool -i eth0
This will show the available driver features, including offloading capabilities and other hardware support.
Security Concepts
Disabling Unnecessary Features
Disabling features such as Wake-on-LAN and Auto-Negotiation is essential to reduce attack surfaces on your system, especially when these features are not in use.
- **Disable Wake-on-LAN** if not required:
ethtool -s eth0 wol d
- **Disable Auto-Negotiation** to avoid unexpected changes in network settings:
ethtool -s eth0 autoneg off
- **Disable checksum offload** for debugging purposes, but note that this might impact performance:
ethtool -K eth0 tx off rx off
These settings can be used to minimize vulnerabilities, especially in environments with strict security policies.
Troubleshooting
Interface Shows as "Disconnected"
If the network interface shows as disconnected even when the physical connection is fine, try the following steps:
Check the Link Status
ethtool eth0 | grep "Link detected"
If it shows "no," the issue could be with the cable, switch, or NIC.
Force Link Settings
Sometimes, forcing the link settings (speed, duplex) can solve the issue:
ethtool -s eth0 speed 1000 duplex full autoneg off
Check Network Interface Driver
Ensure that the driver is correctly installed and supports the network interface:
ethtool -i eth0
Reboot the Interface
Resetting the interface can sometimes resolve connection issues:
ifdown eth0 && ifup eth0
Low Network Performance
If you're experiencing slow network speeds or high latency, consider these steps:
==== Increase Ring Buffer Size** to handle more traffic:
ethtool -G eth0 rx 4096 tx 4096
Check for Dropped Packets
Use `ethtool -S eth0` to check if there are any dropped packets that could indicate network issues.
Disable Offloading Features
Temporarily to test if the offload mechanisms are affecting performance:
ethtool -K eth0 tx off rx off
Check Interface Errors
Use the following command to check for errors on the interface:
ethtool -S eth0
These steps should help identify if there are hardware or driver-related issues affecting the performance.
Useful Links
- [ethtool Manual Page](https://man7.org/linux/man-pages/man8/ethtool.8.html)
- [Linux Ethernet Drivers](https://www.kernel.org/doc/html/latest/networking/)
- [ethtool GitHub Repository](https://github.com/torvalds/linux/tree/master/tools/net/ethtool)
- [Wake-on-LAN Specifications](https://en.wikipedia.org/wiki/Wake-on-LAN)
