[LINUX] 如何將網卡定速?

這裡是在 HP DL-380 G4 上,安裝 RHEL ES/AS 3 的版本來做示範,一般的作法都是在 /etc/modules.conf 裡面針對網卡加上 option 來達成定速的目的,如下面所示:
RHAS3 # cat /etc/modules.conf
alias eth0 bcm5700
alias eth1 bcm5700
alias scsi_hostadapter cciss
alias usb-controller usb-uhci
alias usb-controller1 ehci-hcd
options softdog nowayout=0
options bcm5700 auto_speed=0 full_duplex=1 line_speed=100
options bcm5700 auto_speed=0 full_duplex=1 line_speed=100

不過這裡我們改用 ethtool 來達到這個結果,作法為:
在想要定速的網卡,例如:eth1,就去修改 /etc/sysconfig/network-scripts/ifcfg-eth1
在最後加上 ETHTOOL_OPTS="speed 100 duplex full autoneg off" 如下所示:
RHAS3 # cat /etc/sysconfig/network-scripts/ifcfg-eth1
# Broadcom CorporationNetXtreme BCM5704 Gigabit Ethernet
DEVICE=eth1
BOOTPROTO=static
HWADDR=00:0E:7F:F2:2B:B0
BROADCAST=172.17.65.255
IPADDR=172.17.65.3
NETMASK=255.255.255.0
NETWORK=172.17.65.0
ONBOOT=yes
TYPE=Ethernet
ETHTOOL_OPTS="speed 100 duplex full autoneg off"

然後用 "service network restart" 把網路重起後,再用 ethtool ethx (x 為想看的網卡)
應該就會看到如下面的結果:
RHAS3 # ethtool eth1
Settings for eth1:
Supported ports: [ MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: Not reported
Advertised auto-negotiation: No
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: g
Wake-on: d
Current message level: 0x000000ff (255)
Link detected: no
0 Responses