ethtool linux_Linux ethtool教程及其用法示例

ethtool linux

ethtool linux

ethtool  is useful utility used for Network Interface Card configuration. It provides simple and fast way to get and set configuration about IP address, interface speed, interface duplex or half duplex etc.

ethtool是用于网络接口卡配置的有用实用程序。 它提供了简单快速的方法来获取和设置有关IP地址,接口速度,接口双工或半双工等的配置。

列表和打印机界面属性 (List and Printer Interface Properties)

We will start with simply listing given network interface properties. We will see that there is a lot of network interface properties which is outputted by ethtool . For this operation we do not need to provide any option. We will just provide the interface name which is ens33 in this case.

我们将从简单列出给定的网络接口属性开始。 我们将看到ethtool输出的网络接口属性很多。 对于此操作,我们不需要提供任何选项。 在这种情况下,我们只提供接口名称ens33

$ ethtool ens33
List and Printer Interface Properties
List and Printer Interface Properties
列表和打印机界面属性

We listed following properties of network interface

我们列出了网络接口的以下属性

  • Supported link modes shows supported network speed and duplex modes.

    Supported link modes显示支持的网络速度和双工模式。

  • Supports auto-negotition shows whether interface supports auto set link mode.

    Supports auto-negotition显示接口是否支持自动设置链接模式。

  • Speed shows currently set network interface speed.

    Speed显示当前设置的网络接口速度。

  • Duplex shows currently set duplex status

    Duplex显示当前设置的双工状态

  • Auto-negotiation shows current auto-negotiate mode.

    Auto-negotiation显示当前的自动协商模式。

列出并打印网络接口驱动程序设置 (List and Print Network Interface Driver Settings)

Network Interfaces are managed and used with drivers. Drivers are operating system level modules which is the same for network interface cards with same chipset. We can list currently used driver of  given network interface card with the -i option and the interface name.

网络接口由驱动程序管理和使用。 驱动程序是操作系统级别的模块,与具有相同芯片组的网络接口卡相同。 我们可以使用-i选项和接口名称列出给定网络接口卡当前使用的驱动程序。

$ ethtool -i ens33
List and Print Network Interface Driver Settings
List and Print Network Interface Driver Settings
列出并打印网络接口驱动程序设置

列出并打印网络接口驱动程序的自动协商(List and Print Auto-negotiation of Network Interface Driver)

As stated previously auto-negotiation is used to determine link speed of the network interface transmitter. The other end of the link is another factor for link speed. We can enable auto-negotiation for talk the link speed with the remote host and set the best speed for the link. We can print current auto-negotiation setting with the -a and network interface name.

如前所述,自动协商用于确定网络接口发送器的链路速度。 链接的另一端是链接速度的另一个因素。 我们可以启用自动协商功能以与远程主机进行链接速度协商,并为链接设置最佳速度。 我们可以使用-a和网络接口名称打印当前的自动协商设置。

$ ethtool -a ens33
List and Print Auto-negotiation of Network Interface Driver
List and Print Auto-negotiation of Network Interface Driver
列出并打印网络接口驱动程序的自动协商

显示网络接口的统计信息(Display Statistics of The Network Interface)

Network statistics provides useful information about network utilization of the system. Statistics provides information like rx_packets, tx_packets,rx_bytes,tx_bytes etc. We can list network interfaces statistics with -S option and the interface name.

网络统计信息提供有关系统网络利用率的有用信息。 统计信息提供rx_packets,tx_packets,rx_bytes,tx_bytes等信息。我们可以使用-S选项和接口名称列出网络接口统计信息。

$ ethtool -S ens33
Display Statistics of The Network Interface
Display Statistics of The Network Interface
显示网络接口的统计信息

设置网络接口的自动协商(Set Auto-Negotiation of Network Interface)

We can change auto-negotiation of the given network interface card. We will use -s option with autoneg off parameter to disable or autoneg on to enable. We need root privileges becauase of system level chages.

我们可以更改给定网络接口卡的自动协商。 我们将使用-s选项和autoneg off参数禁用或启用autoneg on启用。 由于系统级变更,我们需要root特权。

$ sudo ethtool -s ens33 autoneg on

OR

要么

$ sudo ethtool -s ens33 autoneg off

设置网络接口速度 (Set Speed of Network Interface)

We can change the speed of the network interface card. This can be useful if remote interface do not supports auto-negotiation or there are link speed related problems. We will use -s option with speed 100 to set speed to 100Mbps. Also disabling auto-negotiation is good practice.

我们可以更改网络接口卡的速度。 如果远程接口不支持自动协商或存在与链接速度有关的问题,则此功能很有用。 我们将使用-s选项( speed 100将速度设置为100Mbps。 禁用自动协商也是一种好习惯。

$ sudo ethtool -s ens33 speed 100 autoneg off

闪烁指定的网络接口指示灯 (Blink Specified Network Interface Led)

As we know network interface cards have some leds to give information about traffic and link. We can blink these leds by using ethtool. This may be useful if we need to blink leds to specify network interface card. We will use -p for this operation.

众所周知,网络接口卡具有一些指示灯,可以提供有关流量和链接的信息。 我们可以使用ethtool闪烁这些ethtool 。 如果需要闪烁指示灯以指定网络接口卡,这可能会很有用。 我们将使用-p进行此操作。

$ sudo ethtool -p ens33

永久进行更改和配置 (Make Changes and Configurations Permanent)

After a system reboot all configurations will be reset. But we can make these configuration permanent in order to save configuration time. Just add following lines to the related operation system configuration file.

系统重启后,所有配置将被重置。 但是我们可以使这些配置永久化,以节省配置时间。 只需将以下行添加到相关的操作系统配置文件中。

LEARN MORE  What Is NAT (Network Address Translation) and How It Works?
了解更多NAT(网络地址转换)是什么以及它如何工作?

Ubuntu,Debian,Mint,Kali (Ubuntu, Debian, Mint, Kali)

#File /etc/network/interfaces
post-up /sbin/ethtool -s duplex full speed 100

Fedora,CentOS,RHEL (Fedora, CentOS, RHEL)

# File /etc/sysconfig/network/scripts/ens33
/sbin/ethtool -s duplex full speed 100
 

翻译自: https://www.poftut.com/linux-ethtool-tutorial-usage-examples/

ethtool linux

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值