Adjust the duplex and speed of the network card under Linux

Original post: http://freesky.dns-dns.com/read.php?tid=46 The original
poster Posted on: 30 days ago Just
look at the original poster |
Adjust the working mode
of the network card under Linux, the current network card is generally 10 /100M/1000M adaptive working mode, we seldom consider its working mode when configuring network card parameters, but on key devices with high traffic such as routers, switches, proxy servers, etc., we should specify the correct working mode for it , This can improve communication efficiency. In the Linux environment, we can use the system's own tool mii-tool (this is a command to set the working mode of the network card) to configure the working mode of the network card. Let's talk about how to use it in detail below.

  1. To view the working mode of the network card, enter the command:

One, use mii-tool to adjust

#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: …

It can be seen from the above information that this network card works in 100M full duplex adaptive mode, and "100BaseTx-FD" means 100M Full Duplex.

  1. To change the working mode of the network card, enter the command:

#mii-tool -F media [interface]

Media optional modes include 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD, etc. Interface represents the selected network card, such as eth0, eth1, etc. The default is eth0.

For example, to set the network card to work in 10M half-duplex mode, enter the command:
#mii-tool -F 1000baseTx-FD eth2

  1. To restore the adaptive working mode of the network card, enter the command:

#mii-tool -r eth2

Second, use ethtool to adjust

ethtool ethX //Query the basic settings of the ethX network port
ethtool -h //Display the command help of ethtool (help)
ethtool -i ethX //Query the information of the ethX network port
ethtool -d ethX //Query the registration information of the ethX network port
ethtool --R ethX //Reset the ethX network port to the adaptive mode
ethtool –S ethX //Query the statistics of receiving and sending packets on the ethX network port
ethtool –s ethX [speed 10|100|1000]/ //Set the network port rate to 10/100/ 1000M
[duplex half|full]/ //Set the network port half/full duplex
[autoneg on|off]/ //Set whether the network port is auto-negotiation
[port tp|aui|bnc|mii]/ //Set the network port type

For example: query the working mode of eth0 network card:
[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
For example: set the network card eth1 to 100M full duplex, auto-negotiation is off

ethtool -s eth1 autoneg off speed 100 duplex full

After the network card mode is modified, if the system is restarted, it will be restored. In order to save our modified settings, there are two aspects:
First, the
ethtool settings can be saved through the /etc/sysconfig/network-scripts/ifcfg-ethX file, and then under the device The option is activated at the next startup.
For example: ethtool -s eth0 speed 100 duplex full autoneg off
This command sets the eth0 device to full duplex autonegation, and the speed is 100Mbs. To set these parameters when eth0 is started, modify the file /etc/sysconfig/network-scripts/ifcfg-eth0 and add the following line:
ETHTOOL_OPTS=“speed 100 duplex full autoneg off”
2.
Write the ethtool setting to /etc/rc. In d/rc.local such as:

#!/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" to
search for more related articles: network card adjustment

Guess you like

Origin blog.csdn.net/Connor_xie/article/details/107234944