≡ Menu

ethtool

ethtool or mii-tool utility checks or sets the status of a network interface’s Media Independent Interface (MII) unit. Most fast ethernet adapters use an MII to autonegotiate link speed and duplex setting.

Due to software or hardware (network switch or Ethernet card ) error it may be possible that you need to restarts auto-negotiation on the specified ethernet device.

Restart autonegotiation

You don’t have to reboot Linux box, all you have to do is type the following command :
# ethtool -r eth0
Or you can use mii-tool (outdated, use ethtool only)
# mii-tool -r eth0
Output:
# tail -f /var/log/messages

Jul 16 09:34:25 smtp1 kernel: e1000: eth0: e1000_watchdog_task: NIC Link is Up 10 Mbps Full Duplex
Jul 16 09:34:25 smtp1 kernel: e1000: eth0: e1000_watchdog_task: 10/100 speed: disabling TSO

See also:

I have already written about how to find and change your network interface speed (NIC), duplex or auto negotiate settings on Linux using ehttool command line options.

However, these settings are not permanent. If you reboot the system or if you just
need to upgrade/downgrade your port speed, run the ehtool command once your port change by network administrator. (If you want to read about how to make Windows 2000/2003 server port speed change, read my previous article.)

Changing your Network Interface Speed, Duplex or Auto Negotiate settings on Red Hat Linux

To set the interface speed, duplex or auto negotiation on Linux system boot up (make settings permanent), you need edit /etc/sysconfig/network-scripts/ifcfg-eth0 file for eth0 interface. This file used by Red Hat enterprise Linux, Fedora core, Cent Os etc.

Open the file:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0

Append following line:
ETHTOOL_OPTS="speed 100 duplex full autoneg off"

Save and close the system. It will set the eth0 device to 100Mbs, full duplex, with the auto negotiation off at boot time. You can simply restart the networking (it will disconnect all ssh or ftp session) or restart the server. Depend upon traffic and load it may take upto 1 minute to setup a new port speed:
# /etc/init.d/network restart

If you want 1000Mbs set line as follows:
ETHTOOL_OPTS="speed 1000 duplex full autoneg off"Update: if above command failed to work for 1000Mbps use following command (see below in comment sections for discussion) :ETHTOOL_OPTS="speed 1000 duplex full autoneg on"

Debian or Ubuntu Linux permanent settings

Under Debian or Ubuntu Linux just create a script as follows:
# vi /etc/init.d/100Mbs
OR
$ sudo vi /etc/init.d/100Mbs
Append following lines:
#!/bin/sh
ETHTOOL="/usr/sbin/ethtool"
DEV="eth0"
SPEED="100 duplex full"
case "$1" in
start)
echo -n "Setting eth0 speed 100 duplex full...";
$ETHTOOL -s $DEV speed $SPEED;
echo " done.";;
stop)
;;
esac
exit 0
Save and close the file. Setup executable permission:
# chmod +x /etc/init.d/100MbsOR$ sudo chmod +x /etc/init.d/100Mbs

Now run script when Debian or Ubuntu Linux boots up. Use update-rc.d command install System-V style init script links:# update-rc.d 100Mbs defaultsOR# sudo update-rc.d 100Mbs defaultsOutput:

 Adding system startup for /etc/init.d/100Mbs ...
   /etc/rc0.d/K20100Mbs -> ../init.d/100Mbs
   /etc/rc1.d/K20100Mbs -> ../init.d/100Mbs
   /etc/rc6.d/K20100Mbs -> ../init.d/100Mbs
   /etc/rc2.d/S20100Mbs -> ../init.d/100Mbs
   /etc/rc3.d/S20100Mbs -> ../init.d/100Mbs
   /etc/rc4.d/S20100Mbs -> ../init.d/100Mbs
   /etc/rc5.d/S20100Mbs -> ../init.d/100Mbs

Reboot the system to take effect or just type scrit name:
# /etc/init.d/100Mbs startOR$ sudo /etc/init.d/100Mbs start

See also: