How to diagnose network speed with Iperf in Linux

iperf is a tool for performing network throughput measurements. It can test either TCP or UDP throughput. To perform an iperf test the user must establish both a server (to discard traffic) and a client (to generate traffic).

Install Iperf

Ubuntu/Debian

apt-get install iperf

CentOS

yum install iperf3

Arch Linux

pacman -S iperf

Use Iperf

Iperf needs to be installed on the two servers you want to test the connection to.

TCP Clients & Servers

Iperf needs to play client and server roles on the two machines. Client to connect to the server you want to test internet speed.
  1. Start server mode on the server you want to test:
    iperf -s
  2. On your other machine, connect to one machine and replace it with the server machine IP
  3. You will see the following output on the server:

UDP Clients & Servers

With Iperf, you can also test the maximum throughput of UDP connections
  1. Start UDP Iperf server

  2. On your other machine, connect to one machine and replace it with the server machine IP.
    The -u option tells Iperf to use a UDP connection. The output is as follows:

  3. You will see the following output on the server: