Find the speed of your Ethernet card in Linux

October 27, 2005
For logging on to the net or for attaching as a node on a LAN, your computer needs a network card. The network card forms the interface between your computer and the network. There are different kinds of network cards available in the market depending on its speed and other features. Here is a tip to find out the characteristics of your network card.

If you want to find what type of network card is used, its speed, on which IRQ it is listed, and the chip type used, you use the following command :

# dmesg |grep eth0

Here eth0 is the first network card. If you have additional cards, it will be named eth1, eth2 and so on. And here is the output of the above command :

divert: allocating divert_blk for eth0
eth0: RealTek RTL8139 at 0xd800, 00:80:48:34:c2:84, IRQ 9
eth0:  Identified 8139 chip type 'RTL-8100B/8139D'
divert: freeing divert_blk for eth0
divert: allocating divert_blk for eth0
eth0: RealTek RTL8139 at 0xd800, 00:90:44:34:a5:33, IRQ 9
eth0:  Identified 8139 chip type 'RTL-8100B/8139D'
eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
eth0: no IPv6 routers present
...

Please take a closer look at the above listing. The output data identifies my Ethernet card is a RealTek RTL8139 chipset based card on IRQ 9 (Interrupt Request). Its speed is 100 Mbps and is a full-duplex card. And the link is up.

mii-tool


As is the philosophy of Linux, there is more than one way of finding the same information. Linux also comes with a cute sounding tool called mii-tool which can also be used to get the same information about your network card.

# mii-tool -v eth0

eth0: negotiated 100baseTx-FD, link ok
product info: vendor 00:00:00, model 0 rev 0
basic mode:   autonegotiation enabled
basic status: autonegotiation complete, link ok
capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD
             10baseT-HD
...

Here -v is verbose mode. From the above listed output, one can see that the Ethernet card is working as a 100baseTX, FD (Full Duplex) card which can work in the following modes :

  • 100 Mbps Speed (Full duplex or half duplex ) or
  • 10 Mbps speed (Full duplex or half duplex).

And it uses auto-negotiation to bring up the link. You can call the above device as a 10/100 NIC.

mii-tool is obsolete. Valid media are only 100baseT4, 100baseTx-FD, 10baseT-FD, and 10baseT-HD ethernet cards. You are encouraged to use the more useful ethtool instead.


ethtool


ethtool is a more powerful cousin to mii-tool. The following is a simple use of ethtool.

# ethtool eth0

You get an output as shown below.

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: p
  Current message level: 0x00000007 (7)
  Link detected: yes

In the output above, full duplex, half duplex and auto-negotiation have the following meanings.

Full Duplex - Logic that enables concurrent sending and receiving. This is usually desirable and enabled when your computer is connected to a switch.

Half Duplex - This logic requires a card to only send or receive at a single point of time. When your machine is connected to a Hub, it auto-negotiates itself and uses half duplex to avoid collisions.

Auto-negotiation - This is the process of deciding whether to work in full duplex mode or half duplex mode. An Ethernet card supporting auto-negotiation will decide for itself which mode is the optimal one depending on the network it is attached to.

8 comments:

  • Thanks, Just what I was looking for

    SM0EPM Ebbe Stockholm

  • Thats a good tutorial, thanks!

  • Exactly what I needed. Thanks.

  • Great. Suse 10.2 does not give any info through the GUI about these settings, neither does ifconfig eth0. Ethtool did the trick. Cool!!, thanks. KlaasB, Netherlands

  • Thanks! Also exactly what I was looking for!

    -The Admiral

  • Jarrod

    What if you don't have root?? I need to find out how to see what the current link speed is inside a script running as a non-privileged user.

  • Surender

    I have noticed few times that mii-tool and ethtool report different values for duplex status, mii-tools says full while ethtool says half-duplex, which one should I trust?

  • MGM Sr.

    Thanks! Very concise and helpfull, exactly what I was looking at.


    By the way, with my r8111, only the ethtool showed the correct status...