Skip to content

ifethtool 命令参考

ifethtool 兼容 Linux ethtool 的主要命令,通过 SIOCETHTOOL ioctl 与内核兼容层通信。

支持范围

命令Linux 对应说明
ifethtool IFNAMEethtool DEVNAME查询链路设置
-h, --help-h显示帮助
-V, --version--version显示版本
-i, --driver-i查询驱动信息
-a, --show-pause-a查询 Pause 参数
-A, --pause-A设置 Pause 参数
-k, --show-features-k查询 feature/offload
-K, --features-K设置 feature/offload
-g, --show-ring-g查询 ring 参数
-G, --set-ring-G设置 ring 参数
-c, --show-coalesce-c查询中断合并参数
-C, --coalesce-C设置中断合并参数
-l, --show-channels-l查询 channel 参数
-L, --set-channels-L设置 channel 参数
-S, --statistics-S查询驱动统计
-r, --negotiate-r重新触发自动协商
-s, --change-s设置链路参数

基本链路查询

bash
ifethtool IFNAME

查询链路基础信息,输出字段:SpeedDuplexAuto-negotiationSupported link modesAdvertised link modesLink detected

对应 ioctl:ETHTOOL_GSETETHTOOL_GLINK

驱动信息 -i

bash
ifethtool -i IFNAME
字段含义
driver驱动短名
version驱动版本
firmware-version固件版本(无则显示 N/A
bus-info总线标识(无则显示 N/A

对应 ioctl:ETHTOOL_GDRVINFOethtool_ops->get_drvinfo

链路参数设置 -s

bash
ifethtool -s IFNAME [speed N] [duplex half|full] [autoneg on|off]
参数取值
speed10/100/1000/2500/10000/25000/40000/100000
duplexhalf / full
autonegon / off

流程:先 ETHTOOL_GSET 读出当前配置,覆盖传入参数后用 ETHTOOL_SSET 下发。

Pause 参数 -a / -A

bash
ifethtool -a IFNAME               # 查询
ifethtool -A IFNAME [autoneg on|off] [rx on|off] [tx on|off]  # 设置

对应 ioctl:ETHTOOL_GPAUSEPARAM / ETHTOOL_SPAUSEPARAM

Feature / Offload -k / -K

bash
ifethtool -k IFNAME               # 查询所有 feature
ifethtool -K IFNAME FEATURE on|off  # 设置某个 feature

常见 feature:

名称含义
rx-checksumRX 校验和卸载
tx-checksum-ipv4IPv4 TX 校验和卸载
tx-tcp-segmentationTSO
tx-generic-segmentationGSO
rx-groGRO
rx-vlan-hw-parseVLAN RX 解析
tx-vlan-hw-insertVLAN TX 插入
rx-hashingRX Hash

Ring 深度 -g / -G

bash
ifethtool -g IFNAME
ifethtool -G IFNAME [rx N] [tx N]

对应 ioctl:ETHTOOL_GRINGPARAM / ETHTOOL_SRINGPARAMethtool_ops->get_ringparam / set_ringparam

中断合并 -c / -C

bash
ifethtool -c IFNAME
ifethtool -C IFNAME [rx-usecs N] [tx-usecs N] [rx-frames N] [tx-frames N]

对应 ioctl:ETHTOOL_GCOALESCE / ETHTOOL_SCOALESCEethtool_ops->get_coalesce / set_coalesce

Channel 数 -l / -L

bash
ifethtool -l IFNAME
ifethtool -L IFNAME [combined N]

对应 ioctl:ETHTOOL_GCHANNELS / ETHTOOL_SCHANNELSethtool_ops->get_channels / set_channels

驱动统计 -S

bash
ifethtool -S IFNAME

对应 ioctl:ETHTOOL_GSSET_INFOETHTOOL_GSTRINGSETHTOOL_GSTATSethtool_ops->get_ethtool_stats

自动协商 -r

bash
ifethtool -r IFNAME

重新触发自动协商。对应 ioctl:ETHTOOL_NWAY_RSTethtool_ops->nway_reset

翼辉信息 · 网络技术部