You can test the network speed (throughput) between Ubuntu/CentOS/Debian/Fedora or Unix box using the iperf command. Iperf commands show info about bandwidth, delay, jitter, and datagram loss. From the man page:
Here is my sample setup:
Step 1 – Installation
You need to install iperf as per your Linux distro version. There are two versions of iperf:
- iperf
- iperf3
The iperf/iperf3 works on Linux, Unix, Windows, *BSD and other operating systems.
Install iperf on a Ubuntu/Debian Linux server
Type the following apt-get command/[nixmcd name=”apt”] to install iperf on both servers:
Sample outputs:
$ sudo apt-get update
$ sudo apt-get install iperf
Sample outputs:
A note about installing iperf3 on a Debian/Ubuntu Linux
It is also possible to install iperf3 (latest version) as follows:
Sample outputs:
$ sudo apt-get install iperf3
Sample outputs:
Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libiperf0 The following NEW packages will be installed: iperf3 libiperf0 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 58.5 kB of archives. After this operation, 238 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://mirrors.linode.com/ubuntu xenial/universe amd64 libiperf0 amd64 3.0.11-1 [50.4 kB] Get:2 http://mirrors.linode.com/ubuntu xenial/universe amd64 iperf3 amd64 3.0.11-1 [8090 B] Fetched 58.5 kB in 0s (4796 kB/s) Selecting previously unselected package libiperf0:amd64. (Reading database ... 26120 files and directories currently installed.) Preparing to unpack .../libiperf0_3.0.11-1_amd64.deb ... Unpacking libiperf0:amd64 (3.0.11-1) ... Selecting previously unselected package iperf3. Preparing to unpack .../iperf3_3.0.11-1_amd64.deb ... Unpacking iperf3 (3.0.11-1) ... Processing triggers for man-db (2.7.5-1) ... Setting up libiperf0:amd64 (3.0.11-1) ... Setting up iperf3 (3.0.11-1) ... Processing triggers for libc-bin (2.23-0ubuntu9) ...
Install iperf on a Fedora Linux server
Type the following [nixmcd name=”dnf”] to install iperf on both servers:
$ sudo dnf install iperf
A note about installing iperf3 on a CentOS/RHEL/SL/Oracle Linux
Type the following command:
$ sudo dnf install iperf3
Install iperf on a CentOS/RHEL/Oracle/Scientific Linux server
Type the following [nixmcd name=”yum”] to install iperf on both servers (first turn on EPEL repo for CentOS/RHEL):
Sample outputs:
$ sudo yum install iperf
Sample outputs:
A note about installing iperf3 on a CentOS/RHEL/SL/Oracle Linux
Type the following command:
$ sudo yum install iperf3
Step 2 – Start an iperf server on serverA (server mode)
Type the following command to run iperf in server mode:
OR
Sample outputs:
iperf -s
OR
iperf3 -s
Sample outputs:
------------------------------------------------------------ Server listening on TCP port 5001 TCP window size: 85.3 KByte (default) ------------------------------------------------------------
A note about firewall config
Please note that you must open TCP port 5001 on the serverA. See how to use ufw to open a port on Ubuntu/Debian Linux:
It is also possible to change the port by passing the -p option as follows (e.g. open and use TCP port 2323):
$ sudo ufw allow from 192.168.149.0/24 to 192.168.149.69 port 5001 proto tcp
It is also possible to change the port by passing the -p option as follows (e.g. open and use TCP port 2323):
iperf -s -p 2323
Step 3 – Start an iperf server on serverB (client mode)
Type the following command to run in client mode, connecting to 192.168.149.69:
OR
Sample outputs:
iperf -c {ip-address-of-serverA-here}
iperf -c {ip-address-of-serverA-here} -p {tcp-port}
iperf -c 192.168.149.69 -p 2323
iperf -c 192.168.149.69
OR
iperf3 -c {ip-address-of-serverA-here}
iperf3 -c {ip-address-of-serverA-here} -p {tcp-port}
iperf3 -c 192.168.149.69 -p 2323
iperf3 -c 192.168.149.69
Sample outputs:
How to use UDP rather than TCP
On the server side:
On the client side:
iperf -s -u
On the client side:
iperf -c 192.168.149.69 -u
How to set number of parallel client threads to run (client mode options)
Pass the -P option:
You can also set time in seconds to transmit for (default 10 secs) as follows:
Sample outputs:
iperf -c 192.168.149.69 -P 3
You can also set time in seconds to transmit for (default 10 secs) as follows:
iperf -c 192.168.149.69 -P 3 -t 30
Sample outputs:
Here is output from iperf3:
Sample outputs:
## on the server side ##
iperf3 -s
## on the client side ##
iperf3 -c 192.168.149.69
Sample outputs:
Getting help
Type the following command:
$ man iperf
$ iperf --help
See iperf home page for more info.