如何使用 ethtool 命令管理以太网卡( 二 )

如何检查以太网卡的驱动程序和固件版本你可以使用 ethtool 命令的 -i 选项检查驱动程序版本、固件版本和总线的详细信息,如下所示:
# ethtool -i eth0driver: vmxnet3version: 1.4.16.0-k-NAPIfirmware-version:expansion-rom-version:bus-info: 0000:0b:00.0supports-statistics: yessupports-test: nosupports-eeprom-access: nosupports-register-dump: yessupports-priv-flags: no如何检查网络使用情况统计你可以使用 ethtool 命令中的 -S 选项来查看网络使用情况统计 。它可以显示传输的字节数、接收的字节数、错误数等 。
# ethtool -S eth0NIC statistics:     Tx Queue#: 0       TSO pkts tx: 2053       TSO bytes tx: 7167572       ucast pkts tx: 4028081       ucast bytes tx: 399093197       mcast pkts tx: 0       mcast bytes tx: 0       bcast pkts tx: 0       bcast bytes tx: 0       pkts tx err: 0       pkts tx discard: 0       drv dropped tx total: 0          too many frags: 0          giant hdr: 0          hdr err: 0          tso: 0       ring full: 0       pkts linearized: 0       hdr cloned: 0       giant hdr: 0     Tx Queue#: 1       TSO pkts tx: 1955       TSO bytes tx: 6536945       ucast pkts tx: 3711838       ucast bytes tx: 346309662       mcast pkts tx: 0       mcast bytes tx: 0       bcast pkts tx: 1186       bcast bytes tx: 49812       pkts tx err: 0       pkts tx discard: 0       drv dropped tx total: 0          too many frags: 0          giant hdr: 0          hdr err: 0          tso: 0       ring full: 0       pkts linearized: 0       hdr cloned: 0       giant hdr: 0     Rx Queue#: 0       LRO pkts rx: 0       LRO byte rx: 0       ucast pkts rx: 5084776       ucast bytes rx: 4673133395       mcast pkts rx: 0       mcast bytes rx: 0       bcast pkts rx: 154143       bcast bytes rx: 45415676       pkts rx OOB: 0       pkts rx err: 0       drv dropped rx total: 0          err: 0          fcs: 0       rx buf alloc fail: 0     Rx Queue#: 1       LRO pkts rx: 0       LRO byte rx: 0       ucast pkts rx: 6346769       ucast bytes rx: 4835534292       mcast pkts rx: 0       mcast bytes rx: 0       bcast pkts rx: 3464       bcast bytes rx: 714646       pkts rx OOB: 0       pkts rx err: 0       drv dropped rx total: 0          err: 0          fcs: 0       rx buf alloc fail: 0     tx timeout count: 0如何改变以太网设备的速度你可以根据需要改变以太网的速度 。当你进行此更改时,网卡将自动掉线,你需要使用 ifup 命令 或 ip 命令或 nmcli 命令将其重新上 。
# ethtool -s eth0 speed 100# ip link set eth0 up如何在 Linux 上启用/禁用以太网卡的自动协商?你可以使用 ethtool 命令中的 autoneg 选项启用或禁用自动协商,如下图所示:


推荐阅读