Linux

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > Linux > Linux测速脚本和命令

常用的Linux测速脚本和命令汇总

作者:网硕互联的小客服

在Linux服务器上,测速脚本和命令是评估网络上传、下载速度以及延迟的重要工具,广泛用于服务器部署后的网络性能测试,以下介绍一些常用的Linux测速脚本和命令,包括下载速度、延迟测试、以及综合带宽测速工具,需要的朋友可以参考下

1. 使用常用测速脚本

1.1 Speedtest CLI

Speedtest.net 提供的官方命令行工具,适合测试服务器的上下行带宽和延迟。

安装 Speedtest CLI

下载并安装 Speedtest CLI:

对于基于 apt 的系统(如 Ubuntu/Debian):

sudo apt update
sudo apt install -y curl
curl -s https://install.speedtest.net/app/cli/install.deb.sh | sudo bash
sudo apt install speedtest

对于基于 yum 的系统(如 CentOS):

sudo yum install -y curl
curl -s https://install.speedtest.net/app/cli/install.rpm.sh | sudo bash
sudo yum install speedtest

验证安装:

speedtest --version 

运行测速

测试网络速度:

speedtest 

输出示例:

Ping: 5.26 ms
Download: 100.23 Mbps
Upload: 20.15 Mbps

使用特定服务器测速:

speedtest --server-id 12345 

(服务器ID可以通过 speedtest --servers 查询。)

1.2 Bench.sh

Bench.sh 是一款轻量级的脚本,用于测试服务器的综合性能,包括网络速度、硬件信息和存储性能。

运行脚本

执行以下命令下载并运行脚本:

curl -fsL https://raw.githubusercontent.com/teddysun/across/master/bench.sh | bash

输出示例

脚本会返回以下信息:

1.3 Superbench

Superbench 是一款功能更强的脚本,专注于网络性能测试,支持全球多个节点的带宽测速。

运行脚本

下载并运行:

wget -qO- git.io/superbench.sh | bash

功能特色

1.4 BestTrace

BestTrace 是一款路由追踪和延迟测试工具,适合测试服务器到特定目标的网络路径、延迟和丢包率。

安装 BestTrace

下载 BestTrace:

wget https://cdn.ipip.net/17mon/besttrace4linux.zip 

解压并赋予权限:

unzip besttrace4linux.zip
chmod +x besttrace

运行测速

测试路由和延迟:

./besttrace www.google.com 

1.5 iperf3

iperf3 是一款专业的带宽测试工具,适合测试两台服务器之间的网络带宽。

安装 iperf3

  1. 安装 iperf3:

对于 Ubuntu/Debian:

sudo apt install -y iperf3 

对于 CentOS:

sudo yum install -y epel-release
sudo yum install -y iperf3

运行测试

在一台服务器上启动 iperf3 服务端:

iperf3 -s 

在另一台服务器上运行客户端,连接服务端测试带宽:

iperf3 -c <服务端IP地址> 

输出示例:

[ ID] Interval           Transfer     Bandwidth
[  4]   0.00-10.00 sec  112 MBytes   94.1 Mbits/sec

2. 使用单节点下载测速命令

2.1 wget 命令

通过 wget 下载大文件测试服务器的下载速度。

示例:测试下载速度

下载测试文件:

wget -O /dev/null http://speedtest.tele2.net/1GB.zip 

输出示例:

1GB.zip 100%[===================>] 1.00G 85.2MB/s in 12s 

2.2 curl 命令

curl 也可以用来测试下载速度。

示例:测试下载速度

curl -o /dev/null http://speedtest.tele2.net/1GB.zip 

3. 使用多节点测速脚本

3.1 LemonBench

LemonBench 是一款多节点网络和硬件综合性能测试脚本。

运行脚本

下载并运行:

curl -fsL https://ilemonra.in/LemonBenchIntl | bash -s fast 

输出

LemonBench 会输出全球多节点的下载速度、延迟和硬件信息。

3.2 三网测速脚本(适用于中国大陆)

三网测速脚本可以测试中国电信、中国联通和中国移动的下载速度。

运行脚本

下载并运行:

bash <(curl -Lso- https://git.io/superspeed) 

输出示例

脚本会输出到中国电信、联通和移动节点的下载速度。

4. Ping 和 Traceroute 测试

4.1 测试延迟(Ping)

使用 ping 测试目标IP或域名的延迟:

ping -c 5 www.google.com 

输出示例:

64 bytes from www.google.com: icmp_seq=1 ttl=115 time=34.2 ms 

4.2 路由追踪(Traceroute)

使用 traceroute 检查服务器到目标的路由路径:

安装:

sudo apt install traceroute  # Ubuntu/Debian
sudo yum install traceroute  # CentOS

使用:

traceroute www.google.com 

输出示例:

traceroute to www.google.com (172.217.160.68), 30 hops max, 60 byte packets
 1  192.168.1.1 (192.168.1.1)  1.02 ms  0.96 ms  0.90 ms
 2  10.0.0.1 (10.0.0.1)  2.05 ms  2.00 ms  1.95 ms
 ...

5. 总结

以下是常用的 Linux 测速工具和命令的推荐用途:

工具/脚本用途适用场景
Speedtest CLI测试上下行带宽和延迟快速测速,简单易用
Bench.sh综合测试网络和硬件性能服务器性能综合评估
Superbench多节点网络测速全球多节点网络测试
iperf3两台服务器之间的带宽测试内网或外网带宽测试
三网测速脚本测试到中国电信、联通、移动的速度中国大陆节点测速
ping/traceroute测试延迟和路由路径延迟、丢包排查

根据需求选择适合的工具,可以快速了解服务器的网络性能并优化配置。

以上就是常用的Linux测速脚本和命令汇总的详细内容,更多关于Linux测速脚本和命令的资料请关注脚本之家其它相关文章!

您可能感兴趣的文章:
阅读全文