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 Speed Description
10baseT-HD 10 megabit half duplex
10baseT-FD 10 megabit full duplex
100baseTx-HD 100 megabit half duplex
100baseTx-FD 100 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

相关文章
|
5天前
|
自然语言处理 数据库 iOS开发
DBeaver Ultimate Edtion 25.0 Multilingual (macOS, Linux, Windows) - 通用数据库工具
DBeaver Ultimate Edtion 25.0 Multilingual (macOS, Linux, Windows) - 通用数据库工具
43 12
DBeaver Ultimate Edtion 25.0 Multilingual (macOS, Linux, Windows) - 通用数据库工具
|
1天前
|
安全 Unix Linux
Veritas NetBackup 11 for Linux & Windows - 领先的企业备份和恢复解决方案
Veritas NetBackup 11 for Linux & Windows - 领先的企业备份和恢复解决方案
12 0
Veritas NetBackup 11 for Linux & Windows - 领先的企业备份和恢复解决方案
|
1月前
|
人工智能 Linux iOS开发
Burp Suite Professional 2025.2 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
Burp Suite Professional 2025.2 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
59 12
Burp Suite Professional 2025.2 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
|
16天前
|
Linux 虚拟化 Docker
Linux服务器部署docker windows
在当今软件开发中,Docker成为流行的虚拟化技术,支持在Linux服务器上运行Windows容器。流程包括:1) 安装Docker;2) 配置支持Windows容器;3) 获取Windows镜像;4) 运行Windows容器;5) 验证容器状态。通过这些步骤,你可以在Linux环境中顺利部署和管理Windows应用,提高开发和运维效率。
73 1
|
17天前
|
NoSQL IDE MongoDB
Studio 3T 2025.4 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.4 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
29 0
Studio 3T 2025.4 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
17天前
|
安全 Linux iOS开发
Gitea Enterprise 23.4.0 (Linux, macOS, Windows) - 本地部署的企业级 Gti 服务
Gitea Enterprise 23.4.0 (Linux, macOS, Windows) - 本地部署的企业级 Gti 服务
36 0
Gitea Enterprise 23.4.0 (Linux, macOS, Windows) - 本地部署的企业级 Gti 服务
|
21天前
|
数据管理 Linux iOS开发
Splunk Enterprise 9.4.1 (macOS, Linux, Windows) 发布 - 机器数据管理和分析
Splunk Enterprise 9.4.1 (macOS, Linux, Windows) 发布 - 机器数据管理和分析
24 0
Splunk Enterprise 9.4.1 (macOS, Linux, Windows) 发布 - 机器数据管理和分析
|
24天前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.49 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.49 (macOS, Linux, Windows) - 开源渗透测试框架
36 0
Metasploit Framework 6.4.49 (macOS, Linux, Windows) - 开源渗透测试框架
|
3月前
|
安全 网络协议 Linux
telnet在windows和linux上的使用方法
Telnet是一个简单且强大的网络工具,广泛用于远程管理和网络诊断。尽管存在安全风险,但在受控环境中,Telnet仍然是一个非常有用的工具。通过本文的介绍,您应该能够在Windows和Linux系统上安装并使用Telnet进行各种网络操作。
289 18
|
3月前
|
Ubuntu 网络协议 Linux
快速部署WSL(Windows Subsystem for Linux)
WSL提供了一种轻量级的方法,使开发者能够在Windows上无缝运行Linux环境。通过本文介绍的步骤,可以快速安装、配置和使用WSL,以满足开发和测试的需求。
349 8