Linux network device control using ethtool

by mn.sobieh
network device control using ethtool

In Linux systems. You can control ethernet speed using many tools. In this article, we will explain the tool ” ethtool “. This tool displays the Ethernet device settings and changes them. 

ethtool can be used to query and change ethernet hardware settings such as speed, auto-negotiation, and checksum offload on Ethernet devices.

Install ethtool package

ethtool is pre-packages by most Linux distributions. So, to install this package

Debian / Ubuntu. 

sudo apt update 

sudo apt install ethtool -y

Redhat / OEL

yum install ethtool -y

ethtool syntax

The command syntax is as following

ethtool devname [settings]

Common options

-S –statisticsQueries the specified network device for NIC- and driver-specific statistics.
-s –change

Allows changing some or all settings of the specified network device. All following options only apply if -s was specified.

-4

speed NSet speed in Mb/s.

 ethtool with just the device name as an argument will show you the supported device speeds.

duplex half|fullSets full or half duplex mode.


port tp|aui|bnc|mii Selects device port.


autoneg on|offSpecifies whether autonegotiation should be enabled. Autonegotiation is enabled by default, but some network devices may have trouble with it, so you can disable it if really necessary.


advertise NSets the speed and duplex advertised by autonegotiation. The argument is a hexadecimal value using one or a combination of the following values:

phyad PHY address.

xcvr internal|externalSelects transceiver type. Currently only internal and external can be specified, in the future further types might be added.

wol p|u|m|b|a|g|s|d…Sets Wake-on-LAN options. Not all devices support this. The argument to this option is a string of characters specifying which options to enable.

Example

# ethtool eth0 -s speed 100 duplex full autoneg off

In conclusion, The ethtool is a utility that allows you to manage network device hardware

Related Posts