How To Install Speedtest-cli On a FreeBSD To Check Internet Speed

I am using the FreeBSD system. How do I install Speedtest-cli on a FreeBSD Unix system for checking the Internet speed?

Speedtest CLI allows FreeBSD users to test Internet speed using the command line. This command is meant for software developers, system administrators, and computer enthusiasts alike. It will enable us to measure internet connection performance metrics like download, upload, latency, and packet loss natively without relying on a web browser. Let us see how to install speedtest CLI on FreeBSD.
Tutorial details
Difficulty Easy (rss)
Root privileges Yes
Requirements FreeBSD Unix
Time 5m

ADVERTISEMENTS

How to install speedtest-cli on a FreeBSD

First thing first, update your FreeBSD system and install security package updates using the pkg command:
# pkg update
# pkg upgrade

Then search for speedtest cli package, run:
# pkg search speedtest
Outputs:

py27-speedtest-cli-2.1.2       Python 2.x CLI for testing internet bandwidth
py37-speedtest-cli-2.1.2       Python 3.x version for testing internet bandwidth

Getting information about package

Run the following comamnd:
# pkg info py37-speedtest-cli
Sample info:

Name           : py37-speedtest-cli
Version        : 2.1.2
Installed on   : Fri Oct  9 21:52:08 2020 IST
Origin         : net/py-speedtest-cli
Architecture   : FreeBSD:11:*
Prefix         : /usr/local
Categories     : python net
Licenses       : APACHE20
Maintainer     : nivit@FreeBSD.org
WWW            : https://github.com/sivel/speedtest-cli
Comment        : Command line interface for testing internet bandwidth
Options        :
	DOCS           : on
Annotations    :
	flavor         : py37
	repo_type      : binary
	repository     : FreeBSD
Flat size      : 184KiB
Description    :
Command line interface for testing internet bandwidth using speedtest.net

WWW: https://github.com/sivel/speedtest-cli

Installing speedtest-cli on a FreeBSD Unix system

Since I am using Python version 3.7, I need to install py37-speedtest-cli-2.1.2 as follows:
# pkg install py37-speedtest-cli
How to Install Speedtest-cli On a FreeBSD To Check Internet Speed

How to check the Internet speed

Simply type the following command:
$ speedtest-cli
## or ##
$ speedtest

Force HTTPS instead of HTTP when communicating with speedtest.net operated servers or mirros:
$ speedtest-cli --secure
Internet UP/DL speed session:

Retrieving speedtest.net configuration...
Testing from MY_ISP (13.xxx.yyy.zzz)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by NewMedia Express (Singapore) [6.13 km]: 43.585 ms
Testing download speed........................................
Download: 85.66 Mbit/s
Testing upload speed..........................................
Upload: 85.08 Mbit/s

NOTE: There will be a small speed drop when connected to OpenVPN or WireGuard VPN.

Want to simulate a typical file transfer? Force a single connection instead of multiple (default):
$ speedtest --single
We can display the Internet speed values in bytes instead of bits on my FreeBSD system as follows:
$ speedtest --bytes

Suppress verbose output

We can only show basic information such as ping time, download and upload speed from the CLI:
$ speedtest --secure --simple
Which will result into the following:

Ping: 43.57 ms
Download: 85.63 Mbit/s
Upload: 87.08 Mbit/s

JSON or CSV format

We can view test results via CSV, JSONL, or JSON format. Pretty useful for automation and programming tasks:
$ speedtest --secure --csv
$ speedtest --secure --json

Let us redirect output to a file named /tmp/output.json:
$ speedtest --secure --csv > /tmp/output.csv
$ speedtest --secure --json > /tmp/output.json

Display the file called output.{json,csv} using the cat command:
$ cat /tmp/output.json
Now, we can use jq, which is a lightweight and flexible command-line JSON processor for Unix-like systems. For instance:
$ jq . /tmp/out.json
# get download, upload speed, and ping time #
$ jq -r '.download' /tmp/out.json
$ jq -r '.upload' /tmp/out.json
$ jq -r '.ping' /tmp/out.json

JQ and internet connection measurement for developers in JSON format

How do I specify a server ID to test against a different speedtest.net server?

First see a list of speedtest.net servers sorted by distance by passing the --list option:
$ speedtest --list | more
## Filter output using the grep command/egrep command ##
$ speedtest --list | grep COUNTRY_NAME
$ speedtest --list | grep ISP_NAME

Next, I am going to specify a server ID 13623 (Singtel) to test against:
$ speedtest --server 13623 --secure

Conclusion

In this quick tutorial, we learned how to install speedtest-cli for testing internet bandwidth using speedtest.net on a FreeBSD Unix server or desktop system. For the web browser-based, try the speedtest or fast service from Netflix.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
2 comments… add one
  • NTT4Life Oct 9, 2020 @ 17:43

    > There will be a small speed drop when connected to OpenVPN or WireGuard VPN.
    Why? What cause speed drop? Is it FreeBSD issue or VPN software?

    • acheron51 Oct 9, 2020 @ 17:55

      VPN tunnel overhead or throughput depends on hardware, software, VPN license from vendors such as Cisco, network stack, Internet speed, and other factors. The majority of such elements are out of your control. I would use iperf instead of speedtest-cli to test the actual speed between a VPN server and client.

      TL;DR: Not FreeBSD problem.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.