Linux命令之Ethtool用法詳解

2021-09-20 16:28:55 字數 3584 閱讀 3332

描述:

ethtool是用於查詢及設定網絡卡引數的命令。

概要:

ethtool ethx      //查詢ethx網口基本設定

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]\         //設定網口速率10/100/1000m

[duplex half|full]\           //設定網口半/全雙工

[autoneg on|off]\            //設定網口是否自協商

[port tp|aui|bnc|mii]\         //設定網口型別

[phyad n]\                 

[xcvr internal|exteral]\

[wol p|u|m|b|a|g|s|d...]\

[sopass xx:yy:zz:aa:bb:cc]\

[msglvl n]

舉例:

1)[root@linux /]# ethtool eth1

settings for eth0:

2)[root@linux /]#ethtool -i eth1

driver: bnx2

version: 2.0.8-rh

firmware-version: 6.2.12 bc 5.2.3 ncsi 2.0.11

bus-info: 0000:01:00.0

3)[root@linux /]# ethtool -s eth1

nic statistics:

rx_bytes: 216494818

rx_error_bytes: 0

tx_bytes: 27084170553

tx_error_bytes: 0

rx_ucast_packets: 2933822

rx_mcast_packets: 33

rx_bcast_packets: 956

tx_ucast_packets: 18464909

tx_mcast_packets: 6

tx_bcast_packets: 179

tx_mac_errors: 0

tx_carrier_errors: 0

rx_crc_errors: 0

rx_align_errors: 0

tx_single_collisions: 0

tx_multi_collisions: 0

tx_deferred: 0

tx_excess_collisions: 0

tx_late_collisions: 0

tx_total_collisions: 0

rx_fragments: 0

rx_jabbers: 0

rx_undersize_packets: 0

rx_oversize_packets: 0

rx_64_byte_packets: 959

rx_65_to_127_byte_packets: 2930241

rx_128_to_255_byte_packets: 2634

rx_256_to_511_byte_packets: 752

rx_512_to_1023_byte_packets: 169

rx_1024_to_1522_byte_packets: 56

rx_1523_to_9022_byte_packets: 0

tx_64_byte_packets: 183

tx_65_to_127_byte_packets: 357

tx_128_to_255_byte_packets: 750

tx_256_to_511_byte_packets: 224

tx_512_to_1023_byte_packets: 991032

tx_1024_to_1522_byte_packets: 17472548

tx_1523_to_9022_byte_packets: 0

rx_xon_frames: 0

rx_xoff_frames: 0

tx_xon_frames: 0

tx_xoff_frames: 0

rx_mac_ctrl_frames: 0

rx_filtered_packets: 0

rx_ftq_discards: 0

rx_discards: 0

rx_fw_discards: 0

4)[root@linux /]# ethtool -s eth1 autoneg off speed 100 duplex full

相關:

1)[root@linux /]# which ethtool

/sbin/ethtool

2)[root@linux /]# rpm -qf /sbin/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之中。

二解決方法:

對intel千兆網絡卡禁用自適應時必須指定鏈路速度和全雙工模式。當使用ethtool來禁用使用e1000網絡卡驅動模組的網絡卡自適應特性時,必須同時指定鏈路速度和全雙工工作模式。例如: ethtool -s eth0 autoneg off

會邊比自適應,但是只是臨時禁用,如果在命令中沒有指定鏈路速度和全雙工工作模式,驅動會自動重新開啟自適應。 

為了使用ethtool工具來禁用e1000網絡卡驅動模組的網絡卡自適應特性,使用以下步驟 

1. 進入終端模式。 2. 以root身份執行 ethtool -s ethx autoneg off speed 1000 duplex full

這裡ethx是網絡卡的名字(例如eth0或者eth1等等),這個命令將關閉該網絡卡的自適應特性,並且強制設定網絡卡速度為1gb,全雙公模式。

另外ethtool比mii-tool要高階,mii-tool只支援 port: mii的網絡卡.

ethtool 命令詳解

命令描述 ethtool 是用於查詢及設定網絡卡引數的命令。使用概要 ethtool ethx 查詢ethx網口基本設定,其中 x 是對應網絡卡的編號,如eth0 eth1等等 ethtool h 顯示ethtool的命令幫助 help ethtool i ethx 查詢ethx網口的相關資訊 et...

ethtool 命令詳解

ethtool 是用於查詢及設定網絡卡引數的命令。使用概要 ethtool enp5s0fx 查詢ethx網口基本設定,其中 x 是對應網絡卡的編號,如enp5s0fx 等等 ethtool h 顯示ethtool的命令幫助 help ethtool i enp5s0fx 查詢ethx網口的相關資訊...

用ethtool 命令解決Linux 網絡卡丟包

生產中有一台linux裝置併發比較大,droped包比較多,尤其是在跑遊戲資料報的時候,存在嚴重的丟包現象,懷疑網絡卡效能不足,在更換裝置前想能不有通過軟體方法解決,通過網上一些資料顯示,出現這種現象,也有可能是網絡卡buffer size 太小的原因,遂嘗試更改buffer 大小解決,下面的裝置執...