更改接口设置

[root@centos72m ~]# ethtool --change enp0s3 speed 100 duplex full autoneg off

显示系统上安装的Ethtool的版本

linux-xcsw:~ # ethtool --version
ethtool version 4.2

Ethtool-NIC实用程序

Ethtool是网络接口卡(NIC)实用程序/配置工具。Ethtool允许您查询和更改NIC设置,例如Speed,Port,自动协商和许多其他参数。在下面的示例中,我们将向您展示如何安装Ethtool实用程序,并演示该工具可用于的一些基本功能。在下面的示例中,我们使用的是CentOS 7.2,openSUSE Tumbleweed和Ubuntu。

显示网卡设置

[root@centos72m ~]# ethtool enp0s3
Settings for enp0s3:
	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: umbg
	Wake-on: d
	Current message level: 0x00000007 (7)
			       drv probe link
	Link detected: yes

在RHEL或CentOS上安装Ethtool

[root@centos72m ~]# yum list ethtool 
[root@centos72m ~]# yum install ethtool.x86_64 -y

永久更改

使用Ethtool进行了任何更改,在系统重启后会丢失。

可以通过在启动脚本中添加条目来指定可以运行的脚本或命令。在大多数系统上,启动脚本是/etc/rc.local
但是,在许多系统中,也可以直接在接口配置文件中指定选项。

点亮网卡指示灯

[root@centos72m ~]# ethtool --identify enp0s3 20

LED灯将在指定的接口上点亮20秒。(请注意,此选项取决于接口和硬件的类型)

ethtool命令语法

ethtool [Option...] devname

devname是网口的设备名称。如果不知道设备名,可以使用 ifconfig -aip a s查看

显示接口统计

Linux如何查看网口的流量

[root@centos72m ~]# ethtool --statistics enp0s3
NIC statistics:
     rx_packets: 1876
     tx_packets: 411
     rx_bytes: 173016
     tx_bytes: 46476
     rx_broadcast: 1300
     tx_broadcast: 2
     rx_multicast: 0
     tx_multicast: 8
     rx_errors: 0
     tx_errors: 0
     tx_dropped: 0
     multicast: 0
     collisions: 0

显示自动协商,接收和发送设置

[root@centos72m ~]# ethtool -a enp0s3
Pause parameters for enp0s3:
Autonegotiate:	on
RX:		on
TX:		off
ethtool网络工具

在openSUSE上安装Ethtool

linux-xcsw:~ # zypper se ethtool

linux-xcsw:~ # zypper install ethtool

显示接口设备驱动程序

[root@centos72m ~]# ethtool -i enp0s3
driver: e1000
version: 7.3.21-k8-NAPI
firmware-version: 
bus-info: 0000:00:03.0
supports-statistics: yes
supports-test: yes
supports-eeprom-access: yes
supports-register-dump: yes
supports-priv-flags: no

在Ubuntu上安装Ethtool

### 检查是否已安装Ethtool
$ sudo apt-cache policy ethtool

### 安装ethtool
$ sudo apt-get update
$ sudo apt-get install ethtool
日期:2019-04-29 03:17:34 来源:oir作者:oir