I just installed a new gigabit network interface card (NIC) in Linux. How do I tell if it is really set to gigabit speeds? I see ethtool
has an option to set the speed, but I can't seem to figure out how to report its current speed.
- 2,386
- 4
- 19
- 21
-
1ethtool -h says: ethtool DEVNAME Display standard information about device – Ryan Babchishin Oct 17 '15 at 23:12
8 Answers
Just use a command like: ethtool eth0
to get the needed info. Ex:
$ sudo ethtool eth0 | grep Speed
Speed: 1000Mb/s
- 575
- 2
- 8
- 22
- 35,688
- 8
- 69
- 98
-
7If you want to have the full list of all your interfaces with theyr speed, you can use this command: `for i in $(netstat -i | cut -f1 -d" " | tail -n+3) ; do echo "$i: $(ethtool "$i" | grep Speed | sed 's/Speed://g')" ; done` – Code-Source Nov 11 '17 at 20:13
-
1If you get "Speed: Unknown!" you may be using the wrong ethXX name, worth a double check :) – rogerdpack Sep 24 '18 at 16:00
-
2This only gives you the [negotiated speed](https://superuser.com/questions/1410862/types-of-ethernet-link-modes-from-ethtool) of your current network configuration (hence your ethernet port must be connected). The speed indicated also depends on the cable and the other end of the connection. This does NOT give the max supported speed of the NIC on your PC. For that, you need to look under `Supported link modes` also shown in `ethtool`. `1000baseT` means [gigabit ethernet](https://en.wikipedia.org/wiki/Gigabit_Ethernet#1000BASE-T), etc. – Rufus Nov 05 '20 at 02:19
-
-
1
It is possible to use the information from the kernel when ethtool is missing:
cat /sys/class/net/<interface>/speed
Example for interface named eth0:
cat /sys/class/net/eth0/speed
- 1,561
- 1
- 9
- 4
-
7
-
17
-
-
1@Christian Yes it is thanks, but only on some of my interfaces which I've read is expected so I'm all good – wi1 Sep 25 '17 at 15:10
-
-
2What does it mean if cat /sys/class/net/eth1/speed shows 10000 but "ip a" does only show 1000. Can someone clarify? – jsterr Feb 06 '19 at 16:14
-
Warning: In my case this solution here reports a speed of `100` with `cat /sys/class/net/eth0/speed`. However `mii-tool eth0` reports `eth0: negotiated 1000baseT-HD flow-control, link ok`. – user643011 Dec 31 '19 at 15:39
-
1It seems /sys/class interface was right. Dmesg also lists 100Mbit/s `# dmesg|grep duplex [ 5.417536] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xC5E1`. I am running on a special purpose OS build without `ethtool`. – user643011 Dec 31 '19 at 15:48
-
1Note: speed is in mbps, so 1000 is gigabit (as expected, but I figured it was good to make sure) – Luc Jun 25 '20 at 09:57
-
I think this should be the accepted answer. It shows the speed the NIC is currently running at / the negotiated speed, NOT the maximum possible speed. – Bim Jan 08 '21 at 10:03
-
-
Um that seems to be the maximal speed, not the negotiated (actual) speed, unfortunately for me. :-( – grin Aug 27 '21 at 11:30
NOTE: the man page for mii-tool
has this disclaimer:
This program is obsolete. For replacement check ethtool.
Use mii-tool
to watch the negotiated network speed.
Ex.
eth0: no link
eth1: negotiated 100baseTx-FD, link ok
- 7,355
- 16
- 54
- 72
- 559
- 3
- 2
-
15For Debian based systems, `ethtool` is not installed by default. But `mii-tool` is, as part of the essential "net-tools" package. So this was the best solution for me. – mivk Jul 06 '14 at 13:20
-
2I see this in the man page for mii-tool "This program is obsolete. Valid media are only 100baseT4, 100baseTx-FD,100baseTx-HD, 10baseT-FD and 10baseT-HD ethernet cards. For replace-ment check ethtool." :| – rogerdpack Jun 28 '17 at 16:13
-
1While `mii-tool` reports 'negotiated **100**baseTx-FD flow-control, link ok', both `ethtool` and `cat /sys/class/net/eth…/speed` agree on '**1000**Mb/s Full duplex'. This is for a USB 3.0 controller, namely ASIX AX88179 ('ax88179_178a' driver for Linux). – Anton Samsonov Sep 24 '18 at 10:11
There are some great answers here, I just wanted to add a few more options.
1. I know this is not quite what you asked (read on for other ways). But if you want to know the real world performance of your NIC, rather than what your computer says it should be, you can use iperf. I usually do this - because you never know. I bought a 1Gb NIC recently that that only transferred at 672Mbps but it's uplink was 1Gb. Good thing I checked.
You'll need two computers.
On computer one, run iperf in server mode:
iperf -s
On the other, run iperf in client mode:
iperf -c 192.168.0.10
If you want to see the full duplex speed, try this instead:
iperf -d -c 192.168.0.10
Substitute 192.168.0.10 for the servers IP address
2. On Ubuntu systems, /var/log/kern.log
has limited logging of kernel events. It will record link speed and status of a NIC when it changes. I'm sure other distributions probably do something similar or can be setup to do so.
$ tail -n 300 /var/log/kern.log.1 | grep slave0
Aug 28 12:54:04 haze kernel: [ 9452.766248] e1000e: slave0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: Rx/Tx
Aug 28 12:54:41 haze NetworkManager[921]: <info> [1472403281.8486] device (slave0): link disconnected
Aug 28 12:54:41 haze kernel: [ 9489.898476] e1000e: slave0 NIC Link is Down
3. You'll probably never, ever need to go this far, but you can write c code that to get the speed. Tested working and root is not required.
https://stackoverflow.com/questions/2872058/get-link-speed-programmatically
#include <stdio.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <linux/sockios.h>
#include <linux/if.h>
#include <linux/ethtool.h>
#include <string.h>
#include <stdlib.h>
int main (int argc, char **argv)
{
int sock;
struct ifreq ifr;
struct ethtool_cmd edata;
int rc;
sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
if (sock < 0) {
perror("socket");
exit(1);
}
strncpy(ifr.ifr_name, "eth0", sizeof(ifr.ifr_name));
ifr.ifr_data = &edata;
edata.cmd = ETHTOOL_GSET;
rc = ioctl(sock, SIOCETHTOOL, &ifr);
if (rc < 0) {
perror("ioctl");
exit(1);
}
switch (ethtool_cmd_speed(&edata)) {
case SPEED_10: printf("10Mbps\n"); break;
case SPEED_100: printf("100Mbps\n"); break;
case SPEED_1000: printf("1Gbps\n"); break;
case SPEED_2500: printf("2.5Gbps\n"); break;
case SPEED_10000: printf("10Gbps\n"); break;
default: printf("Speed returned is %d\n", edata.speed);
}
return (0);
}
- 6,160
- 2
- 16
- 36
-
2
-
2Using iperf as you stated is the answer if one wants to get current speed and not simply the nic potential speed. – droid-zilla Feb 23 '19 at 02:50
As Khaled mentioned, you should be able to run ethtool with just the interface as an argument. This will list the supported speeds, the advertised speeds, the current speed, and a bunch of other things too:
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: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: d
Wake-on: d
Current message level: 0x00000007 (7)
Link detected: yes
You can also run dmesg
, and grep for your interface, but this might not work if your system has been running for a long time and the current buffer no longer has that information (in that case, you'll have to grep the older /var/log/dmesg.* files):
dmesg |grep eth0
[ 2.867481] e1000: eth0: e1000_probe: Intel(R) PRO/1000 Network Connection
[ 19.429444] ADDRCONF(NETDEV_UP): eth0: link is not ready
[ 19.431555] e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
[ 19.449341] ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 26.972379] e1000: eth0: e1000_set_tso: TSO is Enabled
[ 29.920458] eth0: no IPv6 routers present
- 7,172
- 2
- 33
- 41
Use below command
dmesg | grep -i duplex
Output: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
refer this
- 283
- 6
- 14
-
1
-
useful when the log is not overwritten. I'm in the unfortunate situation. – zhaorufei May 05 '16 at 06:01
-
this came in handy when I didn't have superuser privs on the box. thanks! – Sankalp Aug 24 '17 at 08:07
-
If you don't know the name of your network adapter, you can run: `/sbin/ifconfig`. Then: `dmesg | grep -F $nicname` – kevinarpe Apr 12 '22 at 13:14
Also for future reference I've noticed that the speed field in ethtool gives the maximum speed supported by the NIC and mii-tool give the actual speed on which the NIC is running.
[ root @ ]# mii-tool
eth0: negotiated 100baseTx-FD, link ok
[ root @ ]# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 2
Transceiver: internal
Auto-negotiation: on
MDI-X: off (auto)
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes
UPDATE: After a while a found out the mii-tool wasn't returning the right speed as it was outdated and deprecated and ethtool was returning the negotiated speed.
- 111
- 5
ethtool eth0
worked for me. Example:
$ethtool eth0 |grep -i speed
Speed: 1000Mb/s
- 9
-
3Please read other answers before answering. This has alread been said six years ago and is the accepted answer with 66 upvotes. – Sven Jul 11 '16 at 12:15
-
one can still post his answer regardless. Given answers might not work for someone, so just wanted to add another option that suited me in my situation. – dragon Jul 19 '16 at 16:00
-
2Your answer is the exact same as the accepted one and does not add value. – Sven Jul 19 '16 at 16:28
-
-
2look at the very top answer with the green tick beside it. This is the accepted answer and it very clearly uses `ethtool`. – Sven Aug 12 '16 at 11:17
-
it doesnt show the use of the command, yes it mentions the command but doesnt demonstrate how to use it, thats what I tried to fill in, thats all no offense. – dragon Aug 17 '16 at 13:54