How to Use the iperf3 Command to Measure Network Bandwidth in Linux

What is iperf3?

When you experience slow network speeds on a Linux server, relying on internet speed tests (like speedtest.net) is often misleading. Those tests measure your bandwidth out to the public internet, which is influenced by your ISP, local congestion, and routing hops. They do not tell you how fast data is moving inside your local area network (LAN).

iperf3 is the industry-standard command-line tool for active measurement of the maximum achievable bandwidth between two IP networks. By running an iperf3 client on one machine and an iperf3 server on another, you can flood the network with TCP or UDP packets to determine the exact, raw throughput capabilities of your internal switches, cables, and network interface cards.

Step 1: Install iperf3 on Both Machines

To use iperf3, you must install it on two separate Linux machines on the same network.

On Debian, Ubuntu, or Linux Mint:

sudo apt update && sudo apt install iperf3

On RHEL, CentOS, or Fedora:

sudo dnf install iperf3

Step 2: Start the iperf3 Server

Choose one machine to act as the server (the listening node). Open the terminal on this machine and run the following command:

iperf3 -s

The terminal will output “Server listening on 5201”. The machine is now passively waiting for a client to initiate a speed test. Note the IP address of this server machine (for this example, we will use 192.168.1.50).

Note: If you have a firewall enabled (like UFW), you must ensure port 5201 (TCP and UDP) is open.

Step 3: Run a Basic TCP Bandwidth Test

Go to the second Linux machine (the client). To initiate a standard 10-second TCP throughput test, use the -c (client) flag followed by the IP address of the server:

iperf3 -c 192.168.1.50

As the test runs, the client terminal will output data every second, showing the amount of data transferred and the current bitrate (usually in Mbits/sec or Gbits/sec). After 10 seconds, it will provide a summary of the total transferred data and the average bandwidth.

If you are connected via gigabit ethernet, you should expect to see speeds hovering around 940 Mbits/sec (accounting for standard TCP overhead).

Step 4: Run a UDP Jitter and Packet Loss Test

While TCP tests measure raw maximum throughput, UDP tests are critical for diagnosing voice-over-IP (VoIP) or video streaming issues, as they measure packet loss and network jitter.

To run a UDP test, append the -u flag to your client command. You should also use the -b flag to specify the target bandwidth you want to test (e.g., 100M for 100 Megabits):

iperf3 -c 192.168.1.50 -u -b 100M

When the test finishes, look at the server’s terminal output (not the client’s). The server will report the Jitter (the variance in packet arrival time) and the Lost/Total Datagrams percentage. A packet loss rate greater than 1% indicates a severe physical network issue, such as a damaged ethernet cable or a failing switch port.

Step 5: Reverse the Test Direction

By default, iperf3 pushes data from the client to the server (measuring upload speed from the client’s perspective). To measure the download speed, use the -R (Reverse) flag to force the server to push data to the client:

iperf3 -c 192.168.1.50 -R

Testing in both directions is highly recommended, as faulty network hardware often exhibits asynchronous failure rates where uploads are fine but downloads crawl.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.