# ETHTOOL

* **a replacement of mii-tool. used to view setting, speed and duplex of your Network Interface Card (NIC). You can set duplex permanently in /etc/sysconfig/network-scripts/ifcfg-eth0 with ETHTOOL\_OPTS variable.**

**# ethtool eth0**

* **displays ethernet card properties such as speed, wake on, duplex and the link detection status.**&#x20;

**ethtool is a replacement of mii-tool. It is to view, setting speed and duplex of your Network Interface Card (NIC). You can set duplex permanently in /etc/sysconfig/network-scripts/ifcfg-eth0 with ETHTOOL\_OPTS variable.**<br>

**# ethtool eth0**<br>

**Settings for eth0:**

&#x20;       **Current message level: 0x00000007 (7)**

&#x20;       **Link detected: yes**<br>

**1. List Ethernet Device Properties**<br>

**When you execute ethtool command with a device name, it displays the following information about the ethernet device.**<br>

**# ethtool eth0**

**Settings for eth0:**

&#x20;       **Supported ports: \[ TP ]**

&#x20;       **Supported link modes:   10baseT/Half 10baseT/Full**

&#x20;                               **100baseT/Half 100baseT/Full**

&#x20;                               **1000baseT/Full**

&#x20;       **Supports auto-negotiation: Yes**

&#x20;       **Advertised link modes:  10baseT/Half 10baseT/Full**

&#x20;                               **100baseT/Half 100baseT/Full**

&#x20;                               **1000baseT/Full**

&#x20;       **Advertised auto-negotiation: Yes**

&#x20;       **Speed: 100Mb/s**

&#x20;       **Duplex: Full**

&#x20;       **Port: Twisted Pair**

&#x20;       **PHYAD: 1**

&#x20;       **Transceiver: internal**

&#x20;       **Auto-negotiation: on**

&#x20;       **Supports Wake-on: d**

&#x20;       **Wake-on: d**

&#x20;       **Link detected: yes**<br>

**This above ethtool output displays ethernet card properties such as speed, wake on, duplex and the link detection status. Following are the three types of duplexes available.**<br>

&#x20;   **Full duplex : Enables sending and receiving of packets at the same time. This mode is used when the ethernet device is connected to a switch.**

&#x20;   **Half duplex : Enables either sending or receiving of packets at a single point of time. This mode is used when the ethernet device is connected to a hub.**

&#x20;   **Auto-negotiation : If enabled, the ethernet device itself decides whether to use either full duplex or half duplex based on the network the ethernet device attached to.**<br>

**2. Change NIC Parameter Using ethtool Option -s autoneg**<br>

**The above ethtool eth0 output displays that the “Auto-negotiation” parameter is in enabled state. You can disable this using autoneg option in the ethtool as shown below.**<br>

**# ifdown eth0**

&#x20;   **eth0      device: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)**

&#x20;   **eth0      configuration: eth-bus-pci-0000:0b:00.0**<br>

**# ethtool  -s eth0 autoneg off**<br>

**# ethtool eth0**

**Settings for eth0:**

&#x20;       **Supported ports: \[ TP ]**

&#x20;       **Supported link modes:   10baseT/Half 10baseT/Full**

&#x20;                               **100baseT/Half 100baseT/Full**

&#x20;                               **1000baseT/Full**

&#x20;       **Supports auto-negotiation: Yes**

&#x20;       **Advertised link modes:  Not reported**

&#x20;       **Advertised auto-negotiation: No**

&#x20;       **Speed: Unknown! (65535)**

&#x20;       **Duplex: Unknown! (255)**

&#x20;       **Port: Twisted Pair**

&#x20;       **PHYAD: 1**

&#x20;       **Transceiver: internal**

&#x20;       **Auto-negotiation: off**

&#x20;       **Supports Wake-on: g**

&#x20;       **Wake-on: g**

&#x20;       **Link detected: no**

**# ifup eth0**<br>

**After the above change, you could see that the “link detection” value changed to down and auto-negotiation is in off state.**

**3. Change the Speed of Ethernet Device**<br>

**Using ethtool you can change the speed of the ethernet device to work with the certain network devices, and the newly assign speed value should be within the limited capacity.**<br>

**# ethtool -s eth0 speed 100 autoneg off**<br>

**# ethtool eth0**

**Settings for eth0:**

&#x20;       **Supported ports: \[ TP ]**

&#x20;       **Supported link modes:   10baseT/Half 10baseT/Full**

&#x20;                               **100baseT/Half 100baseT/Full**

&#x20;                               **1000baseT/Full**

&#x20;       **Supports auto-negotiation: Yes**

&#x20;       **Advertised link modes:  Not reported**

&#x20;       **Advertised auto-negotiation: No**

&#x20;       **Speed: Unknown! (65535)**

&#x20;       **Duplex: Unknown! (255)**

&#x20;       **Port: Twisted Pair**

&#x20;       **PHYAD: 1**

&#x20;       **Transceiver: internal**

&#x20;       **Auto-negotiation: off**

&#x20;       **Supports Wake-on: g**

&#x20;       **Wake-on: g**

&#x20;       **Link detected: no**<br>

**Once you change the speed when the adapter is online, it automatically goes offline, and you need to bring it back online using ifup command.**<br>

**# ifup eth0**

&#x20;   **eth0      device: Broadcom Corporation NetXtreme II BCM5709 Gigabit Ethernet (rev 20)**

&#x20;   **eth0      configuration: eth-bus-pci-0000:0b:00.0**

**Checking for network time protocol daemon (NTPD):                     running**<br>

**# ethtool eth0**

**Settings for eth0:**

&#x20;       **Supported ports: \[ TP ]**

&#x20;       **Supported link modes:   10baseT/Half 10baseT/Full**

&#x20;                               **100baseT/Half 100baseT/Full**

&#x20;                               **1000baseT/Full**

&#x20;       **Supports auto-negotiation: Yes**

&#x20;       **Advertised link modes:  Not reported**

&#x20;       **Advertised auto-negotiation: No**

&#x20;       **Speed: 100Mb/s**

&#x20;       **Duplex: Full**

&#x20;       **Port: Twisted Pair**

&#x20;       **PHYAD: 1**

&#x20;       **Transceiver: internal**

&#x20;       **Auto-negotiation: off**

&#x20;       **Supports Wake-on: g**

&#x20;       **Wake-on: g**

&#x20;       **Link detected: yes**<br>

**As shown in the above output, the speed changed from 1000Mb/s to 100Mb/s and auto-negotiation parameter is unset.**<br>

**To change the Maximum Transmission Unit (MTU), refer to our ifconfig examples article.**

**4. Display Ethernet Driver Settings**<br>

**ethtool -i option displays driver version, firmware version and bus details as shown below.**<br>

**# ethtool -i eth0**

**driver: bnx2**

**version: 2.0.1-suse**

**firmware-version: 1.9.3**

**bus-info: 0000:04:00.0**<br>

**5. Display Auto-negotiation, RX and TX of eth0**<br>

**View the autonegotiation details about the specific ethernet device as shown below.**<br>

**# ethtool -a eth0**

**Pause parameters for eth0:**

**Autonegotiate:  on**

**RX:             on**

**TX:             on**<br>

**6. Display Network Statistics of Specific Ethernet Device**<br>

**Use ethtool -S option to display the bytes transfered, received, errors, etc, as shown below.**<br>

**# ethtool -S eth0**

**NIC statistics:**

&#x20;    **rx\_bytes: 74356477841**

&#x20;    **rx\_error\_bytes: 0**

&#x20;    **tx\_bytes: 110725861146**

&#x20;    **tx\_error\_bytes: 0**

&#x20;    **rx\_ucast\_packets: 104169941**

&#x20;    **rx\_mcast\_packets: 138831**

&#x20;    **rx\_bcast\_packets: 59543904**

&#x20;    **tx\_ucast\_packets: 118118510**

&#x20;    **tx\_mcast\_packets: 10137453**

&#x20;    **tx\_bcast\_packets: 2221841**

&#x20;    **tx\_mac\_errors: 0**

&#x20;    **tx\_carrier\_errors: 0**

&#x20;    **rx\_crc\_errors: 0**

&#x20;    **rx\_align\_errors: 0**

&#x20;    **tx\_single\_collisions: 0**

&#x20;    **tx\_multi\_collisions: 0**

&#x20;    **tx\_deferred: 0**

&#x20;    **tx\_excess\_collisions: 0**

&#x20;    **tx\_late\_collisions: 0**

&#x20;    **tx\_total\_collisions: 0**

&#x20;    **rx\_fragments: 0**

&#x20;    **rx\_jabbers: 0**

&#x20;    **rx\_undersize\_packets: 0**

&#x20;    **rx\_oversize\_packets: 0**

&#x20;    **rx\_64\_byte\_packets: 61154057**

&#x20;    **rx\_65\_to\_127\_byte\_packets: 55038726**

&#x20;    **rx\_128\_to\_255\_byte\_packets: 426962**

&#x20;    **rx\_256\_to\_511\_byte\_packets: 3573763**

&#x20;    **rx\_512\_to\_1023\_byte\_packets: 893173**

&#x20;    **rx\_1024\_to\_1522\_byte\_packets: 42765995**

&#x20;    **rx\_1523\_to\_9022\_byte\_packets: 0**

&#x20;    **tx\_64\_byte\_packets: 3633165**

&#x20;    **tx\_65\_to\_127\_byte\_packets: 51169838**

&#x20;    **tx\_128\_to\_255\_byte\_packets: 3812067**

&#x20;    **tx\_256\_to\_511\_byte\_packets: 113766**

&#x20;    **tx\_512\_to\_1023\_byte\_packets: 104081**

&#x20;    **tx\_1024\_to\_1522\_byte\_packets: 71644887**

&#x20;    **tx\_1523\_to\_9022\_byte\_packets: 0**

&#x20;    **rx\_xon\_frames: 0**

&#x20;    **rx\_xoff\_frames: 0**

&#x20;    **tx\_xon\_frames: 0**

&#x20;    **tx\_xoff\_frames: 0**

&#x20;    **rx\_mac\_ctrl\_frames: 0**

&#x20;    **rx\_filtered\_packets: 14596600**

&#x20;    **rx\_discards: 0**

&#x20;    **rx\_fw\_discards: 0**<br>

**7. Troubleshoot the Ethernet Connection Issues**<br>

**When there is a problem with the network connection, you might want to check (or change) the ethernet device parameters explained in the above examples, when you see following issues in the output of ethtool command.**<br>

&#x20;   **Speed and Duplex value is shown as Unknown**

&#x20;   **Link detection value is shown as No**<br>

**Upon successful connection, the three parameters mentioned above gets appropriate values. i.e Speed is assigned with known value, Duplex become either Full/Half, and the Link detection becomes Yes.**<br>

**After the above changes, if the Link Detection still says “No”, check whether there are any issues in the cables that runs from the switch and the system, you might want to dig into that aspect further.**<br>

**To capture and analyze packets from a specific network interface, use tcpdump utility.**

**8. Identify Specific Device From Multiple Devices (Blink LED Port of NIC Card)**<br>

**Let us assume that you have a machine with four ethernet adapters, and you want to identify the physical port of a particular ethernet card. (For example, eth0).**<br>

**Use ethtool option -p, which will make the corresponding LED of physical port to blink.**<br>

**# ethtool -p eth0**<br>

**9. Make Changes Permanent After Reboot**<br>

**If you’ve changed any ethernet device parameters using the ethtool, it will all disappear after the next reboot, unless you do the following.**<br>

**On ubuntu, you have to modify /etc/network/interfaces file and add all your changes as shown below.**<br>

**# vim /etc/network/interfaces**

**post-up ethtool -s eth2 speed 1000 duplex full autoneg off**<br>

**The above line should be the last line of the file. This will change speed, duplex and autoneg of eth2 device permanently.**<br>

**On SUSE, modify the /etc/sysconfig/network/ifcfg-eth-id file and include a new script using POST\_UP\_SCRIPT variable as shown below. Include the below line as the last line in the corresponding eth1 adpater config file.**<br>

**# vim /etc/sysconfig/network/ifcfg-eth-id**

**POST\_UP\_SCRIPT='eth1'**<br>

**Then, create a new file scripts/eth1 as shown below under /etc/sysconfig/network directory. Make sure that the script has execute permission and ensure that the ethtool utility is present under /sbin directory.**<br>

**# cd /etc/sysconfig/network/**<br>

**# vim scripts/eth1**

**#!/bin/bash**

**/sbin/ethtool -s duplex full speed 100 autoneg off**<br>
