> For the complete documentation index, see [llms.txt](https://docs.verge.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.verge.io/knowledge-base/zh/networking/ipsec-example-dedicated-ip.md).

# IPsec 示例 - 专用公网 IP

以下 IPsec 示例使用一个专用公网 IP 地址用于 VPN 隧道。VPN 路由器以桥接方式连接到现有内部网络，为该网络提供第 2 层连接。

{% hint style="info" %}
**IPsec 是一个复杂的框架，支持大量配置组合，并且有多种方式实现同一目标，因此不可能提供适用于所有情况的通用说明。以下示例配置仅供参考，应根据具体环境和需求进行调整。**
{% endhint %}

{% hint style="info" %}
**请参阅** [**IPsec 产品指南页面**](/run-the-platform/vpn/ipsec.md) **，了解创建 IPsec 隧道的通用分步说明。**
{% endhint %}

* **VPN 网络名称：** *vpn-ipsec*
* **VPN 路由器地址：** *192.168.0.254*
* **本地 VPN 网络：** *192.168.0.0/24*
* **远程 VPN 网络：** *10.10.0.0/16*
* **桥接内部网络名称：** *Internal-xyz*
* **外部网络名称：** *外部*

## 静态租约

我们导航到 ***Internal-xyz** > IP 地址 > 新建*＊ 用于在该内部网络上为 VPN 路由器保留一个静态地址，以防其他实体占用相同的 IP 地址。有关创建静态租约的完整说明，请参见此处： [创建 DHCP 静态租约](/run-the-platform/networking/dhcp-static-lease.md).

![VPN 静态租约](/files/690695a5f5bc3aa865d6876df855a80a91636be9)

## VPN 网络配置

![VPN 网络配置](/files/2fc8e38b6f1a34057197aa93a2097d499994618c)

## 阶段 1

![阶段 1 配置](/files/bccbf1c0fa906b31a7a93d94405f2a462a544ed9)

## 阶段 2

![阶段 2 配置](/files/e34af22d995963e2a63279222c456ccbff54f964)

## 分配的公网 IP 地址

公网地址必须 [从外部网络分配](/run-the-platform/networking/assign-external-ip.md) 给 VPN 网络。

![分配公网 IP](/files/145debacaee5a6109915483c28051528727b7a86)

## 默认 VPN 网络规则

**默认防火墙规则** - 以下必要的防火墙规则会 **自动创建** ，当创建 VPN 网络时：

* **允许 IKE**：接受到端口 500 的入站 UDP 流量到 **我的路由器 IP**
* **允许 IPsec NAT 穿越**：接受到端口 4500 的入站 UDP 流量到 **我的路由器 IP**
* **允许 ESP**：接受入站 ESP 协议流量到 **我的路由器 IP**
* **允许 AH**：接受入站 AH 协议流量到 **我的路由器 IP**

![查看规则](/files/3dbcffd115878cbb47118e6ee9996b6b2e9681d7)

{% hint style="success" %}
**在适当情况下，这些规则可以修改为仅限制特定源地址。**
{% endhint %}

## 其他 VPN 网络规则

需要在我们新的 VPN 网络上创建其他规则：

**转换规则：** ![VPN Translate to Router](/files/16d2e4b3fba54c55267fbcc744267715dd28ef0e)

{% hint style="info" %}
**该转换规则必须移动到规则列表顶部，位于&#x20;*****接受*****&#x20;规则之前。有关更改规则顺序的说明，请参见产品指南：** [**网络规则 - 更改规则顺序**](/run-the-platform/networking/network-rules.md#change-the-order-of-rules)
{% endhint %}

**默认路由规则：** ![VPN Default Route Rule](/files/38da52b1fde7039eab5a2a66db61ecb980af2620)

## 内部网络规则

需要在 *Internal-xyz* 上配置一条路由规则，以将其 VPN 流量路由到 VPN 网络。

![VPN 默认路由规则](/files/e2f69fb52cc721523bde6fd2525b45dca83d9117)

{% hint style="success" %}
**新规则必须应用到每个网络上才能生效。**
{% endhint %}


---

# 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.verge.io/knowledge-base/zh/networking/ipsec-example-dedicated-ip.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.
