Linux - ethtool 使用方法

时间:2023-02-19 14:04:00

ethtool 是用于查询及设置网卡参数的命令。

1、安装

  • yum源安装:yum install ethtool
  • 源码包安装:ethtool 源码包下载地址:http://ethtool.sourcearchive.com/

2、ethtool常见用法

ethtool eth0  # 查询eth0网口基本设置 
ethtool –h  # 显示ethtool的命令帮助(help) 
ethtool –i eth0  # 查询eth0网口的相关信息
ethtool –d eth0  # 查询eth0网口注册性信息                
ethtool –r eth0  # 重置eth0网口到自适应模式        
ethtool –S eth0  # 查询eth0网口收发包统计               
ethtool –s eth0 [speed 10|100|1000] [duplex half|full] [autoneg on|off]  # 设置网口速率10/100/1000M、设置网口半/全双工、设置网口是否自协商

提示:ethtool设置可通过以下方式永久保存:

ethtool设置可通过 /etc/sysconfig/network-scripts/ifcfg-ethX 文件保存,从而在设备下次启动时激活选项。

例如:

ethtool -s eth0 speed 100 duplex full autoneg off  # 此指令将eth0设备设置为全双工自适应,速度为100Mbs。

# 若要eth0启动时设置这些参数, 修改文件/etc/sysconfig/network-scripts/ifcfg-eth0,添加如下一行:
ETHTOOL_OPTS="speed 100 duplex full autoneg off"