改变网络接口的速度和通信方式的工具miitool 和ethtool

上一篇 / 下一篇  2007-10-11 23:42:38 / 个人分类:网络测试工具

作者:北南南北
V'yD aM0来自:LinuxSir.Org

hE ~ ?|eY.g"h0
1、mii-tool 配置网络设备协商方式的工具;
1.1 mii-tool 介绍;
51Testing软件测试网M G4P.@,f x Ij!^)a

mii-tool - view, manipulate media-independent interface status (mii-tool 是查看,管理介质的网络接口的状态)

8?&s;f}$]0Z!? ]3cT051Testing软件测试网:t3CYU ? c2c+_b~

有时网卡需要配置协商方式 ,比如10/100/1000M的网卡半双工、全双工、自动协商的配置 。但大多数的网络设备是不用我们来修改协商,因为大多数网络设置接入的时候,都采用自动协商来解决相互通信的问题。不过自动协商也不是万能的,有时也会出现错误,比如丢包率比较高,这时就要我们来指定网卡的协商方式 。51Testing软件测试网?MtWLNl\/d

VWR!D}7E0mii-tool 就是能指定网卡的协商方式。下面我们说一说mii-tool的用法;51Testing软件测试网#Y,n Loq


!Wd;N@-}IN;YT6w01.2 mii-tool 的用法;
ix\j5L Huok0

u/SH9f ?4w+D0wrA0mii-tool 在更改网络设备通信协商方式的方法比较简单,用 -v 参数来查看网络接口的状态;看下面的例子;51Testing软件测试网E?6?K.BC&j

51Testing软件测试网T$|Qi[`^ h#H

mii-tool 更改网络接口协商的方法;51Testing软件测试网;LmkV&Ig\ U0d2Jk"L

%j VefP;p"C0

[root@localhost ~]# mii-tool --help
K1kmC,t*@!`$wUT5N0usage: mii-tool [-VvRrwl] [-A media,... | -F media] [interface ...]51Testing软件测试网'_!V A E ]%O],Hp
       -V, --version display version information
Yz F#L-f;U@0       -v, --verbose more verbose output 注:显示网络接口的信息;
6U-S9`+@a0       -R, --reset reset MII to poweron state 注:重设MII到开启状态;
{{D&I;i zq0       -r, --restart restart autonegotiation 注:重启自动协商模式;
HQ,o^){2Q0       -w, --watch monitor for link status changes 注:查看网络接口连接的状态变化;51Testing软件测试网/V MMR.y:\
       -l, --log with -w, write events to syslog 注:写入事件到系统日志
@LrGf7?u`0       -A, --advertise=media,... advertise only specified media 注:指令特定的网络接口;51Testing软件测试网D"oE@2I9ry+]k
       -F, --force=media force specified media technology 注:更改网络接口协商方式;51Testing软件测试网(f@W/exJ
media: 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD,51Testing软件测试网?(t$Y\ iE
       (to advertise both HD and FD) 100baseTx, 10baseT
51Testing软件测试网1y3r0zs9X,yd-e

51Testing软件测试网\^c(m:?(HX

51Testing软件测试网\V"^4Mk;?:j uJ;uU

* 实例一:查看网络接口的协商状态;

!{2e8]'h?!f0
[root@localhost ~]# mii-tool -v eth0
eth0: negotiated 100baseTx-FD, link ok
  product info: vendor 00:00:00, model 0 rev 0basic mode:   autonegotiation enabledbasic 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
51Testing软件测试网fM){ oZEK2_

注:上面的例子,我们可以看得到是自动协商。注意红字的部份;

0i9n,y b:acT8{051Testing软件测试网7Z\7L4^&z{ W R+txF+a

* 实例二:更改网络接口协商方式;51Testing软件测试网!auQe ~4A S+P

51Testing软件测试网)D2zdV}

更改网络接口的协商方式,我们要用到-F选项,后面可以接 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD等参数;

&kx+wNv051Testing软件测试网m0T~6N'\%F,B

如果我们想把网络接口eth0改为 1000Mb/s全双工的模式应该怎么办呢?51Testing软件测试网c*a*s9HE {D)g G vt

[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 0basic mode:   100 Mbit, full duplexbasic status: link ok
  capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
  advertising:  100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
51Testing软件测试网Y"\^ xU7W,mYtnZ

注:是不是已经改过来了?当然,我们也一样用ethtool 工具来更改,比如执行下面的命令;

3iM-h"ZYL}0

2n.s1^}FZkQ3e0

[root@localhost ~]# ethtool -s eth0 speed 100 duplex full

B1wP@T;B~.g051Testing软件测试网;l f;`7u.A(z


6|]j H;[[gcnX-Z02、ethtool 工具关于网络协商功能介绍;
ethtool - Display or change ethernet card settings(ethtool 是用来显示和更改网卡设置的工51Testing软件测试网#Ep3pbb9}{h
具);这个工具比较复杂,功能也特别多。由于洋文比较难懂。所以我们还是把网络设备协商方式的设
/mIr s9Ddx0置方法说一说。

Zv(GrF02.1 ethtool 显示网络端口设置功能;
这个功能比较好办。就是ethtool 后面直接接网絽接口就行;比如下面的例子;

#Xp? wA0

[root@localhost ~]# ethtool eth051Testing软件测试网R`!nI1fP B
Settings for eth0:51Testing软件测试网)F"f_.v!S+H7Q+@4t/o
        Supported ports: [ TP MII ]51Testing软件测试网Srl:sh.E T;@
        Supported link modes: 10baseT/Half 10baseT/Full
~7RT*Wr3@)?'LC0                                100baseT/Half 100baseT/Full51Testing软件测试网0\"S*?/I1i
        Supports auto-negotiation: Yes51Testing软件测试网 D$BJU$]Uyy5u3aq8d
        Advertised link modes: 10baseT/Half 10baseT/Full51Testing软件测试网&V/G)h,os9u {
                                100baseT/Half 100baseT/Full51Testing软件测试网x6i/G8w7M:wC
        Advertised auto-negotiation: No 注:自动协商关闭51Testing软件测试网V.\n,yjk$y
        Speed: 100Mb/s 注:速度 100Mb
3T r!Pw4M6G0        Duplex: Full 注:全双工
$D_Ax?!O0        Port: MII51Testing软件测试网4P"|6H-uA
        PHYAD: 32
yT\M&@kB.O(^0        Transceiver: internal
:A(S#o EI _]0        Auto-negotiation: off51Testing软件测试网8UQmG A0D
        Supports Wake-on: pumbg51Testing软件测试网3u(d%x9t1X)CO!b#c
        Wake-on: d51Testing软件测试网 mY X#P7N%I p
        Current message level: 0x00000007 (7)51Testing软件测试网sz{7m e#IeH#W\
        Link detected: yes 注:eth0已经激活;

?8L#HtK\0

pz2U3{4U:f9X)|I6Do0
51Testing软件测试网sn)_	x[
2.2 ethtool 设置网卡的协商模式;
在ethtool的-h帮助中我们查看到有这样的帮助信息;
51Testing软件测试网y;T~sS

ethtool -s DEVNAME \51Testing软件测试网 \Lv.X}2F,ya
                [ speed 10|100|1000 ] \
v)S {0g8Gf$H/X:_?0                [ duplex half|full ] \51Testing软件测试网'XH|hJ6H,HT2oh
                [ port tp|aui|bnc|mii|fibre ] \51Testing软件测试网OG2a XQ
                [ autoneg on|off ] \
51Testing软件测试网;b4G"l(q1hLcN

C` Z?8Vx!a(FJ051Testing软件测试网EtK I"XL

* 实例一:把网卡eth0 速度改为10Mb/s,采用半双工;

U~ _,z}2nR4o2I0
[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没有激活;

N5gumV$j-NS0* 实例二:把网卡eth0 速度改为100Mb/s,采用全双工;

}xxv/@6k5ZZ#^0
[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网卡没有激活;

2d zT \P1e _s&j0
GQ3C:l7w,V7cL.k0

3?R"A^;tJ0

TAG: 网络测试工具 网络接口速度 miitool ethtool

 

评分:0

我来说两句

Open Toolbar