linux ethtool 檢視網絡卡狀態
ethtool 工具關於網路協商功能介紹;
ethtool - Display or change ethernet card settings(ethtool 是用來顯示和更改網絡卡設定的工具);這個工具比較複雜,功能也特別多。由於洋文比較難懂。所以我們還是把網路裝置協商方式的設定方法說一說。
2.1 ethtool 顯示網路埠設定功能;
這個功能比較好辦。就是ethtool 後面直接接網絽介面就行;比如下面的例子;
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: No 注:自動協商關閉
Speed: 100Mb/s 注:速度 100Mb
Duplex: Full 注:全雙工
Port: MII
PHYAD: 32
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: yes 注:eth0已經啟用;
2.2 ethtool 設定網絡卡的協商模式;
在ethtool的-h幫助中我們檢視到有這樣的幫助資訊;
ethtool -s DEVNAME /
[ speed 10|100|1000 ] /
[ duplex half|full ] /
[ port tp|aui|bnc|mii|fibre ] /
[ autoneg on|off ] /
* 例項一: 把網絡卡eth0 速度改為10Mb/s,採用半雙工;
[[email protected] beinan]# ethtool -s eth1 speed 10 duplex half
[[email protected] beinan]# ethtool eth1
Settings for eth1:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: No
Speed: 10Mb/s 注:速度 10M/s
Duplex: Half 注:半雙工
Port: MII
PHYAD: 32
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: no 注:eth1沒有啟用;
* 例項二: 把網絡卡eth0 速度改為100Mb/s,採用全雙工;
[[email protected] beinan]# ethtool -s eth1 speed 100 duplex full
[[email protected] beinan]# ethtool eth1
Settings for eth1:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: No
Speed: 100Mb/s 注:速度 100M/s
Duplex: Full 注:全雙工
Port: MII
PHYAD: 32
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: pumbg
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: no 注:eth1網絡卡沒有啟用;
命令描述:
ethtool 是用於查詢及設定網絡卡引數的命令。
使用概要:
ethtool ethx //查詢ethx網口基本設定,其中 x 是對應網絡卡的編號,如eth0、eth1等等
ethtool –h //顯示ethtool的命令幫助(help)
ethtool –i ethX //查詢ethX網口的相關資訊
ethtool –d ethX //查詢ethX網口註冊性資訊
ethtool –r ethX //重置ethX網口到自適應模式
ethtool –S ethX //查詢ethX網口收發包統計
ethtool –s ethX [speed 10|100|1000] [duplex half|full] [autoneg on|off] //設定網口速率10/100/1000M、設定網口半/全雙工、設定網口是否自協商
使用舉例:
1)[[email protected] /]# ethtool eth1
Settings for eth1:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: umbg
Wake-on: d
Link detected: yes
2)[[email protected] /]# ethtool -i eth1
driver: e1000
version: 5.0.43-k1
firmware-version: N/A
bus-info: 06:08.1
3)[[email protected] /]# ethtool -S eth1
NIC statistics:
rx_packets: 58068300
tx_packets: 87124083
rx_bytes: 1589713008
tx_bytes: 2165825901
rx_errors: 0
tx_errors: 0
rx_dropped: 0
tx_dropped: 0
multicast: 0
collisions: 0
rx_length_errors: 0
rx_over_errors: 0
rx_crc_errors: 0
rx_frame_errors: 0
rx_fifo_errors: 0
rx_missed_errors: 0
tx_aborted_errors: 0
tx_carrier_errors: 0
tx_fifo_errors: 0
tx_heartbeat_errors: 0
tx_window_errors: 0
4)[[email protected] /]# ethtool -s eth1 autoneg off speed 100 duplex full
相關參考:
1)[[email protected] /]# which ethtool //查詢 ethtool 存放的路徑
/sbin/ethtool
2)[[email protected] /]# rpm -qf /sbin/ethtool //查詢 ethtool 的版本資訊
ethtool-1.6-5
3)將 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"
解決方法二:
將ethtool設定寫入/etc/rc.d/rc.local之中。