ethtool是設置網卡屬性、IP/TCP相關協議屬性的基本工具,功能仍是很強大的。ubuntu的版本里沒有默認集成,使用apt-get install 安裝之。。。。node
使用概要:
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、設置網口半/全雙工、設置網口是否自協商linux
ethtool -k //查看protocol offload的屬性ubuntu
ethtool -K|--offload DEVNAME Set protocol offload // 設置protocol offload的屬性,這個命令很強大,待會再講ssh
[ rx on|off ]
[ tx on|off ]
[ sg on|off ]
[ tso on|off ]
[ ufo on|off ]
[ gso on|off ]
[ gro on|off ]
[ lro on|off ]
[ rxvlan on|off ]
[ txvlan on|off ]
[ ntuple on|off ]
[ rxhash on|off ]tcp
使用舉例:工具
1)[root@linux /]# 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: yesspa
2)[root@linux /]# ethtool -i eth1
driver: e1000
version: 5.0.43-k1
firmware-version: N/A
bus-info: 06:08.1部署
3)[root@linux /]# 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: 0get
4) 把網卡eth0 速度改成10Mb/s,採用半雙工;虛擬機
[root@cuc03 beinan]# ethtool -s eth1 speed 10 duplex half
[root@cuc03 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沒有激活;
5)把網卡eth0 速度改成100Mb/s,採用全雙工;
[root@cuc03 beinan]# ethtool -s eth1 speed 100 duplex full
[root@cuc03 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網卡沒有激活;
6) 最後關於這個ethtool -k eth0 就特別說明一下,這個是顯示網卡的一些特別的協議開關
root@node4:/home/fbw# ethtool -k eth0
Offload parameters for eth0:
rx-checksumming: on
tx-checksumming: off
scatter-gather: off
tcp-segmentation-offload: off
udp-fragmentation-offload: off
generic-segmentation-offload: off
generic-receive-offload: on
large-receive-offload: off
rx-vlan-offload: on
tx-vlan-offload: on
ntuple-filters: off
receive-hashing: on
特別注意,加紅的那個參數,以前看到別人遇到這個問題,在部署OpenStack的計算節點的時候,如何將computer部署在臺式機上,ssh鏈接虛擬機就特別卡,鏈接超時將近1多鍾,可是若是將其部署在刀片上就沒有任何問題。因而,後面將問題定位到臺式機的BCM的網卡上,發現只要敲一下 ethtool -K eth0 tx off ,即只要關掉包發送校檢和,就能夠正常ssh鏈接。