Linux change the speed and duplex settings of an Ethernet card

Posted on in Categories , , , , , , last updated December 24, 2007

Q. How do I change the speed, duplex on for my Ethernet card?

A. Under Linux use mii-tool or ethtool package which allows a Linux sys admin to modify/change and view the negotiated speed of network interface card (NIC) i.e. it is useful for forcing specific Ethernet speed and duplex settings.

Depending on which type of Ethernet card is installed on the system you need to use either mii-tool or ethtool. I recommend installing both and use one of the tool, which will work with your card.

Task: Install mii-tool and ethtool tools

If you are using Debian Linux you can install both of these package with following command:# apt-get install ethtool net-toolsIf you are using Red Hat Enterprise Linux you can install both of these package with following command:# up2date ethtool net-toolsIf you are using Fedora Core Linux you can install both of these package with following command:# yum install ethtool net-tools

Task: Get speed and other information for eth0

Type following command as root user:
# ethtool eth0Output:

Settings for eth0:
     Supported ports: [ TP MII ]
     Supported link modes:   10baseT/Half 10baseT/Full
                             100baseT/Half 100baseT/Full
     Supports auto-negotiation: Yes
     Advertised link modes:  10baseT/Half 10baseT/Full
                             100baseT/Half 100baseT/Full
     Advertised auto-negotiation: Yes
     Speed: 100Mb/s
     Duplex: Full
     Port: MII
     PHYAD: 32
     Transceiver: internal
     Auto-negotiation: on
     Supports Wake-on: pumbg
     Wake-on: d
     Current message level: 0x00000007 (7)
     Link detected: yes

Or use mii-tool command as follows:# mii-tool eth0Output:

eth0: negotiated 100baseTx-FD flow-control, link ok

Task: Change the speed and duplex settings

Setup eth0 negotiated speed with mii-tool
Disable autonegotiation, and force the MII to either 100baseTx-FD, 100baseTx-HD, 10baseT-FD, or 10baseT-HD:# mii-tool -F 100baseTx-HD
# mii-tool -F 10baseT-HD
Setup eth0 negotiated speed with ethtool# ethtool -s eth0 speed 100 duplex full
# ethtool -s eth0 speed 10 duplex half
To make these settings permanent you need to create a shell script and call from /etc/rc.local (Red Hat) or if you are using Debian create a script into the directory /etc/init.d/ directory and run update-rc.d command to update the script.

Read man page of mii-tool and ethtool for more information.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

35 comment

  1. How to get wired LAN running at FULL-DUPLEX

    At the Linux Terminal, type:

    sudo ethtool eth0

    This will tell you the properties of the wired config. If Duplex is showing half, then type:

    sudo ethtool -s eth0 autoneg off
    sudo ethtool -s eth0 duplex full

    Finally, type to view final configuration:

    sudo ethtool eth0

  2. On Red Hat Enterprise, and SuSE Enterprise (and probably others) you can include the options in your interface config file using the ETHTOOL_OPTS argument:
    # red hat: /etc/sysconfig/network-scripts/ifcfg-eth0
    # sles: /etc/sysconfig/network/ifcfg-eth-id-{mac address}
    ETHTOOL_OPTS=”autoneg off speed 100 duplex full”

    Note that you cannot disable autonegotiation on gig-ethernet over copper. Autonegotiation is REQUIRED in the 802.3ab definition (http://standards.ieee.org/reading/ieee/interp/IEEE802.3af-2003interp-6.pdf)

  3. I have a Dell laptop (Precision M6300) with Broadcom NetXtreme ethernet controller and
    a wireless Dell WLAN Mini card. I had Fedora installed and can dual boot Windows XP or Fedora. I decided to start with the Broadcom controller since many of the Web sites imply
    that the wireless ethernet on linux can be frustrating. Unfortunately, the “wired” ethernet is
    also proving to be a problem. I will try the tools you have listed and hope. Certainly the
    Administor->network-> gui interface did not work. Tried the tg3 driver but when I activate
    it, it says it is not there. Of course I am sending this email thru the BroadCom controller but
    with the XP OS. There seems to be a big difference between a linus USER and Admin. Oh well
    I will reboot and try some of your suggestions.

  4. My 1gbit card refuses to report 1gbit. GRRRR! I use the ethtool, but at no vail. The mii-tool dont do to much for my Debian system either.
    Might be a stupid question, but are there some config settings for the network file? Im sure I had it running at 1gbit, but I also remember it was a hassle to get it to run at that speed.
    Well, off to google again.. :)

  5. Super now my Debian is work with my internet, I was change of 100TX to 10T , but Now I like to create one script that when restart my Debian is work my internet, the question is How I’ll create the Script? please any one there help me and send my same example or the solution.

    Thanks for the post.

  6. Very useful article! Trying any of this leaves me with no link, no connection. I can run 10mb/s half duplex, autonegotiated. Attempts to force, no auto yield no link. No response to pon.

    I am running Debian Sid, NIC ethO –>pptp pppO to ASDL modem.

  7. Hi Vivek,

    As you pointed out, mii-tools may be deprecated, so
    would you mind modifying accordingly your very interesting topic,
    and consider adding what Mage767 has most conveniently added:
    How to switch off auto-negocation using ethtool :
    # ethtool -s eth0 autoneg off

    So, to sum uop, either you are lucky enough to do both action alltogether:
    # ethtool -s eth0 duplex full autoneg off
    (this works for my Ethernet Card)

    Either you need to do it in 2 steps:
    # ethtool -s eth0 autoneg off
    # ethtool -s eth0 duplex full

    Thanks for your anwser – BTW you brought up a solution I had been wondering for months !
    — Philippe

    1. How to switch on autoneg on in linux ?
      I tried below command for 10G intel nic card
      # ethtool -s xaui0 duplex full autoneg on
      it is showing follwing output
      Cannot set new settings: Invalid argument
      not setting duplex
      not setting autoneg

  8. This command does not seem to be working with Centos 4.5 Final

    ethtool -s eth0 speed 100 duplex full

    It locks up the NIC. I was able to SSH in from the secondary port and reboot the server gracefully.

    Prior to changing the speed and duplex mode I get:

    [root@hw000 vz-scripts]# 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: Half
    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

    Then I enter and it hangs:

    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: 100baseT/Full
    Advertised auto-negotiation: Yes
    Speed: Unknown! (65535)
    Duplex: Unknown! (255)
    Port: Twisted Pair
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
    Supports Wake-on: umbg
    Wake-on: g
    Current message level: 0x00000007 (7)
    Link detected: no

    – Ethernet controller: Intel Corporation 82541GI Gigabit Ethernet Controller
    – Ethernet controller: Intel Corporation 82547GI Gigabit Ethernet Controller

  9. On RHEL ES4u6 32bit, when I execute “ethtool eth0” it does NOT give me the speed, which I desire to know. I’ve played with the options, but don’t see anything obvious that forcefully provides information on the nic/link speed.

    Any other option/method for determining, via the CLI the nic/link current speed?
    Thanks

    Message submitted 2010/05/24 @ 14:45 EST (as the article and messages don’t indicate their date of posting)

  10. Hmm, my previous attempt to say this seems to have gone off into the ether (but not eth). :)

    Thank you, too—and your are welcome as well, Vivek Gite. I appreciate the quick response!
    However, I’ve no joy with using the ‘mii-tool’ you’d suggested.

    ‘ethtool eth0’ returns only the following output:
    “Settings for eth0:
    Current message Level: 0x00000007 (7)
    Link Detected: yes”
    —-and nothing further.

    ‘dmesg | less’ and manually searching for eth0 returns only the following:
    “divert: allocationg divert_blk for eth0
    eth0: registered as PCnet/PCI II 79c970a
    eth0: no IPV6 routers present”

    ‘mii-tool eth0’ returns only the following:
    “SIOCGMIIPHV on ‘eth0’ failed: Operation not supported.”

    I get this, primarily on VMs within an ESX 3.5.0 host.

    R,
    -Joe Wulf

  11. I changed the full duplex to half duplex using command
    /sbin/ethtool -s eth0 speed 10 duplex half

    but if do
    /sbin/ethtool eth0 getting o/p: as below :
    /sbin/ethtool eth0
    Settings for eth0:
    Supported ports: [ TP MII ]
    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: 100Mb/s
    Duplex: Full
    Port: MII
    PHYAD: 0
    Transceiver: internal
    Auto-negotiation: on
    Supports Wake-on: pumbg
    Wake-on: g
    Current message level: 0x00000033 (51)
    Link detected: yes
    that indicates my PC is not getting changed to half duplex

    Pls help me what i have to do?

  12. yeah really it works…, thanks a lot.
    Actually i was looking it from centos help sites, but i got only dust there,

    now i tried it, And my net is working,
    it is working of 10bastT-HD

    Thanks for supporting code in this simple manner…

  13. I have Red Hat RHEL 5.5 and when I use the ethool
    # ethtool -s eth0 speed 1000 duplex full
    I get the erro of :
    Cannot set new settings: Invalid argument
    not setting speed
    not setting duplex
    Is this a bug in RHEL 5.5? It worked in RHEL 4.8

  14. Hi,
    I am using freescale processor MPC8548E based customized board .

    Once the Linux is loaded on the target I gave the following ommand:
    ifconfig media 100baseTX mediaopt full-duplex
    as mentioned above.

    But it is dispplaying the error:
    ifconfig: bad address ‘media’…

    I am trying to set the board eth1 port to work in 100 Mbps, Full Duplex mode.

    ethtool and mii-tool are not working on the target. I am getting the error as: Command not found…..

  15. For me, it wasn’t auto negotiating to 1000 full duplex even though it had in the past.

    I replaced the ethernet cable from an old cord to a brand new shielded one and it switched right into 1000 Mbps Full Duplex. (The computer is plugged into a gigabit switch, naturally.)

    In my /etc/sysconfig/network-scripts/ifconfig-eno1 the ethtool line is as follows:
    ETHTOOL_OPTS=”autoneg on”

  16. Hi All,

    RHEL 6.5,

    ethtool -s eth0 speed 1000 duplex full
    I get the erro of :
    Cannot set new settings: Invalid argument
    not setting speed
    not setting duplex

    Not able to set any changes required.

    Can anyone help…

    Regards,
    Kumaresan

Leave a Comment