參考網址 參考
下載網址
1 2 3 4 5 6 7 8 9 10 11 12 13 14 # 解壓縮 $tar zxvf ethtool-4.8.tar.gz $cd ethtool-4.8 # 看有哪些指令可以使用 $./configure -help # 看此 SourceCode 的版本 $./configure -version # 環境設定、編譯 $./configure CC=CrossCompilerPath --host=x86 --prefix=Path $make $make install
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 # 看 ethX 基本設定 # ./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: Symmetric Supports auto-negotiation: Yes Advertised link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full Advertised pause frame use: Symmetric Advertised auto-negotiation: Yes Speed: 1000Mb/s Duplex: Full Port: Twisted Pair PHYAD: 1 Transceiver: internal Auto-negotiation: on MDI-X: off Supports Wake-on: pumbg Wake-on: g Current message level: 0x00000007 (7) drv probe link Link detected: yes # 看 ethX 基本訊息 #./ethtool -i eth0 driver: igb // Module 驅動,Intel® 82575/6,82580,I350,I210/211 version: 5.0.6 firmware-version: 1.8, 0x80000bec expansion-rom-version: bus-info: 0000:00:14.0 supports-statistics: yes supports-test: yes supports-eeprom-access: yes supports-register-dump: yes supports-priv-flags: no # 看 ethX Rx/Tx 封包資訊 # ./ethtool -S eth0 NIC statistics: rx_packets: 1638 tx_packets: 1458 rx_bytes: 812443 tx_bytes: 103860 rx_broadcast: 210 tx_broadcast: 36 rx_multicast: 24 tx_multicast: 18 multicast: 24 collisions: 0 rx_crc_errors: 0 rx_no_buffer_count: 0 rx_missed_errors: 0 tx_aborted_errors: 0 tx_carrier_errors: 0 tx_window_errors: 0 # 看 Mac Address #./ethtool -P eth0 Permanent address: 00:a0:c9:00:00:00
Shell 1 2 3 4 5 6 7 8 9 10 11 $$ Shell 本身 PID(ProcessID) $! Shell 最後運行的後台Process PID $? 最後運行指令的返回值 $- 使用Set命令設定的Flag一覽 $* 所有參數列表。如"$*"用「"」括起來的情況、以"$1 $2 … $n"的形式輸出所有參數。 $@ 所有參數列表。如"$@"用「"」括起來的情況、以"$1" "$2" … "$n" 的形式輸出所有參數。 $# 添加到Shell的參數個數 $0 Shell本身的文件名 $1-$n 添加到Shell的各參數值。$1是第1參數、$2是第2參數…。
Shell 測試(test.sh) Shell 參數指令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 printf "The complete list is %s\n" "$$" printf "The complete list is %s\n" "$!" printf "The complete list is %s\n" "$?" printf "The complete list is %s\n" "$*" printf "The complete list is %s\n" "$@" printf "The complete list is %s\n" "$#" printf "The complete list is %s\n" "$0" printf "The complete list is %s\n" "$1" printf "The complete list is %s\n" "$2 # sh test.sh 123 456 ABC ($$) The complete list is 938 ($!) The complete list is ($?) The complete list is 0 ($*) The complete list is 123 456 ABC ($@) The complete list is 123 The complete list is 456 The complete list is ABC ($#) The complete list is 3 ($0) ($1) ($2) ($3) The complete list is test.sh The complete list is 123 The complete list is 456 The complete list is ABC
Shell seq 指令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 # seq 5 1 2 3 4 5 $ seq 2 5 2 3 4 5 $ seq 1 2 5 1 3 5 for i in `seq 1 6` do done
Shell cut 指令
1 2 3 4 5 6 7 8 # echo 00:11:22:33:44:55 | cut -d':' -f1 00 # echo 00:11:22:33:44:55 | cut -d':' -f2 11 # echo 00:11:22:33:44:55 | cut -d':' -f3 22 # echo 00:11:22:33:44:55 | cut -d':' -f4 33
顯示設備 Ethtool 有個指令-E
(寫入EEPROM)需要以下參數
其中magic
就是VenID:DevID
而VenID:DevID
可用以下方式找出
1 2 3 4 5 6 7 8 9 10 lspci -knn | grep -A3 net lspci | grep Ethernet modinfo igb // Module Name ethtool -e eth0 // EEPROM 內容 # lspci -knn|grep -A3 net 00:14.0 Ethernet controller [0200]: Intel Corporation Device [VenID:DevID] (rev 03) # 範例,在 0x2 offset 位置寫入 0xc9 ./ethtool -E eth0 magic 0xAABBCCDD offset 0x2 value 0xc9