Originally published September 1, 2015 @ 6:52 pm

The speedtest.net is probably one of the more popular bandwidth testing utilities, Unfortunately, this and many other similar tools require a Web browser with late-version Flash or Java support, which can be problematic on Unix servers.

Fortunately, speedtest.net also provides a Python-based Linux CLI utility that’s easy to use and delivers consistent results. To install and use the “speedtest-cli” follow the simple steps below:

yum install python-pip -y
pip install speedtest-cli
1

Sample run:

[root@cerberus ~]# speedtest-cli

Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Verizon FiOS (xx.xxx.xx.xx)...
Selecting best server based on latency...
Hosted by T-Mobile (Beltsville, MD) [122.57 km]: 17.768 ms
Testing download speed........................................
Download: 13.24 Mbit/s
Testing upload speed..................................................
Upload: 22.61 Mbit/s

You should keep in mind that – for very fast broadband links – the bottleneck may not be your network connection but the Speedtest.net server. By default, the speedtest-cli will select the nearest test server based on your external IP address.

However, sometimes Speedtest.net does not select the nearest test server. You can also specify an alternate test server. The list of Speedtest.net servers is available here in XML format. You can also get a quick list with the “–list” option like so:

speedtest-cli --list

You can sort by the physical distance between your external IP geolocation coordinates and the test server. Just keep in mind that the closest test server in terms of kilometers does not always offers lowest network latency.

speedtest-cli --list | sort -rn -t[ -k 2

You can specify an alternate test server like so:

speedtest-cli --server=4847

You can even specify several test servers and run the test in a loop to check consistency of the results:

for i in 4847 1875 1775 4438 ; do speedtest-cli --server=${i} 2>/dev/null | egrep "^(Hosted by|Download:|Upload)"; done

A better way to test your broadband link speed would be to connect your computer directly into the broadband router, bypassing any firewalls and switches. You may also consider using the ISP-specific network speed test tool, such as this one from Verizon.

  1. Note: to get the most accurate results, make sure your server is not too busy and your WAN activity is minimal.