How To Change Speed & Duplex of Ethernet Card in Linux with Ethtool Command

September 24, 2019

Introduction

The configuration of your Ethernet Card defines how effectively your servers communicate.

It is necessary to understand how Auto-Negotiation, Speed, and Duplex settings affect the transfer of data to maintain network connectivity with minimal effort.

This article will show you how to change Speed, Duplex, and Auto-Negotiation settings in Linux (CentOS) with ethtool commands.

tutorial on changing speed, duplex and auto-negation of NIC card

Prerequisites

  • Command-line/terminal window
  • A user account with root or sudo privileges
  • The Ethtool configuration tool installed

Half Duplex, Full Duplex, and Auto-Negotiation

Half-duplex mode allows a device to either send or receive packets in turn. A device set to this mode cannot perform both actions at the same time.

When a device’s mode is at full-duplex, it can also send and receive packets simultaneously.

visual representation of full duplex and half duplex concept

Auto-Negotiation is a mechanism by which a device automatically chooses the best performing transmission mode based on its counterparts’ characteristics. It is recommended to keep Auto-Negotiation enabled as it allows devices to choose the most efficient means for the transfer of data.

What is a Duplex Mismatch?

When a device, with enabled auto-negotiation, connects to a device that is not using this signaling method, the process does not work. The end of the connection with an active auto-negotiation is still able to detect the speed of the other end, but cannot correctly detect the duplex mode. As a rule, the auto-negotiating end of the connection is going to use half-duplex while the other end might be at full-duplex. This situation is considered a duplex mismatch.

A duplex mismatch does not stop communication completely. Single packets and small amounts of data do not cause immediate issues. However, when a large amount of data is sent from either end, the speed drops significantly. The connection is working, but the performance is reduced as the data transfer rate is asymmetrical and might lead to packet loss.

How to Use Ethtool Command to Configure NIC Settings

Ethtool is a Network Interface Card configuration command that allows you to retrieve information and change your NIC settings. These settings include Speed, Duplex, Auto-Negotiation, and many other parameters.

To proceed, you'll need to know the name of your network interface card.

To find the name of your network interface card, run the following command from the command terminal:

ifconfig

The output provides the name of the device interface card. To learn more about this command, read our guide How to Install and Use ifconfig.

ifconfig command used to find device name

In the above example, the name of the device is enp0s3.

Now that you have determined the name of the device, check the current Speed, Auto-Negotiation, and Duplex mode settings with the command: ethtool devicename.

In our specific example the command is:

ethtool enp0s3

The output shows that the current speed is 1000Mb/s, that the Duplex is at Full, and that Auto-Negotiation is turned on.

Terminal screen displays the status of speed, auto negotiation and duplex

Ethtool Command to Change Ethernet Adapter Settings

Note: The ethernet adapter settings cannot be changed for virtualized environments (such as a virtual machine) and on unsupported network drivers.

The ethtool -s command can be used to change the current settings by defining the values for speed, duplex, and autoneg in the following format:

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

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

sudo ethtool -s enp0s3 autoneg on speed 1000 duplex full

The ethtool [device_name] command is necessary to confirm that the changes have been applied.

Ethtool_opt Variable to Permanently Set Ethtool Command Settings

Changes made with Ethtool are by default reverted after a system is re-booted.

To apply custom settings each time a system boots edit the file for the device interface:

sudo vi /etc/sysconfig/network-scripts/ifcfg-enp0s3

Add the desired values as a line at the end of the file using the following syntax:

ETHTOOL_OPTS="speed [100|1000|10000] duplex [half|full] autoneg [on|off]"

For example:

ETHTOOL_OPTS="speed 1000 duplex full autoneg on"

Save the changes and exit the file.

Now the changes are applied after every reboot and are permanent unless the file is altered again.

Conclusion

By following this tutorial, you have successfully changed the settings on your Network Interface Card with ethtool commands. You have also gained a better understanding of how Auto-Negotiation and Duplex modes affect server performance.

Was this article helpful?
YesNo
Vladimir Kaplarevic
Vladimir is a resident Tech Writer at phoenixNAP. He has more than 7 years of experience in implementing e-commerce and online payment solutions with various global IT services providers. His articles aim to instill a passion for innovative technologies in others by providing practical advice and using an engaging writing style.
Next you should read
Raid Levels and Types: Advantages and Disadvantages of 0,1,5,10
July 23, 2019

RAID (redundant array of independent disks) is a setup consisting of multiple disks for data storage. They...
Read more
How to Check Memory Usage in Linux, 5 Simple Commands
June 18, 2019

In this tutorial, learn the five most commonly used commands to check memory usage in Linux. We also provide...
Read more
7 Best Website Speed and Performance Testing Tools
June 3, 2019

There are programs that answer two of the most common questions web administrators and SEO's keep asking when...
Read more
Nmap Commands - 17 Basic Commands for Linux Network
May 14, 2019

Nmap is an open-source tool for network exploration and security auditing...
Read more