ethtool:查询及设置网卡参数

功能描述

ethtool 命令用于查询及设置网卡参数。

命令语法

ethtool [选项] [网卡]

选项含义

-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 显示NIC- and driver-specific 的统计参数,如网卡接收/发送的字节数、接收/发送的广播包个数等。
-t 让网卡执行自我检测,有两种模式:offline or online。
-s 修改网卡的部分配置,包括网卡速度、单工/全双工模式、mac地址等

参数实例

实例1

查询网卡参数:

// 查询网口基本信息
[root@cnLinuxer ~]# ethtool ens33// 查询ens33对应哪张网卡
[root@cnLinuxer ~]# ethtool -p ens33 10  【哪块网卡的LED灯在闪,ens33就对应哪块物理网卡】// 查询网口的驱动相关信息
[root@cnLinuxer ~]# ethtool -i ens33
driver: e1000
version: 7.3.21-k8-NAPI// 查看网卡在接收/发送数据时,有没有出错
[root@cnLinuxer ~]# ethtool -S ens33

实例2

配置网卡参数

// 设置网卡工作模式
[root@cnLinuxer ~]# ethtool -s ens33 autoneg off speed 100 duplex full // 将千兆网卡的速度降为百兆
[root@cnLinuxer ~]# ethtool -s ens33 speed 100// 停止网卡的发送模块TX
[root@cnLinuxer ~]# ethtool -A tx off ens33// 查看网卡的tx模块是否已被停止
[root@cnLinuxer ~]# ethtool -a ens33// 关闭网卡对收到的数据包的校验功能
[root@cnLinuxer ~]# ethtool -K ens33 rx off// 查看网卡对收到数据包的校验功能是否已被停止
[root@cnLinuxer ~]# ethtool -k ens33
有收获,点个在看