在 Linux 系统中,尤其是 Ubuntu,ethtool 是一个非常强大的命令行工具,用于查询和控制网络接口卡(NIC)的驱动程序和硬件设置。无论你是系统管理员、开发者,还是刚接触 Linux 的小白用户,掌握 Ubuntu ethtool命令 都能帮助你更好地管理和优化网络连接。
ethtool 是 Linux 内核提供的一个实用程序,用于显示和修改以太网设备的参数,比如:
大多数 Ubuntu 系统默认未安装 ethtool,但安装非常简单。打开终端(Ctrl+Alt+T),输入以下命令:
sudo apt updatesudo apt install ethtool
首先,你需要知道你的网络接口名称。通常是以 eth0、enp0s3 或 ens33 等形式命名。你可以用以下命令列出所有网络接口:
ip a 假设你的有线网卡接口是 enp0s3,那么使用 ethtool 查看其详细信息:
sudo ethtool enp0s3 输出示例(部分):
Settings for enp0s3: Supported ports: [ TP ] Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Supported pause frame use: No 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 Speed: 1000Mb/s Duplex: Full Auto-negotiation: on Port: Twisted Pair PHYAD: 1 Transceiver: internal Link detected: yes
从上面可以看到当前网速为 1000Mb/s(即千兆),双工模式为 Full,并且启用了自动协商。
有时自动协商可能失败,导致网速降为 100M 或 10M。这时你可以手动强制设置速度和双工模式。例如,将 enp0s3 设置为 1000M 全双工:
sudo ethtool -s enp0s3 speed 1000 duplex full autoneg off 参数说明:
speed:设置网速(10 / 100 / 1000 / 2500 / 10000 等)duplex:设置双工模式(half / full)autoneg off:关闭自动协商(必须关闭才能手动设置)⚠️ 注意:手动设置前请确认你的交换机或路由器支持对应的速度和双工模式,否则可能导致网络中断!
如果你希望恢复自动协商(推荐日常使用),只需执行:
sudo ethtool -s enp0s3 autoneg on Q:修改后重启失效怎么办?
A:ethtool 的设置是临时的,重启后会恢复默认。如需永久生效,可将命令写入 /etc/rc.local 或使用 NetworkManager 配置脚本。
Q:如何查看驱动和固件版本?
A:使用以下命令:
ethtool -i enp0s3 通过本教程,你应该已经掌握了 Ubuntu ethtool命令 的基本用法,能够查看和调整 以太网设置,解决常见的网络速度问题。无论是进行 Linux网络配置 还是排查故障,ethtool 都是一个不可或缺的工具。希望这篇 ethtool使用教程 能帮助你更高效地管理 Ubuntu 网络环境!
—— 完 ——
本文由主机测评网于2025-12-16发表在主机测评网_免费VPS_免费云服务器_免费独立服务器,如有疑问,请联系我们。
本文链接:https://www.vpshk.cn/2025128640.html