---
title: '使用 SSH 和 iPerf 测试数据传输速度'
url: 'https://ra1ahq.blog/zh-cn/testirovanie-skorosti-peredachi-dannykh-s-pomoshyu-ssh-i-iperf'
markdown: 'https://ra1ahq.blog/zh-cn/testirovanie-skorosti-peredachi-dannykh-s-pomoshyu-ssh-i-iperf.md'
lang: zh-cn
date: '2021-09-07'
description: '检查互联网或本地网络速度的一种简单方法是使用 iPerf 命令。 简介 Lin'
taxonomy:
  category:
    - blog
  tag:
    - Linux
    - управление
  archives_month:
    - sep_2021
  archives_year:
    - '2021'
---

# 使用 SSH 和 iPerf 测试数据传输速度

7 

 9月 

 2021 

 16:02

### 使用 SSH 和 iPerf 测试数据传输速度

 [Linux](https://ra1ahq.blog/zh-cn/tag:Linux), [управление](https://ra1ahq.blog/zh-cn/tag:%D1%83%D0%BF%D1%80%D0%B0%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5) 

7 9月 2021 16:02

检查互联网或本地网络速度的一种简单方法是使用 iPerf 命令。

### 简介

Linux 中有三种速度测试程序 - iPerf（端口 5001）和 iPerf3（端口 5201）。
本文讨论了第一个 iPerf 程序，但您可以将这些指令应用到 iPerf3 程序，将端口号 5001 替换为 5201，也能获得同样的成功。

### 行动计划

1. 通过为 iPerf 服务器添加允许规则来在服务器上设置防火墙
2. 配置端口转发（对于本地网络，我们跳过）
3. 在客户端安装iperf
4. 通过 SSH 连接到服务器
5. 启动iperf服务器
6. 从客户端执行数据传输速度测试

### 步骤 1. 允许端口 5001 进行速度测试

我们在服务器上配置防火墙：

```
sudo ufw allow 5001
```

其中 5001 是 iPerf 服务的默认端口。

### 步骤 2. 端口转发

对于本地网络或 VPN，我跳过转发点到端口 5001。

对于互联网，您需要在路由器上打开并转发 2 个秘密端口：
1\) 通过 SSH 控制 PC（转发到服务器端口 22）- 端口号 22334。
2\) 用于速度测试（默认转发到 iPerf 服务器的端口 5001）- 端口号 12345。

### 步骤 3. 安装 iPerf 客户端/服务器

在台式计算机（Ubuntu Linux 服务器）和客户端（运行 MX Linux 的上网本）上，我运行了相同的命令：

```
sudo apt-get install iperf
```

### 步骤 4. 通过 SSH 连接到服务器

在本地网络上：

```
ssh user@192.168.1.8 -p 22334
```

如果从外部：

```
ssh user@123.45.67.89 -p 22334
```

其中：user 是服务器上的用户名，123.45.67.8 替换为 Internet 上 SSH 服务器的 IP 地址（“白色”IP 地址），22334 是通过 SSH 进行管理的秘密端口。

我输入密码并进入服务器控制台。

### 步骤 5. 启动 iPerf 服务器

通过服务器上的 SSH 会话，我使用“-s”键启动了该程序

```
iperf -s
```

我让 ssh 会话保持运行状态。 本地网络上的服务器 IP 地址是静态的 - 192.168.1.8。

### 步骤 6. 在本地网络中使用 iPerf 测试数据传输速度

在客户端上启动了另一个终端实例（窗口）。

在本地网络上的客户端上，我运行了以下命令：

```
iperf -c 192.168.1.8 -n 10M
```

其中192.168.1.8是本地网络服务器的IP地址，10M是用于测量速度的数据包大小，
默认端口为5001。

或者，如果使用 iperf3，则命令为：

```
iperf3 -c 192.168.1.8 -n 10M
```

### 结果：

`$ iperf -c 192.168.1.8 -n 10M`

`Client connecting to 192.168.1.8 TCP port 5001`

`TCP window size:  110 KByte (default)`

`------------------------------------------------`

`[  1] local 192.168.1.101 port 49772 connected with 192.168.1.8 port 5001`

`[ ID] Interval       Transfer     Bandwidth`

`[  1] 0.0000-1.1685 sec  10.0 MBytes  71.8 Mbits/sec`

### 步骤 7. 使用 iPerf 从本地网络外部测量速度

服务器端保持不变：

```
iperf -s
```

客户端部分：使用“白色”IP 地址（123.45.67.8）和“-p”键（转发到 iPerf 服务器的端口号）调用命令。

```
iperf -c 123.45.67.8 -p 12345  -n 10M
```

### 结果：

了解如何测量两点之间的速度。

以后由于设置已完成，所以只需执行步骤4、5、7即可测量速度。

### iperf 和 iperf3 之间的区别

这些程序是在不同时间编写的。
iperf3是第一个5001端口，最新的iperf3是5201端口。

### iperf3 作为服务

systemd（Linux中的服务初始化和管理子系统）中的iPerf3可以作为服务启动：

```
systemctl enable --now operf3.service
```

执行指定命令后，指定的iperf3服务将被启用并立即启动。
您可以使用以下命令查看服务的状态

```
systemctl status iperf3.service
```

如上所述，通过iperf3协议连接的外部端口是5201/TCP。
如果 iperf3.service 服务正在运行，则无需执行启动 iperf3 服务器的“iperf3 -s”命令，因为运行 iperf3.service 服务的计算机在从另一台客户端计算机执行该命令时始终响应对端口 5201 的请求 `iperf3 -c ip_адрес_сервера -n 10M`。

*最后更改：2022 年 8 月 21 日*

### 相关出版物

 [ ![](https://ra1ahq.blog/images/d/2/5/c/7/d25c7282750b398f71041fb8b90640b692e7e4b8-decibelfmtitle.png) 用于收听网络广播电台的 Linux Cinnamon 桌面小程序 ](https://ra1ahq.blog/zh-cn/applety-dlya-rabochego-stola-linux-cinnamon-dlya-proslushivaniya-internet-radiostancii) 

 [ ![禁止摄影](https://ra1ahq.blog/user/themes/mytheme/images/no-image.png) 将参数传递给 Linux 模块/驱动程序 ](https://ra1ahq.blog/zh-cn/peredacha-parametra-modulyu-draiveru-linux) 

 [ ![](https://ra1ahq.blog/images/5/c/4/e/a/5c4ea9c8c3f0b4dd890116d8fe7cbadfdb9814ba-archer-ac600.webp) 在 Debian 13“Trixie”中安装 TP-Link Archer T600U Nano Wi-Fi 适配器驱动程序 ](https://ra1ahq.blog/zh-cn/ustanovka-draivera-wi-fi-adaptera-tp-link-archer-t600u-nano-v-debian-13-trixie) 

 [ ![](https://ra1ahq.blog/images/b/f/f/0/f/bff0f99f5897e0420fac9a6eef7254247f39c29d-pulseaudio-equalizer.png) 在Linux上安装音频均衡器pulseaudio-equalizer-ladspa ](https://ra1ahq.blog/zh-cn/ustanovka-v-linux-ekvalaizera-zvuka-pulseaudio-equalizer-ladspa) 

 [ ![](https://ra1ahq.blog/images/e/6/d/7/1/e6d71e1e85f93d0c7c19f4841dad7aadd8f1e02b-lvmschemerus.png) Установка Sparky Linux (Debian) на раздел LVM ](https://ra1ahq.blog/zh-cn/ustanovka-sparky-linux-debian-na-razdel-lvm) 

[ 后退](https://ra1ahq.blog/zh-cn/nastroika-servera-sshd-i-klienta-ssh-v-linux "上一页")

[ 向前 ](https://ra1ahq.blog/zh-cn/ustranenie-problemy-sistemnaya-oshibka-pri-vypolnenii-komandy-ping "下一页")

## 语言

- [Русский](https://ra1ahq.blog/posts/testirovanie-skorosti-peredachi-dannykh-s-pomoshyu-ssh-i-iperf)
- [English](https://ra1ahq.blog/en/posts/testirovanie-skorosti-peredachi-dannykh-s-pomoshyu-ssh-i-iperf)
- [Deutsch](https://ra1ahq.blog/de/posts/testirovanie-skorosti-peredachi-dannykh-s-pomoshyu-ssh-i-iperf)
- [Français](https://ra1ahq.blog/fr/posts/testirovanie-skorosti-peredachi-dannykh-s-pomoshyu-ssh-i-iperf)
- [中文 (简体) (cn)](https://ra1ahq.blog/zh-cn/testirovanie-skorosti-peredachi-dannykh-s-pomoshyu-ssh-i-iperf)

## 主题

## RSS订阅

 [ Atom 1.0](https://ra1ahq.blog/zh-cn/.atom) [ RSS](https://ra1ahq.blog/zh-cn/.rss) 

## 热门标签

 [APRS](https://ra1ahq.blog/zh-cn/tag:APRS) [CW](https://ra1ahq.blog/zh-cn/tag:CW) [DX](https://ra1ahq.blog/zh-cn/tag:DX) [FM](https://ra1ahq.blog/zh-cn/tag:FM) [Linux](https://ra1ahq.blog/zh-cn/tag:Linux) [firefox](https://ra1ahq.blog/zh-cn/tag:firefox) [morse](https://ra1ahq.blog/zh-cn/tag:morse) [soundtrack](https://ra1ahq.blog/zh-cn/tag:soundtrack) [video](https://ra1ahq.blog/zh-cn/tag:video) [windows](https://ra1ahq.blog/zh-cn/tag:windows) [youtube](https://ra1ahq.blog/zh-cn/tag:youtube) [КВ](https://ra1ahq.blog/zh-cn/tag:%D0%9A%D0%92) [ТВ](https://ra1ahq.blog/zh-cn/tag:%D0%A2%D0%92) [УКВ](https://ra1ahq.blog/zh-cn/tag:%D0%A3%D0%9A%D0%92) [антенны](https://ra1ahq.blog/zh-cn/tag:%D0%B0%D0%BD%D1%82%D0%B5%D0%BD%D0%BD%D1%8B) [безопасность](https://ra1ahq.blog/zh-cn/tag:%D0%B1%D0%B5%D0%B7%D0%BE%D0%BF%D0%B0%D1%81%D0%BD%D0%BE%D1%81%D1%82%D1%8C) [длинные волны](https://ra1ahq.blog/zh-cn/tag:%D0%B4%D0%BB%D0%B8%D0%BD%D0%BD%D1%8B%D0%B5%20%D0%B2%D0%BE%D0%BB%D0%BD%D1%8B) [путешествия](https://ra1ahq.blog/zh-cn/tag:%D0%BF%D1%83%D1%82%D0%B5%D1%88%D0%B5%D1%81%D1%82%D0%B2%D0%B8%D1%8F) [религия](https://ra1ahq.blog/zh-cn/tag:%D1%80%D0%B5%D0%BB%D0%B8%D0%B3%D0%B8%D1%8F) [соревнования](https://ra1ahq.blog/zh-cn/tag:%D1%81%D0%BE%D1%80%D0%B5%D0%B2%D0%BD%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D1%8F) [спутники](https://ra1ahq.blog/zh-cn/tag:%D1%81%D0%BF%D1%83%D1%82%D0%BD%D0%B8%D0%BA%D0%B8) [средние волны](https://ra1ahq.blog/zh-cn/tag:%D1%81%D1%80%D0%B5%D0%B4%D0%BD%D0%B8%D0%B5%20%D0%B2%D0%BE%D0%BB%D0%BD%D1%8B) [схемы](https://ra1ahq.blog/zh-cn/tag:%D1%81%D1%85%D0%B5%D0%BC%D1%8B) [тесты](https://ra1ahq.blog/zh-cn/tag:%D1%82%D0%B5%D1%81%D1%82%D1%8B) [трансивер](https://ra1ahq.blog/zh-cn/tag:%D1%82%D1%80%D0%B0%D0%BD%D1%81%D0%B8%D0%B2%D0%B5%D1%80) [управление](https://ra1ahq.blog/zh-cn/tag:%D1%83%D0%BF%D1%80%D0%B0%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5) [фотографии](https://ra1ahq.blog/zh-cn/tag:%D1%84%D0%BE%D1%82%D0%BE%D0%B3%D1%80%D0%B0%D1%84%D0%B8%D0%B8) [中波](https://ra1ahq.blog/zh-cn/tag:%E4%B8%AD%E6%B3%A2) [卫星](https://ra1ahq.blog/zh-cn/tag:%E5%8D%AB%E6%98%9F) [原声带](https://ra1ahq.blog/zh-cn/tag:%E5%8E%9F%E5%A3%B0%E5%B8%A6) [原理图](https://ra1ahq.blog/zh-cn/tag:%E5%8E%9F%E7%90%86%E5%9B%BE) [天线](https://ra1ahq.blog/zh-cn/tag:%E5%A4%A9%E7%BA%BF) [安全](https://ra1ahq.blog/zh-cn/tag:%E5%AE%89%E5%85%A8) [宗教](https://ra1ahq.blog/zh-cn/tag:%E5%AE%97%E6%95%99) [控制](https://ra1ahq.blog/zh-cn/tag:%E6%8E%A7%E5%88%B6) [收发器](https://ra1ahq.blog/zh-cn/tag:%E6%94%B6%E5%8F%91%E5%99%A8) [旅行](https://ra1ahq.blog/zh-cn/tag:%E6%97%85%E8%A1%8C) [比赛](https://ra1ahq.blog/zh-cn/tag:%E6%AF%94%E8%B5%9B) [测试](https://ra1ahq.blog/zh-cn/tag:%E6%B5%8B%E8%AF%95) [甚高频](https://ra1ahq.blog/zh-cn/tag:%E7%94%9A%E9%AB%98%E9%A2%91) [电视](https://ra1ahq.blog/zh-cn/tag:%E7%94%B5%E8%A7%86) [莫尔斯](https://ra1ahq.blog/zh-cn/tag:%E8%8E%AB%E5%B0%94%E6%96%AF) [视频](https://ra1ahq.blog/zh-cn/tag:%E8%A7%86%E9%A2%91) [长波](https://ra1ahq.blog/zh-cn/tag:%E9%95%BF%E6%B3%A2) [高频](https://ra1ahq.blog/zh-cn/tag:%E9%AB%98%E9%A2%91) 

## 随机发布

 [ 我会很幸运！](https://ra1ahq.blog/zh-cn/random) 

## 出版物档案

- [ 10月 2026 ✒ 1 ](https://ra1ahq.blog/zh-cn/archives_month:oct_2026)
- [ 9月 2026 ✒ 10 ](https://ra1ahq.blog/zh-cn/archives_month:sep_2026)
- [ 8月 2026 ✒ 6 ](https://ra1ahq.blog/zh-cn/archives_month:aug_2026)
- [ 7月 2026 ✒ 13 ](https://ra1ahq.blog/zh-cn/archives_month:jul_2026)
- [ 6月 2026 ✒ 8 ](https://ra1ahq.blog/zh-cn/archives_month:jun_2026)
- [ 5月 2026 ✒ 2 ](https://ra1ahq.blog/zh-cn/archives_month:may_2026)
- [ 4月 2026 ✒ 6 ](https://ra1ahq.blog/zh-cn/archives_month:apr_2026)
- [ 3月 2026 ✒ 3 ](https://ra1ahq.blog/zh-cn/archives_month:mar_2026)
- [ 2月 2026 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:feb_2026)
- [ 1月 2026 ✒ 8 ](https://ra1ahq.blog/zh-cn/archives_month:jan_2026)
- [ 12月 2025 ✒ 12 ](https://ra1ahq.blog/zh-cn/archives_month:dec_2025)
- [ 11月 2025 ✒ 9 ](https://ra1ahq.blog/zh-cn/archives_month:nov_2025)
- [ 10月 2025 ✒ 8 ](https://ra1ahq.blog/zh-cn/archives_month:oct_2025)
- [ 9月 2025 ✒ 5 ](https://ra1ahq.blog/zh-cn/archives_month:sep_2025)
- [ 8月 2025 ✒ 8 ](https://ra1ahq.blog/zh-cn/archives_month:aug_2025)
- [ 7月 2025 ✒ 5 ](https://ra1ahq.blog/zh-cn/archives_month:jul_2025)
- [ 6月 2025 ✒ 10 ](https://ra1ahq.blog/zh-cn/archives_month:jun_2025)
- [ 5月 2025 ✒ 4 ](https://ra1ahq.blog/zh-cn/archives_month:may_2025)
- [ 4月 2025 ✒ 4 ](https://ra1ahq.blog/zh-cn/archives_month:apr_2025)
- [ 3月 2025 ✒ 4 ](https://ra1ahq.blog/zh-cn/archives_month:mar_2025)
- [ 2月 2025 ✒ 11 ](https://ra1ahq.blog/zh-cn/archives_month:feb_2025)
- [ 12月 2024 ✒ 8 ](https://ra1ahq.blog/zh-cn/archives_month:dec_2024)
- [ 11月 2024 ✒ 2 ](https://ra1ahq.blog/zh-cn/archives_month:nov_2024)
- [ 10月 2024 ✒ 8 ](https://ra1ahq.blog/zh-cn/archives_month:oct_2024)
- [ 9月 2024 ✒ 3 ](https://ra1ahq.blog/zh-cn/archives_month:sep_2024)
- [ 8月 2024 ✒ 5 ](https://ra1ahq.blog/zh-cn/archives_month:aug_2024)
- [ 7月 2024 ✒ 9 ](https://ra1ahq.blog/zh-cn/archives_month:jul_2024)
- [ 6月 2024 ✒ 6 ](https://ra1ahq.blog/zh-cn/archives_month:jun_2024)
- [ 5月 2024 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:may_2024)
- [ 4月 2024 ✒ 5 ](https://ra1ahq.blog/zh-cn/archives_month:apr_2024)
- [ 3月 2024 ✒ 5 ](https://ra1ahq.blog/zh-cn/archives_month:mar_2024)
- [ 2月 2024 ✒ 5 ](https://ra1ahq.blog/zh-cn/archives_month:feb_2024)
- [ 1月 2024 ✒ 6 ](https://ra1ahq.blog/zh-cn/archives_month:jan_2024)
- [ 12月 2023 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:dec_2023)
- [ 11月 2023 ✒ 4 ](https://ra1ahq.blog/zh-cn/archives_month:nov_2023)
- [ 10月 2023 ✒ 8 ](https://ra1ahq.blog/zh-cn/archives_month:oct_2023)
- [ 9月 2023 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:sep_2023)
- [ 8月 2023 ✒ 4 ](https://ra1ahq.blog/zh-cn/archives_month:aug_2023)
- [ 7月 2023 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:jul_2023)
- [ 6月 2023 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:jun_2023)
- [ 5月 2023 ✒ 5 ](https://ra1ahq.blog/zh-cn/archives_month:may_2023)
- [ 4月 2023 ✒ 6 ](https://ra1ahq.blog/zh-cn/archives_month:apr_2023)
- [ 3月 2023 ✒ 5 ](https://ra1ahq.blog/zh-cn/archives_month:mar_2023)
- [ 2月 2023 ✒ 2 ](https://ra1ahq.blog/zh-cn/archives_month:feb_2023)
- [ 1月 2023 ✒ 5 ](https://ra1ahq.blog/zh-cn/archives_month:jan_2023)
- [ 12月 2022 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:dec_2022)
- [ 11月 2022 ✒ 8 ](https://ra1ahq.blog/zh-cn/archives_month:nov_2022)
- [ 10月 2022 ✒ 6 ](https://ra1ahq.blog/zh-cn/archives_month:oct_2022)
- [ 9月 2022 ✒ 9 ](https://ra1ahq.blog/zh-cn/archives_month:sep_2022)
- [ 8月 2022 ✒ 8 ](https://ra1ahq.blog/zh-cn/archives_month:aug_2022)
- [ 7月 2022 ✒ 4 ](https://ra1ahq.blog/zh-cn/archives_month:jul_2022)
- [ 6月 2022 ✒ 9 ](https://ra1ahq.blog/zh-cn/archives_month:jun_2022)
- [ 5月 2022 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:may_2022)
- [ 4月 2022 ✒ 3 ](https://ra1ahq.blog/zh-cn/archives_month:apr_2022)
- [ 3月 2022 ✒ 4 ](https://ra1ahq.blog/zh-cn/archives_month:mar_2022)
- [ 2月 2022 ✒ 6 ](https://ra1ahq.blog/zh-cn/archives_month:feb_2022)
- [ 1月 2022 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:jan_2022)
- [ 12月 2021 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:dec_2021)
- [ 11月 2021 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:nov_2021)
- [ 10月 2021 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:oct_2021)
- [ 9月 2021 ✒ 10 ](https://ra1ahq.blog/zh-cn/archives_month:sep_2021)
- [ 8月 2021 ✒ 6 ](https://ra1ahq.blog/zh-cn/archives_month:aug_2021)
- [ 7月 2021 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:jul_2021)
- [ 6月 2021 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:jun_2021)
- [ 5月 2021 ✒ 7 ](https://ra1ahq.blog/zh-cn/archives_month:may_2021)
- [ 4月 2021 ✒ 4 ](https://ra1ahq.blog/zh-cn/archives_month:apr_2021)
- [ 3月 2021 ✒ 4 ](https://ra1ahq.blog/zh-cn/archives_month:mar_2021)
- [ 2月 2021 ✒ 3 ](https://ra1ahq.blog/zh-cn/archives_month:feb_2021)
- [ 1月 2021 ✒ 4 ](https://ra1ahq.blog/zh-cn/archives_month:jan_2021)
- [ 12月 2020 ✒ 8 ](https://ra1ahq.blog/zh-cn/archives_month:dec_2020)
- [ 11月 2020 ✒ 2 ](https://ra1ahq.blog/zh-cn/archives_month:nov_2020)
- [ 10月 2020 ✒ 3 ](https://ra1ahq.blog/zh-cn/archives_month:oct_2020)
- [ 9月 2020 ✒ 3 ](https://ra1ahq.blog/zh-cn/archives_month:sep_2020)
- [ 8月 2020 ✒ 5 ](https://ra1ahq.blog/zh-cn/archives_month:aug_2020)
- [ 7月 2020 ✒ 5 ](https://ra1ahq.blog/zh-cn/archives_month:jul_2020)
- [ 6月 2020 ✒ 8 ](https://ra1ahq.blog/zh-cn/archives_month:jun_2020)
- [ 5月 2020 ✒ 10 ](https://ra1ahq.blog/zh-cn/archives_month:may_2020)
- [ 4月 2020 ✒ 4 ](https://ra1ahq.blog/zh-cn/archives_month:apr_2020)
- [ 3月 2020 ✒ 2 ](https://ra1ahq.blog/zh-cn/archives_month:mar_2020)
- [ 1月 2020 ✒ 1 ](https://ra1ahq.blog/zh-cn/archives_month:jan_2020)
- [ 12月 2019 ✒ 2 ](https://ra1ahq.blog/zh-cn/archives_month:dec_2019)

## 站内搜索

## 天气预报

[На 14 дней](https://world-weather.ru/pogoda/russia/saint_petersburg/14days/)
[world-weather.ru](https://world-weather.ru/)

---

## Navigation

- Parent: [RA1AHQ](https://ra1ahq.blog/zh-cn/index.md)
- Previous: [解决执行ping命令时出现“系统错误”问题](https://ra1ahq.blog/zh-cn/ustranenie-problemy-sistemnaya-oshibka-pri-vypolnenii-komandy-ping.md)
- Next: [在 Linux 上设置 SSHD 服务器和 SSH 客户端](https://ra1ahq.blog/zh-cn/nastroika-servera-sshd-i-klienta-ssh-v-linux.md)
