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


Introduction

Ethernet cards, also known as network interface cards (NICs), are hardware components that allow computers to connect to networks. These cards enable data transmission between devices by converting digital signals from a computer into electrical signals that can be sent over the network's physical medium, such as copper wires or fiber-optic cables. Ethernet cards are essential for accessing the internet, file sharing and printing in a local network.

Understanding Ethtool Command

Definition and Functionality

Ethtool is a Linux command-line utility that allows users to query and change various network interface card (NIC) settings. It provides detailed information about the NICs installed in a system, including speed, duplex, auto-negotiation, driver information, and more. Additionally, it can be used to configure many of these settings according to user requirements.

Types of Ethernet Adapters Supported by Ethtool Command

Ethtool supports various types of Ethernet adapters including 10/100/1000Mbps. It also supports some wireless network adapters and other network devices such as virtual interfaces created by VLAN tagging or bridge interface configuration.

Basic Syntax and Options

The basic syntax for using the ethtool command is as follows −

ethtool [options] [device]

The options available with the ethtool command vary depending on the device being queried or configured. Some common options include −

  • i − displays driver information for a particular device.

  • a − displays current adapter settings.

  • s SPEED/DUPLEX − sets advertised speed/duplex mode when autonegotiation is enabled.

  • S − displays statistics for a particular device.

  • p − enables identification led on an ethernet port.

By using these options along with the name of the NIC device like eth0 or enp1s0f1 etc., users can perform operations such as querying status, turning on/off features like Large Receive Offload (LRO), TCP Segmentation Offload (TSO) etc., setting auto-negotiation On/Off, setting advertised speed/duplex etc.

Checking Current Speed and Duplex Settings

Using ethtool to Display Current Settings

Before making any changes to the speed and duplex settings, it is important to check the current configuration of the Ethernet card. This can be done using the "ethtool" command, which is a powerful tool used to view and modify network interface settings.

To check the current speed and duplex settings of an Ethernet card, simply run the "ethtool" command followed by the name of the interface. For example, if we want to check the current configuration of "eth0", we would run −

sudo ethtool eth0  

This command will display detailed information about our Ethernet card, including its speed, duplex mode, link status, and more.

Interpreting the Output

The output of the "ethtool" command can sometimes be overwhelming due to its extensive details. However, understanding how to interpret this output is crucial when it comes to configuring your Ethernet card's speed and duplex settings.

The most important information related to our topic includes −

  • Speed − The current speed (in Mbps) at which our Ethernet card is operating.

  • Duplex − The current duplex mode (either half or full) at which our Ethernet card is operating.

  • Link Detected − Whether or not a valid link has been detected on this interface.

Other useful information includes −

  • Auto-negotiation: Whether or not auto-negotiation is enabled for this interface.

  • Advertised Auto-negotiation: The advertised auto-negotiation capabilities for this interface.

  • Supported Ports: The list of supported ports for this interface (e.g., copper vs fiber).

  • Supported Link Modes: The list of supported link modes for this interface (e.g., 10baseT/Half/Full). Understanding these details will help you identify the current configuration of your Ethernet card and make informed decisions when changing its speed and duplex settings.

Changing Speed and Duplex Settings with Ethtool Command

Setting Speed with Ethtool Command

The speed of an Ethernet card determines how much data can be transmitted over the network. By default, most Ethernet cards use auto-negotiation to determine the appropriate speed for the connection. However, sometimes it may be necessary to manually configure the speed settings to ensure proper network performance.

Auto-negotiation vs Manual Configuration

Auto-negotiation allows devices on the same network to automatically detect and configure their respective speeds and duplex modes. This is usually sufficient for most networks as it ensures that all devices can communicate without any issues.

However, in some cases, auto-negotiation may not work properly due to various factors such as cable quality or device compatibility issues. In such situations, manual configuration of speed may be required.

With Ethtool command, you can set specific speeds such as 10/100/1000Mbps by using the following command −

$ sudo ethtool -s ethX speed Y 

Replace 'ethX' with your Ethernet adapter name and 'Y' with your desired speed.

Verifying Changes With Ethtool Command

You can verify changes made to your Ethernet card's speed settings by running the following command −

$ sudo ethtool ethX 

This will display detailed information about your Ethernet adapter including its current configured speed.

Setting Duplex with Ethtool Command

Duplex mode determines whether a connection can transmit and receive data simultaneously or only one at a time.

Half-duplex vs Full-duplex Configuration

Half-duplex allows transmission and reception of data, but not at the same time. This is due to the fact that the Ethernet card cannot send and receive data at the same time. Conversely, full-duplex allows simultaneous transmission and reception of data, thereby increasing network performance.

Configuring Specific Duplex Modes (Half/Full)

You can configure your Ethernet card's duplex mode using Ethtool command by running the following command −

$ sudo ethtool -s ethX duplex Y 

Replace 'ethX' with your Ethernet adapter name and 'Y' with either 'half' or 'full', depending on your preferred duplex mode.

Verifying Changes With Ethtool Command

To verify changes made to the duplex settings of your Ethernet card, run the following command −

$ sudo ethtool ethX 

This will display detailed information about your Ethernet adapter including its current configured speed and duplex mode.

Ethtool command is a powerful utility that can be used to configure various network settings including speed and duplex modes. Configuring these settings manually can help improve overall network performance in certain situations where auto-negotiation may not be sufficient.

However, it is important to note that improper configuration of these settings can cause issues such as connection drops or errors. Therefore, it is recommended to thoroughly test any changes made with Ethtool before implementing them in production environments.

Conclusion

In this article, we have discussed the importance of properly configuring the Ethernet card for network performance. We have explained what Ethernet cards are and why configuring speed and duplex settings is crucial.

Additionally, we introduced Ethtool, a utility that can be used to configure these settings. We have covered how to check current speed and duplex settings as well as how to change them with Ethtool command.

We learned that Ethtool supports a variety of Ethernet adapters and offers both automatic negotiation and manual configuration options for setting speed. For duplex configuration, Ethtool allows full or half-duplex modes.

Updated on: 24-Aug-2023

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements