> 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/run-the-platform/zh/vpn/wireguard-examples.md).

# WireGuard 配置示例

以下内容作为 WireGuard 示例实现提供。有关各个字段设置的更多指导，请参阅 WireGuard 一般帮助页面。注意：以下示例使用示例地址方案；实际实现应根据特定环境配置合适的地址/设置。

## 示例：在两个 VergeOS 系统之间创建 VPN 隧道

在此示例中，“SystemA”和“SystemB”将用于表示通过 VPN 连接的 2 个 VergeOS 系统。

**在 SystemA 上：**

1. **创建一个 WireGuard 接口。**
2. **复制** 生成的公钥（用于该接口）到剪贴板，使用复制图标。

**在 SystemB 上：**\
3\. **创建一个 WireGuard 接口。**\
4\. **创建一个 Peer** 定义（以允许 SystemA 连接到此系统。） - 在 ***公钥*** 密钥字段中，粘贴从 SystemA 复制的密钥。 - 在 ***允许的 IP*** 部分：- 添加一个条目，用于 **SystemA 上的 WireGuard 接口的地址**。- 添加一个条目，用于 **SystemA 上连接的网络** （例如，WireGuard 连接到的网络。

![guard-b-peer.png](/files/0d65c6229723552d1803f128760c8d086e31ed1e) ![guard-b-peer2.png](/files/95f5899efb36d7d65b34a09785c996400eaf8f7e) 5. **在 SystemB 上继续，**&#x4F7F;用复制图标复制生成的公钥。

**在 SystemA 上：**\
6\. 创建一个新的 Peer 定义（供 SystemB 连接到此处。）- 在 ***公钥*** 字段中，粘贴 **从 SystemB 复制的密钥**。- 在 ***允许的 IP*** 部分：- 添加一个条目，用于 SystemB 上的 WireGuard 接口的地址 **SystemB**。- 添加一个条目，用于 **SystemB 上连接的网络** （例如，WireGuard 连接到的网络。） ![guard-a-peer.png](/files/9f7374b29fc2439329848205ef40243113726a7b) ![guard-a-peer2.png](/files/3358fe1ed07581b705bb4283fb8ff2a0dde33491)

**在 SystemA 和 SystemB 上：**\
7\. **应用规则** （在创建 Wireguard 接口的网络上）以使系统生成的网络规则生效。

### 测试站点到站点的 VPN 连接

可以先使用每个系统上的诊断工具进行简单的 ping 测试，作为连接的初步测试。

**在 SystemA 上：** 导航到网络仪表板（WireGuard 所连接到的网络） ![guard-a-pingtest.png](/files/7c9c3d8d642ce7c7e4a564f5193852b35e111b7e)

* **选择 ping** 从查询列表下拉菜单中。
* **ping SystemB 上的接口地址**（在我们的示例中：192.68.1.2）
* 同样，这里也可以对 SystemB 中的其他 IP 地址（例如，所连接网络上的虚拟机）进行 ping 测试。
* **从 SystemB 执行同样的测试，以 ping SystemA 上的地址**

## 示例：为远程访问配置 - Windows 客户端

此示例涵盖单个远程访问对等端（Windows 客户端）的设置，并假定服务器端（VergeOS 系统）上已创建好 WireGuard 接口。

### 创建新 Peer

1. 在 VergeOS 系统上，导航到 **WireGuard(VPN) 仪表板**.
2. 单击 **新 Peer** 左侧菜单中的。
3. 选择合适的 WireGuard ***接口*** 从下拉列表中。
4. 分配一个 ***名称*** 给该对等端，例如远程用户的姓名。
5. 可选地，可以指定 ***描述*** 可输入以存储有关此对等端的其他信息。
6. 勾选 ***自动生成 Peer 配置*** 复选框，以自动化设置并创建可在客户端上使用的配置文件。
7. 输入 ***Endpoint*** 用于该对等端（此系统将用于与该对等端通信的外部 IP 地址、主机名或 URL。）
8. 在 ***配置防火墙*** 下拉菜单，选择 **远程用户**
9. 单击 **提交** 以保存新的对等端条目。 ![client-peer-form.png](/files/d1f53f1678b2022d953a5ce6722866007d971331)

### 下载配置文件

点击对等端记录上的 Download Config 按钮并为文件选择一个位置；下载到客户端计算机可访问的位置，或可从该位置传输到客户端的其他位置。

![download-link.png](/files/ad0ee0aca9239d253ff46f321769d4539fd1d28d) ![configuration-file.png](/files/6b711d5f47062dd6a9d7a1152e702fbe058e10bc)

### 在客户端上安装 WireGuard 软件

可从以下地址下载 WireGuard 客户端软件：<https://wireguard.com/install。（在此示例中，我们下载并安装适用于> Windows 64 位的 WireGuard，以便在 Windows 10 Pro 机器上使用。） ![add-tunnel.png](/files/6fb9a526cb0ab0f6caa71d77917133d451e4304a)

1. 单击 **添加隧道**.
2. 导航到并 **选择生成的配置文件**.
3. 该配置文件用于在客户端机器上自动创建接口和对等端。点击 **激活** 按钮以打开隧道，如果它尚未自动激活。 ![tunnel-active.png](/files/ab36acda7695f23ff52a5db6acb2c5bf1c6f3e56)


---

# 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/run-the-platform/zh/vpn/wireguard-examples.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.
