ethtool是用于查询和设置网卡参数的命令,它的功能非常强大,几乎网卡的收发数据的参数都可以在这里设置。
(1)语法
ethtool [-s|-a|-A|-c|-C|-g|-G……] ethX <options>
(2)描述
ethX表示以太网卡的名称,第一块以太网卡为eth0,第二块为eth1……
通常选择不同的参数有不同的options。
参数 | 说明 |
---|---|
-a | 查看网卡中接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off。 |
-A | 修改网卡中 接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off。 |
-c | display the Coalesce(聚合、联合) information of the specified ethernet card.聚合网口信息,使看起来更有规律。 |
-C | Change the Coalesce setting of the specified ethernet card.修改网卡聚合信息。 |
-g | Display the rx/tx ring parameter information of the specified ethernet card. 显示网卡的接收/发送环形参数。 |
-G | Change the rx/tx ring setting of the specified ethernet card. 修改网卡的接收/发送环形参数。 |
-i | 显示网卡驱动的信息,如驱动的名称、版本等。 |
-d | 显示register dump信息, 部分网卡驱动不支持该选项。 |
-e | 显示EEPROM dump信息,部分网卡驱动不支持该选项。 |
-E | 修改网卡EEPROM byte. |
-k | 显示网卡Offload参数的状态:on 或 off,包括rx-checksumming、tx-checksumming等。 |
-K | 修改网卡Offload参数的状态 |
-p | 用于区别不同ethX对应网卡的物理位置,常用的方法是使网卡port上的led不断的闪;N指示了网卡闪的持续时间,以秒为单位。 |
-r | 如果auto-negotiation模块的状态为on,则restarts auto-negotiation. |
-s | 修改网卡的部分配置,包括网卡速度、单工/全双工模式、mac地址等。加上-s选项修改的内容才会生效 |
-S | 显示NIC- and driver-specific 的统计参数,如网卡接收/发送的字节数、接收/发送的广播包个数等。 |
-t | 让网卡执行自我检测,有两种模式:offline or online. |
1. 网口基本设置ethtool ethX
,查询ethx网口基本设置,其中 x 是对应网卡的编号,如eth0、eth1等等。
[root@vworkstation ~]# ethtool enp4s0
Settings for enp4s0:
Supported ports: [ TP MII ]
//支持模式
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes// 支持自动协商
Supported FEC modes: Not reported
//通告模式
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: Symmetric Receive-only
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Speed: 10Mb/s//当前速率
Duplex: Half//工作模式为半双工
Port: MII
PHYAD: 0
Transceiver: internal
Auto-negotiation: on//自动协商
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000033 (51)
drv probe ifdown ifup
Link detected: no
ethtool -i ethX
driver: r8169//驱动
version: 2.3LK-NAPI//版本
firmware-version: rtl8168g-3_0.0.1 04/23/13//固件信息
expansion-rom-version:
bus-info: 0000:04:00.0
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no
3. 设置网口工作方式
(1)关闭/打开网卡对数据包的校验功能
关闭/打开网卡对收到的数据包的校验功能,请输入:ethtool -K eth0 rx off/on
关闭/打开网卡对发送的数据包的校验功能,请输入:ethtool -K eth0 tx off/on
操作完毕后可以输入ethtool -k eth0
查看校验功能是否已关闭
(2)定位ethX对应的网卡
输入ethtool -p eth0 10
,操作完毕后eth0网卡的led灯会闪烁。
注:本文为小yip原创,未经许可不得在任何平台转载。如需转载,与作者联系~
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。