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

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

作者:北南南北51Testing软件测试网1d3]Y?2X+H
来自:LinuxSir.Org51Testing软件测试网4S[&C} |~RAF

1、mii-tool 配置网络设备协商方式的工具;
1.1 mii-tool 介绍;
51Testing软件测试网~#H,s#e#{%Z

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

)g.V8F Ik!}hq051Testing软件测试网MsvxY5PG

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

\/D2[r'L7U]0

e5Q'O$|aeJ0mii-tool 就是能指定网卡的协商方式。下面我们说一说mii-tool的用法;51Testing软件测试网9M9Z @gX


il_1@5URb5t Mi5u01.2 mii-tool 的用法;51Testing软件测试网 vKA-n]@(N C

,["Gf7p'K&Vl3[0mii-tool 在更改网络设备通信协商方式的方法比较简单,用 -v 参数来查看网络接口的状态;看下面的例子;51Testing软件测试网 Y8K't;}7BS

S_dw%TZ+Y&b3M0mii-tool 更改网络接口协商的方法;

"FJio|,E-k?L051Testing软件测试网[*V$ru1t,mo6X

[root@localhost ~]# mii-tool --help51Testing软件测试网xg hU%?
usage: mii-tool [-VvRrwl] [-A media,... | -F media] [interface ...]51Testing软件测试网0VZ ybA;wf,h{
       -V, --version display version information51Testing软件测试网*|#A+d]%YA2b#G4w
       -v, --verbose more verbose output 注:显示网络接口的信息;
"]%z"xU l0       -R, --reset reset MII to poweron state 注:重设MII到开启状态;51Testing软件测试网5BE6Gl.TbFfpf
       -r, --restart restart autonegotiation 注:重启自动协商模式;51Testing软件测试网P;xo1r-kA
       -w, --watch monitor for link status changes 注:查看网络接口连接的状态变化;51Testing软件测试网L EV cW
       -l, --log with -w, write events to syslog 注:写入事件到系统日志51Testing软件测试网*PAbNXI
       -A, --advertise=media,... advertise only specified media 注:指令特定的网络接口;
2p1I$~ Pq1O(q.R9{0       -F, --force=media force specified media technology 注:更改网络接口协商方式;51Testing软件测试网]{ Kz5S@
media: 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD,
.H9|.jh:CT0       (to advertise both HD and FD) 100baseTx, 10baseT

}:J6ba;S6Fef3s,F0

nH\:x;x H-s(Ix;l0

|:eIp[g8u V~0* 实例一:查看网络接口的协商状态;

]4emt O4|2Q,][$D0
[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

)G F9F'{C#q5U0注:上面的例子,我们可以看得到是自动协商。注意红字的部份;

q @+z'_eLi051Testing软件测试网*ui9P6w"W t4qu

* 实例二:更改网络接口协商方式;51Testing软件测试网,Z7aqPb/@!D W$X

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

y0p7y:v2H051Testing软件测试网A0g$P5t.DNa*\uxb

如果我们想把网络接口eth0改为 1000Mb/s全双工的模式应该怎么办呢?51Testing软件测试网m$K m!o t7I

[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

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

Oa2W[$n p^0

0i2[%A'a4Ce0

[root@localhost ~]# ethtool -s eth0 speed 100 duplex full
51Testing软件测试网7j0VP*hs B(eT6kN#v

O ~@Fd6s0

3n)x3wp*C$t$pL y {d02、ethtool 工具关于网络协商功能介绍;
ethtool - Display or change ethernet card settings(ethtool 是用来显示和更改网卡设置的工
"L yCZi(cqR0具);这个工具比较复杂,功能也特别多。由于洋文比较难懂。所以我们还是把网络设备协商方式的设51Testing软件测试网9@^!}_@P$H*SU0t{
置方法说一说。

}7M YYO/H!x7H5U02.1 ethtool 显示网络端口设置功能;
这个功能比较好办。就是ethtool 后面直接接网絽接口就行;比如下面的例子;
51Testing软件测试网4Sl%w[3sR

[root@localhost ~]# ethtool eth0
}5WN yy P0Settings for eth0:51Testing软件测试网3c~@3HA:u(I
        Supported ports: [ TP MII ]
Pb0q;HZ@R7]N0        Supported link modes: 10baseT/Half 10baseT/Full51Testing软件测试网/Zm `+M4x8PGT,gUs0k f(d
                                100baseT/Half 100baseT/Full
rME3B:dX#q8qH0        Supports auto-negotiation: Yes51Testing软件测试网t8T"T5I1q0VU-gA!`/{n
        Advertised link modes: 10baseT/Half 10baseT/Full
,PuUp ]6d5o0                                100baseT/Half 100baseT/Full
Ty0BM;T~&Qg0        Advertised auto-negotiation: No 注:自动协商关闭51Testing软件测试网O PU Xt\
        Speed: 100Mb/s 注:速度 100Mb
Til?O-}xv5[0        Duplex: Full 注:全双工
D"oj8Tz q s0        Port: MII
?(bL5C_"Nxb5h0        PHYAD: 3251Testing软件测试网7Ft*d$p$j
        Transceiver: internal
]3{C!@q*N&G)z0        Auto-negotiation: off51Testing软件测试网@m{+i.Rd
        Supports Wake-on: pumbg
!?5yy|mB0        Wake-on: d51Testing软件测试网DT t&KT$O7Ma@
        Current message level: 0x00000007 (7)51Testing软件测试网Cp\,N7P1Lf"|
        Link detected: yes 注:eth0已经激活;
51Testing软件测试网 aTC4c[8e

#dV{*o2jwOu2H8M0

I N-t2qg"xy"_d"C02.2 ethtool 设置网卡的协商模式;
在ethtool的-h帮助中我们查看到有这样的帮助信息;
51Testing软件测试网S_`J;WM

ethtool -s DEVNAME \51Testing软件测试网Bu D!z5RS
                [ speed 10|100|1000 ] \51Testing软件测试网1T&g+eQJQ
                [ duplex half|full ] \
Ixj B8A0                [ port tp|aui|bnc|mii|fibre ] \51Testing软件测试网QLVe"Jq
                [ autoneg on|off ] \

MlSLxb#jC051Testing软件测试网&O)mLnyfn

u&vk%|jU&W0* 实例一:把网卡eth0 速度改为10Mb/s,采用半双工;51Testing软件测试网OO]n5If g b

[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没有激活;

:bc#j;x4s0* 实例二:把网卡eth0 速度改为100Mb/s,采用全双工;

!^V1K t|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网卡没有激活;

9EFN#u-NrNk r051Testing软件测试网@k7tO3QL }j T9h

%Z#H[#Y%Z?^\7q e X0

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

 

评分:0

我来说两句

Open Toolbar