How to Set Ethernet Card Speed in Linux with ethtool

How to Set Ethernet Card Speed in Linux with ethtool

Ethtool is a networking utility on Linux used to view and change the Ethernet device parameters. This article will learn how to use the ethtool command on Linux.

The configuration of your Ethernet card allows your computer to communicate effectively over the network. Ethtool provides much information about Ethernet devices connected to your Linux system.

In addition, you can change ethernet card parameters as required, including auto-negotiation, Speed, Duplex, and Wake-on LAN.

The following information will help you understand how an Ethernet card works.

  • Auto-Negotiation: It is a mechanism that allows a device to choose the best network speed and mode of operation automatically.
  • Speed: By default, it uses maximum speed, and you can change it according to your need.
  • Half Duplex: This allows a device to either send or receive packets at a time.
  • Full Duplex: This allows a device to send and receive packets simultaneously.
  • Wake-on-LAN (WoL): Industry standard protocol allows a computer to be turned on or awakened by a network message.
  • Link detection: This shows the status of the network interface card. If it shows “no,” then try restarting the interface. If the link detection still says “no,” check if there are any issues with the cables connected between the switch and the system.

How to Find Available Network Interfaces on Linux

Firstly you’ll need to know the name of your network interface card. If you’re not sure how to operate with network devices in Linux, we recommend our excellent guide on the subject, “How to Set Static IP Address and Modifying Routing Table on Linux.”

Run the following command from the command terminal:

ip a
How to view the available network interface in Linux

As you can see in the example above, we have many network devices. So, depending on the available devices on your computer, determine which is the network device you want to change the parameters on. In our case, this is enp7s0.

How to Check Network Interface Information on Linux with ethtool

Once you have the Ethernet interface name, you can quickly check its details using the ethtool command.

When you execute the ethtool command with a device name, it displays ethernet card properties such as speed, wake on, duplex, and the link detection status.

sudo ethtool enp7s0
Check network interface information in Linux with ethtool

How to Get Ethernet Card Driver and Firmware Version on Linux with ethtool

You can also check the driver, firmware, and bus details using the ethtool command with the -i option, as shown below.

sudo ethtool -i enp7s0
Check the ethernet card driver and the firmware version in Linux with the ethtool command

How to Change Ethernet Card Settings on Linux with ethtool

The -s option can be used to change the current settings by defining the values for speed, duplex, and auto-negotioation in the following format:

sudo ethtool -s [device_name] speed [10/100/1000] duplex [half/full] autoneg [on/off]

For example, to set the speed at 100Mb/s, the duplex mode to full, and the auto-negotiation to on, the command would be:

sudo ethtool -s enp7s0 speed 100 duplex full autoneg on

In addition, you can change each option individually:

sudo ethtool -s enp7s0 speed 100
sudo ethtool -s enp7s0 duplex full
sudo ethtool -s enp7s0 autoneg on

Note: Once you change the speed when the adapter is online, it automatically goes offline, and you need to bring it back online using the ifup command.

sudo ifup enp7s0

Please note that if you’ve changed any ethernet card parameters using the ethtool, it will disappear after the next reboot.

How to Persist ethtool Settings Across Reboot

However, after a system restarts, the changes you made with ethtool will be reverted by default.

To make custom settings permanent, you need to update your value in the network configuration file. Depending on your Linux distro, you may need to update this value to the correct file.

For Red Hat-based systems modify the /etc/sysconfig/network-scripts/ifcfg-eth-id file and include a line as shown below:

ETHTOOL_OPTS="speed 100 duplex full autoneg on"

For Debian/Ubuntu-based systems you have to modify /etc/network/interfaces file and add your changes as shown below:

post-up ethtool -s enp5s0 speed 100 duplex full autoneg on

Conclusion

You have figured out that this is just a basic introduction to ethtool because it provides many other options not explained above. However, combined with other such tools, this can become one fantastic tool in a sysadmin’s bag of tricks.

Bobby Borisov
Bobby Borisov

Bobby is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, Bobby has worked as a Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Leave a Reply

Your email address will not be published. Required fields are marked *