How to check interfaces’ speed/duplex → ethtool
How to Check Network Interface Speed and Duplex Settings Using ethtool
Table of Contents
1. [Introduction](#introduction)
2. [Prerequisites](#prerequisites)
3. [Understanding Network Interface Speed and Duplex](#understanding-network-interface-speed-and-duplex)
4. [Installing and Using ethtool](#installing-and-using-ethtool)
5. [Basic ethtool Commands for Speed and Duplex](#basic-ethtool-commands-for-speed-and-duplex)
6. [Advanced ethtool Usage](#advanced-ethtool-usage)
7. [Practical Examples and Use Cases](#practical-examples-and-use-cases)
8. [Troubleshooting Common Issues](#troubleshooting-common-issues)
9. [Best Practices and Professional Tips](#best-practices-and-professional-tips)
10. [Alternative Methods](#alternative-methods)
11. [Conclusion](#conclusion)
Introduction
Network interface speed and duplex settings are fundamental aspects of network configuration that directly impact system performance and connectivity reliability. The `ethtool` command is the industry-standard utility for querying and controlling network device driver and hardware settings in Linux environments.
This comprehensive guide will teach you how to effectively use `ethtool` to check interface speed and duplex settings, understand the output, troubleshoot common networking issues, and implement best practices for network management. Whether you're a system administrator, network engineer, or Linux enthusiast, mastering these skills is essential for maintaining optimal network performance.
By the end of this article, you'll be able to:
- Use ethtool to check current interface speed and duplex settings
- Interpret ethtool output accurately
- Troubleshoot speed and duplex-related network issues
- Configure interface settings for optimal performance
- Implement monitoring and automation strategies
Prerequisites
Before proceeding with this guide, ensure you have:
System Requirements
- A Linux-based operating system (Ubuntu, CentOS, RHEL, Debian, etc.)
- Root or sudo privileges for system-level network operations
- Access to a terminal or command-line interface
Knowledge Prerequisites
- Basic understanding of Linux command-line operations
- Fundamental knowledge of networking concepts
- Familiarity with network interface concepts
Tools and Software
- ethtool utility (installation covered in this guide)
- Network interfaces available for testing
- Text editor for configuration files (optional)
Understanding Network Interface Speed and Duplex
Network Interface Speed
Network interface speed refers to the maximum data transmission rate supported by a network connection, typically measured in megabits per second (Mbps) or gigabits per second (Gbps). Common speeds include:
- 10 Mbps: Legacy Ethernet
- 100 Mbps: Fast Ethernet
- 1000 Mbps (1 Gbps): Gigabit Ethernet
- 10 Gbps: 10 Gigabit Ethernet
- 25 Gbps, 40 Gbps, 100 Gbps: High-speed enterprise connections
Duplex Modes
Duplex mode determines how data flows between network devices:
Half Duplex: Data can flow in both directions but not simultaneously. Only one device can transmit at a time, similar to a walkie-talkie conversation.
Full Duplex: Data can flow in both directions simultaneously, allowing for more efficient communication and higher effective throughput.
Auto-negotiation: Modern network interfaces automatically negotiate the highest common speed and duplex mode with the connected device.
Why Speed and Duplex Matter
Incorrect speed and duplex settings can cause:
- Reduced network performance
- Packet loss and retransmissions
- Connection instability
- Increased latency
- Network timeouts
Installing and Using ethtool
Installation on Different Linux Distributions
Ubuntu/Debian Systems
```bash
sudo apt update
sudo apt install ethtool
```
CentOS/RHEL/Fedora Systems
```bash
CentOS/RHEL 7 and earlier
sudo yum install ethtool
CentOS/RHEL 8+ and Fedora
sudo dnf install ethtool
```
SUSE/openSUSE Systems
```bash
sudo zypper install ethtool
```
Verifying Installation
After installation, verify ethtool is available:
```bash
ethtool --version
```
Expected output:
```
ethtool version 5.16
```
Basic ethtool Syntax
The basic syntax for ethtool is:
```bash
ethtool [OPTIONS] INTERFACE_NAME
```
Where `INTERFACE_NAME` is typically something like `eth0`, `ens33`, `enp0s3`, etc.
Basic ethtool Commands for Speed and Duplex
Identifying Network Interfaces
Before using ethtool, identify available network interfaces:
```bash
ip link show
```
Example output:
```
1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 08:00:27:8d:c0:4d brd ff:ff:ff:ff:ff:ff
3: eth1: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 08:00:27:1e:36:4a brd ff:ff:ff:ff:ff:ff
```
Checking Current Speed and Duplex Settings
To check the current speed and duplex settings for an interface:
```bash
ethtool eth0
```
Example output:
```
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
MDI-X: off (auto)
Supports Wake-on: umbg
Wake-on: d
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes
```
Key Information in ethtool Output
Speed: Current negotiated speed (e.g., 1000Mb/s)
Duplex: Current duplex mode (Full or Half)
Auto-negotiation: Whether auto-negotiation is enabled
Link detected: Whether a physical link is established
Supported link modes: All speed/duplex combinations the interface supports
Advertised link modes: Speed/duplex modes the interface advertises during negotiation
Quick Speed and Duplex Check
For a concise view focusing on speed and duplex:
```bash
ethtool eth0 | grep -E "(Speed|Duplex)"
```
Output:
```
Speed: 1000Mb/s
Duplex: Full
```
Advanced ethtool Usage
Checking Link Status
To verify if a link is active:
```bash
ethtool eth0 | grep "Link detected"
```
Viewing Supported Capabilities
To see all supported speeds and duplex modes:
```bash
ethtool eth0 | grep -A 10 "Supported link modes"
```
Monitoring Multiple Interfaces
Create a script to check multiple interfaces:
```bash
#!/bin/bash
for interface in $(ip link show | awk -F: '$0 !~ "lo|vir|wl|^[^0-9]"{print $2;getline}' | sed 's/^ *//'); do
echo "Interface: $interface"
ethtool $interface 2>/dev/null | grep -E "(Speed|Duplex|Link detected)" || echo " ethtool not supported or interface down"
echo
done
```
Setting Speed and Duplex Manually
Warning: Manual configuration should be done carefully as it can disrupt network connectivity.
To set speed and duplex manually:
```bash
Set to 100Mbps full duplex
sudo ethtool -s eth0 speed 100 duplex full autoneg off
Set to auto-negotiation
sudo ethtool -s eth0 autoneg on
```
Making Changes Persistent
Manual ethtool changes are temporary. To make them persistent:
On Ubuntu/Debian (using /etc/network/interfaces):
```bash
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
post-up ethtool -s eth0 speed 1000 duplex full autoneg off
```
On CentOS/RHEL (using network scripts):
Add to `/etc/sysconfig/network-scripts/ifcfg-eth0`:
```bash
ETHTOOL_OPTS="speed 1000 duplex full autoneg off"
```
Using systemd (modern approach):
Create `/etc/systemd/system/ethtool-settings.service`:
```bash
[Unit]
Description=Configure ethtool settings
After=network.target
[Service]
Type=oneshot
ExecStart=/sbin/ethtool -s eth0 speed 1000 duplex full autoneg off
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
```
Enable the service:
```bash
sudo systemctl enable ethtool-settings.service
```
Practical Examples and Use Cases
Example 1: Diagnosing Slow Network Performance
A server is experiencing slow network performance. Check the interface settings:
```bash
ethtool eth0
```
If the output shows:
```
Speed: 100Mb/s
Duplex: Half
Auto-negotiation: off
```
This indicates the interface is running at 100Mbps half-duplex, which could be the performance bottleneck. Enable auto-negotiation:
```bash
sudo ethtool -s eth0 autoneg on
```
Example 2: Troubleshooting Intermittent Connectivity
For intermittent connectivity issues, check if the link is stable:
```bash
Monitor link status
watch -n 1 'ethtool eth0 | grep "Link detected"'
```
Example 3: Verifying Gigabit Connection
After connecting to a gigabit switch, verify the connection negotiated properly:
```bash
ethtool eth0 | grep -E "(Speed|Duplex|Auto-negotiation)"
```
Expected output for optimal gigabit connection:
```
Speed: 1000Mb/s
Duplex: Full
Auto-negotiation: on
```
Example 4: Creating a Network Interface Report
Generate a comprehensive report for all interfaces:
```bash
#!/bin/bash
echo "Network Interface Speed/Duplex Report"
echo "Generated on: $(date)"
echo "========================================"
for iface in $(ls /sys/class/net/ | grep -v lo); do
echo
echo "Interface: $iface"
echo "------------------------"
# Check if interface is up
if ip link show $iface | grep -q "state UP"; then
ethtool $iface 2>/dev/null | grep -E "(Speed|Duplex|Auto-negotiation|Link detected)" || echo "ethtool data not available"
else
echo "Interface is DOWN"
fi
done
```
Example 5: Automated Speed/Duplex Monitoring
Create a monitoring script that alerts when interfaces aren't running at expected speeds:
```bash
#!/bin/bash
EXPECTED_SPEED="1000"
LOG_FILE="/var/log/interface_monitoring.log"
for iface in eth0 eth1; do
current_speed=$(ethtool $iface 2>/dev/null | grep "Speed:" | awk '{print $2}' | sed 's/Mb\/s//')
if [ "$current_speed" != "$EXPECTED_SPEED" ]; then
echo "$(date): WARNING - $iface running at ${current_speed}Mb/s, expected ${EXPECTED_SPEED}Mb/s" >> $LOG_FILE
# Send alert (email, SNMP trap, etc.)
fi
done
```
Troubleshooting Common Issues
Issue 1: ethtool Command Not Found
Problem: `bash: ethtool: command not found`
Solution: Install ethtool using your distribution's package manager:
```bash
Ubuntu/Debian
sudo apt install ethtool
CentOS/RHEL
sudo yum install ethtool # or dnf install ethtool
```
Issue 2: Permission Denied
Problem: `Operation not permitted` when trying to change settings
Solution: Use sudo or run as root:
```bash
sudo ethtool -s eth0 autoneg on
```
Issue 3: Interface Not Supported
Problem: `Cannot get device settings: Operation not supported`
Solutions:
1. Verify the interface name is correct:
```bash
ip link show
```
2. Some virtual interfaces don't support ethtool. Check if it's a physical interface:
```bash
ls -la /sys/class/net/
```
3. For wireless interfaces, use `iwconfig` instead:
```bash
iwconfig wlan0
```
Issue 4: Auto-negotiation Fails
Problem: Interface doesn't negotiate optimal speed/duplex
Solutions:
1. Force auto-negotiation restart:
```bash
sudo ethtool -r eth0
```
2. Check cable and port on the switch
3. Manually set speed and duplex as a temporary workaround:
```bash
sudo ethtool -s eth0 speed 1000 duplex full autoneg off
```
Issue 5: Speed Showing as Unknown
Problem: ethtool shows `Speed: Unknown!`
Possible causes and solutions:
1. Cable not connected: Check physical connections
2. Interface down: Bring interface up:
```bash
sudo ip link set eth0 up
```
3. Driver issues: Check dmesg for errors:
```bash
dmesg | grep eth0
```
Issue 6: Duplex Mismatch
Problem: One end is full-duplex, the other is half-duplex
Symptoms:
- High collision rates
- Poor performance
- Intermittent connectivity
Solution: Ensure both ends use the same settings or both use auto-negotiation:
```bash
sudo ethtool -s eth0 autoneg on
```
Issue 7: Changes Don't Persist After Reboot
Problem: Manual ethtool settings are lost after system restart
Solution: Make changes persistent using your distribution's network configuration method (covered in the Advanced Usage section).
Best Practices and Professional Tips
1. Always Use Auto-negotiation When Possible
Modern networks should use auto-negotiation unless there's a specific technical reason not to. Manual configuration can lead to mismatches and problems.
```bash
Preferred approach
sudo ethtool -s eth0 autoneg on
```
2. Document Network Configurations
Maintain documentation of any manual speed/duplex settings:
```bash
Create a network configuration document
echo "$(hostname) - $(date)" >> /etc/network-config.txt
echo "eth0: Manual 1000Mb/s Full Duplex - Required for legacy switch compatibility" >> /etc/network-config.txt
```
3. Monitor Network Performance Regularly
Create monitoring scripts to track interface performance:
```bash
#!/bin/bash
Add to crontab: /5 * /usr/local/bin/network-monitor.sh
LOG_FILE="/var/log/network-performance.log"
TIMESTAMP=$(date)
for iface in $(ip link show | grep -E '^[0-9]+: (eth|ens|enp)' | cut -d: -f2 | tr -d ' '); do
speed=$(ethtool $iface 2>/dev/null | grep "Speed:" | awk '{print $2}')
duplex=$(ethtool $iface 2>/dev/null | grep "Duplex:" | awk '{print $2}')
link=$(ethtool $iface 2>/dev/null | grep "Link detected:" | awk '{print $3}')
echo "$TIMESTAMP,$iface,$speed,$duplex,$link" >> $LOG_FILE
done
```
4. Test Changes in Non-Production Environments
Always test speed and duplex changes in development or staging environments before applying to production systems.
5. Use Consistent Naming Conventions
When documenting or scripting, use consistent interface naming:
```bash
Good: Use predictable interface names
MGMT_INTERFACE="ens192"
DATA_INTERFACE="ens224"
Check management interface
ethtool $MGMT_INTERFACE | grep -E "(Speed|Duplex)"
```
6. Implement Change Management
For production environments, implement proper change management:
1. Document the current configuration
2. Plan the change during maintenance windows
3. Have a rollback plan
4. Test connectivity after changes
7. Consider Network Topology
Understand your network topology when configuring speed and duplex:
- Server to Switch: Usually auto-negotiation
- Switch to Switch: May require manual configuration for optimal performance
- Legacy Equipment: May require manual configuration
8. Use Configuration Management Tools
For large environments, use configuration management tools like Ansible, Puppet, or Chef:
```yaml
Ansible example
- name: Configure network interface speed
shell: ethtool -s {{ item }} speed 1000 duplex full autoneg off
with_items:
- eth0
- eth1
become: yes
```
9. Regular Auditing
Periodically audit network configurations:
```bash
#!/bin/bash
Network configuration audit script
echo "Network Interface Audit - $(date)"
echo "=================================="
for iface in $(ls /sys/class/net/ | grep -E '^(eth|ens|enp)'); do
echo "Interface: $iface"
ethtool $iface 2>/dev/null | grep -E "(Speed|Duplex|Auto-negotiation)" | sed 's/^/ /'
echo
done
```
10. Keep Firmware and Drivers Updated
Ensure network drivers and firmware are up to date for optimal auto-negotiation and performance:
```bash
Check driver information
ethtool -i eth0
```
Alternative Methods
While ethtool is the standard tool, there are alternative methods to check interface speed and duplex:
Using /sys filesystem
```bash
Check speed (in Mbps)
cat /sys/class/net/eth0/speed
Check duplex
cat /sys/class/net/eth0/duplex
Check carrier status
cat /sys/class/net/eth0/carrier
```
Using ip command
```bash
Basic interface information
ip link show eth0
```
Using mii-tool (deprecated but sometimes available)
```bash
Check interface status
mii-tool eth0
Verbose output
mii-tool -v eth0
```
Note: mii-tool is deprecated and may not work with modern network drivers. ethtool is the preferred method.
Using NetworkManager (GUI environments)
On systems with NetworkManager:
```bash
nmcli device show eth0
```
Using /proc/net/dev for statistics
```bash
cat /proc/net/dev
```
This shows interface statistics but not speed/duplex information.
Conclusion
Mastering the `ethtool` command for checking and configuring network interface speed and duplex settings is essential for effective Linux system administration and network troubleshooting. This comprehensive guide has covered everything from basic usage to advanced troubleshooting scenarios and best practices.
Key Takeaways
1. ethtool is the standard tool for network interface configuration in Linux environments
2. Auto-negotiation is preferred in most modern network environments
3. Speed and duplex mismatches can cause significant performance issues
4. Persistent configuration requires distribution-specific approaches
5. Regular monitoring helps prevent and quickly identify network issues
6. Documentation and change management are crucial in production environments
Next Steps
To further develop your network administration skills:
1. Practice in a lab environment with different network configurations
2. Learn about advanced ethtool features like wake-on-LAN and offloading
3. Study network troubleshooting methodologies that incorporate ethtool
4. Explore network monitoring tools that can automate interface monitoring
5. Understand your specific network hardware and its optimal configurations
Final Recommendations
- Always test configuration changes in non-production environments first
- Keep detailed documentation of any manual network configurations
- Implement monitoring to catch speed and duplex issues early
- Stay updated with the latest networking best practices and tools
- Consider the entire network path when troubleshooting performance issues
By following the guidance in this article, you'll be well-equipped to effectively manage network interface speed and duplex settings using ethtool, troubleshoot related issues, and maintain optimal network performance in your Linux environments.