linux
主页 > 服务器 > linux >

常用的Linux测速脚本和命令

2025-12-01 | 佚名 | 点击:

1. 使用常用测速脚本

1.1 Speedtest CLI

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

安装 Speedtest CLI

下载并安装 Speedtest CLI:

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

1

2

3

4

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):

1

2

3

sudo yum install -y curl

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

sudo yum install speedtest

验证安装:

1

speedtest --version

运行测速

测试网络速度:

1

speedtest

输出示例:

1

2

3

Ping: 5.26 ms

Download: 100.23 Mbps

Upload: 20.15 Mbps

使用特定服务器测速:

1

speedtest --server-id 12345

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

1.2 Bench.sh

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

运行脚本

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

1

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

输出示例

脚本会返回以下信息:

1.3 Superbench

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

运行脚本

下载并运行:

1

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

功能特色

1.4 BestTrace

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

安装 BestTrace

下载 BestTrace:

1

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

解压并赋予权限:

1

2

unzip besttrace4linux.zip

chmod +x besttrace

运行测速

测试路由和延迟:

1

./besttrace www.google.com

1.5 iperf3

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

安装 iperf3

  1. 安装 iperf3:

对于 Ubuntu/Debian:

1

sudo apt install -y iperf3

对于 CentOS:

1

2

sudo yum install -y epel-release

sudo yum install -y iperf3

运行测试

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

1

iperf3 -s

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

1

iperf3 -c <服务端IP地址>

输出示例:

1

2

[ ID] Interval           Transfer     Bandwidth

[  4]   0.00-10.00 sec  112 MBytes   94.1 Mbits/sec

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

2.1 wget 命令

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

示例:测试下载速度

下载测试文件:

1

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

输出示例:

1

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

2.2 curl 命令

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

示例:测试下载速度

1

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

3. 使用多节点测速脚本

3.1 LemonBench

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

运行脚本

下载并运行:

1

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

输出

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

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

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

运行脚本

下载并运行:

1

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

输出示例

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

4. Ping 和 Traceroute 测试

4.1 测试延迟(Ping)

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

1

ping -c 5 www.google.com

输出示例:

1

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

4.2 路由追踪(Traceroute)

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

安装:

1

2

sudo apt install traceroute  # Ubuntu/Debian

sudo yum install traceroute  # CentOS

使用:

1

traceroute www.google.com

输出示例:

1

2

3

4

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 测试延迟和路由路径 延迟、丢包排查

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

原文链接:
相关文章
最新更新