2 May 2011
2 mins read

How to Use ethtool Command with Examples

The ethtool command is used to display/change Ethernet adapter settings. You can change network card speed, auto-negotiation, wake on LAN setting, duplex mode using this tool in Linux. In this article, I will show you some ethtool command examples that help you to troubleshoot ethernet card issues.

1) Display Ethernet Interface Details

The ethtool command retrieves the status of the Ethernet interface. The output displays properties like speed, duplex, status and wake on of the etho interface.

Given below is an example:

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

There are three types of duplexes:

Full Duplex: Used when the Ethernet is connected to the switch. Allows two- way transfers, that is, sending and receiving of packets simultaneously.

Half Duplex: Used when the Ethernet is in connection with the hub. Allows only one- way transfers, that is, either sending or receiving of packets.

Auto negotiation: On the basis of the network connection, the Ethernet interface decides whether to use full or half duplex.

2) ETHTOOL_OPTS Variable

The Ethtool command settings can be set permanently with the Ethtool_opt variable. Let us have a look at the example given below:

# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 BOOTPROTO=static ONBOOT=yes ETHTOOL_OPTS="speed 50 duplex full autoneg off"

You can test the above setting with ifup and ifdown commands.

3) Display Statistics

The Ethernet driver settings and auto-negotiation can be checked with the following commands:

# ethtool -i eth0 driver: bnx2 version: 2.0.1-suse firmware-version: 1.9.3 bus-info: 0000:04:00.0
[root@localhost ~]# ethtool –a eth0 Pause parameters for eth0: Autonegotiate: on RX: on TX: on

The ‘–p option’ of Ethtool command helps to identify the specific device from multiple devices.

# ethtool –p eth0

Having the statistics of network card is very useful in troubleshooting of network issues.

# ethtool –S eth0 NIC statistics: tx_packets: 148683 rx_packets: 179489 tx_errors: 0 rx_errors: 0 rx_missed: 0 align_errors: 0 tx_single_collisions: 0 tx_multi_collisions: 0 unicast: 116884 broadcast: 25361 multicast: 61674 tx_aborted: 0 tx_underrun: 0

The output above shows the details about the transferred and received packets.

4) Enable flow control

Flow control in full duplex can be enabled by ‘PAUSE’ parameter in the latest MAC and GMAC embedded devices.

Here is the solution:

# ethtool -A eth0 [autoneg on|off] [rx on|off] [tx on|off]

Offload parameters details can be obtained as follows:

# ethtool –k eth0

However, any changes made in the Ethernet parameter settings will disappear at the time of the next boot. In order to have them intact in the next boot, you have to make these changes permanent by adding the command to /etc/rc.local

# cat /etc/rc.local ethtool -s eth0 speed 100 duplex full autoneg on 1>/dev/null 2>/dev/null ethtool -s eth1 speed 100 duplex full autoneg on 1>/dev/null 2>/dev/null

5) Set Duplex Mode

Below example shows how to set speed or duplex mode using ethtool command is as follows:

# ethtool -s eth0 speed 100 duplex full # ethtool -s eth0 speed 10 duplex half
Bobbin Zachariah

Bobbin Zachariah

Bobbin Zachariah is the editor-in-chief of Linoxide and has an experienced team of Linux enthusiastic authors who makes this blog awesome. Linoxide is one of the top 20 Linux Blog by whizlabs.

Leave a Reply

Your email address will not be published.

Previous Story

How to Use ldapsearch Command Query with Examples

Next Story

How to Check Apache Status and Uptime on CentOS/Ubuntu

Latest from Blog

Top 8 Reasons to Use Garuda Linux

Have you been going back and forth between multiple Linux flavors in search of an exciting experience? Or perhaps you are coming from a Windows or MAC environment and want to try

How to Rename Multiple Files in Linux

In a Linux system, you can easily rename a file using mv command. But, if you have multiple files which you want to rename, in this situation you need some extra tools

How to Install TensorFlow on Ubuntu 20.04

Tensorflow is an open-source platform for machine learning and artificial intelligence. It is developed by the Google Brain team. It contains tools, libraries, and community resources for developers to build ML powered
Go toTop