Linux下调整网卡的工作模式

Linux下调整网卡的工作模式


发布日期: 1970-01-01 更新日期: 2015-01-30 编辑:giser 浏览次数: 4744

标签:

摘要: 现在的网卡一般都是10/100M/1000M自适应工作模式,在配置网卡参数时我们很少考虑它的工作模式,但是在路由器、交换机、代理服务器等通信量比较大的关键设 备上,我们应该为它指定正确的工作模式,这样可以提高通信效率。在Linux环境下,我们可以使用系统自带的...

现在的网卡一般都是10/100M/1000M自适应工作模式,在配置网卡参数时我们很少考虑它的工作模式,但是在路由器、交换机、代理服务器等通信量比较大的关键设 备上,我们应该为它指定正确的工作模式,这样可以提高通信效率。在Linux环境下,我们可以使用系统自带的工具mii- tool(这是专门设置网卡工作模式的命令)来配置网卡工作模式。下面我们具体来谈一下它的使用方法。

一,用mii-tool来调整

1. 查看网卡的工作模式,输入命令:

# mii-tool -v

eth0: negotiated 100baseTx-FD,link ok product info:Vendor 00:05:be,model 8 rev
0 basic status: autonegotiation complete,link ok basic mode:autonegotiation
enabled. Capabilities: .............. 

从以上信息中可以看出,这块网卡工作在100M全双工自适应模式下 ,“100BaseTx-FD”意为100M Full Duplex。

2. 更改网卡的工作模式,输入命令:

mii-tool -F media [interface]

media可选的模式有100baseTx-FD、100baseTx-HD、10baseT-FD、10baseT-HD等。Interface代表所选择的网卡,如eth0、eth1等,默认为eth0。 例如,设置网卡工作在10M半双工模式下,输入命令:

mii-tool -F 1000baseTx-FD eth2

3. 恢复网卡的自适应工作模式,输入命令:

mii-tool -r eth2

二,用ethtool来调整

ethtool ethX //查询ethX网口基本设置 ethtool –h //显示ethtool的命令帮助(help) ethtool –i ethX //查询ethX网口的相关信息 ethtool –d ethX //查询ethX网口注册性信息 ethtool –r ethX //重置ethX网口到自适应模式 ethtool –S ethX //查询ethX网口收发包统计 ethtool –s ethX [speed 10|100|1000]/ //设置网口速率10/100/1000M [duplex half|full]/ //设置网口半/全双工 [autoneg on|off]/ //设置网口是否自协商 [port tp|aui|bnc|mii]/ //设置网口类型 例如:查询eth0网卡的工作模式:

[root@freesky ~]# ethtool eth0 Settings for eth0: Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full
1000baseT/Full Supports auto-negotiation: Yes Advertised link modes:
10baseT/Half 10baseT/Full 100baseT/Half 100baseT/Full 1000baseT/Full
Advertised auto-negotiation: Yes Speed: 1000Mb/s Duplex: Full Port: Twisted
Pair PHYAD: 0 Transceiver: internal Auto-negotiation: on Supports Wake-on:
umbg Wake-on: g Current message level: 0x00000007 (7) Link detected: yes
例如:将网卡eth1设置为100M全双工、自动协商关闭

# ethtool -s eth1 autoneg off speed 100 duplex full

网卡模式修改后如果系统重启好就恢复原样了,为了保存我们修改好的设置有两种方面: 一, ethtool设置可通过/etc/sysconfig/network- scripts/ifcfg-ethX文件保存,从而在设备下次启动时激活选项。 例如:ethtool -s eth0 speed 100 duplex full autoneg off 此指令将eth0设备设置为全双工自适应,速度为100Mbs。若要eth0启动时设置这些参数, 修改文件/etc/sysconfig/network-scripts/ifcfg-eth0 ,添加如下一行: ETHTOOL_OPTS="speed 100 duplex full autoneg off" 二, 将ethtool设置写入/etc/rc.d/rc.local之中如:

!/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.

touch /var/lock/subsys/local ETHTOOL_OPTS="speed 100 duplex full autoneg off"

关注公众号
获取免费资源

随机推荐


Copyright © Since 2014. 开源地理空间基金会中文分会 吉ICP备05002032号

Powered by TorCMS

OSGeo 中国中心 邮件列表

问题讨论 : 要订阅或者退订列表,请点击 订阅

发言 : 请写信给: osgeo-china@lists.osgeo.org