开发手册 欢迎您!
软件开发者资料库

Linux ethtool 命令

Linux命令是对Linux系统进行管理的命令。对于Linux系统来说,无论是中央处理器、内存、磁盘驱动器、键盘、鼠标,还是用户等都是文件,Linux系统管理的命令是它正常运行的核心,与之前的DOS命令类似。linux命令在系统中有两种类型:内置Shell命令和Linux命令。本文主要介绍Linux ethtool 命令。

1、命令简介

ethtool:显示或更改以太网卡设置

2、命令用法

ethtool ethXethtool -h|--helpethtool -a|--show-pause ethXethtool -A|--pause ethX [autoneg on|off] [rx on|off] [tx on|off]ethtool -c|--show-coalesce ethXethtool -C|--coalesce ethX [adaptive-rx on|off] [adaptive-tx on|off] [rx-usecs N] [rx-frames N] [rx-usecs-irq N] [rx-frames-irq N] [tx-usecs N] [tx-frames N] [tx-usecs-irq N] [tx-frames-irq N] [stats-block-usecs N] [pkt-rate-low N] [rx-usecs-low N] [rx-frames-low N] [tx-usecs-low N] [tx-frames-low N] [pkt-rate-high N] [rx-usecs-high N] [rx-frames-high N] [tx-usecs-high N] [tx-frames-high N] [sample-interval N]ethtool -g|--show-ring ethXethtool -G|--set-ring ethX [rx N] [rx-mini N] [rx-jumbo N] [tx N]ethtool -i|--driver ethXethtool -d|--register-dump ethX [raw on|off] [hex on|off] [file name]ethtool -e|--eeprom-dump ethX [raw on|off] [offset N] [length N]ethtool -E|--change-eeprom ethX [magic N] [offset N] [value N]ethtool -k|--show-offload ethXethtool -K--offload ethX [rx on|off] [tx on|off] [sg on|off] [tso on|off] [ufo on|off] [gso on|off] [gro on|off]ethtool -p|--blink ethX [N]ethtool -r|--negotiate ethXethtool -S|--statistics ethXethtool -t|--test ethX [offline|online]ethtool -s ethX [speed 10|100|1000|2500|10000] [duplex half|full] [port tp|aui|bnc|mii|fibre] [autoneg on|off] [advertise N] [phyad N] [xcvr internal|external] [wol p|u|m|b|a|g|s|d...] [sopass xx:yy:zz:aa:bb:cc] [msglvl N]

3、命令描述

ethtool用于查询和修改以太网设备的设置。

ethX是ethtool运行的以太网设备名称。

4、命令选项

选项

描述

-a

查看网卡中 接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off。

-A

修改网卡中 接收模块RX、发送模块TX和Autonegotiate模块的状态:启动on 或 停用off。

-c

显示指定以太网卡的Coalesce信息。

-C

修改指定以太网卡的Coalesce设置。

-g

查看指定以太网卡的rx/tx ring参数信息。

-G

修改指定以太网卡的rx/tx环设置。

-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地址等

5、使用示例

1)查询网口基本信息

[root@wonhero ~]# ethtool ens33

2)查询ens33对应的网卡(通过网卡的灯闪烁查看)

[root@wonhero ~]# ethtool -p ens33 10

3)查询网口的驱动相关信息

[root@wonhero ~]# ethtool -i ens33

4)设置网卡工作模式

[root@wonhero ~]# ethtool -s ens33 autoneg off speed 100 duplex full

5)将千兆网卡的速度降为百兆

[root@wonhero ~]# ethtool -s ens33 speed 100

6)查看网卡对收到数据包的校验功能是否已被停止

[root@wonhero ~]# ethtool -k ens33