歡迎您光臨本站 註冊首頁

Linux下如何改變一個網卡的速度

←手機掃碼閱讀     火星人 @ 2014-03-23 , reply:0

  如何改變一個網卡的速度,工作方式或者其他的參數

  解決方法:

  根據你系統安裝的網卡的類型,可以下面的兩個工具中的一個來改變網卡的速度,工作方式(半雙工和全雙工),和其他的選項:ethtool或者mii-tool. 如果一些網卡不能夠通過ethtool來設置,這種情況下,請嘗試使用mii-tool,反之亦然。首先檢查下面的軟體包是否安裝。

   # rpm -q ethtool
   # rpm -q net-tools

  如果軟體包沒有安裝,將輸出下面的結果:

   # rpm -q ethtool
   package ethtool is not installed
   # rpm -q net-tools
   package net-tools is not installed

  如果這些軟體包已經安裝,這個命令將輸出軟體包的版本號:

   # rpm -q ethtool
   ethtool-1.2-1
   # rpm -q net-tools
   net-tools-1.60-20.1

  如果這些軟體包沒有安裝,可以從安裝光碟來安裝。如果你的系統已經在紅帽網路(RHN)註冊,也可以使用up2date安裝. 如果你的系統已經註冊到RHN上,執行up2date ethtool 或者 up2datenet-tools. RHN就會下載和安裝這些軟體包到你的系統上.

  下一步,查看網路介面的當前設置,使用下面的語法: command device_name, 其中command是 ethtool 或者 mii-tool,device_name 是eth0, eth1等等.下面的例子來自2個不同的網卡:

   # ethtool eth0
   Settings 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 eth1
   eth1: no autonegotiation, 10baseT-HD, link ok

  關於如何設置網卡的選項:比如全雙工,半雙工和改變速度等等,可以查看man的幫助手冊.

   # man ethtool
   # man mii-tool

  一旦決定了你的設置,可以立即通過命令行進行設置。如果使用ethtool,為了使eth0每次啟動時,都完成這個設置,在/etc/sysconfig/network-scripts/ifcfg-eth0加入下面的信息.

   ETHTOOL_OPTS="speed 100 duplex full autoneg off"

  不幸的是,除非把設置命令和參數放在/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 off
   mii-tool -F 100baseTx-FD eth1
   touch /var/lock/subsys/local

  如果你保存了這些改變,當系統下次啟動的時候,網卡的速度和工作模式就會按照你設置的來工作(如果你的設置選項對於這個網卡是合適的)。

  注: 有些網卡對於ethtool是不工作的,如果是這種情況,可以嘗試使用mii-tool反之亦然。

[火星人 ] Linux下如何改變一個網卡的速度已經有515次圍觀

http://coctec.com/docs/linux/show-post-125629.html