In this article, I will show you how to use ethtool command on Linux. I will be using Debian 9 Stretch for the demonstration. But any modern Linux distribution should work. Let’s get started.
Checking ethtool Availability:
In most cases, ethtool should already be installed on your favorite Linux distribution. You can check whether ethtool is installed already with the following command:
As you can see, ethtool 4.8 is installed on my Debian 9 Stretch machine.
If you see an error, then ethtool may not be installed on your computer. You can install ethtool very easily in your favorite Linux distribution. I will show you how to install ethtool on Ubuntu, Debian, RHEL 7 and CentOS 7 in the next sections of this article below.
Installing ethtool on Ubuntu and Debian:
ethtool is available in the official package repository of Ubuntu and Debian. So it is really easy to install.
First, update the APT package repository cache with the following command:
Now, install ethtool with the following command:
Installing ethtool on CentOS 7 and RHEL 7:
ethtool is available in the official package repository of CentOS 7 and RHEL 7. You can install it very easily.
First, update the YUM cache with the following command:
Finally, install ethtool with the following command:
Displaying Network Interface Card Information with ethtool:
You can display information about the network interface cards (NICs) connected to your computer with ethtool utility. To do that, you need the network interface name of your network interface card (NIC).
On Linux, every network interface card (NIC) is assigned unique names such as eth0, ens32 etc.
First, find the assigned names of all the available network interfaces of your computer, with the following command:
As you can see, I have only two network interface cards (NICs) connected to my computer. If you have more, it should show up here. The assigned names of my network interfaces are ens33 and enx00e04c42a3fe respectively. Yours should be different. But take a note of these as you will need it from now on.
Now, to display more information about a network interface card (let’s say enx00e04c42a3fe) with ethtool, run the following command:
As you can see, a lot of information about the network interface card enx00e04c42a3fe is listed here.
For example, the supported link modes of your NIC is displayed here.
The currently used duplex mode and speed is displayed here as well. As you can see, it is connected in full duplex mode at 100 Mbps speed.
You can also find out whether your NIC supports auto negotiation from here. If auto negotiation is enabled, your NIC picks a random link mode from one of its supported link modes depending on the Router or switch port it’s connected to.
Checking Which Driver your NIC is Using:
You can also check which driver your NIC is using with ethtool command.
For example, to check for the driver used by one of your NIC (let’s say enx00e04c42a3fe), run ethtool command as follows:
As you can see, my enx00e04c42a3fe NIC is using Realtek r8152 driver version 1.08.7. Yours may be different.
Display Network Usage Statistics with ethtool:
You can find out how many packets the NIC sent (Tx or transmitted) and received (Rx or received) using ethtool. You can also find out how many of these packets collided, transmission (Tx) errors and receiver errors (Rx) and many more.
To display your NIC (let’s say enx00e04c42a3fe) statistics, run ethtool as follows:
As you can see, a lot of statistics data on your NIC is displayed.
Making your NIC Blink Using ethtool:
Making your NIC blink may sound useless. But imagine a case where your computer has lots of network interfaces. How would you know which port is assigned what network interface name? Well, just blink each network interface and find out for yourself using ethtool. Simple!
To blink a network interface (let’s say enx00e04c42a3fe) with ethtool, run ethtool as follows:
This feature may not be available on your NIC card. Check the manual of your NIC card for more information on this.
My NIC card do not have this feature, so all I get is an error.
Setting Speed and Modes on NICs Manually:
At times, auto negotiation may fail and your NIC may use the wrong speed and mode. You can easily fix that with ethtool.
First, check what speeds and modes are supported on your NIC (Let’s say enx00e04c42a3fe) with the following command:
You can find the supported link modes of your NIC in the Supported link modes section and your Routers or Switches advertised link modes on Link partner advertised link modes section as you can see in the marked section of the screenshot below. My NIC and Router supports, 10baseT and 100baseT in Half and Full duplex mode.
Currently, my NIC enx00e04c42a3fe is working in Full duplex mode at 100 Mbps speed.
To change it, let’s say in Full duplex mode at 10 Mbps speed, run ethtool as follows:
As you can see, the speed is changed to 10Mbps and the duplex mode is full. Also, auto negotiation is turned off.
Getting Help on ethtool:
The ethtool command has lots of options. It’s not possible to show how every option work in this article due to the scope and hardware limitation of my computer.
But you should be able to find what you need on the manpage of ethtool, which you can access with the following command:
So, that’s how you use ethtool on Linux. Thanks for reading this article.