改變網絡接口的速度和協商方式的工具
miitool
和
ethtool
經過
mii-tool
和
ethtool
工具來調整網卡的速度、雙工等,這樣能提升網卡的效率;
mii-tool
配置網絡設備協商方式的工具
mii-tool
介紹
mii-tool - view, manipulate media-independent interface status
(
mii-tool
是查看,管理介質的網絡接口的狀態)
有時網卡須要配置協商方式
,好比
10/100/1000M
的網卡半雙工、全雙工、自動協商的配置
。但大多數的網絡設備是不用咱們來修改協商,由於大多數網絡設置接入的時候,都採用自動協商來解決相互通訊的問題。但在有的狀況下,須要咱們手動來設置網卡的協商方式;
mii-tool
就是能指定網卡的協商方式。
註明:我在使用
mii-tool
工具修改協商模式時,提示是錯誤的,由於是在虛擬機中作的,不過虛擬機中的網卡我查看是支持全雙工模式的,但是提示錯誤
SIOCGMIIPHY on 'eth0' failed: Operation not supported
,問題出在那裏也不清楚,用
google
查了下,發現很多人都是這樣的錯誤,也沒說明緣由;不過多數人提示能夠使用
ethtool
工具去修改,我測試了下,還行!還有一種方法是修改
/etc/modules.conf
配置文件;
#
ethtool -s eth0 autoneg off
#
ethtool -s eth0 duplex full
在
/etc/modules.conf
添加內容
alias eth0 bcm5700 line_speed=100 full_duplex=1
options bcm5700 line_speed=100 full_duplex=1
重起!
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
ethtool
工具關於網絡協商功能介紹
ethtool - Display or change ethernet card settings
(
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已經激活;
ethtool
設置網卡的協商模式;
ethtool -s DEVNAME \
[ speed 10|100|1000 ] \
[ duplex half|full ] \
[ port tp|aui|bnc|mii|fibre ] \
[ autoneg on|off ]
\
把網卡
eth0
速度改成
10Mb/s
,採用半雙工;
[root@localhost]# ethtool -s eth1 speed 10 duplex half
[root@localhost]# 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@localhost]# ethtool -s eth1 speed 100 duplex full
[root@localhost]# 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網卡沒有激活;