ethtool 網絡卡配置檢視及修改工具

2021-08-13 16:21:53 字數 3870 閱讀 5583

命令描述:

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)查詢eth0網口基本設定(網絡卡速率是百兆還是千兆等):

# 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 //是否支援自動協商

advertised link modes: 10baset/half 10baset/full

100baset/half 100baset/full

1000baset/full

advertised pause frame use: no

advertised auto-negotiation: yes

speed: 1000mb/s //速率

duplex: full //全雙工

port: twisted pair //電口

phyad: 0

transceiver: internal

auto-negotiation: on

mdi-x: unknown

supports wake-on: d

wake-on: d

current message level: 0x00000007 (7)

drv probe link

link detected: yes //網線連線狀態

2)檢視網絡卡的驅動資訊:

# ethtool -i eth0                //檢視網絡卡的驅動版本

driver: e1000

version: 7.3

.21-k8-napi

firmware-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

3)檢視網絡卡的輸入流量,輸出流量,輸入包,輸出包,輸入的廣播,輸出的廣播,輸入的網路錯包,輸出的網路錯包等:

# 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

最近碰到的乙個問題: 將eth1掛到ovs dpdk網橋上,將網橋刪除以後,再使用 ifconfig -a ,發現eth3不見了。

解決過程:

首先使用如下兩條命令,可以找出eth1的bus-info: 0000:03:00.1

# lspci|grep eth    // 列出機器中的pci裝置資訊,如音效卡,顯示卡,modem,網絡卡等資訊

02:00.1 ethernet controller: advanced micro devices, inc. [amd] 79c970 [pcnet32 lance] (rev 10)

03:00.1 ethernet controller: silicon integrated systems [sis] sis900 pci fast ethernet (rev 91)

# ethtool -i eth0 //檢視網絡卡的驅動版本

driver: ixgbe

version: 7.3

.21-k8-napi

firmware-version:

bus-info: 0000:02:00.1 // 對應bus-info

supports-statistics: yes

supports-test: yes

supports-eeprom-access: yes

supports-register-dump: yes

supports-priv-flags: no

接下來做兩件事:

# 解綁裝置驅動

echo

"0000:03:00.1" > /sys/bus/pci/devices/0000\:03:00.1/driver/unbind

# 重新繫結驅動

echo

"0000:03:00.1" > /sys/bus/pci/driver/ixgbe/bind

ok! ifconfig -a 又可以看見eth1了!

/sys/bus/pci/devices/目錄下列出了系統中所有pci裝置的名稱(不管有沒有安裝對應的驅動程式),pci裝置的名稱就是相應的pci位址(即「域:pci匯流排號:槽位號:功能號」)。

/sys/bus/pci/drivers目錄下則列出了所有pci裝置的驅動。

相關目錄下會有一些別的檔案,像bind用來指定某個pci裝置由此驅動接管,unbind則起相反的作用。通常,乙個驅動都有自己支援的裝置型號的列表。

ethtool 檢視網絡卡

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

ethtool檢視網絡卡以及修改網絡卡配置

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

Linux 網絡卡特性配置ethtool詳解

於 ethtool 常用命令如下,比如對eth0的操作 ethtool eth0 查詢ethx網口基本設定,其中 x 是對應網絡卡的編號,如eth0 eth1等等 ethtool h 顯示ethtool的命令幫助 help ethtool i eth0 查詢eth0網口的相關資訊 ethtool d...