3 handy command-line internet speed tests

Check your internet and network speeds with these three open source tools.
212 readers like this.
Opensource.com CFP and September preview

Florida Memory. Modified by Opensource.com. CC BY-SA 4.0

Being able to validate your network connection speed puts you in control of your computer. Three open source tools that enable you to check your internet and network speeds at the command line are Speedtest, Fast, and iPerf.

Speedtest

Speedtest is an old favorite. It's implemented in Python, packaged in Apt, and also available with pip. You can use it as a command-line tool or within a Python script.

Install it with:

sudo apt install speedtest-cli

or

sudo pip3 install speedtest-cli

Then run it with the command speedtest:

$ speedtest
Retrieving speedtest.net configuration...
Testing from CenturyLink (65.128.194.58)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by CenturyLink (Cambridge, UK) [20.49 km]: 31.566 ms
Testing download speed................................................................................
Download: 68.62 Mbit/s
Testing upload speed......................................................................................................
Upload: 10.93 Mbit/s

This gives you your download and upload Internet speeds. It's fast and scriptable, so you can run it regularly and save the output to a file or database for a record of your network speed over time.

Fast

Fast is a service provided by Netflix. Its web interface is located at Fast.com, and it has a command-line interface available through npm:

npm install --global fast-cli

Both the website and command-line utility provide the same basic interface: it's a simple-as-possible speed test:

$ fast

     82 Mbps ↓

The command returns your Internet download speed. To get your upload speed, use the -u flag:

$ fast -u

   ⠧ 80 Mbps ↓ / 8.2 Mbps ↑

iPerf

iPerf is a great way to test your LAN speed (rather than your Internet speed, as the two previous tools do). Debian, Raspbian, and Ubuntu users can install it with apt:

sudo apt install iperf

It's also available for Mac and Windows.

Once it's installed, you need two machines on the same network to use it (both must have iPerf installed). Designate one as the server.

Obtain the IP address of the server machine:

ip addr show | grep inet.*brd

Your local IP address (assuming an IPv4 local network) starts with either 192.168 or 10. Take note of the IP address so you can use it on the other machine (the one designated as the client).

Start iperf on the server:

iperf -s

This waits for incoming connections from clients. Designate another machine as a client and run this command, substituting the IP address of your server machine for the sample one here:

iperf -c 192.168.1.2

iPerf

It only takes a few seconds to do a test, and it returns the transfer size and calculated bandwidth. I ran a few tests from my PC and my laptop, using my home server as the server machine. I recently put in Cat6 Ethernet around my house, so I get up to 1Gbps speeds from my wired connections but much lower speeds on WiFi connections.

iPerf

­You may notice where it recorded 16Gbps. That was me using the server to test itself, so it's just testing how fast it can write to its own disk. The server has hard disk drives, which are only 16Gbps, but my desktop PC gets 46Gbps, and my (newer) laptop gets over 60Gbps, as they have solid-state drives.

iPerf

Wrapping up

Knowing the speed of your network is a rather straightforward task with these tools. If you prefer to script or run these from the command line for the fun of it, any of the above projects will get you there. If you're after specific point-to-point metrics, iPerf is your go-to.

What other tools do you use to measure the network at home? Share in the comments.


This article was originally published on Ben Nuttall's Tooling blog and is used here with permission.

What to read next
User profile image.
Ben is a software engineer for BBC News Labs, and formerly Raspberry Pi's Community Manager. He's into Linux, Python and all things open source! Follow Ben on Twitter @ben_nuttall.

7 Comments

This is really great. You’ve taught me something I didn’t know and it’s likely more accurate than the speed test my ISP provides. :)

iPerf involves no writing to the disk, all test data is only ever in memory. Those devices performing better just happen to have better CPU performance to be able to better shuffle the packets around.

However, there's a few public iPerf servers from around the world, listed on the iPerf website: https://iperf.fr/iperf-servers.php

One thing to keep in mind is that the client is sending by default on iPerf. If you want, you can use the -R option to have the server send instead, to test against these public iPerf servers, in the downstream direction.

One comment, iperf does not utilize the disk for testing. so slow disks will not slow it down. You can also use -P with a number to speed it up depending on how many cores it has.

+1 for speedtest!

I think fast is good for me

I didn't know about speedtest-cli! Thanks that will come in handy!

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.