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/shSave and close the file. Setup executable permission:
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
# 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


41 comment
In Debian or Ubuntu, it’s much easier to add a pre-up line to /etc/network/interfaces. Something like this:
iface eth0 inet staticpre-up /usr/sbin/ethtool -s $IFACE 10 duplex half
address ...
“Speed” keyword seems to be needed (could be a more recent requirement since this thread is many years old), like so:
Roshan
Good tip; my bad I should have thought about it.
Appreciate your post.
A few weeks ago, I did the same thing in SuSE as the switch in work reports the wrong settings.
Just add a script in /etc/sysconfig/network/scripts called ethtool-settings (for example) and link to it in /etc/sysconfig/network/if-up.d
The contents could be something like :-
/usr/sbin/ethtool -s eth0 speed 100 duplex full autoneg off
Your example for 1000 speed will not work.
ETHTOOL_OPTS=”speed 1000 duplex full autoneg off”
speed 1000 REQUIRES autonegotiate.
Read up on your ethernet networking fundamentals here:
http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/ethernet.htm#wp1020985
Noop, command is right. I have tested these commands lots of times. I have Intel NIC (e1000 driver) and it works w/o problem.
ethtool -s ethx autoneg off speed 1000 duplex full
Changing speed or duplex settings almost may require disabling auto negotiation with ‘autoneg off’. However you may need to turn on autoneg for 1000Mbps; it did work for my Intel card. But failed to work for other make NIC. So try both options.
Appreciate your post.
Very thank , i used this.
Hi,
i added a ethtool option (ETHTOOL_OPTS=”wol g”) in the file /etc/sysconfig/network-scripts/ifcfg-eth0 to have wol automatic enabled, but if i have eth0 configured with dhcp options i can’t get the “wol g” option active. On the contrary if i configure the eth0 nic with static ip address the ethtool option is well set.
I have a sme-server (CentOS based) and i’m going to be crazy to have wol g enabled with dhcp on… how can i get it to work?
Thanks,
Stefano – Italy
I don’t have ethtool on my version of RedHat so the ETHTOOL_OPTS won’t automate the settings for me. How do I automate the mii-tool options in the etc/sysconfig/network-scripts/ifcfg-eth0 file?
mii-tool is obsolete and it will be removed from future version or updates. You can easily install ethtool by running any one of the following command:
or (for rhel 4.x or older )
To automate mii-tool …
Add mii-tool command to /etc/rc.local with speed, which will run mii-tool on fly after Linux boots up. For eg following will set eth0 to 100Mbps FD
HTH
Thanx so much Vivek I already added the command to rc.local I was just wondering if there was another method. I’ll definitely upgrade to ethtool.
simply superb
If you’re unable to permanently set the wol option:
Stefano, I have a similar issue with the ethtool in Debian/Ubuntu 7.10:
I noticed that the ethtool setting for WOL kept getting turned off each time I rebooted. Then I realized this happened each time I turned turned the adapter on or off (ifdown eth0 | ifup eth0)… wol was getting disabled.
Workaround: Add this line to “/etc/network/interfaces”:
post-up /usr/sbin/ethtool -s eth0 wol g
John Scobie’s resolution should also work…
But using Roshan Shariff’s code (but with the wol option instead of speed) didn’t work if I used the variable $IFACE… I had to specify eth0 instead.
Hope this helps anyone who is unable to permanently the WOL option in ethtool; I’ve spent the last 3 hours doing google searches and trying to troubleshoot before finding this.
Debian:
/etc/network/interfaces
up ethtool -s eth0 speed 100 duplex full autoneg off
Worked for me. Our servers with out-of-the-box OS settings always went half-duplex during auto-negotiation with the router. So this line fixes that.
Ditto for ETHTOOL_OPTS line from article for Redhat.
My questions is: my /etc/sysconfig/network-scripts/ifcfg-eth0 is not having details of the NIC speed but when i issue command ethtool eth0 i am getting NIC speed. Where could be this information picking from? Is there any place which ethtool command picks this information?
Hi Vasudev,
I am also looking for the answer for same query posted by You.Please inform me as well if You got this.
A variant on the script that handles multiple interfaces and reads the interdfaces from a configuration file.
Enjoy.
Cheers
Interface entry in /etc/default/100Mbs:
INTERFACES=”eth0 eth1 eth3″
/etc/init.d/100Mbs startup script:#!/bin/sh
# Startup script for changing netowork interface parameters
#
ETHTOOL=”/usr/sbin/ethtool”
OPTIONS=”speed 100 duplex full autoneg off”
# Check for a configuration file in /etc/default
if [ ! -f /etc/default/100Mbs ]; then
echo “/etc/default/100Mbs does not exist! – Aborting…”
exit 1
fi
. /etc/default/100Mbs
case “$1” in
start)
if test “$INTERFACES” != “”; then
for I in $INTERFACES; do
echo -n “Setting ${I} $OPTIONS …”;
$ETHTOOL -s ${I} $OPTIONS;
echo ” done.”
done
fi
;;
stop)
;;
esac
exit 0
Thx for the arcticle. Helped me out.
Hi!! I have some question about this script, I’m enter in this script but some expression I don’t understand.
Well gooo.
#!/bin/sh
ETHTOOL=”/usr/sbin/ethtool”
DEV=”eth0″ // well here in the end the expression no coming “;” well in each expression.
SPEED=”100 duplex full”
case “$1” in
start) //well here not is start()
echo -n “Setting eth0 speed 100 duplex full…”;
$ETHTOOL -s $DEV speed $SPEED;
echo ” done.”;;
stop) // here too stop ()
;;
esac
exit 0
well this script I’ll work but no change the base 100TX to 10T when restart my Debian, Now I’m use the tools like ethtool for change in the moment, well send me the solution and thank for the post is good information.
Hmmm… I have 2.6.25 and and I just managed to cut myself access from the server by issuing
ethtool -s eth0 autoneg off speed 1000 duplex full
even when I got this:
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: 100Mb/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
I have a new gbit switch there but I can’t get the desired speed… any bright ideas?
In Ubuntu/Debian for 100-Full, this works for a static IP in /etc/network/interfaces:
—————————-
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo eth0
iface lo inet loopback
# The primary network interface
iface eth0 inet static
pre-up /usr/sbin/ethtool -s eth0 speed 100 duplex full autoneg off
address 192.168.1.101
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
gateway 192.168.1.1
——————–
this should work for DHCP/Auto setup:
——————–
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo eth0
iface lo inet loopback
# The primary network interface
iface eth0 inet dhcp
pre-up /usr/sbin/ethtool -s eth0 speed 100 duplex full autoneg off
Hi,
I have 2 ethernets (eth0 and eth1) with bouding done as bond0.
# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: g
Current message level: 0x000000ff (255)
Link detected: yes
# ethtool eth1
Settings for eth1:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: g
Current message level: 0x000000ff (255)
Link detected: yes
[root@amuswatnas01 ~]# ethtool bond0
Settings for bond0:
No data available
I want to hard-code the speed to 1000 MBps Full duplex, how can I do that on bouded network,
Do I need to simply edit ifcfg-eth0 and ifcfg-eth1 file with following entries.
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Append following line:
ETHTOOL_OPTS=”speed 100 duplex full autoneg on”
Let me know if any other changes are required.
ethtool shows its 1000 Mbps FD, Do I still need to hard-code, From which file, it shows such configiration?
Thanks,
Prachi
What do I need to add to the Debian script to turn autonegot off?
if device is eth1 generate error, to solve:
DEV=`netstat -i | awk ‘/eth/ {print $1}’`
Hi, nice post! For Debian, I think that you just need append the follow line at /etc/network/interfaces file:
post-up ethtool -s eth0 speed 10 duplex half
I tested it , and for me it works very well. Regards from Brazil.
For Debian, like Rafael Guedes said, isn’t it easier to append in /etc/network/interfaces?
Not just it, but you can add routes and delete them too using post-up and post-down option in Debian… I never tested in Ubuntu though…
By the way, Cyberciti is my favorite site 😀
Regards from Brazil!!
could pls tel ,how to set the speed to 10mbps full duplex, i tried ur above script & steps (with 10 instead of 100),but its not working..
OS : Ubuntu 10.4 LTS
Thanx in advance
Thanks for the tip. I applied it to my hardware and I am happy that the speed it blazing in my VM. I will keep watch on whether the ethernet card drops the connection as it has been doing in the past. If it remands up, I am extremely happy.
(AMD Phenom II X4 940, 8G memory, 2 gig ethernet, 3 Tb of harddrive, nvidia cards)
on centos 5.4 final this command work
mii-tool -F 100baseTx-FD
thk for help
Ubuntu 10.10, a Marvell Gigabit Ethernet and gigabit 1000mbit speed:
— Manual change while working on it:
ethtool -s eth0 speed 1000 duplex full autoneg off
— Hopefully permanent – /etc/network/interfaces:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
pre-up /sbin/ethtool -s $IFACE speed 1000 duplex full autoneg off
— Testing the file (NOTICE: ifconfig eth0 down/up does NOT test the file):
ifdown eth0
ifup eth0
(All above is run as administrator -do ‘sudo passwd root’ to set your password, then ‘su’)
Another notice, if you already have done the above tip with /etc/init.d/, here is how to remove that:
rm /etc/init.d/100mbit
update-rc.d 100mbit remove (notice the actual file removal must be done before)
Good option
Thank you!!
Very usefull for my old laptop!
Added ETHTOOL_OPTS=”speed 1000 duplex full autoneg off” to ifcfg-eth1 to force gigabit. After a restart I get these messages. What’s wrong with eth1 (Realtek RTL-8169), working fine on 100 Mbs though…?
# etc/init.d/network restart
Shutting down interface eth1: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0:
Determining IP information for eth0… failed; no link present. Check cable?
[FAILED]
Bringing up interface eth1: Cannot get current device settings: Operation not supported
not setting speed
not setting duplex
not setting autoneg
@Peter try autoneg on since setting speed to 1000 needs autoneg on
Hi andrej,
Thank you for your help! I have to try ‘autoneg on’ later. I had to remove the Realtek card because of rebooting problems. So, sadly my secondary 3Com 100Mbps card became primary again… As soon as I know the result of your suggestion, I’ll let you know. Regards, Peter.
doesn’t work either:
# ethtool -s eth1 autoneg on speed 1000 duplex full
Cannot set new settings: Operation not supported
not setting speed
not setting duplex
not setting autoneg
For lastests Debian or debian based distributions I strongly recommend reading /usr/share/doc/ethtool/README.Debian
@Damián Viano, thank you, after a lot of search, this was the only way to do it.
Hi,
Switching autoneg (off) on a interface is showing no link , when i switch on autoneg , link is shown
# ethtool -s eth1 autoneg off speed 1000 duplex full
Cannot set new settings: Operation not supported
not setting speed
not setting duplex
not setting autoneg