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、設置網口半/全雙工、設置網口是否自協商
ethtool -E eth0 magic 0x10798086 offset 0x10 value 0x1A 修改網卡EEPROM內容(0x1079 網卡device id , 0x8086網卡verdor id )
ethtool -e eth0 : dump網卡EEPROM內容
使用舉例:
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)[root@linux /]# ethtool -s eth1 autoneg off speed 100 duplex full
相關參考:
1)[root@linux /]# which ethtool //查詢 ethtool 存放的路徑
/sbin/ethtool
2)[root@linux /]# rpm -qf /sbin/ethtool //查詢 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之中。
典型用法:查詢網絡端口位置ethtool -p
這個命令多用於管理多網口的服務器主機,由於背板的網絡端口數量大,有時候不知道那個物理端口對應eth0或其他設備號,我們就可以使用這個命令來查詢。
用法:ethtool -p eth0
效果:設備號eth0對應的物理端口的兩個指示燈會閃爍
典型用法:修改端口速率ethtool -s
用法:ethtool -s eth0 speed 1000 duplex full autoneg off
效果:將設備號eth0對應的物理端口設置為速率為1000Mbps,全雙工工作模式,同時關閉自動協商。
注:若需要永久更改有兩種方法:1. 將上述命令寫入/etc/rc.local文件中,開機自動執行;2. 在/etc/sysconfig/network-scripts/ifcfg-eth0中添加一行ETHTOOL_OPTS="speed 1000 duplex full autoneg off"。這里僅僅以eth0為例,其他設備號同理。
命令格式集合
ethtool DEVNAME Display standard information about device 顯示該設備的標准信息。 ethtool -s|--change DEVNAME Change generic options 更改基本選項 [ speed 10|100|1000 ] //端口速率選項,單位是Mbps [ duplex half|full ] //端口半雙工和全雙工選項 [ port tp|aui|bnc|mii|fibre ] //端口選項,默認為TP [ autoneg on|off ] //自動協商選項,默認為on [ phyad %%d ] //物理地址號,一般為1或0 [ xcvr internal|external ] [ wol p|u|m|b|a|g|s|d... ] [ sopass %%x:%%x:%%x:%%x:%%x:%%x ] [ msglvl %%d ] ethtool -a|--show-pause DEVNAME Show pause options 顯示相應設備中止選項設置情況 ethtool -A|--pause DEVNAME Set pause options 對相應設備進行中止選項設置 [ autoneg on|off ] [ rx on|off ] [ tx on|off ] ethtool -c|--show-coalesce DEVNAME Show coalesce options 顯示相應設備聯合選項設置情況 ethtool -C|--coalesce DEVNAME Set coalesce options 對相應設備進行聯合選項設置 [adaptive-rx on|off] [adaptive-tx on|off] [rx-usecs N] [rx-frames N] [rx-usecs-irq N] [rx-frames-irq N] [tx-usecs N] [tx-frames N] [tx-usecs-irq N] [tx-frames-irq N] [stats-block-usecs N] [pkt-rate-low N] [rx-usecs-low N] [rx-frames-low N] [tx-usecs-low N] [tx-frames-low N] [pkt-rate-high N] [rx-usecs-high N] [rx-frames-high N] [tx-usecs-high N] [tx-frames-high N] [sample-interval N] ethtool -g|--show-ring DEVNAME Query RX/TX ring parameters 查詢接收/發送回環參數 ethtool -G|--set-ring DEVNAME Set RX/TX ring parameters 設置接收/發送回環參數 [ rx N ] [ rx-mini N ] [ rx-jumbo N ] [ tx N ] ethtool -k|--show-offload DEVNAME Get protocol offload information 獲取協議卸載信息 ethtool -K|--offload DEVNAME Set protocol offload 設置協議卸載 [ rx on|off ] [ tx on|off ] [ sg on|off ] [ tso on|off ] [ ufo on|off ] [ gso on|off ] ethtool -i|--driver DEVNAME Show driver information 顯示相應設備的驅動信息 ethtool -d|--register-dump DEVNAME Do a register dump 寄存器轉存 ethtool -e|--eeprom-dump DEVNAME Do a EEPROM dump EEPROM轉存 [ raw on|off ] [ offset N ] [ length N ] ethtool -E|--change-eeprom DEVNAME Change bytes in device EEPROM 更改設備EEPROM中的字節 [ magic N ] [ offset N ] [ value N ] ethtool -r|--negotiate DEVNAME Restart N-WAY negotation 重啟N路交互 ethtool -p|--identify DEVNAME Show visible port identification (e.g. blinking) 顯示可見的端口識別(比如相應端口指示燈會亮) [ TIME-IN-SECONDS ] ethtool -t|--test DEVNAME Execute adapter self test 執行適配器自我測試 [ online | offline ] ethtool -S|--statistics DEVNAME Show adapter statistics 顯示適配器的統計信息 ethtool -h|--help DEVNAME Show this help 顯示幫助
轉自:https://blog.csdn.net/sdvch/article/details/48712519