How to Use ethtool Command with examples

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Hello, friends. In this post, you will learn how to use ethtool Command to correctly manipulate your Ethernet card on Linux. We will also use examples to help you better understand the content. Let’s go.

Introduction

Ethtool is a tool to manage the parameters of our network card on a Linux system. This tool allows, among many other things, to know the characteristics of a network card (speed, duplex, wake-on, link status, etc.).

It is almost not present by default in any Linux distribution, but it is included in almost all official repositories. So, you can enjoy it without too much effort.

The tool has many options, but we will highlight the main and most useful ones for almost any user. Let’s go.

Install ethtool on Linux

As I said before, ethtool is not installed by default in almost any Linux distribution; however, it is in the repositories of each of them.

So to install it, open a terminal on your Linux distro and run one of these commands

#For Debian, Ubuntu and derivatives
sudo apt install ethtool

#``For RHEL and derivates like Alma Linux or Rocky Linux, CentOS and Fedora
sudo dnf install ethtool

#For Arch Linux, manjaro and derivates
sudo pacman -S ethtool

#For OpenSUSE
sudo zypper in ethtool
Install ethtool on Linux
Install ethtool on Linux

As you can see then that the ethtool package is present in many distributions and is easy to obtain.

Manipulate Ethernet Card using ethtool command

There are many uses and things we can do using the ethtool command, but we will limit ourselves to the most basic and useful uses.

In this post, it is assumed that the name of the ethernet network interface is enp1s0 but to find out what is the name of yours, you can run

ip a

And you will get a screen output like this

Finding the network interface with ip command
Finding the network interface with ip command

In that screen output, you will notice that enp1s0 is the name of the ethernet network interface.

Display NIC (Ethernet) card information

To display basic information about the network card, run

sudo ethtool [interface]

You will get a long output screen like this

Using ethtool
Using ethtool Command

Then you can learn more about your network card.

Knowing the network card driver

If you want to know the driver of your network card, it is as easy as this:

sudo ethtool -i enp1s0

Sample output:

driver: r8169
version: 6.0.12-76060006-generic
firmware-version: rtl8168h-2_0.0.2 02/26/15
expansion-rom-version: 
bus-info: 0000:01:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no

There you will notice that the first value is driver which indicates which one it uses.

Display a statistic for the card

To get a usage statistic run

sudo ethtool -S enp1s0

Output:

NIC statistics:
     tx_packets: 108816
     rx_packets: 159963
     tx_errors: 0
     rx_errors: 0
     rx_missed: 0
     align_errors: 0
     tx_single_collisions: 0
     tx_multi_collisions: 0
     unicast: 159043
     broadcast: 70
     multicast: 850
     tx_aborted: 0
     tx_underrun: 0

Display Auto-negotiation, RX and TX of the network interface

If you want to know if these options are available on the NIC:

sudo ethtool -a enp1s0

Output:

Pause parameters for enp1s0:
Autonegotiate:	on
RX:		off
TX:		off
RX negotiated: off
TX negotiated: off

Turn on the LED lights on the card to identify a specific network card.

Usually, servers have several network cards, so one way to identify which one is related to the network interface is to turn on its LED light.

To do this, run

sudo ethtool -p enp1s0 4

This command will turn on the LED lights of the network card on the enp1s0 interface for 4 seconds.

Set Duplex Mode using ethtool

In this case, you can run

sudo ethtool -s enp1s0 speed 100 duplex full
sudo ethtool -s enp1s0 speed 10 duplex half

This is how quickly you can enable Duplex Mode.

Querying the MAC address of the NIC

If you want to find out the MAC address of the network card related to the network interface, you can use the -P option

sudo ethtool -P enp1s0

Sample output:

Permanent address: a8:a1:51:0a:f3:c1

Make Changes Permanent After Reboot

Many changes you make with ethtool will not be permanent. To make them permanent on Debian and derivatives, you have to edit a file /etc/network/interfaces.

sudo vim /etc/network/interfaces

And for example, add this to modify some options

post-up ethtool -s enp1s0 speed 1000 duplex full autoneg off

Save and refresh the network interface.

Show ethtool help

The ethtool help is quite comprehensive and allows you to learn more about the tool’s options. If you want to get it, you can run.

man ethtool

Or:

ethtool --help

Conclusion

ethtool is a simple tool but with so many options that you will be able to manage and handle your NIC card without problems.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook