Linux ethtool Command with Practical Examples

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, we will explore the Linux ethtool command and its practical applications. The ethtool command is a powerful tool for retrieving and modifying network interface settings, allowing users to diagnose and troubleshoot network issues. We will start by understanding the various options provided by the ethtool command, then proceed to retrieve detailed information about the network interfaces on our system. Finally, we will demonstrate how to modify the settings of a network interface using the ethtool command.

The lab covers the following steps:

  1. Understand the ethtool Command
  2. Retrieve Network Interface Information
  3. Modify Network Interface Settings

The ethtool command is a widely used tool in the Linux ecosystem, and it is typically pre-installed on most Linux distributions. However, if it is not available on your system, you may need to install the necessary package using your distribution's package manager.

Linux Commands Cheat Sheet


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/RemoteAccessandNetworkingGroup(["`Remote Access and Networking`"]) linux/RemoteAccessandNetworkingGroup -.-> linux/ifconfig("`Network Configuring`") linux/RemoteAccessandNetworkingGroup -.-> linux/netstat("`Network Monitoring`") linux/RemoteAccessandNetworkingGroup -.-> linux/ip("`IP Managing`") subgraph Lab Skills linux/ifconfig -.-> lab-422664{{"`Linux ethtool Command with Practical Examples`"}} linux/netstat -.-> lab-422664{{"`Linux ethtool Command with Practical Examples`"}} linux/ip -.-> lab-422664{{"`Linux ethtool Command with Practical Examples`"}} end

Understand the ethtool Command

In this step, we will explore the ethtool command, a powerful tool in Linux for retrieving and modifying network interface settings. The ethtool command provides a wide range of options to diagnose and troubleshoot network issues.

First, let's check the version of ethtool installed on our system:

ethtool --version

Example output:

ethtool version 5.15

The ethtool command offers a variety of options to interact with network interfaces. Some of the commonly used options include:

  • --show-features: Display the supported features of the network interface.
  • --show-link: Display the current link state of the network interface.
  • --show-eee: Display the Energy-Efficient Ethernet (EEE) status.
  • --show-pause: Display the pause parameters of the network interface.
  • --show-ringparam: Display the ring buffer parameters of the network interface.
  • --show-priv-flags: Display the private flags of the network interface.
  • --show-offload: Display the offload parameters of the network interface.

To get a complete list of available options, you can use the --help flag:

ethtool --help

In the next steps, we will explore some practical examples of using the ethtool command to retrieve and modify network interface settings.

Retrieve Network Interface Information

In this step, we will use the ethtool command to retrieve information about the network interfaces on our system.

First, let's list all the available network interfaces:

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

Now, let's use the ethtool command to retrieve detailed information about 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

This output provides detailed information about the eth0 interface, including the supported link modes, speed, duplex, and other parameters.

You can also use the ethtool command to retrieve specific information about the interface, such as the link state, driver information, and more. For example:

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

In the next step, we will learn how to modify the network interface settings using the ethtool command.

Modify Network Interface Settings

In this step, we will learn how to use the ethtool command to modify the settings of a network interface.

First, let's check 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, let's try to change the speed and duplex settings of the eth0 interface:

sudo ethtool -s eth0 speed 100 duplex full

Example output:

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

You can see that the speed has been changed to 100Mb/s and the duplex mode has been set to Full.

Additionally, you can use the ethtool command to enable or disable features of the network interface, such as:

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

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

Remember that modifying network interface settings can impact the connectivity of your system, so it's important to understand the implications of the changes you make.

Summary

In this lab, we first explored the ethtool command, a powerful tool in Linux for retrieving and modifying network interface settings. We learned about the various options available in ethtool, such as displaying the supported features, link state, Energy-Efficient Ethernet status, pause parameters, ring buffer parameters, private flags, and offload parameters. We also discovered how to get a complete list of available options using the --help flag.

Next, we used the ethtool command to retrieve detailed information about the network interfaces on our system. We started by listing all the available network interfaces using the ip link show command, and then used ethtool to gather more specific details about the eth0 interface.

Linux Commands Cheat Sheet

Other Linux Tutorials you may like