Featured image of post Run your own bandwidth speed test server thanks to iPerf

Run your own bandwidth speed test server thanks to iPerf

If you are reading this, I'm pretty sure you may want to have your own selfhosted speedtest server. There are multiple reasons to run your own

When it comes to this kind of analysis, iPerf is one of the first options I think of to perform network tests.

Installing iPerf

So, that said let’s just get hands on. This example relies on running a Linux machine wherever you want to host your speed test instance. Thus the only thing you just need is to install the iperf3 tool.

Then the next step would be running the speed test instance, which can be achieved by running this:

/usr/bin/iperf3 -s -p 5500

Where -s means “run in server mode” and -p 5500 means “in port 5500” (this is the one by default, you can change it to whatever you want). If the server is running behind a NAT firewall don’t forget to set the proper port-forwarding rules.

Running the server

At this point, the only thing you have to do to start measuring your speed connection against this iPerf instance is running this command:

iperf3 -c ${IPERF\_SERVER\_ADDRESS} -p 5500 -P 8 -t 30

Where -c points the server to connect to, -P the number of parallel client streams to run and -t the ammount of time (in seconds) we want it to keep running.

You should get an output similar to this:

- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-10.00  sec  32.4 MBytes  27.2 Mbits/sec  444             sender
[  5]   0.00-10.00  sec  29.3 MBytes  24.6 Mbits/sec                  receiver
(...)
[SUM]   0.00-10.00  sec   276 MBytes   232 Mbits/sec  2663             sender
[SUM]   0.00-10.00  sec   259 MBytes   217 Mbits/sec                  receiver

Set it up as a Systemd service

Also, if you are running Systemd you can create a script file to make it run as a service on your system. For this, simply create the file `/etc/systemd/system/speedtest.service` and copy the following content into it:

[Unit]
Description=iPerf3 speed test server
After=network.target

[Service]
ExecStart=/usr/bin/iperf3 -s -p 5500

[Install]
WantedBy=multi-user.target

Once created just reload Systemd’s configuration and start it:

sudo systemctl daemon-reload sudo systemctl start speedtest.service

Lastly, if you wish to get your iPerf3 instance running on system startup go enable the new service:

sudo systemctl enable speedtest.service

And that’s it, now you can start measuring your bandwidth speed test against your own server.

See you next time!

Built with Hugo