Ethtool

Linux Ethtool Command Examples

Ethtool - NIC Utility


Ethtool is a Network Interface Cards (NICs) utility/configuration tool. Ethtool allows you to query and change your NIC settings such as the Speed, Port, auto-negotiation and many other parameters. In the examples below, we will show you how to install the "Ethtool" utility and demonstrate some basic functions that the tool can be used for. In the examples below we are using CentOS 7.2, openSUSE Tumbleweed and Ubuntu.



Installing Ethtool on Ubuntu


If you need to install Ethtool, you can use the following commands:



$ sudo apt-get update
$ sudo apt-get install ethtool

Note: In Ubuntu 15.10 Ethtool came pre installed. (No need to install). If you want to check to see if "Ethtool" is installed, you may issue the command:
sudo apt-cache policy ethtool
This command will display any installed versions of "Ethtool" found.


Installing Ethtool on RHEL or CentOS


To install ethtool on a RHEL/CentOS system (64bit), simply issue the following command: yum install ethtool.x86_64 -y
On most RHEL/CentOS systems "Ethtool" will probably be already installed. If you want to check to see if "ethtool" is already installed, then you can issue the command "yum list ethtool"



[root@centos72m ~]# yum install ethtool.x86_64 -y

Installing Ethtool on openSUSE


To install ethtool on an openSUSE Linux system, simply issue the following command: zypper install ethtool
On most openSUSE systems "Ethtool" will probably be already installed. You can check this by issuing the command zypper se ethtool. If "ethtool" is installed a small "i" will be displayed in the first column of output.



linux-xcsw:~ # zypper install ethtool

Basic Command Structure for Ethtool


The basic structure of the ethtool command is as follows.



ethtool [Option...] devname

Where Option can be none or more options. devname is the name of your interface card. For example "eth0", "em1" or "enp0s3". If you are unsure of the name of the interface on your system, you may issue one of the following commands "ifconfig -a or ip a s Both of these commands will display your systems interfaces.



ifconfig -a

linux-xcsw:~ # ifconfig -a
enp0s3    Link encap:Ethernet  HWaddr 08:00:27:1D:01:7C  
          inet addr:192.168.0.34  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe1d:17c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14737 errors:0 dropped:12 overruns:0 frame:0
          TX packets:7193 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:18385937 (17.5 Mb)  TX bytes:478753 (467.5 Kb)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

ip a s

linux-xcsw:~ # ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:1d:01:7c brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.34/24 brd 192.168.0.255 scope global dynamic enp0s3
       valid_lft 85025sec preferred_lft 85025sec
    inet6 fe80::a00:27ff:fe1d:17c/64 scope link 
       valid_lft forever preferred_lft forever

Display Version of Ethtool


To display the version of Ethtool that is installed on your system, issue the command ethtool --version.



linux-xcsw:~ # ethtool --version
ethtool version 4.2

From the above we can see that version 4.2 is currently installed on this particular Linux system (openSUSE).



Display NIC settings


If you issue the ethtool command with only the device name of your interface, then a list of the current settings will be displayed to your screen. To see all available parameters/settings, it is best to issue the command as the "root" user.


ethtool device_name

[root@centos72m ~]# ethtool enp0s3
Settings for enp0s3:
	Supported ports: [ TP ]
	Supported link modes:   10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Supported pause frame use: No
	Supports auto-negotiation: Yes
	Advertised link modes:  10baseT/Half 10baseT/Full 
	                        100baseT/Half 100baseT/Full 
	                        1000baseT/Full 
	Advertised pause frame use: No
	Advertised auto-negotiation: Yes
	Speed: 1000Mb/s
	Duplex: Full
	Port: Twisted Pair
	PHYAD: 0
	Transceiver: internal
	Auto-negotiation: on
	MDI-X: off (auto)
	Supports Wake-on: umbg
	Wake-on: d
	Current message level: 0x00000007 (7)
			       drv probe link
	Link detected: yes

From the above output we are able to see quickly important settings such as Speed, Auto Negotiation, Duplex settings and link detection status.


Display Interface Device Driver


Using the "ethtool" utility you can display the name of the device driver that is in use for the specified device:


ethtool -i device_name

[root@centos72m ~]# ethtool -i enp0s3
driver: e1000
version: 7.3.21-k8-NAPI
firmware-version: 
bus-info: 0000:00:03.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: no

In the example above, the device name is "enp0s3" and the driver in use is "e1000". Additional firmware information will also be displayed.


Display Interface Statistics


Using the "ethtool" utility you can display network statistics for your specified interface by using the option "--statistics" or "-S".


ethtool --statistics device_name

[root@centos72m ~]# ethtool --statistics enp0s3
NIC statistics:
     rx_packets: 1876
     tx_packets: 411
     rx_bytes: 173016
     tx_bytes: 46476
     rx_broadcast: 1300
     tx_broadcast: 2
     rx_multicast: 0
     tx_multicast: 8
     rx_errors: 0
     tx_errors: 0
     tx_dropped: 0
     multicast: 0
     collisions: 0

The above example output has been reduced for clarity. More parameters/statistics will be displayed by default.


Changing Interface Settings


The "ethtool" utility gives you the ability to quickly change various settings on your interface. Below are some examples using the "--change option. The "-s" option may also be used as the short-form version of the command.


ethtool --change device_name parameter

[root@centos72m ~]# ethtool --change enp0s3 speed 100 duplex full autoneg off

In the above example we specified a value for "speed", "duplex" and "autoneg". For a full list of these values, it is worth consulting the man pages by issuing the commands:
"man ethtool" or "ethtool --help".


Display Autonegotiate, RX and TX settings


To display the Autonegotiate, RX and TX settings, you can issue the command.


ethtool -a device_name

[root@centos72m ~]# ethtool -a enp0s3
Pause parameters for enp0s3:
Autonegotiate:	on
RX:		on
TX:		off

Blink Network Port Light


It is possible to identify a given port on an interface by issuing the "--identify" or "-p" option. This option will typically blink the LED light of your interface.


ethtool --identify device_name integer

[root@centos72m ~]# ethtool --identify enp0s3 20

In the above example the LED light will be illuminated for a period of 20 seconds on the specified interface. (Please note, this option is dependant on the type of interface and hardware)


Persistent Changes


If you have made any change using the "Ethtool", it is important to understand that by default, these changes will be lost after a system re-boot. However, it is possible to specify a script or command that can be run by adding entries into your start up scripts. On most systems this will be "/etc/rc.local". However, on many systems it is also possible to specify options directly within the interface configuration file.