发新话题
打印

如何改变一个网卡的速度,工作方式或者其他的参数?

如何改变一个网卡的速度,工作方式或者其他的参数?

解决方法:
根据你系统安装的网卡的类型,可以下面的两个工具中的一个来改变网卡的速度,工作方式(半双工和全双工),和其他的选项:ethtool或者mii-tool. 如果一些网卡不能够通过ethtool来设置,这种情况下,请尝试使用mii-tool,反之亦然。首先检查下面的软件包是否安装。



# rpm -q ethtool# rpm -q net-tools</PRE>如果软件包没有安装,将输出下面的结果:



# rpm -q ethtoolpackage ethtool is not installed# rpm -q net-toolspackage net-tools is not installed</PRE>如果这些软件包已经安装,这个命令将输出软件包的版本号:



# rpm -q ethtoolethtool-1.2-1# rpm -q net-toolsnet-tools-1.60-20.1</PRE>如果这些软件包没有安装,可以从安装光盘来安装。如果你的系统已经在红帽网络(RHN)注册,也可以使用up2date安装. 如果你的系统已经注册到RHN上,执行up2date ethtool 或者 up2date net-tools. RHN就会下载和安装这些软件包到你的系统上.

下一步,查看网络接口的当前设置,使用下面的语法: command device_name, 其中command 是 ethtool 或者 mii-tool,device_name 是eth0, eth1等等.下面的例子来自2个不同的网卡:



# ethtool eth0Settings 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: Yes        Speed: 100Mb/s        Duplex: Full        Port: Twisted Pair        PHYAD: 1        Transceiver: internal        Auto-negotiation: on        Supports Wake-on: puag        Wake-on: g        Link detected: yes# mii-tool eth1eth1: no autonegotiation, 10baseT-HD, link ok</PRE>关于如何设置网卡的选项:比如全双工,半双工和改变速度等等,可以查看man的帮助手册.



# man ethtool # man mii-tool</PRE>一旦决定了你的设置,可以立即通过命令行进行设置。如果使用ethtool,为了使eth0每次启动时,都完成这个设置,在/etc/sysconfig/network-scripts/ifcfg-eth0加入下面的信息.



ETHTOOL_OPTS="speed 100 duplex full autoneg off"</PRE>不幸的是,除非把设置命令和参数放在/etc/rc.local文件中(在后面解释),没有一个办法可以使这些设置在系统每次启动的时候永久保存,这样系统每次启动的最后阶段就会运行这个文件中的命令,也可以通过创建启动脚本让相关的设置在启动过程的前期运行.

作为最后的一个办法,你可以把他们放在/etc/rc.local文件中。在/etc/rc.local文件中,把ethtool和mii-tool字符串和设置选项分别放在一个新行中。下面的例子会对你的配置有帮助:



#!/bin/sh## This script will be executed *after* all the other init scripts.# You can put your own initialization stuff in here if you don't# want to do the full Sys V style init stuff.ethtool -s eth0 speed 100 duplex full autoneg offmii-tool -F 100baseTx-FD eth1touch /var/lock/subsys/local</PRE>如果你保存了这些改变,当系统下次启动的时候,网卡的速度和工作模式就会按照你设置的来工作(如果你的设置选项对于这个网卡是合适的)。

注: 有些网卡对于ethtool是不工作的,如果是这种情况,可以尝试使用mii-tool反之亦然.


<SCRIPT src="http://www.google-analytics.com/urchin.js" type=text/javascript></SCRIPT><SCRIPT type=text/javascript>_uacct = "UA-838462-1";urchinTracker();</SCRIPT><!-- FOOTER=stretchy_v1.html updated 112601 -->      

TOP

发新话题