![ethtool linux](https://i-blog.csdnimg.cn/blog_migrate/ef22f4a9fc7f8ec3d72deb86e176c04f.png)
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](https://i-blog.csdnimg.cn/blog_migrate/a25180a86c63d4b6e99719b4c736cd31.png)
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 statusDuplex
显示当前设置的双工状态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](https://i-blog.csdnimg.cn/blog_migrate/194ffaf1d6ea1e7234ea61348ed8637b.png)
列出并打印网络接口驱动程序的自动协商(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](https://i-blog.csdnimg.cn/blog_migrate/f8ab687ed3e24a23a066b8b3a5d4a8fe.png)
显示网络接口的统计信息(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](https://i-blog.csdnimg.cn/blog_migrate/05aa9e3da7a4e82dca057d10d90c53a9.png)
设置网络接口的自动协商(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.
系统重启后,所有配置将被重置。 但是我们可以使这些配置永久化,以节省配置时间。 只需将以下行添加到相关的操作系统配置文件中。
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