Americas

  • United States
sandra_henrystocker
Unix Dweeb

Looking at your Linux system’s network interface with ethtool

How-To
Sep 20, 20215 mins
Linux

businessman holding virtual interface iot internet of things icon network connection abstract globe
Credit: ipopba / Getty Images

The ethtool utility on Linux allows you to view and change some of your network-driver and interface-card settings, especially for wired devices. These include their speed, whether the interface uses auto-negotiation, and whether it runs in half- or full-duplex mode. Ethtool also provides an easy way to view or troubleshoot your network interface.

More than likely, ethtool is already available on your Linux system. However, to check, you can use one or both of these commands:

$ which ethtool
/usr/sbin/ethtool
$ sudo ethtool —version
ethtool version 5.13

To get a sense of how this utility can control settings, run a command like the one below. The -h means “help”. You’ll likely find yourself looking at 10 pages or so of syntax like what is shown here.

$ ethtool -h | more
ethtool version 5.13
Usage:
        ethtool [ FLAGS ] DEVNAME       Display standard information about device
        ethtool [ FLAGS ] -s|—change DEVNAME   Change generic options
                [ speed %d ]
                [ lanes %d ]
                [ duplex half|full ]
                [ port tp|aui|bnc|mii|fibre|da ]
                [ mdix auto|on|off ]
                [ autoneg on|off ]
                [ advertise %x[/%x] | mode on|off ... [—] ]
                [ phyad %d ]
                [ xcvr internal|external ]
                [ wol %d[/%d] | p|u|m|b|a|g|s|f|d... ]
                  [ sopass %x:%x:%x:%x:%x:%x ]
                [ msglvl %d[/%d] | type on|off ... [—] ]
                [ master-slave preferred-master|preferred-slave|forced-master|forced-slave ]
        ethtool [ FLAGS ] -a|—show-pause DEVNAME       Show pause options
        ethtool [ FLAGS ] -A|—pause DEVNAME    Set pause options
                [ autoneg on|off ]
                [ rx on|off ]
—More—

View settings

There are clearly many things that the ethtool utility can do for you. However, to simply view the settings on your network interface, type “ethtool” followed by the name of your network interface (e.g. eth0). In the examples below, we’re looking at a network interface named enp0s25.

$ ethtool enp0s25:
Settings for enp0s25:
	Supported ports: [ TP ]
	Supported link modes:   10baseT/Half 10baseT/Full
	                        100baseT/Half 100baseT/Full
	Supported pause frame use: No
	Supports auto-negotiation: Yes
	Supported FEC modes: Not reported
	Advertised link modes:  10baseT/Half 10baseT/Full
	                        100baseT/Half 100baseT/Full
	Advertised pause frame use: No
	Advertised auto-negotiation: Yes
	Advertised FEC modes: Not reported
	Speed: 100Mb/s
	Duplex: Full
	Auto-negotiation: on
	Port: Twisted Pair
	PHYAD: 1
	Transceiver: internal
	MDI-X: on (auto)
        Current message level: 0x00000007 (7)
                               drv probe link
	Link detected: yes

Notice the “yes” in the last line telling you that this interface is working. The output also displays the supported link modes and that auto-negotiation is turned on. Notice the speed (100Mbps) and that the interface is running in full duplex.

You can check Ethernet driver settings with a command like this one:

$ ethtool -i enp0s25
driver: e1000e
version: 5.13.9-200.fc34.x86_64
firmware-version: 1.1-2
expansion-rom-version:
bus-info: 0000:00:19.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: yes

Network-interface stats

To view your network-interface stats, you can use a command like the one below. I put the output into two columns to make it a little easier to review the settings.

$ ethtool -S enp0s25 | column
NIC statistics:				     tx_single_coll_ok: 0
     rx_packets: 455502			     tx_multi_coll_ok: 0
     tx_packets: 44344			     tx_timeout_count: 0
     rx_bytes: 79840149			     tx_restart_queue: 0
     tx_bytes: 4734660			     rx_long_length_errors: 0
     rx_broadcast: 261026		     rx_short_length_errors: 0
     tx_broadcast: 35			     rx_align_errors: 0
     rx_multicast: 154850		     tx_tcp_seg_good: 165
     tx_multicast: 3561			     tx_tcp_seg_failed: 0
     rx_errors: 0			     rx_flow_control_xon: 0
     tx_errors: 0			     rx_flow_control_xoff: 0
     tx_dropped: 0			     tx_flow_control_xon: 0
     multicast: 154850			     tx_flow_control_xoff: 0
     collisions: 0			     rx_csum_offload_good: 289057
     rx_length_errors: 0		     rx_csum_offload_errors: 0
     rx_over_errors: 0			     rx_header_split: 0
     rx_crc_errors: 0			     alloc_rx_buff_failed: 0
     rx_frame_errors: 0			     tx_smbus: 0
     rx_no_buffer_count: 0		     rx_smbus: 0
     rx_missed_errors: 0		     dropped_smbus: 0
     tx_aborted_errors: 0		     rx_dma_failed: 0
     tx_carrier_errors: 0		     tx_dma_failed: 0
     tx_fifo_errors: 0			     rx_hwtstamp_cleared: 0
     tx_heartbeat_errors: 0		     uncorr_ecc_errors: 0
     tx_window_errors: 0		     corr_ecc_errors: 0
     tx_abort_late_coll: 0		     tx_hwtstamp_timeouts: 0
     tx_deferred_ok: 0			     tx_hwtstamp_skipped: 0

No collisions and no errors. That’s a good sign.

To test a network interface, you need to use sudo and a command like the one below with the -t (test) option. Notice that the interface has passed the test.

$ sudo ethtool -t enp0s25
The test result is PASS          
The test extra info:
Register test  (offline)         0
Eeprom test    (offline)         0
Interrupt test (offline)         0
Loopback test  (offline)         0
Link test   (on/offline)         0

Notice that these tests were all run in offline mode. There are two modes, online and offline, and offline is the default. It runs the full set of tests, but can interrupt normal operations. Online tests are limited and will not cause any interruptions. Keep this in mind if you are working on a production system.

Changing settings

Network interface changes will require that you use sudo or run as root. In addition, changes don’t persist through a reboot unless you also modify settings in the configuration file on your particular Linux distribution. For some changes, you also need to bring the interface down with ifdown and back up with ifup so you should be working on the system console.

sandra_henrystocker
Unix Dweeb

Sandra Henry-Stocker has been administering Unix systems for more than 30 years. She describes herself as "USL" (Unix as a second language) but remembers enough English to write books and buy groceries. She lives in the mountains in Virginia where, when not working with or writing about Unix, she's chasing the bears away from her bird feeders.

The opinions expressed in this blog are those of Sandra Henry-Stocker and do not necessarily represent those of IDG Communications, Inc., its parent, subsidiary or affiliated companies.

More from this author