How to use ethtool to Change Speed, Duplex, and Auto-negotiation settings in Linux

This post describes how to change network device settings, such as speed, duplex, and auto-negotiation in Linux with ethtool commands.

Basic Terminologies

Half-duplex mode allows a device to either send or receive packets in turn. A device set to this mode could not perform both actions at the same time. When a device is using a mode of full-duplex, it could send and receive packets simultaneously.

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. 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.

To Check Current NIC Settings

Ethtool is a Network Interface Card configuration command that allows us to retrieve information and change our NIC settings. The information includes Speed, Duplex, Auto-Negotiation, and many other parameters.

To continue, we have to know the name of the network interface card. To get the name of the network interface card, just run:

# ip addr
1: lo: <loopback,up,lower_up> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet scope host lo
valid_lft forever preferred_lft forever

2: enp0s3: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet xx.xx.xx.xx/24 brd xx.xx.xx.xx scope global dynamic enp0s3
valid_lft 85936sec preferred_lft 85936sec</broadcast,multicast,up,lower_up></loopback,up,lower_up>

From the example above, the name of the device is enp0s3. So we have got the name of the device.

To further check the current Speed, Auto-Negotiation, and Duplex mode settings with the command: ethtool devicename. For example:

# ethtool enp0s3
Settings for enp0s3:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
Transceiver: internal
Auto-negotiation: on
MDI-X: off (auto)
Supports Wake-on: umbg
Wake-on: d
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes

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

To Change Ethernet Adapter Settings

The “ethtool –s” command could define the values for “speed”, “duplex”, and “autoneg”. Syntax is:

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

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

# ethtool –s enp0s3 speed 1000 duplex full autoneg on

To Permanently Set Ethtool Command Settings

Modifications made with ethtool command are by default disappeared after a reboot. For permanent settings, the interface configuration file has to be edited. For example in our case we have to modify the file “/etc/sysconfig/network-scripts/ifcfg-enp0s3”:

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

Add a line with 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 file and restart network service or reboot server and then the changes are now permanent.

# service network restart