linux ethtool 查看网卡状态
ethtool?工具關(guān)于網(wǎng)絡(luò)協(xié)商功能介紹;?
ethtool?-?Display?or?change?ethernet?card?settings(ethtool?是用來顯示和更改網(wǎng)卡設(shè)置的工具);這個工具比較復(fù)雜,功能也特別多。由于洋文比較難懂。所以我們還是把網(wǎng)絡(luò)設(shè)備協(xié)商方式的設(shè)置方法說一說。
2.1?ethtool?顯示網(wǎng)絡(luò)端口設(shè)置功能;
這個功能比較好辦。就是ethtool?后面直接接網(wǎng)絽接口就行;比如下面的例子;
[root@localhost?~]#?ethtool?eth0
Settings?for?eth0:
????????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?注:自動協(xié)商關(guān)閉
????????Speed:?100Mb/s?注:速度?100Mb
????????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:?yes?注:eth0已經(jīng)激活;
2.2?ethtool?設(shè)置網(wǎng)卡的協(xié)商模式;
在ethtool的-h幫助中我們查看到有這樣的幫助信息;
ethtool?-s?DEVNAME?/
????????????????[?speed?10|100|1000?]?/
????????????????[?duplex?half|full?]?/
????????????????[?port?tp|aui|bnc|mii|fibre?]?/
????????????????[?autoneg?on|off?]?/
?
*?實例一:?把網(wǎng)卡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沒有激活;
*?實例二:?把網(wǎng)卡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網(wǎng)卡沒有激活;
?
命令描述:
ethtool?是用于查詢及設(shè)置網(wǎng)卡參數(shù)的命令。?
使用概要:
ethtool?ethx???????//查詢ethx網(wǎng)口基本設(shè)置,其中?x?是對應(yīng)網(wǎng)卡的編號,如eth0、eth1等等
ethtool?–h????????//顯示ethtool的命令幫助(help)
ethtool?–i?ethX????//查詢ethX網(wǎng)口的相關(guān)信息?
ethtool?–d?ethX????//查詢ethX網(wǎng)口注冊性信息
ethtool?–r?ethX????//重置ethX網(wǎng)口到自適應(yīng)模式
ethtool?–S?ethX????//查詢ethX網(wǎng)口收發(fā)包統(tǒng)計
ethtool?–s?ethX?[speed?10|100|1000]?[duplex?half|full]??[autoneg?on|off]????????//設(shè)置網(wǎng)口速率10/100/1000M、設(shè)置網(wǎng)口半/全雙工、設(shè)置網(wǎng)口是否自協(xié)商
使用舉例:
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
相關(guān)參考:
1)[root@linux?/]#?which?ethtool????????//查詢?ethtool?存放的路徑
????/sbin/ethtool
2)[root@linux?/]#?rpm?-qf?/sbin/ethtool????????//查詢?ethtool?的版本信息
???ethtool-1.6-5
3)將?ethtool?設(shè)置永久保存在網(wǎng)絡(luò)設(shè)備的方法
????????解決方法一:
????????ethtool?設(shè)置可通過?/etc/sysconfig/network-scripts/ifcfg-ethX?文件保存,從而在設(shè)備下次啟動時激活選項。?
例如:ethtool?-s?eth0?speed?100?duplex?full?autoneg?off
此指令將eth0設(shè)備設(shè)置為全雙工自適應(yīng),速度為100Mbs。若要eth0啟動時設(shè)置這些參數(shù),?修改文件/etc/sysconfig/network-scripts/ifcfg-eth0?,添加如下一行:?
ETHTOOL_OPTS="speed?100?duplex?full?autoneg?off"
?????????解決方法二:
?????????將ethtool設(shè)置寫入/etc/rc.d/rc.local之中。
總結(jié)
以上是生活随笔為你收集整理的linux ethtool 查看网卡状态的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 原神天云草实怎么获得,原神天云草实获得方
- 下一篇: linux下查看系统socket读写缓冲