Ubuntu Server is a powerful, reliable, and flexible platform—there is no end to what you can do with the operating system. For instance, if you like to tweak and tune your network, Ubuntu Server offers plenty of tools. One such networking tool is ethtool.
With this command-line tool, you can query or control your network driver and hardware settings and troubleshoot problematic network hardware. For example, you can change the following and much more:
- The speed of the device
- Display all NIC settings
- Display auto-negotiation, RX, and TX settings
- Display network statistics for a specific NIC
- Troubleshoot ethernet connections
- Blink the LED of a specific NIC
Let’s explore how to use this must-know tool. Notes: ethtool is not a new tool. Also, ethtool is not specific to Ubuntu, and it can be used on most Linux distributions.
SEE: System Monitoring Policy (Tech Pro Research)
Chances are, the release of Ubuntu Server you’re using includes ethtool. To confirm, open a terminal window and issue the command which ethtool, and you’ll know right away if the tool is installed.
If ethtool is not installed, follow these steps.
- Open a terminal window.
- Issue the command sudo apt-get update.
- Install the app with the command sudo apt-get install ethtool.
- Allow the installation to complete.
You need to know the name of the ethernet device you’ll be working with. To find that out, issue the command ifconfig. The device’s name will be listed in the left column (Figure A).
Once you have the device name, issue the command sudo ethtool DEVNAME (DEVNAME is the actual device name). You should see a complete listing of configurations applied to your device (Figure B).
If you want to get statistics about your NIC, issue the command:
sudo ethtool -S DEVNAME
The output from that command will include such things as the following and more:
Using the above command is a great way to troubleshoot issues with a particular NIC. If you find ethtool reporting-specific errors on a card, there’s a problem. The specific errors reported will help you know where to continue your troubleshooting efforts.
Say you want display auto-negotiation and RX/TX information about the card. To do this, issue the command:
sudo ethtool -a DEVNAME
The above command will display the settings for these three particular options (Figure C).
Here are two samples that illustrate how to change these settings. Note: Before making any changes, you must first use the ifdown. To do this, issue the command sudo ifdown DEVNAME (DEVNAME is the actual device name). After making your changes, bring the device back up with the command sudo ifup DEVNAME.
Disable auto-negotiation and enable Half Duplex (DEVNAME is the actual device name):
sudo ethtool -s DEVNAME duplex half autoneg off
Disable auto-negotiation, enable Half Duplex, and set Speed to 1000 Mb/s:
sudo ethtool -s eth1 duplex full speed 1000 autoneg off
Locating a specific NIC
Here’s a really useful trick ethtool offers: You have a server with multiple NICs, and one of them is malfunctioning; you’re not sure which one it is, and you don’t want to go random mode on your server and just start yanking out NICs. You can use ethtool to blink the NIC LED in order to determine which NIC you’re looking to troubleshoot. Say you want to blink the LED of ethernet device enp0s3 for 15 seconds—the command for that would be:
sudo ethtool -p enpS03 15
The LED will begin blinking, so you know which card you’re dealing with.
Testing your NIC
The ethtool command offers a couple of handy tests you can run on a NIC:
- Online – tests nvram and a link test
- Offline – tests register, memory, loopback, interrupt
Let’s run an online test on our NIC. This command looks like:
sudo ethtool -t DEVNAME online
When you run that command, it will seem that ethtool is hanging. Allow the command to complete its test, and it will return the results (Figure D).
If the test fails, ethtool will report which portion of the test didn’t pass. Note: Some ethernet devices do not support offline testing; if your NIC fails offline testing, it could simply mean it doesn’t support the feature.
Much more to the tool
We’ve only scratched the surface as to what the ethtool command can do. For more information about the tool, issue man ethtool to see every available option you can use.