ethtool的基本設置


 

 

 ethtool是設置網卡屬性、IP/TCP相關協議屬性的基本工具,功能還是很強大的。ubuntu的版本里沒有默認集成,使用apt-get install 安裝之。。。。

 

使用概要:
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、設置網口半/全雙工、設置網口是否自協商

ethtool -k      //查看protocol offload的屬性

ethtool -K|--offload DEVNAME Set protocol offload  // 設置protocol offload的屬性,這個命令很強大,待會再講

[ 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 ]

 

使用舉例:


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: yes

 

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: 0

 

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連接。



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM