ethtool

ethtool

ethtool是一个常用的命令行工具,用于配置和查询以太网接口的驱动程序和硬件参数。它提供了一种简单的方式来检查和修改网络接口的设置,以及获取与以太网接口相关的统计数据和状态信息。
ethtool可以执行以下常见的操作:
查询接口信息:使用ethtool命令可以获取以太网接口的各种信息,包括接口名称、连接状态、速度、双工模式、MAC地址、驱动程序信息等。
修改接口参数:ethtool还可以用于修改以太网接口的参数。例如,可以使用ethtool命令设置接口的速度和双工模式,启用或禁用接口的自动协商功能,更改接口的MAC地址等。
查询和重置统计数据:ethtool命令可以获取接口的统计信息,如接收和发送的数据包数量、错误计数等。还可以使用ethtool命令重置这些统计数据。
支持的功能查询:ethtool可以查询网络接口支持的功能列表,如支持的传输速率、双工模式、Wake-on-LAN功能等。
高级功能配置:ethtool还允许对高级功能进行配置,如RSS(接收侧扩展)和TSS(传输侧扩展)等。

请注意,使用ethtool需要root权限或者以root权限运行命令。使用时,可以通过"ethtool <接口名称>"的格式来执行不同的操作。例如,"ethtool eth0"将显示eth0接口的详细信息。

作者:炭烤毛蛋 ,点击博主了解更多。


提示:ethtool 网卡设置较为常用工具。

文章目录

  • ethtool
  • 前期准备
    • .1 Andorid
    • .2 Linux
  • 1. 网口速率设定
  • Tips
  • 结语


前期准备

.1 Andorid

Android 编译 ethtool 命令

source build/envsetup.sh
lunch rk3568_s-userdebug
mmm external/ethtool/
[ 99% 1005/1006] finishing build rules ...
[100% 1044/1044] Install: out/target/product/rk3568_s/system/bin/ethtool

user 版本需要刷机导入命令,userdebug版本工程机支持命令手动推入到指定目录

adb root
adb remount
adb push X:\xxx\out\target\product\rk3568_s\system\bin\ethtool /system/bin/

.2 Linux

Linux 安装 ethtool 命令

sudo apt-get update
sudo apt-get install ethtool

1. 网口速率设定

  • 查询ethx网口基本设置,其中 x 是对应网卡的编号,如eth0、eth1等等
ethtool eth0
Settings for eth0:
        Supported ports: [ TP AUI BNC MII FIBRE ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: Symmetric Receive-only
        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: No
        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: ug
        Wake-on: d
        Current message level: 0x0000003f (63)
                               drv probe link timer ifdown ifup
        Link detected: no
  • 查询eth0网口的相关信息
ethtool -i eth0
driver: st_gmac
version: Jan_2016
firmware-version:
expansion-rom-version:
bus-info:
supports-statistics: yes
supports-test: no
supports-eeprom-access: no
supports-register-dump: yes
supports-priv-flags: no
  • 查询eth0网口注册性信息
ethtool -d eth0
Offset          Values
------          ------
0x0000:         0c 0c 61 00 04 00 00 00 05 00 81 00 02 20 02 00
0x0010:         04 01 00 00 e1 01 00 00 00 00 00 00 00 00 00 00
0x0020:         35 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0030:         00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00
0x0040:         97 ef 00 80 ca d9 00 82 00 00 00 00 00 00 00 00
0x0050:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0060:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0070:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0080:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0090:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00a0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00b0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00c0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x00d0:         00 00 00 00 00 00 00 00 0d 00 00 00 00 08 90 01
0x00e0:         00 00 00 00 00 00 00 00 00 40 12 f7 00 60 12 f7
0x00f0:         00 00 66 00 06 20 20 02 61 a0 01 00 00 00 00 00
0x0100:         ff 00 00 00 01 00 11 00 00 00 00 00 00 00 00 00
0x0110:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0120:         00 00 00 00 d0 66 12 f7 f0 53 12 f7 00 00 00 00
0x0130:         42 c8 83 c3 17 0f 0d 00 00 00 00 00 00 00 00 00
0x0140:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0150:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0160:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0170:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0180:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0190:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x01a0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x01b0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x01c0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x01d0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x01e0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x01f0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0200:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0210:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0220:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0230:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0240:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0250:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0260:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0270:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0280:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0290:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x02a0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x02b0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x02c0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x02d0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x02e0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x02f0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0300:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0310:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0320:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0330:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0340:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0350:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0360:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0370:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0380:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0390:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x03a0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x03b0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x03c0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x03d0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x03e0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x03f0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0400:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0410:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0420:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0430:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0440:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0450:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0460:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0470:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0480:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0490:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x04a0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x04b0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x04c0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x04d0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x04e0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x04f0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0500:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0510:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0520:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0530:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0540:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0550:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0560:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0570:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0580:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0590:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x05a0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x05b0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x05c0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x05d0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x05e0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x05f0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0600:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0610:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0620:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0630:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0640:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0650:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0660:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0670:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0680:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0690:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x06a0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x06b0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x06c0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x06d0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x06e0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x06f0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0700:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0710:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0720:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0730:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0740:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0750:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0760:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0770:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0780:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0790:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x07a0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x07b0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x07c0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x07d0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x07e0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x07f0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0800:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0810:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0820:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0830:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0840:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0850:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0860:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0870:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0880:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0890:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x08a0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x08b0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x08c0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x08d0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x08e0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x08f0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0900:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0910:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0920:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0930:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0940:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0950:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0960:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0970:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0980:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0990:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x09a0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x09b0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x09c0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x09d0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x09e0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x09f0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0a00:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0a10:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0a20:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0a30:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0a40:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0a50:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0a60:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0a70:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0a80:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0a90:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0aa0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ab0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ac0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ad0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ae0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0af0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0b00:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0b10:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0b20:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0b30:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0b40:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0b50:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0b60:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0b70:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0b80:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0b90:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ba0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0bb0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0bc0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0bd0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0be0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0bf0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c00:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c10:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c20:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c30:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c40:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c50:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c60:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c70:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c80:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0c90:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ca0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0cb0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0cc0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0cd0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ce0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0cf0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0d00:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0d10:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0d20:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0d30:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0d40:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0d50:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0d60:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0d70:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0d80:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0d90:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0da0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0db0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0dc0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0dd0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0de0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0df0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0e00:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0e10:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0e20:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0e30:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0e40:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0e50:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0e60:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0e70:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0e80:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0e90:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ea0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0eb0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ec0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ed0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ee0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ef0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0f00:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0f10:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0f20:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0f30:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0f40:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0f50:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0f60:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0f70:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0f80:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0f90:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0fa0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0fb0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0fc0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0fd0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0fe0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ff0:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x1000:         00 08 90 01 00 00 00 00 00 00 00 00 00 40 12 f7
0x1010:         00 60 12 f7 00 00 66 00 06 20 20 02 61 a0 01 00
0x1020:         00 00 00 00 ff 00 00 00 01 00 11 00 00 00 00 00
0x1030:         00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x1040:         00 00 00 00 00 00 00 00 d0 66 12 f7 f0 53 12 f7
0x1050:         00 00 00 00 42 c8 83 c3 17 0f 0d 00 00 00 00 00
  • 查询eth0网口收发包统计
ethtool -S eth0
NIC statistics:
     mmc_tx_octetcount_gb: 163917
     mmc_tx_framecount_gb: 738
     mmc_tx_broadcastframe_g: 0
     mmc_tx_multicastframe_g: 0
     mmc_tx_64_octets_gb: 0
     mmc_tx_65_to_127_octets_gb: 0
     mmc_tx_128_to_255_octets_gb: 0
     mmc_tx_256_to_511_octets_gb: 0
     mmc_tx_512_to_1023_octets_gb: 0
     mmc_tx_1024_to_max_octets_gb: 0
     mmc_tx_unicast_gb: 0
     mmc_tx_multicast_gb: 0
     mmc_tx_broadcast_gb: 0
     mmc_tx_underflow_error: 0
     mmc_tx_singlecol_g: 0
     mmc_tx_multicol_g: 0
     mmc_tx_deferred: 0
     mmc_tx_latecol: 0
     mmc_tx_exesscol: 0
     mmc_tx_carrier_error: 0
     mmc_tx_octetcount_g: 163917
     mmc_tx_framecount_g: 738
     mmc_tx_excessdef: 0
     mmc_tx_pause_frame: 0
     mmc_tx_vlan_frame_g: 0
     mmc_rx_framecount_gb: 3283
     mmc_rx_octetcount_gb: 994286
     mmc_rx_octetcount_g: 994222
     mmc_rx_broadcastframe_g: 0
     mmc_rx_multicastframe_g: 3100
     mmc_rx_crc_error: 1
     mmc_rx_align_error: 0
     mmc_rx_run_error: 0
     mmc_rx_jabber_error: 0
     mmc_rx_undersize_g: 0
     mmc_rx_oversize_g: 0
     mmc_rx_64_octets_gb: 0
     mmc_rx_65_to_127_octets_gb: 0
     mmc_rx_128_to_255_octets_gb: 0
     mmc_rx_256_to_511_octets_gb: 0
     mmc_rx_512_to_1023_octets_gb: 0
     mmc_rx_1024_to_max_octets_gb: 0
     mmc_rx_unicast_g: 0
     mmc_rx_length_error: 0
     mmc_rx_autofrangetype: 0
     mmc_rx_pause_frames: 0
     mmc_rx_fifo_overflow: 0
     mmc_rx_vlan_frames_gb: 0
     mmc_rx_watchdog_error: 0
     mmc_rx_ipc_intr_mask: 2147385342
     mmc_rx_ipc_intr: 0
     mmc_rx_ipv4_gd: 1585
     mmc_rx_ipv4_hderr: 0
     mmc_rx_ipv4_nopay: 0
     mmc_rx_ipv4_frag: 0
     mmc_rx_ipv4_udsbl: 0
     mmc_rx_ipv4_gd_octets: 0
     mmc_rx_ipv4_hderr_octets: 0
     mmc_rx_ipv4_nopay_octets: 0
     mmc_rx_ipv4_frag_octets: 0
     mmc_rx_ipv4_udsbl_octets: 0
     mmc_rx_ipv6_gd_octets: 0
     mmc_rx_ipv6_hderr_octets: 0
     mmc_rx_ipv6_nopay_octets: 0
     mmc_rx_ipv6_gd: 1643
     mmc_rx_ipv6_hderr: 0
     mmc_rx_ipv6_nopay: 0
     mmc_rx_udp_gd: 0
     mmc_rx_udp_err: 0
     mmc_rx_tcp_gd: 0
     mmc_rx_tcp_err: 0
     mmc_rx_icmp_gd: 0
     mmc_rx_icmp_err: 0
     mmc_rx_udp_gd_octets: 0
     mmc_rx_udp_err_octets: 0
     mmc_rx_tcp_gd_octets: 0
     mmc_rx_tcp_err_octets: 0
     mmc_rx_icmp_gd_octets: 0
     mmc_rx_icmp_err_octets: 0
     tx_underflow: 0
     tx_carrier: 0
     tx_losscarrier: 0
     vlan_tag: 0
     tx_deferred: 0
     tx_vlan: 0
     tx_jabber: 0
     tx_frame_flushed: 0
     tx_payload_error: 0
     tx_ip_header_error: 0
     rx_desc: 0
     sa_filter_fail: 0
     overflow_error: 0
     ipc_csum_error: 0
     rx_collision: 0
     rx_crc_errors: 0
     dribbling_bit: 0
     rx_length: 0
     rx_mii: 0
     rx_multicast: 0
     rx_gmac_overflow: 0
     rx_watchdog: 0
     da_rx_filter_fail: 0
     sa_rx_filter_fail: 0
     rx_missed_cntr: 0
     rx_overflow_cntr: 0
     rx_vlan: 0
     tx_undeflow_irq: 0
     tx_process_stopped_irq: 0
     tx_jabber_irq: 0
     rx_overflow_irq: 0
     rx_buf_unav_irq: 0
     rx_process_stopped_irq: 0
     rx_watchdog_irq: 0
     tx_early_irq: 0
     fatal_bus_error_irq: 0
     rx_early_irq: 0
     threshold: 1
     tx_pkt_n: 738
     rx_pkt_n: 3282
     normal_irq_n: 4417
     rx_normal_irq_n: 2772
     napi_poll: 4041
     tx_normal_irq_n: 755
     tx_clean: 4041
     tx_set_ic_bit: 738
     irq_receive_pmt_irq_n: 0
     mmc_tx_irq_n: 0
     mmc_rx_irq_n: 0
     mmc_rx_csum_offload_irq_n: 0
     irq_tx_path_in_lpi_mode_n: 0
     irq_tx_path_exit_lpi_mode_n: 0
     irq_rx_path_in_lpi_mode_n: 0
     irq_rx_path_exit_lpi_mode_n: 0
     phy_eee_wakeup_error_n: 0
     ip_hdr_err: 0
     ip_payload_err: 0
     ip_csum_bypassed: 0
     ipv4_pkt_rcvd: 0
     ipv6_pkt_rcvd: 0
     no_ptp_rx_msg_type_ext: 0
     ptp_rx_msg_type_sync: 0
     ptp_rx_msg_type_follow_up: 0
     ptp_rx_msg_type_delay_req: 0
     ptp_rx_msg_type_delay_resp: 0
     ptp_rx_msg_type_pdelay_req: 0
     ptp_rx_msg_type_pdelay_resp: 0
     ptp_rx_msg_type_pdelay_follow_up: 0
     ptp_rx_msg_type_announce: 0
     ptp_rx_msg_type_management: 0
     ptp_rx_msg_pkt_reserved_type: 0
     ptp_frame_type: 0
     ptp_ver: 0
     timestamp_dropped: 0
     av_pkt_rcvd: 0
     av_tagged_pkt_rcvd: 0
     vlan_tag_priority_val: 0
     l3_filter_match: 0
     l4_filter_match: 0
     l3_l4_filter_no_match: 0
     irq_pcs_ane_n: 0
     irq_pcs_link_n: 0
     irq_rgmii_n: 0
     mtl_tx_status_fifo_full: 0
     mtl_tx_fifo_not_empty: 0
     mmtl_fifo_ctrl: 0
     mtl_tx_fifo_read_ctrl_write: 0
     mtl_tx_fifo_read_ctrl_wait: 0
     mtl_tx_fifo_read_ctrl_read: 0
     mtl_tx_fifo_read_ctrl_idle: 0
     mac_tx_in_pause: 0
     mac_tx_frame_ctrl_xfer: 0
     mac_tx_frame_ctrl_idle: 0
     mac_tx_frame_ctrl_wait: 0
     mac_tx_frame_ctrl_pause: 0
     mac_gmii_tx_proto_engine: 0
     mtl_rx_fifo_fill_level_full: 0
     mtl_rx_fifo_fill_above_thresh: 0
     mtl_rx_fifo_fill_below_thresh: 0
     mtl_rx_fifo_fill_level_empty: 0
     mtl_rx_fifo_read_ctrl_flush: 0
     mtl_rx_fifo_read_ctrl_read_data: 0
     mtl_rx_fifo_read_ctrl_status: 0
     mtl_rx_fifo_read_ctrl_idle: 0
     mtl_rx_fifo_ctrl_active: 0
     mac_rx_frame_ctrl_fifo: 0
     mac_gmii_rx_proto_engine: 0
     tx_tso_frames: 0
     tx_tso_nfrags: 0
  • 设置网卡速率
    设置网口速率10/100/1000M、设置网口半/全双工、设置网口是否自协商
    ethX是以太网卡的名称,Linux系统将检测到的第一块以太网卡命名为eth0, 第二块为eth1。
ethtool -s ethx [speed 10|100|1000] [duplex half|full] [autoneg on|off]

# 设定eth0 10M
ethtool -s eth0 speed 10 duplex full autoneg on
# 设定eth0 100M
ethtool -s eth0 speed 100 duplex full autoneg on
# 设定eth0 1G
ethtool -s eth0 speed 1000 duplex full autoneg on
  • 重置eth0网口到自适应模式
ethtool -r eth0
  • 查看protocol offload的属性
ethtool -k
  • 设置protocol offload的属性
ethtool -K|--offload DEVNAME Set protocol offload
[ rx on|off ]
[ tx on|off ]
[ sg on|off ]
[ tso on|off ]
[ ufo on|off ]
[ gso on|off ]
[ gro on|off ]
[ lro on|off ]
[ rxvlan on|off ]
[ txvlan on|off ]
[ ntuple on|off ]
[ rxhash on|off ]
  • 显示ethtool的命令帮助(help)
ethtool -h
ethtool version 5.3
Usage:
        ethtool DEVNAME Display standard information about device
        ethtool -s|--change DEVNAME     Change generic options
                [ speed %d ]
                [ duplex half|full ]
                [ port tp|aui|bnc|mii|fibre ]
                [ mdix auto|on|off ]
                [ autoneg on|off ]
                [ advertise %x ]
                [ phyad %d ]
                [ xcvr internal|external ]
                [ wol p|u|m|b|a|g|s|f|d... ]
                [ sopass %x:%x:%x:%x:%x:%x ]
                [ msglvl %d | msglvl type on|off ... ]
        ethtool -a|--show-pause DEVNAME Show pause options
        ethtool -A|--pause DEVNAME      Set pause options
                [ autoneg on|off ]
                [ rx on|off ]
                [ tx on|off ]
        ethtool -c|--show-coalesce DEVNAME      Show coalesce options
        ethtool -C|--coalesce DEVNAME   Set coalesce options
                [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 DEVNAME  Query RX/TX ring parameters
        ethtool -G|--set-ring DEVNAME   Set RX/TX ring parameters
                [ rx N ]
                [ rx-mini N ]
                [ rx-jumbo N ]
                [ tx N ]
        ethtool -k|--show-features|--show-offload DEVNAME       Get state of protocol offload and other features
        ethtool -K|--features|--offload DEVNAME Set protocol offload and other features
                FEATURE on|off ...
        ethtool -i|--driver DEVNAME     Show driver information
        ethtool -d|--register-dump DEVNAME      Do a register dump
                [ raw on|off ]
                [ file FILENAME ]
        ethtool -e|--eeprom-dump DEVNAME        Do a EEPROM dump
                [ raw on|off ]
                [ offset N ]
                [ length N ]
        ethtool -E|--change-eeprom DEVNAME      Change bytes in device EEPROM
                [ magic N ]
                [ offset N ]
                [ length N ]
                [ value N ]
        ethtool -r|--negotiate DEVNAME  Restart N-WAY negotiation
        ethtool -p|--identify DEVNAME   Show visible port identification (e.g. blinking)
               [ TIME-IN-SECONDS ]
        ethtool -t|--test DEVNAME       Execute adapter self test
               [ online | offline | external_lb ]
        ethtool -S|--statistics DEVNAME Show adapter statistics
        ethtool --phy-statistics DEVNAME        Show phy statistics
        ethtool -n|-u|--show-nfc|--show-ntuple DEVNAME  Show Rx network flow classification options or rules
                [ rx-flow-hash tcp4|udp4|ah4|esp4|sctp4|tcp6|udp6|ah6|esp6|sctp6 [context %d] |
                  rule %d ]
        ethtool -N|-U|--config-nfc|--config-ntuple DEVNAME      Configure Rx network flow classification options or rules
                rx-flow-hash tcp4|udp4|ah4|esp4|sctp4|tcp6|udp6|ah6|esp6|sctp6 m|v|t|s|d|f|n|r... [context %d] |
                flow-type ether|ip4|tcp4|udp4|sctp4|ah4|esp4|ip6|tcp6|udp6|ah6|esp6|sctp6
                        [ src %x:%x:%x:%x:%x:%x [m %x:%x:%x:%x:%x:%x] ]
                        [ dst %x:%x:%x:%x:%x:%x [m %x:%x:%x:%x:%x:%x] ]
                        [ proto %d [m %x] ]
                        [ src-ip IP-ADDRESS [m IP-ADDRESS] ]
                        [ dst-ip IP-ADDRESS [m IP-ADDRESS] ]
                        [ tos %d [m %x] ]
                        [ tclass %d [m %x] ]
                        [ l4proto %d [m %x] ]
                        [ src-port %d [m %x] ]
                        [ dst-port %d [m %x] ]
                        [ spi %d [m %x] ]
                        [ vlan-etype %x [m %x] ]
                        [ vlan %x [m %x] ]
                        [ user-def %x [m %x] ]
                        [ dst-mac %x:%x:%x:%x:%x:%x [m %x:%x:%x:%x:%x:%x] ]
                        [ action %d ] | [ vf %d queue %d ]
                        [ context %d ]
                        [ loc %d]] |
                delete %d
        ethtool -T|--show-time-stamping DEVNAME Show time stamping capabilities
        ethtool -x|--show-rxfh-indir|--show-rxfh DEVNAME        Show Rx flow hash indirection table and/or RSS hash key
                [ context %d ]
        ethtool -X|--set-rxfh-indir|--rxfh DEVNAME      Set Rx flow hash indirection table and/or RSS hash key
                [ context %d|new ]
                [ equal N | weight W0 W1 ... | default ]
                [ hkey %x:%x:%x:%x:%x:.... ]
                [ hfunc FUNC ]
                [ delete ]
        ethtool -f|--flash DEVNAME      Flash firmware image from the specified file to a region on the device
               FILENAME [ REGION-NUMBER-TO-FLASH ]
        ethtool -P|--show-permaddr DEVNAME      Show permanent hardware address
        ethtool -w|--get-dump DEVNAME   Get dump flag, data
                [ data FILENAME ]
        ethtool -W|--set-dump DEVNAME   Set dump flag of the device
                N
        ethtool -l|--show-channels DEVNAME      Query Channels
        ethtool -L|--set-channels DEVNAME       Set Channels
               [ rx N ]
               [ tx N ]
               [ other N ]
               [ combined N ]
        ethtool --show-priv-flags DEVNAME       Query private flags
        ethtool --set-priv-flags DEVNAME        Set private flags
                FLAG on|off ...
        ethtool -m|--dump-module-eeprom|--module-info DEVNAME   Query/Decode Module EEPROM information and optical diagnostics if available
                [ raw on|off ]
                [ hex on|off ]
                [ offset N ]
                [ length N ]
        ethtool --show-eee DEVNAME      Show EEE settings
        ethtool --set-eee DEVNAME       Set EEE settings
                [ eee on|off ]
                [ advertise %x ]
                [ tx-lpi on|off ]
                [ tx-timer %d ]
        ethtool --set-phy-tunable DEVNAME       Set PHY tunable
                [ downshift on|off [count N] ]
                [ fast-link-down on|off [msecs N] ]
                [ energy-detect-power-down on|off [msecs N] ]
        ethtool --get-phy-tunable DEVNAME       Get PHY tunable
                [ downshift ]
                [ fast-link-down ]
                [ energy-detect-power-down ]
        ethtool --reset DEVNAME Reset components
                [ flags %x ]
                [ mgmt ]
                [ mgmt-shared ]
                [ irq ]
                [ irq-shared ]
                [ dma ]
                [ dma-shared ]
                [ filter ]
                [ filter-shared ]
                [ offload ]
                [ offload-shared ]
                [ mac ]
                [ mac-shared ]
                [ phy ]
                [ phy-shared ]
                [ ram ]
                [ ram-shared ]
                [ ap ]
                [ ap-shared ]
                [ dedicated ]
                [ all ]
        ethtool --show-fec DEVNAME      Show FEC settings
        ethtool --set-fec DEVNAME       Set FEC settings
                [ encoding auto|off|rs|baser [...]]
        ethtool -Q|--per-queue DEVNAME  Apply per-queue command.The supported sub commands include --show-coalesce, --coalesce
             [queue_mask %x] SUB_COMMAND
        ethtool -h|--help               Show this help
        ethtool --version               Show version number

Tips

结语

不枉博主详细讲解,欢迎订阅博主-炭烤毛蛋 。

你可能感兴趣的:(Linux,#,LAN,服务器,网络,linux)