ethtool 是用于查询及设置网卡参数的命令,常见用法如下:
注意:该命令只是临时设置,如果网卡重启就失效了,如果想要永久保存应该配置 /etc/sysconfig/network-scripts/ifcfg-eth0 文件
查看指定网卡的基本设置,内容包括网卡速率、网卡的工作模式等
ethtool eth0
[root@mysql ~]# ethtool eth0 Settings for eth0: 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 Advertised FEC modes: Not reported Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 0 Transceiver: internal Auto-negotiation: on MDI-X: off (auto) Supports Wake-on: d Wake-on: d Current message level: 0x00000007 (7) drv probe link Link detected: yes
查看指定网卡的驱动信息,内容包括驱动的型号、驱动的版本等
ethtool -i eth0
[root@mysql ~]# ethtool -i eth0 driver: e1000 version: 7.3.21-k8-NAPI firmware-version: expansion-rom-version: bus-info: 0000:02:01.0 supports-statistics: yes supports-test: yes supports-eeprom-access: yes supports-register-dump: yes supports-priv-flags: no
[root@mysql ~]# ethtool -s eth0 speed [10|100|1000] # 设置网卡的速率,单位是:Mb/s [root@mysql ~]# ethtool -s eth0 duplex [half|full] # 设置网卡的工作模式,可设置为半双工或全双工 [root@mysql ~]# ethtool -s eth0 autoneg [on|off] # 设置网卡是否自动协商,自动协商的内容主要包括工作模式、网卡速率以及流控等参数 [root@mysql ~]# ethtool -s eth0 autoneg off speed 100 duplex full # 也可以同时写在一起