The ethtool command is a powerful utility in Linux used for viewing and modifying the settings of Ethernet network interfaces. It provides system administrators with the ability to control hardware settings, diagnose network issues, and optimize network performance directly from the command line.
This utility is particularly valuable for server environments where network performance is critical, allowing administrators to fine-tune network interface parameters without having to recompile the kernel or modify hardware settings through BIOS.
One of the most common uses of ethtool is to modify the speed and duplex settings of a network interface:
ethtool -s eth0 speed 100 duplex full autoneg off
This command:
Sets the speed to 100 Mbps
Sets the duplex mode to full
Disables auto-negotiation
It's important to note that changing these settings may temporarily disrupt network connectivity, and the interface may need to be restarted for changes to take effect.
The ethtool command can perform various tests on a network interface to check for hardware issues:
ethtool -t eth0
This runs a series of diagnostic tests on the interface and reports any failures, which can help identify hardware problems before they cause network outages.
In systems with multiple network interfaces, it can be challenging to identify which physical port corresponds to which interface name. ethtool provides a solution:
ethtool -p eth0 5
This command causes the LED on the physical port associated with eth0 to blink for 5 seconds, making it easy to identify the correct port.
If a network interface is experiencing connectivity problems, you can use ethtool to check the link status:
ethtool eth0 | grep "Link detected"
If the output shows "Link detected: no", there may be a physical connection issue. You can then try:
ethtool -s eth0 autoneg off speed 100 duplex full
This disables auto-negotiation and sets a specific speed and duplex mode, which can sometimes resolve compatibility issues with older network equipment.
Changes made with ethtool are not persistent across reboots. To make them permanent, you need to add the commands to your system's network configuration.
For Ubuntu/Debian systems, add to /etc/network/interfaces:
auto eth0iface eth0 inet dhcp post-up ethtool -s eth0 speed 1000 duplex full autoneg off
For RHEL/CentOS systems, create a script in /etc/sysconfig/network-scripts/:
# /etc/sysconfig/network-scripts/ifup-local#!/bin/bashif [ "$1" = "eth0" ]; then ethtool -s eth0 speed 1000 duplex full autoneg offfi
Make the script executable with chmod +x /etc/sysconfig/network-scripts/ifup-local.
The ethtool command is an essential tool for Linux system administrators managing network interfaces. It provides comprehensive capabilities for viewing and modifying Ethernet device settings, troubleshooting network issues, and optimizing network performance.
By mastering ethtool, administrators can ensure optimal network configuration, diagnose hardware problems, and fine-tune network performance for specific workloads. Whether you're managing a single server or a large data center, ethtool is an indispensable utility in your Linux networking toolkit.
Test Your Knowledge
Take a quiz to reinforce what you've learned
Exam Preparation
Access short and long answer questions for written exams