Check link speed linux

How do I verify the speed of my NIC?

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.

9 Answers 9

Just use a command like: ethtool eth0 to get the needed info. Ex:

$ sudo ethtool eth0 | grep Speed

If 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

This only gives you the negotiated speed 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, etc.

It is possible to use the information from the kernel when ethtool is missing:

Example for interface named eth0:

@Christian Yes it is thanks, but only on some of my interfaces which I’ve read is expected so I’m all good

What does it mean if cat /sys/class/net/eth1/speed shows 10000 but «ip a» does only show 1000. Can someone clarify?

It 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 .

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.

eth0: no link eth1: negotiated 100baseTx-FD, link ok 

For 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.

I 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.» 😐

While mii-tool reports ‘negotiated 100baseTx-FD flow-control, link ok’, both ethtool and cat /sys/class/net/eth…/speed agree on ‘1000Mb/s Full duplex’. This is for a USB 3.0 controller, namely ASIX AX88179 (‘ax88179_178a’ driver for Linux).

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.

On computer one, run iperf in server mode:

Читайте также:  Linux ubuntu удалить пакеты

On the other, run iperf in client mode:

If you want to see the full duplex speed, try this instead:

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]: [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.

#include #include #include #include #include #include #include #include #include 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); > 

Using iperf as you stated is the answer if one wants to get current speed and not simply the nic potential speed.

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 

Источник

How to Verify the Speed of My NIC?

announcement - icon

The Kubernetes ecosystem is huge and quite complex, so it’s easy to forget about costs when trying out all of the exciting tools.

To avoid overspending on your Kubernetes cluster, definitely have a look at the free K8s cost monitoring tool from the automation platform CAST AI. You can view your costs in real time, allocate them, calculate burn rates for projects, spot anomalies or spikes, and get insightful reports you can share with your team.

Connect your cluster and start monitoring your K8s costs right away:

1. Introduction

It’s a good practice to verify that any newly installed hardware operates correctly. While there are many hardware modules in a computer, we’ll focus on the NIC (Network Interface Card).

Читайте также:  Add user to all groups linux

In this tutorial, we’ll learn how to verify that the NIC has the correct network speed using two different ways: with standard Linux tools, and with the ethtool command.

2. Using Standard Linux Tools

We can check the speed of our NIC module by using the /sys pseudo-filesystem:

The advantage of this method is that we don’t need to install any external software tools.

Before we run the command, we need to know the network interface name. Two easy ways to find it are by using the ifconfig command or the ip command. Of course, we can always just list the interfaces within the /sys/class/net/ directory:

$ ls /sys/class/net bond0 bonding_masters dummy0 eth0 lo sit0 tunl0

Once we know the network interface name, we can run the cat command on its speed file. For example, if the interface name is eth0, here’s the command to execute:

$ cat /sys/class/net/eth0/speed 100

The output is 100, which means that the speed of our networking interface is 100 Mbit/s.

3. Using the ethtool Command

Another way of checking the speed of our NIC is to use the ethtool command. ethtool is a useful utility to get the settings of the networking devices on a system.

As our main focus is the network speed, we’ll filter the ethtool output for the speed by using the grep command, for example:

$ sudo ethtool eth0 | grep Speed Speed: 100Mb/s

The command above consists of multiple sub-commands. Let’s look at them in more detail:

  • sudo provides root access
  • ethtool is the main command
  • eth0 is the interface name
  • grep Speed filters the ethtool output through a | pipe for the actual speed

As a result, we’ve obtained the speed of our NIC in a readable form. Further, it matches the information we already have from /sys/class/net/.

4. Conclusion

In this article, we learned how to find the speed of our NIC. Firstly, we looked at the standard Linux tool, where we checked the /sys/class/net//speed file. And secondly, we learned how to use the ethtool command to filter out the same speed information.

Источник

The link speed in a basic network refers to the maximum speed that a device can communicate with the wireless router. The link speed is expressed in bits/second and may vary depending on the device and the wireless access point.

In most cases, you will find speeds like 144.4Mbps, 300Mbps, 100Mbps for fast ethernets, or 1000Mbps for devices such as Gigabit ethernets.

I will not dive into how the various layers of the TCP/IP process the speeds. Instead, we’ll focus on how to check for link speed on Ubuntu.

Method 1: Using the IP Command

The very first method to get the link speed of your interface is using the IP command.

We are all familiar with the IP command in Linux; it is part of the net-tools package. It allows us to configure network interfaces in the Linux system, including bringing interfaces up and down, setting IP addresses, netmasks, routes, and more. Thus, it is a powerful tool for network administrators.

To get the link speed of your interface, use the ip command followed by grep as:

Читайте также:  Команда чтобы узнать версию linux

In the above command, we grep for qlen, which shows the transmit queue length of the network interface in packets.

The above shows the interfaces, loopback, and eth0, which is an ethernet adapter.

Method 2: Ask the Kernel

As you guessed, in this method, we will view the interface speed directly from the kernel. The network interface information is stored in the /sys/classes/net/[interface_name]/speed.

All we need to do is query the file using a cat as:

Method 3: Network Manager

The simplest and most common is to look at the network interface in the network manager GUI tool.

In Ubuntu, to get the Link speed of the ethernet interface. Click on the Network connection action in the top bar and select “Wired Settings.”

This should take you to the network management window that shows the link speed as shown below:

Method 4: Mii-Tool/Ethtool

The next method is somewhat unconventional but works for systems with the tool installed. In this case, you can use the mii-tool or ethtool. They both allow users to query the device for information.

However, that may require you to have root or a user with sudo privileges to work.

NOTE: If you are on a Linux machine that does not have the tools installed, use the method discussed above as it will work in most systems.

To get the link speed of a network interface using the ethtool, use the command:

The command below shows the link speed for the interface eth0 as shown:

To learn more how to use the ethtool, consider the manual in the 8th section or use the link below:

Conclusion

In this tutorial, we discussed various methods and tricks to get the link speed of network interfaces in Ubuntu.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list

Источник

How can I verify the speed of my NIC in ubuntu?

Is there a command that I can verify by its output the speed of my NIC and some information about its characteristics such as duplex full or half .

3 Answers 3

Suppose your NIC name eth0 :

You can verify the speed and some informations by three Commands :

First Command :

enter image description here

Second Command :

enter image description here

FD : full duplex , Logic that enables concurrent sending and receiving. This is usually desirable and enabled when your computer is connected to a switch.

HD : half duplex , his 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.

Third command :

ethtool eth0 ethtool - Display or change ethernet card settings 
sudo apt-get install ethtool 
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: 0 Transceiver: internal Auto-negotiation: on MDI-X: Unknown Supports Wake-on: d Wake-on: d Current message level: 0x00000007 (7) drv probe link Link detected: yes 

Источник

Оцените статью
Adblock
detector