> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/welcome/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/welcome/cn/elastic-compute/load-balancing/07-all-ports-listener.md).

# 负载均衡器全端口监听器

全端口监听器是单个监听器，可匹配其协议上的**所有端口**——一条规则覆盖目的端口从 1 到 65535 的所有 TCP（或 UDP）流量。适用于目的端口是协议组成部分、后端本身已知如何处理所有端口的工作负载。

## 工作原理

![全端口监听器：每个目的端口端到端保留](/files/brjRU0G0KK2FMLOOv0Uz)

连接到 VIP 上任意端口的客户端都由该监听器匹配，调度器选取一台健康的后端，**客户端的目的端口在到达后端的过程中保持不变**。不同端口上的不同流量可能落到相同或不同的后端——端口在整个链路上保持一致。

为此，后端的端口必须配置为"与监听器端口相同"。字段说明请参见[后端服务器](/welcome/cn/elastic-compute/load-balancing/04-backend.md)。

## 适用与不适用场景

| 场景                                                      | 是否使用？ | 原因                                   |
| ------------------------------------------------------- | ----- | ------------------------------------ |
| 后端将目的端口作为协议的一部分——FTP 主动模式、RTSP/RTP、MMO 和游戏服务器、动态端口自定义协议 | ✅ 是   | 一条监听器规则覆盖整个端口范围；原始目的端口原封不动地到达后端。     |
| VIP 前置于某服务的直通模式，所有端口决策均由后端负责                            | ✅ 是   | 将端口策略的决定权交给后端，LB 不介入。                |
| 工作负载可以用明确的端口表示——即使是很长的列表                                | ❌ 否   | 明确的端口更易于监控、审计和推理。                    |
| 您还希望在同一协议上配置明确端口的监听器                                    | ❌ 否   | 全端口与明确端口监听器在每个端口上都重叠；二者只能选其一，不能同时配置。 |
| 需要按端口评估健康状态                                             | ❌ 否   | 每台后端只有一个探测，覆盖整个端口范围；无法检测到部分端口的故障。    |

## 限制

* 每个监听器对应一种协议。如果您需要 TCP 全端口和 UDP 全端口，请创建两个监听器。
* 所有端口共享同一后端池、调度器和健康检查——调度和健康检查行为无法在端口范围内有所不同。
* 不支持按端口的可观测性（按端口流量计数器、按端口速率限制）。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.console.zenlayer.com/welcome/cn/elastic-compute/load-balancing/07-all-ports-listener.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
