We are introducing a certain amount of CentOS computers and I am often asked by regional IT people how they can check and change the configuration of their network cards to reflect the configuration of the attached network Switches. That made me think of this post (my first one on CentOS) in which I will explain how you can determine the current Ethernet connection link speed of your CentOS system.
To do that you can take advantage of ETHTOOL, which is an easy utility that can be used to display and/or change settings of your Ethernet Network cards.
In the following example I will assume that you are willing to change the parameters for your first network card (usually eth0).
The syntax to show the NIC parameters is very simple, just enter:
and look for the Speed parameter:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
Advertised auto-negotiation: Yes
Port: Twisted Pair
Supports Wake-on: g
Current message level: 0x000000ff (255)
Other interesting parameters you could have a look at are the Duplex mode and the Auto-negotiation mode, of course. But, before you can configure this two parameters, you have to better understand what they are used for. The difference between Half-duplex and Full-duplex is straightforward. In Full-duplex communication, the two systems can communicate with one another in both directions at the same time. On the contrary a half-duplex NIC provides also communication in both directions, but only one direction at the time (not simultaneously I mean). Auto-negotiation is an optional Ethernet function that enables devices to automatically exchange information over a link about Speed and Duplex capabilities.
To force your NIC to 1000mb in Full-Duplex and the same time turn off Auto-negotiation on 'eth0' just enter:
ethtool -s eth0 speed 1000 duplex full autoneg off
To disable Auto-negotiation and switch back to Half-Duplex enter the following command:
ethtool -s eth0 duplex half autoneg off
You can play with all these parameters as long as you like until you find the network performance that best suits you. Just remember that under CentOS any change made through the command line is lost at the next reboot. To make the changes permanent, edit your network card configuration file which is located under the /etc/sysconfig/network-scripts directory. Inside this folder, each interface will have a file called 'ifcfg-ethX'. So for 'eth0' look for the file 'ifcfg-eth0' and add the following line to force your card to transmit at 1Gbps:
ETHTOOL_OPTS="autoneg on speed 1000 duplex full"
If you don't have ETHTOOL, know that it can be downloaded from SourceForge.
Here's the possible switches you can use with ETHTOOL for your reference:
- -a queries the specified ethernet device for pause parameter information.
- -A change the pause parameters of the specified ethernet device.
- autoneg on|off: Specify if pause autonegotiation is enabled.
- rx on|off:Specify if RX pause is enabled.
- tx on|off:Specify if TX pause is enabled.
- -c queries the specified ethernet device for coalescing information.
- -C change the coalescing settings of the specified ethernet device.
- -g queries the specified ethernet device for rx/tx ring parameter information.
- -G change the rx/tx ring parameters of the specified ethernet device.
- rx N Change number of ring entries for the Rx ring.
- rx-mini N Change number of ring entries for the Rx Mini ring.
- rx-jumbo N Change number of ring entries for the Rx Jumbo ring.
- tx N Change number of ring entries for the Tx ring.
- -i queries the specified ethernet device for associated driver information.
- -d retrieves and prints a register dump for the specified ethernet device. When raw is enabled, then it dumps the raw register data to stdout.
- -e retrieves and prints an EEPROM dump for the specified ethernet device. When raw is enabled, then it dumps the raw EEPROM data to stdout. The length and offset parameters allow dumping certain portions of the EEPROM. Default is to dump the entire EEP-ROM.
- -E Changes EEPROM byte for the specified ethernet device. offset and value specify which byte and it’s new value. Because of the persistent nature of writing to the EEPROM, a device-specific magic key must be specified to prevent the accidental writing to the EEPROM.
- -k queries the specified ethernet device for offload information.
- -K change the offload parameters of the specified ethernet device.
- rx on|off: Specify if RX checksumming is enabled.
- tx on|off: Specify if TX checksumming is enabled.
- sg on|off: Specify if scatter-gather is enabled.
- tso on|off: Specify if tcp segmentation offload is enabled.
- -p initiates adapter-specific action intended to enable an operator to easily identify the adapter by sight. typically this involves blinking one or more LEDs on the specific ethernet port.
- N Length of time to perform phys-id, in seconds.
- -r restarts auto-negotiation on the specified ethernet device, if auto-negotiation is enabled.
- -S queries the specified ethernet device for NIC- and driver-specific statistics.
- -t executes adapter selftest on the specified ethernet device. Possible test modes are offline|online
- -s option allows changing some or all settings of the specified ethernet device. All following options only apply if -s was specified.
- speed 10|100|1000 Set speed in Mb/s. ethtool with single argument will show you the supported device speeds.
- duplex half|full Set full or half duplex mode.
- port tp|aui|bnc|mii Select device port.
- autoneg on|off Specify if autonegotiation is enabled. In the usual case it is, but might cause some problems with some network devices, so you can turn it off.
- phyad N PHY address.
- xcvr internal|external Select transceiver type. Currently only internal and external can be specified, in the future further types might be added.
- wol p|u|m|b|a|g|s|d... Set Wake-on-LAN options. Not all devices support this. The argument to this option is a string of characters specifying which options to enable.
- p Wake on phy activity
- u Wake on unicast messages
- m Wake on multicast messages
- b Wake on broadcast messages
- a Wake on ARP
- g Wake on MagicPacket(tm)
- s Enable SecureOn(tm) password for MagicPacket(tm)
- d Disable (wake on nothing). This option clears all previous options.
- sopass xx:yy:zz:aa:bb:cc Set the SecureOn(tm) password. The argument to this option must be 6 bytes in ethernet MAC hex format (xx:yy:zz:aa:bb:cc).
- msglvl N Set the driver message level. Meanings differ per driver.