ethtool Command in Linux

Introduction to Linux ethtool

This lab explores the power of the Linux `ethtool` command for system administration. We'll dive into how `ethtool` can be used to inspect and modify network interface settings, essential for network diagnosis and troubleshooting. You'll learn to use `ethtool` options, retrieve detailed network interface information, and modify interface settings.

This lab will guide you through the following:

  1. Understanding the `ethtool` Command
  2. Retrieving Network Interface Details
  3. Modifying Network Interface Configurations

As a standard tool within the Linux ecosystem, `ethtool` typically comes pre-installed on many Linux distributions. If `ethtool` isn't available, you'll need to install the appropriate package via your distribution's package manager for systemadmin tasks.

Understanding the ethtool Command

This section focuses on the `ethtool` command, a vital Linux tool for managing network interfaces. We'll explore how to use `ethtool` to both retrieve information and modify network interface settings. `ethtool` is especially useful when needing to diagnose and resolve complex networking issues.

Let's begin by checking the version of `ethtool` on your system:

ethtool --version

Example output:

ethtool version 5.15

The `ethtool` command offers a rich set of options for interacting with network interfaces. Some commonly used options include:

  • --show-features: Displays supported features of the network interface, useful for understanding capabilities.
  • --show-link: Displays the current link state, helping to identify connectivity issues.
  • --show-eee: Displays Energy-Efficient Ethernet (EEE) status, relevant for power management.
  • --show-pause: Displays pause parameters of the network interface, impacting flow control.
  • --show-ringparam: Displays ring buffer parameters, affecting packet handling efficiency.
  • --show-priv-flags: Displays private flags specific to the interface or driver.
  • --show-offload: Displays offload parameters, indicating hardware acceleration capabilities.

For a complete listing of available options, utilize the --help flag:

ethtool --help

The following sections present practical examples of how to retrieve and modify network interface settings using `ethtool`.

Retrieve Network Interface Information

This part demonstrates using `ethtool` to obtain details about network interfaces on your Linux system.

First, list all available network interfaces. This is essential for any systemadmin trying to get their bearings:

ip link show

Example output:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff

Next, use `ethtool` to get comprehensive information about the `eth0` interface. This is a fundamental `ethtool` command:

ethtool eth0

Example output:

Settings for eth0:
        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: pumbg
        Wake-on: d
        Current message level: 0x00000007 (7)
        Link detected: yes

The output displays various details about the `eth0` interface, including supported link modes, speed, duplex settings, and other relevant parameters. This information is crucial for systemadmin work.

`ethtool` also enables retrieval of specific information, such as the link state or driver information. For instance:

ethtool --show-link eth0
ethtool --driver eth0

The following section explains how to modify network interface settings using the `ethtool` command as a root user.

Modify Network Interface Settings

This section demonstrates modifying network interface settings using the `ethtool` command. It's critical for a systemadmin to understand the implications of these changes.

Start by reviewing the current settings of the `eth0` interface:

ethtool eth0

Example output:

Settings for eth0:
        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: pumbg
        Wake-on: d
        Current message level: 0x00000007 (7)
        Link detected: yes

Now, attempt to modify the speed and duplex settings of the `eth0` interface. Root privileges are required for this operation.

sudo ethtool -s eth0 speed 100 duplex full

Example output:

Settings for eth0:
        Speed: 100Mb/s
        Duplex: Full

As seen in the output, the speed has been adjusted to 100Mb/s and the duplex mode set to Full.

Additionally, `ethtool` can enable or disable features of the network interface:

## Enable wake-on-lan
sudo ethtool -s eth0 wol g

## Disable auto-negotiation
sudo ethtool -s eth0 autoneg off

Remember that changing network interface parameters can impact your system's connectivity. Always be aware of the effects of any modifications you implement as a systemadmin. Also, some settings might not persist after a reboot and might require configuration through network configuration files.

Summary

This lab provided an overview of the `ethtool` command, a critical tool for Linux systemadmin tasks, enabling the retrieval and modification of network interface settings. You learned about the various options available in `ethtool`, like displaying supported features, link state, Energy-Efficient Ethernet status, pause parameters, ring buffer parameters, private flags, and offload parameters. Furthermore, we showed you how to obtain a complete list of all available options using the --help flag.

We then moved on to show how to use `ethtool` to gather detailed information about network interfaces. We first listed the available interfaces using the `ip link show` command, then used `ethtool` to get more granular information about the `eth0` interface.

400+ Linux Commands