mii-tool与ethtool的用法详解
From: http://blog.chinaunix.net/uid-20639775-id-154546.html
?
1、mii-tool 配置網(wǎng)絡(luò)設(shè)備協(xié)商方式的工具;
感謝原文作者!原文地址:http://ygning.blog.com.cn/archives/2007/2153373.shtml
1.1 mii-tool 介紹;
mii-tool - view, manipulate media-independent interface status (mii-tool 是查看,管理介質(zhì)的網(wǎng)絡(luò)接口的狀態(tài))
有 時(shí)網(wǎng)卡需要配置協(xié)商方式 ,比如10/100/1000M的網(wǎng)卡半雙工、全雙工、自動(dòng)協(xié)商的配置 。但大多數(shù)的網(wǎng)絡(luò)設(shè)備是不用我們來(lái)修改協(xié)商,因?yàn)榇蠖鄶?shù)網(wǎng)絡(luò)設(shè)置接入的時(shí)候,都采用自動(dòng)協(xié)商來(lái)解決相互通信的問(wèn)題。不過(guò)自動(dòng)協(xié)商也不是萬(wàn)能的,有時(shí)也會(huì)出 現(xiàn)錯(cuò)誤,比如丟包率比較高,這時(shí)就要我們來(lái)指定網(wǎng)卡的協(xié)商方式 。
mii-tool 就是能指定網(wǎng)卡的協(xié)商方式。下面我們說(shuō)一說(shuō)mii-tool的用法;
1.2 mii-tool 的用法;
mii-tool 在更改網(wǎng)絡(luò)設(shè)備通信協(xié)商方式的方法比較簡(jiǎn)單,用 -v 參數(shù)來(lái)查看網(wǎng)絡(luò)接口的狀態(tài);看下面的例子;
mii-tool 更改網(wǎng)絡(luò)接口協(xié)商的方法;
[root@localhost ~]# mii-tool --helpusage: mii-tool [-VvRrwl] [-A media,... | -F media] [interface ...]
??????? -V, --version display version information
??????? -v, --verbose more verbose output 注:顯示網(wǎng)絡(luò)接口的信息;
??????? -R, --reset reset MII to poweron state 注:重設(shè)MII到開啟狀態(tài);
??????? -r, --restart restart autonegotiation 注:重啟自動(dòng)協(xié)商模式;
??????? -w, --watch monitor for link status changes 注:查看網(wǎng)絡(luò)接口連接的狀態(tài)變化;
??????? -l, --log with -w, write events to syslog 注:寫入事件到系統(tǒng)日志;
??????? -A, --advertise=media,... advertise only specified media 注:指令特定的網(wǎng)絡(luò)接口;
??????? -F, --force=media force specified media technology 注:更改網(wǎng)絡(luò)接口協(xié)商方式;
media: 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD,
??????? (to advertise both HD and FD) 100baseTx, 10baseT
* 實(shí)例一:查看網(wǎng)絡(luò)接口的協(xié)商狀態(tài);
[root@localhost ~]# mii-tool -v eth0eth0: 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
注:上面的例子,我們可以看得到是自動(dòng)協(xié)商。注意紅字的部份;
* 實(shí)例二:更改網(wǎng)絡(luò)接口協(xié)商方式;
更 改網(wǎng)絡(luò)接口的協(xié)商方式,我們要用到-F選項(xiàng),后面可以接 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD等參數(shù);
如 果我們想把網(wǎng)絡(luò)接口eth0改為 1000Mb/s全雙工的模式應(yīng)該怎么辦呢?
[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
注:是不是已經(jīng)改過(guò)來(lái)了?當(dāng)然,我們也一樣用ethtool 工具來(lái)更改,比如執(zhí)行下面的命令;
[root@localhost ~]# ethtool -s eth0 speed 100 duplex full
2、ethtool 工具關(guān)于網(wǎng)絡(luò)協(xié)商功能介紹;
ethtool - Display or change ethernet card settings(ethtool 是用來(lái)顯示和更改網(wǎng)卡設(shè)置的工具);這個(gè)工具比較復(fù)雜,功能也特別多。由于洋文比較難懂。所以我們還是把網(wǎng)絡(luò)設(shè)備協(xié)商方式的設(shè)置方法說(shuō)一說(shuō)。
2.1 ethtool 顯示網(wǎng)絡(luò)端口設(shè)置功能;
這 個(gè)功能比較好辦。就是ethtool 后面直接接網(wǎng)絽接口就行;比如下面的例子;
[root@localhost ~]# ethtool eth0Settings 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 注:自動(dòng)協(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 ethX????? //查詢ethX網(wǎng)口基本設(shè)置
ethtool –h??????? //顯示ethtool的命令幫助(help)
ethtool –i ethX??? //查詢ethX網(wǎng)口的相關(guān)信息?
ethtool –d ethX??? //查詢ethX網(wǎng)口注冊(cè)性信息
ethtool –r ethX??? //重置ethX網(wǎng)口到自適應(yīng)模式
ethtool –S ethX??? //查詢ethX網(wǎng)口收發(fā)包統(tǒng)計(jì)
ethtool –s ethX [speed 10|100|1000]\???????? //設(shè)置網(wǎng)口速率10/100/1000M
[duplex half|full]\?????????? //設(shè)置網(wǎng)口半/全雙工
[autoneg on|off]\??????????? //設(shè)置網(wǎng)口是否自協(xié)商
[port tp|aui|bnc|mii]\???????? //設(shè)置網(wǎng)口類型
[phyad N]\?????????????????
[xcvr internal|exteral]\
[wol p|u|m|b|a|g|s|d...]\
[sopass xx:yy:zz:aa:bb:cc]\
[msglvl N]
在 ethtool的-h幫助中我們查看到有這樣的幫助信息;
ethtool -s DEVNAME \???????????????? [ speed 10|100|1000 ] \
???????????????? [ duplex half|full ] \
???????????????? [ port tp|aui|bnc|mii|fibre ] \
???????????????? [ autoneg on|off ] \
* 實(shí)例一:?把網(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沒(méi)有激活;
* 實(shí)例二:?把網(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)卡沒(méi)有激活;
總結(jié)
以上是生活随笔為你收集整理的mii-tool与ethtool的用法详解的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 中文分词之HMM模型详解
- 下一篇: 35.使用拦截器实现权限验证