> 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/networking/01-overview-3/07-configuration-guide.md).

# NAT 网关配置指南

## 配置流程

![配置流程 — 从零开始搭建可用的 NAT 网关](/files/GRQRlGmyRYiUNMnYVzyy)

步骤 **1–3** 为必要步骤。**4a** 和 **4b** 相互独立 — 可以只配置其中一个或两个都配置。**5** 为验证步骤。

| #  | 任务             | Console 路径                                                                                 | 您将设置的内容                                                            |
| -- | -------------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------ |
| 1  | 分配弹性 IP        | [弹性计算 → 弹性 IPv4 → 分配 EIP](https://console.zenlayer.com/zec/elastic-ip)                     | 与网关同地区                                                             |
| 2  | 创建公网 NAT 网关    | [公网 NAT 网关 → 创建公网 NAT 网关](https://console.zenlayer.com/zec/nat-gateway/create)             | 全球 VPC · 需通过网关路由的子网                                                |
| 3  | 向网关绑定 EIPv4    | 打开 [公网 NAT 网关](https://console.zenlayer.com/zec/nat-gateway) → 网关 → **信息** → **绑定弹性 IPv4** | 选择已分配的 EIP 之一                                                      |
| 4a | 添加 SNAT 条目（出站） | 同一网关 → **NAT 规则** → **创建 SNAT 条目**                                                         | 源子网 / CIDR · 出站 EIPv4                                              |
| 4b | 添加 DNAT 条目（入站） | 同一网关 → **NAT 规则** → **创建 DNAT 条目**                                                         | EIPv4 + 公网端口 → 私有 IP + 私有端口 · 协议（`tcp` / `udp`；`any` 仅在不填写端口字段时使用） |
| 5  | 验证 VPC 路由（可选）  | [VPC → 路由表](https://console.zenlayer.com/zec/route-table)，按类型 **NAT 网关**过滤                 | 每个覆盖子网都有指向网关的默认路由                                                  |

网关必须达到`运行中`状态后才能执行步骤 3。每条新的 SNAT/DNAT 条目在网关应用规则后即时生效。

## 日常运维

| 任务                | Console 路径                                                                                                         |
| ----------------- | ------------------------------------------------------------------------------------------------------------------ |
| 变更子网关联            | 网关详情面板 → 编辑子网选择                                                                                                    |
| 删除 SNAT 或 DNAT 条目 | 网关 → **NAT 规则** → 在目标条目上点击**删除**                                                                                   |
| 删除网关              | [公网 NAT 网关](https://console.zenlayer.com/zec/nat-gateway) → **⋯**（操作） → **删除**。请先删除未使用的条目；剩余 EIP 将自动解绑，网关路由也将自动撤销。 |
| 查看账单和订单           | 网关 → **信息** → **订单和计费** → **查看相关订单** / **查看账单详情**                                                                  |


---

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

```
GET https://docs.console.zenlayer.com/welcome/cn/elastic-compute/networking/01-overview-3/07-configuration-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
