miitool 和ethtool工具介紹


文章來源:https://www.cnblogs.com/fengyv/p/2423895.html

1.1 mii-tool 介紹;
mii-tool - view, manipulate media-independent interface status (mii-tool 是查看,管理介質的網絡接口的狀態)
有時網卡需要配置協商方式 ,比如10/100/1000M的網卡半雙工、全雙工、自動協商的配置 。但大多數的網絡設備是不用我們來修改協商,因為大多數網絡設置接入的時候,都采用自動協商來解決相互通信的問題。不過自動協商也不是萬能的,有時也會出現錯誤,比如丟包率比較高,這時就要我們來指定網卡的協商方式 。
mii-tool 就是能指定網卡的協商方式。下面我們說一說mii-tool的用法;

1.2 mii-tool 的用法;


mii-tool 在更改網絡設備通信協商方式的方法比較簡單,用 -v 參數來查看網絡接口的狀態;看下面的例子;
mii-tool 更改網絡接口協商的方法;
[root@localhost ~]# mii-tool --help
usage: mii-tool [-VvRrwl] [-A media,... | -F media] [interface ...]
       -V, --version display version information
       -v, --verbose more verbose output 注:顯示網絡接口的信息;
       -R, --reset reset MII to poweron state 注:重設MII到開啟狀態;
       -r, --restart restart autonegotiation 注:重啟自動協商模式;
       -w, --watch monitor for link status changes 注:查看網絡接口連接的狀態變化;
       -l, --log with -w, write events to syslog 注:寫入事件到系統日志;
       -A, --advertise=media,... advertise only specified media 注:指令特定的網絡接口;
       -F, --force=media force specified media technology 注:更改網絡接口協商方式;
media: 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD,
       (to advertise both HD and FD) 100baseTx, 10baseT

* 實例一:查看網絡接口的協商狀態;
[root@localhost ~]# mii-tool -v eth0
eth0: negotiated 100baseTx-FD, link ok
  product info: vendor 00:00:00, model 0 rev 0
basic mode: autonegotiation enabled
  basic status: autonegotiation complete, link ok
  capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  advertising:  100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
注:上面的例子,我們可以看得到是自動協商。注意紅字的部份;


* 實例二:更改網絡接口協商方式;
更改網絡接口的協商方式,我們要用到-F選項,后面可以接 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD等參數;
如果我們想把網絡接口eth0改為 1000Mb/s全雙工的模式應該怎么辦呢?
[root@localhost ~]# mii-tool -F  100baseTx-FD
[root@localhost ~]#mii-tool -v eth0
eth0: 100 Mbit, full duplex, link ok
  product info: vendor 00:00:00, model 0 rev 0
basic mode: 100 Mbit, full duplex
  basic status: link ok
  capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  advertising:  100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
注:是不是已經改過來了?當然,我們也一樣用ethtool 工具來更改,比如執行下面的命令;
[root@localhost ~]# ethtool -s eth0 speed 100 duplex full

2、ethtool 工具關於網絡協商功能介紹;
ethtool - Display or change ethernet card settings(ethtool 是用來顯示和更改網卡設置的工具);這個工具比較復雜,功能也特別多。由於洋文比較難懂。所以我們還是把網絡設備協商方式的設置方法說一說。


2.1 ethtool 顯示網絡端口設置功能;
這個功能比較好辦。就是ethtool 后面直接接網絽接口就行;比如下面的例子;
[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 注:自動協商關閉
        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已經激活;


2.2 ethtool 設置網卡的協商模式;
在ethtool的-h幫助中我們查看到有這樣的幫助信息;
ethtool -s DEVNAME /
                [ speed 10|100|1000 ] /
                [ duplex half|full ] /
                [ port tp|aui|bnc|mii|fibre ] /
                [ autoneg on|off ] /


* 實例一: 把網卡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沒有激活;


* 實例二: 把網卡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網卡沒有激活;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM