本帖最后由 木二 于 2022-8-25 17:17 编辑
一 Ethtool简介 ethtool 是用于查询及设置网卡参数的命令。 二 ethtool使用 2.1 安装 ethtool源码包下载地址:http://ethtool.sourcearchive.com/ 2.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"
复制代码
三 延伸mii-tool 3.1 mii-tool介绍 mii-tool - view, manipulate media-independent interface status(mii-tool是查看,管理介质的网络接口的状态)。mii-tool可配置网卡协商方式 ,比如10/100/1000M的网卡半双工、全双工、自动协商的配置。 3.2 mii-tool使用 - [root@localhost ~]# mii-tool --help
- usage: mii-tool [-VvRrwl] [-A media,... | -F media] [interface ...]
- -V, --version display version information
- -v, --verbose more verbose output #显示网络接口的信息;
- -R, --reset reset MII to poweron state #重设MII到开启状态;
- -r, --restart restart autonegotiation #重启自动协商模式;
- -w, --watch monitor for link status changes #查看网络接口连接的状态变化;
- -l, --log with -w, write events to syslog #写入事件到系统日志;
- -A, --advertise=media,... advertise only specified media #指令特定的网络接口;
- -F, --force=media force specified media technology #更改网络接口协商方式;
- # mii-tool -v eth0 #查看网络接口的协商状态
- # mii-tool -F 100baseTx-FD #更改网络接口协商方式
复制代码
|