Проверка скорости интернета и сети в linux через консоль

Задача проверить download и upload скорость через консоль.
На помощь приходит speedtest-clihttps://github.com/sivel/speedtest-cli
и iperf в случае если имеется второй компьютер в сети

speedtest-cli

wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest_cli.py
chmod +x speedtest-cli
$ ./speedtest-cli -h
Usage: speedtest-cli [options]

Command line interface for testing internet bandwidth using speedtest.net.
--------------------------------------------------------------------------
https://github.com/sivel/speedtest-cli

Options:
  -h, --help         show this help message and exit
  --bytes            Display values in bytes instead of bits. Does not affect
                     the image generated by --share
  --share            Generate and provide a URL to the speedtest.net share
                     results image
  --simple           Suppress verbose output, only show basic information
  --list             Display a list of speedtest.net servers sorted by
                     distance
  --server=SERVER    Specify a server ID to test against
  --mini=MINI        URL of the Speedtest Mini server
  --source=SOURCE    Source IP address to bind to
  --timeout=TIMEOUT  HTTP timeout in seconds. Default 10
  --version          Show the version number and exit

Сохранить список доступных удалённых серверов. Список будет упорядочен по удалённости в км. от текущего ип.

./speedtest-cli --list>list.txt

Подсматривием нужный номер сервера и тестим

./speedtest-cli --server 5580
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from VimpelCom (78.106.1.1)...
Hosted by H1 LLC (Moscow) [164.76 km]: 6.641 ms
Testing download speed........................................
Download: 81.59 Mbit/s
Testing upload speed..................................................
Upload: 73.78 Mbit/s

Если нужно похвастаться и показать картинку со скоростями, то такое тоже возможно, ключ --share

./speedtest-cli --server 2322 --simple --share
Ping: 9.726 ms
Download: 44.13 Mbit/s
Upload: 58.31 Mbit/s
Share results: https://www.speedtest.net/result/4233232365.png

iperf

На принимающей стороне (сервер)

iperf -s 192.168.1.1 -P 10

На клиенте

iperf -c 192.168.1.1 -P 10

-P 10 — 10 потоков

$ iperf -c 192.168.1.1 -P 10
------------------------------------------------------------
Client connecting to 192.168.1.1, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[ 12] local 192.168.1.2 port 49328 connected with 192.168.1.1 port 5001
[  3] local 192.168.1.2 port 49319 connected with 192.168.1.1 port 5001
[  5] local 192.168.1.2 port 49321 connected with 192.168.1.1 port 5001
[  4] local 192.168.1.2 port 49320 connected with 192.168.1.1 port 5001
[  6] local 192.168.1.2 port 49322 connected with 192.168.1.1 port 5001
[  7] local 192.168.1.2 port 49323 connected with 192.168.1.1 port 5001
[  8] local 192.168.1.2 port 49324 connected with 192.168.1.1 port 5001
[  9] local 192.168.1.2 port 49325 connected with 192.168.1.1 port 5001
[ 10] local 192.168.1.2 port 49326 connected with 192.168.1.1 port 5001
[ 11] local 192.168.1.2 port 49327 connected with 192.168.1.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  5]  0.0-10.1 sec  12.0 MBytes  9.93 Mbits/sec
[ 10]  0.0-10.1 sec  9.62 MBytes  7.96 Mbits/sec
[ 11]  0.0-10.1 sec  9.62 MBytes  7.96 Mbits/sec
[  8]  0.0-10.2 sec  12.0 MBytes  9.91 Mbits/sec
[  9]  0.0-10.2 sec  12.0 MBytes  9.91 Mbits/sec
[ 12]  0.0-10.2 sec  11.9 MBytes  9.79 Mbits/sec
[  4]  0.0-10.2 sec  12.0 MBytes  9.89 Mbits/sec
[  6]  0.0-10.2 sec  12.0 MBytes  9.89 Mbits/sec
[  7]  0.0-10.2 sec  12.0 MBytes  9.88 Mbits/sec
[  3]  0.0-10.2 sec  12.0 MBytes  9.88 Mbits/sec
[SUM]  0.0-10.2 sec   115 MBytes  94.8 Mbits/sec

Суммарная пропускная способность 94.8 Mbits/sec