Linux / Unix: Test Internet Connection Speed From Console Over SSH Command Line

by on December 14, 2012 · 10 comments· LAST UPDATED December 15, 2012

in , , ,

I have recently rented a dedicated server for my hobby projects and learning CentOS Linux server. I was informed that I am connected to the 100M/s port. How do I test my Internet connection download speed from the console over the ssh session without using HTML5 or Adobe flash/Java applets based websites? How do I test my upload speed from the console?

Tutorial details
DifficultyEasy (rss)
Root privilegesNo
Requirementslftp or wget+wput/ftp
Estimated completion timeN/A

I recommend that you use lftp command to test Internet upload and download speed from console. You can run lftp using the ssh client:

[a] wget - Retrieves files from the web (download speed test).

[b] wput - A tiny wget-like ftp-client for uploading files (upload speed test).

[c] axel - Another light download accelerator.

[d] iperf - Perform network throughput tests.

Installation

You can use the following yum command to install lftp and iperf under RHEL / CentOS / Fedora Linux:
# yum install lftp iperf
OR use the following apt-get command under Debian or Ubuntu Linux:
$ sudo apt-get install lftp iperf

Step #1: Find out download url

You need a large size file to test download speed. For example, you can visit the home page of "Argonne National Laboratory Public Software Mirror" to grab Centos Linux ISO file.

Step #2: Use lftp command to test download speed

The syntax is:

lftp -e 'pget http://example.com/file.iso; exit; '
lftp -e 'pget http://speedtest.example.com/500M.bin; exit; '
lftp -e 'pget http://mirror.anl.gov/pub/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-LiveCD.iso; exit; '
 

Sample outputs:

Fig.01: lftp testing internet speed

Fig.01: lftp testing internet speed


You will also get the report as follows:

725617504 bytes transferred in 65 seconds (10.63M/s) 

A note about wget command

You can use the wget command as follows for testing download speed:
$ wget -O /dev/null http://mirror.anl.gov/pub/centos/6.3/isos/x86_64/CentOS-6.3-x86_64-LiveCD.iso
Sample outputs:

Fig.02: wget command in action

Fig.02: wget command in action

Step #3: Use lftp command to test upload speed

The sytnax is as follows:

 
lftp -u userName ftp.example.com -e 'put largecd1.avi; bye'
lftp -u userName,passWord ftp.example.com -e 'put largecd1.avi; bye'
lftp -u userName,passWord ftp.example.com -e 'put /path/to/large.iso; bye'
 

In this example, I am uploading a file to my private ftp server:

lftp -u admin homeserver -e 'cd video; put /home/vivek/Downloads/debian-testing-amd64-CD-1.iso; bye'

OR

lftp -u admin homeserver.public.ip.here -e 'cd video; put /home/vivek/Downloads/debian-testing-amd64-CD-1.iso; bye'

Sample outputs:

Fig.03: lftp upload speed test in action

Fig.03: lftp upload speed test in action

How do I test network throughput rate between two Linux or Unix servers?

Consider the following setup:

+------------------+                                  +----------------+
| Linux server A    +--------- ISP Internet-----------+ Linux server B +
+------------------+                                  +----------------+
IP:202.54.1.1                                         IP:203.54.1.1
iperf server                                          iperf client

Iperf is a tool to measure maximum TCP bandwidth, allowing the tuning of various parameters and UDP characteristics. Iperf reports bandwidth, delay jitter, datagram loss. On server A start iperf as follows:
# iperf -s -B 202.54.1.1
On server B type the same command as follows:
# iperf -c 202.54.1.1 -d -t 60 -i 10
Sample outputs:

Fig.04: iperf client in action

Fig.04: iperf client in action


Where,

  1. -s : Run in server mode.
  2. -B IP : Bind to IP, an interface or multicast address.
  3. -c IP : Run in client mode, connecting to IP.
  4. -d : Do a bidirectional test simultaneously.
  5. -t 60 : Time in seconds to transmit for (default 10).
  6. -i 10 : Pause n seconds between periodic bandwidth reports.
Recommended readings

See the following man pages for information:
man lftp
man wget
man iperf

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 10 comments… read them below or add one }

1 Phron January 5, 2013 at 12:23 am

this is awesome information…
and i’m learning a lot with your work!!
Thank you very much!!!

Reply

2 Deltaray March 7, 2013 at 2:14 pm

What does ssh have to do with lftp? They are from different packages.

Reply

3 Thái Snake October 24, 2013 at 3:48 pm

I allways use “wget” to check the speed, but i don’t know if have any reason affect the results.
My connection is 100Mbps, i allways download the link from my country, but, the speed only 9-10MB/s. And when i check on windows server, the speed if max 11-12MB/s

Reply

4 Zaman November 15, 2013 at 4:13 pm

Dear sir,

Actually, 100Mbps is represented in bit and 12MBytes.
if you divide 100Mbit / 8 = 12 MByte
because 1Byte = 8bits

hop you can understand

Reply

5 ravi December 18, 2013 at 1:09 pm

Hello,

I´would like to know whether the iperf is used to find the bandwidth of the bluetooth file transfer rate?. I was trying to find the bandwidth while transfering the file from ARM linux board via Bluetooth to host PC or mobile.

If there are any other possibility would be appreciated.
Thank you in advance.

Reply

6 Roman March 27, 2014 at 3:22 pm

could it work on openWrt ?
if so can I get the source code ?

Reply

7 yayaska April 18, 2014 at 6:21 am

The best way to test is to download speedtest.net and use it under python
# wget -O speedtest-cli.py https://github.com/sivel/speedtest-cli/raw/master/speedtest_cli.py

then start the command
# python speedtest-cli.py

I hope this will work for you.
need more help reply to my post

Reply

8 mH~ August 24, 2014 at 1:28 am

Root privileges are not needed. :P

Reply

9 David Ford August 24, 2014 at 10:15 am

Sweet..thanks for the info…almost a Linux-Fu Orange Belt…:D

Reply

10 lalala August 24, 2014 at 11:12 am

you can also use `axel` utility

Reply

Leave a Comment

Tagged as: , , , , , , ,

Previous Faq:

Next Faq: