Saturday, December 6, 2008

How to Setup or Check Network Speed and Duplex on Linux?

What is Half and Full Duplex?

In Full duplex, the data (signal) can flow in both directions

In Half duplex, the data (signal) can flow in one direction at a time

So, the duplex settings is very important. To check duplex and speed settings, ethtool is the best tool.

To see the duplex and speed setting of interface eth0 just run following command

# ethtool eth0

To setup, 100 Mbps speed, Full duplex and make it static on interface eth0 , run below command:

# ethtool -s eth0 autoneg off duplex full speed 100

autoneg off make sure that this setting does not change in response to the port setting on which this interface is connected, such as switch.

In newer version, this settings can be done in configuration file. For example in newer version SUSE such as 10.x, this setting can be done in respective interface configuration file, which can be found under /etc/sysconfig/network. The interface configuration file looks like ifcfg-eth-id-00:c0:0d:01:75:05

In older versions such as SUSE 9, we need to set up manually. I added this settings in a bash shell script and placed under /etc/sysconfig/network/scripts and created symbolic links from /etc/sysconfig/network/if-up.d.

# ls -al
total 8
drwxr-xr-x 2 root root 4096 Apr 22 2008 .
drwxr-xr-x 6 root root 4096 Feb 19 2008 ..
lrwxrwxrwx 1 root root 21 Apr 22 2008 eth0-setup -> ../scripts/eth0-setup

# cat ../scripts/eth0-setup

#!/bin/bash
#
# This script has been added by Sikkandar to make sure
# that the NIC Configuration is set to FULL DUPLEX with SPEED 100
#
# Date : 04.Oct.2007
#
# OS : SUSE LINUX Enterprise Server 9
#
/usr/sbin/ethtool -s eth0 autoneg off duplex full speed 100


Have Fun ........


Sikkandar.Linux at GMail.Com

No comments: