Linux setting ethernet speed

HowTo: Change Speed and Duplex of Ethernet card in Linux

To change Speed and Duplex of an ethernet card, we can use ethtool – a Linux utility for Displaying or Changing ethernet card settings.

1. Install ethtool

You can install ethtool by typing one of the following commands, depending upon your Linux distribution.

Install ethtool in Fedora, CentOS, RHEL etc.:

Install ethtool in Ubuntu, Debian etc.:

# sudo apt-get install ethtool

2. Get the Speed, Duplex and other information for the interface eth0

To get speed, duplex and other information for the network interface eth0, type the following command as root.

Settings for eth0: Supported ports: [ MII ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Half 1000baseT/Full Advertised auto-negotiation: Yes Speed: 100Mb/s Duplex: Half Port: Twisted Pair PHYAD: 1 Transceiver: internal Auto-negotiation: on Supports Wake-on: g Wake-on: d Current message level: 0x000000ff (255) Link detected: yes

3. Change the Speed and Duplex settings

The following changes are temporary and they’ll stop working after reboot. Read the next section, to make settings permanent.

The next command enables Auto-Negotiate feature:

# ethtool -s eth0 autoneg on

The next command disables Auto-Negotiation, enables Half Duplex and sets up Speed to 10 Mb/s:

# ethtool -s eth0 speed 10 duplex half autoneg off

The next command disables Auto-Negotiation, enables Full Duplex and sets up Speed to 100 Mb/s:

# ethtool -s eth0 speed 100 duplex full autoneg off

4. Change the Speed and Duplex settings Permanently on CentOS/RHEL

To make settings permanent, you need to edit /etc/sysconfig/network-scripts/ifcfg-eth0 file for eth0 interface. This file is used by RHEL, CentOS, Fedora etc.

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

Append the line as follows to disable Auto-Negotiation, enable Full Duplex and set up Speed to 100 Mb/s:

ETHTOOL_OPTS="speed 100 duplex full autoneg off"

Restart the interface to apply changes:

Читайте также:  Linux папка мои документы

Источник

Изменяем скорость и дуплекс сетевой карты в Linux

Для изменения скорости и дуплекса сетевой карты, можно воспользоваться утилитой ethtool.

Установка ETHTOOL#

Для установки ethtool, выполните одну из следующих команд, в зависимости от Вашего дистрибутива Linux.

Установка ethtool в Fedora, CentOS, RHEL и т. д.:

Установка ethtool в Ubuntu, Debian и т. д.:

# sudo apt-get install ethtool 

Узнать скорость, дуплекс и прочую информации о сетевом интерфейсе eth0#

Для того, чтобы узнать текущую скорость, дуплекс и прочую информацию об интерфейсе eth0, выполните следующую команду с правами пользователя root.

Пример результата выполнения команды:

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 
Settings for eth0:  Supported ports: [ MII ]  Supported link modes: 10baseT/Half 10baseT/Full  100baseT/Half 100baseT/Full  1000baseT/Half 1000baseT/Full  Supports auto-negotiation: Yes  Advertised link modes: 10baseT/Half 10baseT/Full  100baseT/Half 100baseT/Full  1000baseT/Half 1000baseT/Full  Advertised auto-negotiation: Yes  Speed: 100Mb/s  Duplex: Half  Port: Twisted Pair  PHYAD: 1  Transceiver: internal  Auto-negotiation: on  Supports Wake-on: g  Wake-on: d  Current message level: 0x000000ff (255)  Link detected: yes 

Изменение настроек скорости и дуплекса#

Данные изменения являются временными и перестанут действовать после перезагрузки. См. п.4, если Вам необходимы изменения на постоянной основе. Примеры Активировать функцию Авто-Определения: # ethtool -s eth0 autoneg on​

Отключить функцию Авто-Определения, установить режим Полу-Дуплекса и задать Скорость 10 Mb/s: # ethtool -s eth0 speed 10 duplex half autoneg off

Отключить функцию Авто-Определения, установить режим Полного Дуплекса и задать Скорость 100 Mb/s: # ethtool -s eth0 speed 100 duplex full autoneg off

Изменение настроек скорости и дуплекса на постоянной основе#

Для Fedora/CentOS/RHEL Для того, чтобы настройки сохранились после перезагрузки, необходимо внести изменения в файл /etc/sysconfig/network-scripts/ifcfg-eth0 для интерфейса eth0. # vi /etc/sysconfig/network-scripts/ifcfg-eth0

Добавьте следующую строку для отключения функции Авто-Определения, установки Полного Дуплекса и Скорость 100 Mb/s: ETHTOOL_OPTS=»speed 100 duplex full autoneg off»

Читайте также:  Linux где лежит пакет

Перезапустите интерфейс для применения настроек: # ifdown eth0 && ifup eth0

Источник

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

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

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

Читайте также:  Convert gpt to mbr with linux

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:

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:

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

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.

Источник

Оцените статью
Adblock
detector