Content
Checking connection speed with iperf
iperf is a powerful tool for testing network bandwidth, enabling the measurement of data transfer speeds between two devices. It is widely used by system administrators and engineers to diagnose network issues and evaluate connection performance. In this article, we’ll explore how to install iperf, how to use it, and how to properly configure a firewall for its correct operation.
Installing iperf
Before starting, you need to install iperf on both devices: the server (receiving traffic) and the client (sending traffic). There are two popular versions—iperf2 and iperf3. We recommend using iperf3, as it is actively supported and offers enhanced features.
Installation on Linux
- Ubuntu/Debian:
sudo apt update sudo apt install iperf3
- CentOS/RHEL:
sudo yum install iperf3
Installation on Windows
- Download iperf3 from the official website (e.g., https://iperf.fr/)
- Extract the archive to a convenient folder (e.g., C:\iperf).
- Add the folder path to the PATH environment variable for easy command-line access.
Installation on macOS
- Via Homebrew:
brew install iperf3
After installation, verify the version to ensure the tool is working:
iperf3 --version
How Does iperf Work?
iperf operates on a client-server model:
- Server: Runs on one device and listens for incoming connections.
- Client: Connects to the server and sends data to measure speed.
By default, iperf3 uses TCP port 5201 (iperf2 uses 5001). You can change the port using the -p option.
Configuring the Firewall for iperf
To ensure iperf works correctly, verify that the firewall on your device does not block connections on the ports used by iperf (default is TCP 5201, but you can specify another port with -p). Below are instructions for configuring the firewall on different operating systems.
Windows
- Open firewall settings:
- Press Win + R, type
control
, and select "Windows Defender Firewall." - Go to "Allow an app or feature through Windows Defender Firewall."
- Press Win + R, type
- Add a rule for iperf:
- Click "Allow another app," then "Browse," and select the iperf3.exe file.
- Allow incoming and outgoing connections for private and public networks.
- Create a port rule (alternative method):
- In "Advanced settings," select "Inbound Rules" → "New Rule."
- Choose "Port," specify TCP and the port (e.g., 5201), then allow the connection.
- Repeat for outbound connections if needed.
Linux
Different firewall management tools are used depending on the distribution:
- For ufw (Ubuntu, Debian):
sudo ufw allow 5201/tcp sudo ufw status # Check status
- For firewalld (CentOS, RHEL):
sudo firewall-cmd --add-port=5201/tcp --permanent sudo firewall-cmd --reload sudo firewall-cmd --list-ports # Check open ports
- For iptables (manual configuration):
sudo iptables -A INPUT -p tcp --dport 5201 -j ACCEPT sudo iptables -A OUTPUT -p tcp --sport 5201 -j ACCEPT
macOS
- Open firewall settings:
- Go to "System Settings" → "Security & Privacy" → "Firewall" tab.
- Ensure the firewall is enabled.
- Add an exception:
- Click "Firewall Options" → "+" and add the iperf3 application.
- Allow incoming connections.
- Via terminal (alternative):
echo "pass in proto tcp from any to any port 5201" | sudo pfctl -f - sudo pfctl -e # Enable firewall
General Recommendations
- Ensure the port used in the iperf command (e.g.,
iperf3 -s -p 5201
) matches the port opened in the firewall. - Use
netstat
orss
(e.g.,ss -tuln | grep 5201
) to verify the port is listening. - If testing over the internet, configure the router or cloud server firewall accordingly.
Using iperf
Starting the Server
On the device acting as the server, run:
iperf3 -s
You’ll see a message indicating the server is running and listening on port 5201.
Starting the Client
On the second device (client), specify the server’s IP address:
iperf3 -c 192.168.1.100
-c
: Client mode.192.168.1.100
: Replace with your server’s IP address.
By default, the test runs for 10 seconds. Results will show the data transfer speed in megabits per second (Mbps).
Testing with a Public Server
If you can’t run your own server, you can use public iperf servers. For example, Bouygues Telecom’s server:
iperf3 -c bouygues.iperf.fr
This command connects to the public server bouygues.iperf.fr (default port 5201) and measures the speed between your device and the server. Note that public server availability may vary, and results depend on your internet connection.
Useful Options
-t <time>
: Test duration in seconds (e.g.,-t 30
).-p <port>
: Specify port (e.g.,-p 5001
).-u
: Use UDP instead of TCP.-b <speed>
: Limit bandwidth (e.g.,-b 10M
for 10 Mbps).-R
: Test reverse direction (server to client).
Example UDP test:
iperf3 -c 192.168.1.100 -u -b 100M
Interpreting Results
After the test, iperf3 displays a table with results:
- Interval: Time interval.
- Transfer: Amount of data transferred.
- Bandwidth: Bandwidth in Mbps.
Example output for a local test:
[ 5] 0.00-10.00 sec 1.13 GBytes 970 Mbits/sec
This indicates that 1.13 GB was transferred over 10 seconds at an average speed of 970 Mbps.
Example output for a test with the public server bouygues.iperf.fr:
iperf3 -c bouygues.iperf.fr Connecting to host bouygues.iperf.fr, port 5201 [ 4] local 192.168.0.47 port 56396 connected to 89.84.1.222 port 5201 [ ID] Interval Transfer Bandwidth Retr Cwnd [ 4] 0.00-1.00 sec 608 KBytes 4.98 Mbits/sec 0 48.1 KBytes [ 4] 1.00-2.00 sec 1.24 MBytes 10.4 Mbits/sec 0 80.6 KBytes [ 4] 2.00-3.00 sec 1.62 MBytes 13.6 Mbits/sec 0 120 KBytes [ 4] 3.00-4.00 sec 2.11 MBytes 17.7 Mbits/sec 0 151 KBytes [ 4] 4.00-5.00 sec 2.92 MBytes 24.5 Mbits/sec 0 173 KBytes [ 4] 5.00-6.00 sec 2.98 MBytes 25.0 Mbits/sec 0 191 KBytes [ 4] 6.00-7.00 sec 3.42 MBytes 28.7 Mbits/sec 0 212 KBytes [ 4] 7.00-8.00 sec 1.30 MBytes 10.9 Mbits/sec 0 212 KBytes [ 4] 8.00-9.00 sec 445 KBytes 3.65 Mbits/sec 1 212 KBytes [ 4] 9.00-10.00 sec 891 KBytes 7.30 Mbits/sec 0 212 KBytes [ ID] Interval Transfer Bandwidth Retr [ 4] 0.00-10.00 sec 17.5 MBytes 14.7 Mbits/sec 1 sender [ 4] 0.00-10.00 sec 16.7 MBytes 14.0 Mbits/sec receiver
In this case, the test shows that 17.5 MB was transferred over 10 seconds at an average speed of 14.7 Mbps (sender) and 14.0 Mbps (receiver). The Retr
column indicates retransmissions (1 in this case), and Cwnd
shows the congestion window size, which increases during the test.
Conclusion
iperf is a simple and effective tool for testing network speed. It allows you to quickly identify bottlenecks in a connection and evaluate actual performance, whether in a local network or with public servers like bouygues.iperf.fr. Ensure your firewall is properly configured and use the appropriate options for your needs. If you have any questions, leave a comment below!