How to use the command 'ethtool' (with examples)

How to use the command 'ethtool' (with examples)

The ’ethtool’ command is a powerful utility for displaying and modifying Network Interface Controller (NIC) parameters on a Linux system. It provides a wide range of options to retrieve information about the network interface, as well as to configure and troubleshoot it.

Use case 1: Display the current settings for an interface

Code:

ethtool eth0

Motivation: By using this command, you can quickly check the current settings of a specific network interface, such as the link speed, duplex mode, and auto-negotiation status. This information can be useful for troubleshooting network connectivity issues or for verifying the configuration.

Explanation:

  • ethtool: The base command to invoke the utility.
  • eth0: Specifies the network interface for which you want to display the settings. Replace ’eth0’ with the name of the interface you wish to examine.

Example output:

Settings for eth0:
        Speed: 1000Mb/s
        Duplex: Full
        Auto-negotiation: on
        ...

Use case 2: Display the driver information for an interface

Code:

ethtool --driver eth0

Motivation: Sometimes it can be helpful to know which driver is responsible for managing a network interface. This information is essential for troubleshooting driver-related problems or for identifying compatibility issues.

Explanation:

  • --driver: Specifies that you want to display the driver information.
  • eth0: Specifies the network interface for which you want to retrieve the driver details.

Example output:

driver: e1000e
version: 3.2.6-k
firmware-version: 0.1-4
...

Use case 3: Display all supported features for an interface

Code:

ethtool --show-features eth0

Motivation: Knowing the features that a network interface supports can help you optimize network performance or troubleshoot issues related to specific functionality. By using this command, you can get a comprehensive list of the features supported by a given interface.

Explanation:

  • --show-features: Instructs ’ethtool’ to display the supported features.
  • eth0: Specifies the network interface for which you want to see the features.

Example output:

NIC Features for eth0:
        ...
        rx-vlan-filter: off [fixed]
        tx-vlan-offload: off [fixed]
        ...

Use case 4: Display the network usage statistics for an interface

Code:

ethtool --statistics eth0

Motivation: Monitoring the network usage statistics of a specific interface can help you identify potential bottlenecks or unusual behavior. By running this command, you can retrieve detailed statistics about transmitted and received packets, errors, and other related information.

Explanation:

  • --statistics: Specifies that you want to display the network usage statistics.
  • eth0: Specifies the network interface for which you want to retrieve the statistics.

Example output:

NIC statistics for eth0:
        ...
        rx_packets: 2098751
        tx_packets: 2351893
        rx_errors: 0
        tx_errors: 0
        ...

Code:

ethtool --identify eth0 10

Motivation: Identifying the physical network interface associated with a particular NIC can be challenging in a rack-mounted server room or a network switch with several connected devices. With this command, you can make the associated LEDs blink for a specific duration, making it easier to locate the interface visually.

Explanation:

  • --identify: Instructs ’ethtool’ to blink the LEDs.
  • eth0: Specifies the network interface for which you want to blink the LEDs.
  • 10: Defines the duration in seconds for which the LEDs will blink.

Example output:

LED blink started on eth0 for 10 seconds...

Code:

ethtool -s eth0 speed 1000 duplex full autoneg off

Motivation: In some scenarios, you may need to manually configure the link speed, duplex mode, and auto-negotiation parameters of a network interface. This command allows you to specify these settings explicitly, giving you finer control over the network configuration.

Explanation:

  • -s: Specifies that you want to set the specific parameters for the interface.
  • eth0: Specifies the network interface you want to configure.
  • speed: Sets the desired link speed (in Mbps), which can be 10, 100, or 1000.
  • duplex: Sets the desired duplex mode, which can be ‘half’ or ‘full’.
  • autoneg: Sets the state of auto-negotiation, which can be ‘on’ or ‘off’.

Example output:

Setting link speed on eth0 to 1000 Mbps...
Setting duplex mode on eth0 to full...
Disabling auto-negotiation on eth0...

Conclusion:

The ’ethtool’ command is a versatile tool for managing network interface parameters in a Linux environment. It provides a straightforward way to display various settings, retrieve driver information, check supported features, monitor network usage, identify interfaces physically, and modify configuration parameters. Understanding and using the examples outlined above will enable you to effectively troubleshoot network issues, optimize performance, and customize network configurations according to your requirements.

Related Posts

How to use the command 'pip3' (with examples)

How to use the command 'pip3' (with examples)

The ‘pip3’ command is the package manager for Python. It allows users to install, upgrade, and uninstall Python packages easily.

Read More
How to use the command `zcat` (with examples)

How to use the command `zcat` (with examples)

The zcat command is used to print the contents of gzip compressed files to the standard output.

Read More
How to use the command 'jest' (with examples)

How to use the command 'jest' (with examples)

Jest is a zero-configuration JavaScript testing platform used to run tests and monitor changes in JavaScript files.

Read More