Linux(Windows)下如何改变网卡的LinkSpeed工作模式

       由于办公环境改变,网线不够长,翻箱捣柜找出一个HUB接上。可无论如何也获取不到IP。一看HUB才知道,原来HUB的带宽才10M,而我的网卡是10/100M自适应模式(比较老的网卡自适应能力比较差)。可能是网卡和HUB自适应模式不兼容引起的,网卡速率不能够自动识别,从而无法达到网络通信。因此我的网卡只能设置在10M的环境下才能正常运行。
 
Windows:
       其实在Windows下解决方法很简单,在“设备管理器”-“网卡属性”-“高级”中的“LinkSpeed/Duplex Mode”设置为10M的就可以了。
 
 
Linux:
        Linux下的实现方法很多,不过配置起来却很困难,其实只要用mii-tool那实现起来就相当简单了,如下:
 
写一个脚本
********************************
ifconfig eth0 up
mii-tool -F 10baseT-FD
ifup eth0
********************************
然后把脚本加入/etc/rc.d/init.d/,让它开机自动运行就OK了。看,是不是很简单啊!:-)
 
:mii-tool -F 10baseT-FD 这句是将网卡的的LinkSpeed改为10M全双工模式
 
 ------------------------------------------------------------------------------
 ------------------------------------------------------------------------------
       以下是mii-tool工具的使用方法,从[url]http://linux-ip.net/html/tools-mii-tool.html[/url]上摘抄的,供大家一起学习。

         A key tool for determining if you are connected to the Ethernet, and if so, at what speed. The  mii-tool program does not support all Ethernet devices, as some Ethernet devices have their own vendor-supplied tools to report the same information. The  mii-tool source code is based on a tool called  mii-diag which provides slightly more information but is less user friendly.
The information reported by  mii-tool is quite terse. The following table should clarify the meaning of the speeds you'll encounter in output from  mii-tool(There is a standard speed/Ethernet transmission style supported by  mii-tool to which I have not referred. That is 100BaseT4. 100BaseT4 provides support for 100 megabit Ethernet networking over Category 3 rated cable. This is probably not a concern for most recently upgraded network infrastructure. The standard networking cable pulled in new construction and renovation is now Category 5 cable which supports 100Base-Tx-FD and possibly gigabit Ethernet. So, let's relegate 100BaseT4 to this footnote, and resume.)
Table B.2. Ethernet Port Speed Abbreviations
Port SpeedDescription
10baseT-HD10 megabit half duplex
10baseT-FD10 megabit full duplex
100baseTx-HD100 megabit half duplex
100baseTx-FD100 megabit full duplex
The raw number indicates the number of bits which can be exchanged between two Ethernet devices over the wire. So 10 megabit Ethernet can support the transmission of ten million bits per second. The suffix to each identifier indicates whether both hosts can send and receive simultaneously or not. Half duplex means that each device can either send or receive in the same instant. Full duplex means that both devices can send and receive simultaneously.
The simplest use of  mii-tool reports the link status of all Ethernet devices on a system. Any argument to  mii-tool is interpreted as an interface name to query for link status.
Example B.21. Detecting link layer status with mii-tool
[root@tristan]# mii-tool
eth0: negotiated 100baseTx-FD, link ok
[root@tristan]# mii-tool -v
eth0: negotiated 100baseTx-FD, link ok
product info: vendor 08:00:17, model 1 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
In the above example, we can infer that tristan has only one Ethernet device (or no Ethernet drivers loaded for any other present Ethernet devices). The first Ethernet device has successfully negotiated a 100 megabit full duplex connection with the device to which it is connected.
Although a great rarity, you may have occasion to dictate to the Ethernet interface the speed at which it should talk to the switch or hub.  mii-tool supports a mode of operation under which you indicate supported modes for autonegotiation. Normally, two connected devices will negotiate the fastest possible commonly shared speed. You can select what speeds you want to support on an Ethernet interface by using  mii-tool.
Example B.22. Specifying Ethernet port speeds with mii-tool --advertise
[root@tristan]# mii-tool mii-tool --advertise 10baseT-HD,10baseT-FD
restarting autonegotiation...
[root@tristan]# mii-tool
eth0: negotiated 10baseT-FD, link ok
After we specified that we wished only to support 10baseT-HD and 10baseT-FD as acceptable speeds, mii-tool caused the Ethernet driver to renegotiate port speed with the attached device. Here we selected 10baseT-FD.
Example B.23. Forcing Ethernet port speed with mii-tool --force
[root@tristan]# mii-tool --force 10baseT-FD
[root@tristan]# mii-tool
eth0: 10 Mbit, full duplex, link ok
[root@tristan]# mii-tool --restart
restarting autonegotiation...
[root@tristan]# mii-tool
eth0: negotiated 100baseTx-FD, link ok
After manipulating the speed at which the Ethernet driver would communicate with the connected device on tristan, we chose to restart the autonegotiation process without forcing a particular speed or advertising a particular speed.
So, if you must know at what speed your linux machine is connected to another device,  mii-tool comes to your rescue.
 


 
本文转自 saturn 51CTO博客,原文链接:http://blog.51cto.com/saturn/33663

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值