ethtool是Linux下用于查询和配置网络接口的命令行工具,可查看网卡速度、双工模式、驱动信息及统计数据显示链路状态;通过ethtool interface查看基本信息,-i查看驱动版本,-S获取收发错误等统计数据,-k管理卸载功能,-s可强制设置速率与双工模式(需注意匹配对端设备),-p用于物理定位网卡指示灯;使用时需root权限,注意接口命名规则变化,修改非持久化,部分功能受限于硬件或驱动支持,误操作可能导致链路异常。

ethtool
在 Linux 系统中,使用
ethtool
ethtool
比如说,如果你的网卡接口是
eth0
enp0s3
ethtool eth0 # 或者 ethtool enp0s3
执行这个命令后,你会看到一系列关于该网卡的基本信息,包括:
除了查看基本信息,
ethtool
查看驱动程序信息:
ethtool -i eth0
这会显示网卡的驱动程序名称、版本、固件版本和总线信息,对于排查驱动兼容性问题很有用。
查看统计信息:
ethtool -S eth0
这个命令会输出大量的网卡统计数据,比如接收/发送的字节数、错误包、丢包、碰撞次数等。这些数据对于分析网络性能瓶颈和故障非常有价值。
查看或修改网卡卸载(offload)设置:
ethtool -k eth0 # 查看当前设置 # ethtool -K eth0 rx off # 关闭接收卸载功能(谨慎操作)
网卡卸载功能(如TCP Segmentation Offload, Generic Receive Offload)可以将一些网络处理任务从CPU转移到网卡硬件上,提高性能。但有时,这些功能可能导致兼容性问题,需要临时关闭进行测试。
让网卡指示灯闪烁:
sudo ethtool -p eth0 10
这个命令会让指定网卡的指示灯闪烁10秒钟,对于在机架中快速定位物理网卡非常实用。需要
sudo
记住,很多
ethtool
root
sudo
ethtool
初次接触
ethtool
当你运行
ethtool <interface>
<interface>
Speed: 1000Mb/s
Duplex: Full
Speed
Duplex
Full
Half
Half
Link detected: yes
no
Supported link modes
Advertised link modes
Supported link modes
1000baseT/Full
Advertised link modes
Driver: e1000e
Version: 3.2.6-k
Firmware version: 0.13-4
ethtool -i
rx_packets: 123456
tx_packets: 654321
ethtool -S
rx_errors
tx_errors
rx_dropped
tx_dropped
collisions
理解这些参数,就能让你在面对网络问题时,快速定位问题大致出在哪里,是物理连接、驱动程序还是网络配置层面的问题。
ethtool
ethtool
强制设置网卡速度与双工模式:
sudo ethtool -s eth0 speed 100 duplex full autoneg off
这个命令是双刃剑,一般不推荐随意使用,因为自动协商(
autoneg on
100Mb/s Full
诊断网卡卸载(Offload)功能引起的奇怪问题: 你可能会遇到网络吞吐量异常低、TCP连接经常中断,或者某些特定应用网络性能奇差的问题,但其他网络工具却显示一切正常。这时候,
ethtool -k <interface>
tx-checksumming
scatter-gather
tso
gso
gro
ethtool -k eth0 # 查看当前卸载设置 # 如果怀疑某个功能有问题,可以尝试关闭它 # sudo ethtool -K eth0 tso off gso off gro off
通过逐一关闭或开启这些功能来测试,往往能定位到问题的根源。这需要一定的经验和耐心,但一旦找到,解决起来就豁然开朗。
结合统计数据(ethtool -S
ethtool -S
ifconfig
ip -s
rx_fifo_errors
tx_timeout
物理定位网卡:ethtool -p
sudo ethtool -p eth0 60
这些“妙用”往往需要你在面对具体问题时,结合其他工具(如
tcpdump
ip
ss
ethtool
尽管
ethtool
权限问题: 这是最常见的。很多
ethtool
ethtool -S
ethtool -p
root
sudo
sudo
网卡名称的变迁: 以前 Linux 系统中网卡接口通常是
eth0
eth1
systemd
enp0s3
ens33
eno1
eth0
ethtool eth0
ip a
ifconfig -a
修改设置的持久化问题: 使用
ethtool -S
/etc/network/interfaces
NetworkManager
硬件兼容性与驱动支持: 并非所有网卡都支持
ethtool
ethtool
ethtool -p
ethtool -K
盲目修改的风险:
ethtool -S
autoneg on
ethtool: command not found
ethtool
sudo apt install ethtool
sudo yum install ethtool
sudo dnf install ethtool
在使用
ethtool
以上就是Linux怎么使用ethtool检查网卡信息的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号