# WireGuard

**WireGuard** 是一种自由开源的虚拟专用网络（VPN）协议，通过 UDP 建立加密、经过认证的 IP 隧道，其设计围绕小巧的代码库、现代密码学和简洁的基于密钥的配置展开。它由杰森·A·多嫩费尔德（Jason A. Donenfeld）创建，于 2016 年 6 月 28 日面向 [Linux 内核](https://www.edgepedia.org/zh/linux-kernel)公开发布，并随 2020 年 3 月 29 日发布的 Linux 5.6 版本并入主线内核。<sup>[1](https://lwn.net/Articles/693015/)</sup><sup> • </sup><sup>[2](https://lists.zx2c4.com/pipermail/wireguard/2019-December/004704.html)</sup><sup> • </sup><sup>[3](https://www.kernel.org/pub/linux/kernel/v5.x/)</sup> 如今它已跨平台，为 Windows、macOS、BSD、iOS 和 Android 提供官方客户端，并被各大商业 VPN 服务商采用。<sup>[4](https://www.wireguard.com/?trk=public_post_reshare-text)</sup><sup> • </sup><sup>[5](https://www.tunnelpicks.net/blog/choosing-right-vpn-protocol-2026-wireguard-openvpn-ikev2-lightway)</sup>

| 关键事实 | 详情 |
|---|---|
| 创建者与发布 | 杰森·A·多嫩费尔德于 2016 年 6 月 28 日发布 WireGuard，作为一个加密、经过认证的内核隧道接口<sup>[1](https://lwn.net/Articles/693015/)</sup> |
| Linux 主线 | 并入 Linux 5.6，2020 年 3 月 29 日发布；5.6 之前的内核使用树外兼容模块<sup>[2](https://lists.zx2c4.com/pipermail/wireguard/2019-December/004704.html)</sup><sup> • </sup><sup>[3](https://www.kernel.org/pub/linux/kernel/v5.x/)</sup> |
| 代码库规模 | 发布时约 4,000 行代码，而 OpenVPN 超过 100,000 行，IPsec 实现则达数十万行<sup>[1](https://lwn.net/Articles/693015/)</sup><sup> • </sup><sup>[6](https://www.ismslite.de/en/blog/choosing-vpn-solution)</sup> |
| 密码学套件 | ChaCha20-Poly1305（AEAD）、Curve25519 ECDH、BLAKE2s 哈希、SipHash24、HKDF，构建于 Noise 协议框架之上<sup>[7](https://www.wireguard.com/protocol/?trk=article-ssr-frontend-pulse_little-text-block)</sup> |
| 传输方式 | IP 数据包封装于 UDP 之上；1-RTT 握手每隔几分钟更新对称密钥，以实现前向保密<sup>[4](https://www.wireguard.com/?trk=public_post_reshare-text)</sup><sup> • </sup><sup>[7](https://www.wireguard.com/protocol/?trk=article-ssr-frontend-pulse_little-text-block)</sup> |
| 形式化验证 | Tamarin 和 ProVerif 中的符号证明，以及 eCK 和 ACCE 模型中的计算证明，涵盖密钥保密性、前向保密性和身份隐藏<sup>[8](https://www.wireguard.com/formal-verification/)</sup> |
| 范围限制 | 密钥分发与推送配置不在范围内；动态 IP 分配和集中管理需要额外工具<sup>[4](https://www.wireguard.com/?trk=public_post_reshare-text)</sup><sup> • </sup><sup>[6](https://www.ismslite.de/en/blog/choosing-vpn-solution)</sup> |

## 设计与运行

WireGuard 将自身呈现为一个普通网络接口，通常命名为 `wg0`，使用 `ip link add dev wg0 type wireguard` 等标准工具创建。管理员用私钥和一份对等方列表来配置该接口，每个对等方由公钥、一组允许的隧道 IP 地址和一个远程 UDP 端点标识。配置刻意模仿 SSH：双方交换公钥后即可开始交换数据包，无需证书、无需 X.509、也无需单独的密钥管理守护进程。<sup>[4](https://www.wireguard.com/?trk=public_post_reshare-text)</sup><sup> • </sup><sup>[1](https://lwn.net/Articles/693015/)</sup>

**加密密钥路由。** 协议的核心是将公钥与允许的隧道 IP 地址列表相关联。当数据包离开接口时，WireGuard 查找目标 IP 以选择对等方，用该对等方的密钥加密整个 IP 数据包，并作为 UDP 发送至对等方的端点。接收时，它解密并认证数据包，根据外层源地址更新对等方的端点，并且仅当内层数据包的源 IP 对该对等方被允许时才接受它。这种一一映射的作用类似于反向路径过滤，使微分段变得实用，因为每个设备密钥都绑定到特定的允许 IP。<sup>[4](https://www.wireguard.com/?trk=public_post_reshare-text)</sup><sup> • </sup><sup>[9](https://blog.openvpn.net/wireguard-mesh-vpn-trade-offs)</sup>

**认证前保持沉默。** 一项明确的设计目标是不为未认证的数据包存储任何状态，也不对其发送任何响应，从而使 WireGuard 对非合法对等方和网络扫描器不可见。初始握手消息的重放由加密且经过认证的 12 字节 TAI64N 时间戳防止，这是一个由响应方跟踪的、每个对等方单调递增的 96 位数。<sup>[10](https://www.wireguard.com/papers/wireguard.pdf)</sup>

**密钥轮换。** 初始握手为数据传输建立对称密钥，握手按定时器每隔几分钟重复一次，而非基于数据包内容，从而提供轮换密钥以实现完美前向保密，同时容忍数据包丢失。一个可选的预共享对称密钥可以作为额外一层混入公钥交换中，包括作为对量子对手的防范。<sup>[7](https://www.wireguard.com/protocol/?trk=article-ssr-frontend-pulse_little-text-block)</sup><sup> • </sup><sup>[11](https://www.wireguard.com/papers/dowling-paterson-computational-2018.pdf)</sup>

## 密码学与验证

该协议固定使用单一的原语套件，而不提供协商：ChaCha20 用于对称加密，在 RFC 7539 的 AEAD 构造下以 Poly1305 认证；[Curve25519](https://www.edgepedia.org/zh/curve25519) 用于椭圆曲线迪菲–赫尔曼密钥交换；BLAKE2s 用于哈希；SipHash24 用于哈希表键；HKDF 用于密钥派生，握手则构建于 Noise 协议框架的 IK 模式之上。<sup>[7](https://www.wireguard.com/protocol/?trk=article-ssr-frontend-pulse_little-text-block)</sup><sup> • </sup><sup>[11](https://www.wireguard.com/papers/dowling-paterson-computational-2018.pdf)</sup>

WireGuard 的密码学、协议和实现均已接受形式化验证。由杰森·多嫩费尔德和凯文·米尔纳（Kevin Milner）合作的 Tamarin 符号证明确立了正确性、强密钥协商与真实性、抗密钥泄露冒充、抗未知密钥共享攻击、密钥保密性、前向保密性、会话唯一性和身份隐藏；该模型是开源的，可独立重新运行。<sup>[8](https://www.wireguard.com/formal-verification/)</sup> 安全协议形式化验证领域的研究者本杰明·利普（Benjamin Lipp）使用 CryptoVerif 在一个类 ACCE 模型中构建了整个协议（包括传输数据消息）的机械化计算证明。<sup>[8](https://www.wireguard.com/formal-verification/)</sup> 本杰明·道林（Benjamin Dowling）和密码学教授肯尼斯·G·佩特森（Kenneth G. Paterson）的 eCK 模型计算证明需要证明该协议的一个变体，因为 WireGuard 的密钥确认承载于第一条传输数据消息中，而非握手本身；他们的分析还记录了一种在非常特定的密钥泄露能力组合下的前向保密攻击，他们认为这更像是强证明的障碍，而非实际攻击。<sup>[8](https://www.wireguard.com/formal-verification/)</sup><sup> • </sup><sup>[11](https://www.wireguard.com/papers/dowling-paterson-computational-2018.pdf)</sup> 在实现层面，WireGuard 使用了来自 HACL* 和 Fiat-Crypto 的经过形式化验证的 Curve25519 标量乘法代码，研究人员已对照 Tamarin 模型验证了官方 Go 实现的很大一部分。<sup>[8](https://www.wireguard.com/formal-verification/)</sup><sup> • </sup><sup>[12](https://arxiv.org/abs/2212.04171)</sup>

## 性能及与 OpenVPN 和 IPsec 的比较

WireGuard 的性能优势来自高速密码学原语及其在 Linux 内核内部的位置，这避免了 OpenVPN 等用户空间隧道反复的内核到用户空间拷贝；它既适用于智能手机，也适用于满载的主干路由器。<sup>[4](https://www.wireguard.com/?trk=public_post_reshare-text)</sup> 评测者一致认为 WireGuard 比 OpenVPN 更快，因为协议更精简、代码行数更少；在 TechRadar 2026 年的测试中，在 10 Gbps 测试连接上，PrivadoVPN 通过 WireGuard 达到 2,334 Mbps，NordVPN 达到 1,249 Mbps，而同一服务商的 OpenVPN 结果远低于其 WireGuard 数据。<sup>[13](https://www.techradar.com/vpn/fastest-vpn)</sup><sup> • </sup><sup>[14](https://www.techradar.com/reviews/windscribe)</sup>

在一项涵盖 Azure 和 VMware 环境的 2025 年同行评审研究中，结果表明哪种协议表现最佳在很大程度上取决于具体情境：WireGuard 在一种环境中实现了最高的 TCP 吞吐量和最低的数据包丢失，而 OpenVPN 在另一种环境的高延迟情况下表现更好。<sup>[9](https://blog.openvpn.net/wireguard-mesh-vpn-trade-offs)</sup> 在工业环境中，2025 年在迈宁根 Adtran Terafactory 进行的一项概念验证使用 WireGuard 保护 [Open RAN](https://www.edgepedia.org/zh/open-ran) 部署中的用户面和控制面流量，测得吞吐量、延迟和 CPU 使用方面的开销极小，实现了与 IPsec 相当的性能，同时显著降低了配置复杂性。<sup>[15](https://arxiv.org/abs/2512.10135)</sup>

拒绝服务韧性因协议而异。在具有 40 Gb/s 接口的高性能硬件上进行的对抗性测试发现，已建立的 WireGuard 连接上的数据传输可被 700 Mb/s 的攻击流量完全阻断，而对手仅需 75 Mb/s 即可阻断新的 strongSwan（IPsec）连接，并可用 100 Mb/s 的洪泛流量压垮 OpenVPN，同时阻断数据传输和连接建立。<sup>[16](https://arxiv.org/abs/2110.00407)</sup>

## 采用与部署

在比较性指南中，WireGuard 是新远程访问部署的推荐选择，而 IPsec 仍是站点间链路的既定标准；其局限在于动态 IP 分配和集中管理需要额外工具，开源 WireGuard 网状 VPN 如 Netbird 为此增加了 Web 界面和身份提供方集成。<sup>[6](https://www.ismslite.de/en/blog/choosing-vpn-solution)</sup> 商业服务商直接采用它，或采用其衍生产品：NordVPN 的 NordLynx 是基于 WireGuard 的专有协议，Proton VPN 在 OpenVPN 及其 Stealth 协议之外提供 WireGuard，[ExpressVPN](https://www.edgepedia.org/zh/expressvpn) 于 2025 年 8 月 13 日在其专有 Lightway 协议之外增加了 WireGuard，并将其与 ML-KEM 加密配对以实现量子安全密钥交换。<sup>[17](https://www.techradar.com/vpn/what-is-nordlynx)</sup><sup> • </sup><sup>[18](https://www.techradar.com/reviews/protonvpn)</sup><sup> • </sup><sup>[19](https://www.techradar.com/vpn/best-vpn)</sup> 对服务商基础设施的独立审计定期覆盖 WireGuard 服务器；Cure53 在 2024 年对 Mullvad 的 WireGuard 和 OpenVPN 中继基础设施进行的白盒渗透测试和源代码审计未发现可能损害用户流量匿名性或完整性的问题，且所发现的漏洞均不可被远程攻击者利用。<sup>[20](https://cure53.de/pentest-report_mullvad_2024_v1.pdf)</sup>

## 已知限制

WireGuard 的漫游机制根据任何正确认证数据包的外层源地址更新对等方的端点，无需额外的往返或认证。因此，主动中间人可以替换源 IP 地址，并在失去中间位置后中继内容仍无法解读的数据包；将 WireGuard 套接字锁定到特定 IP 地址的普通防火墙规则可缓解此问题。<sup>[21](https://www.wireguard.com/known-limitations/)</sup> 身份隐藏有一种有限的形式：握手用响应方的静态公钥加密发送方的公钥，因此响应方私钥泄露加上过往握手日志会暴露谁发送了握手，但不会暴露其中的数据；而基于响应方公钥的 mac1 字段允许通过试哈希来猜测数据包的预期响应方。<sup>[21](https://www.wireguard.com/known-limitations/)</sup> 由于 WireGuard 使用固定的、可识别的数据包格式，其流量容易被深度包检测识别且难以混淆，这在 VPN 使用受限的地方很重要。<sup>[22](https://www.cerias.purdue.edu/assets/pdf/bibtex_archive/2021-3.pdf)</sup>

隐私行为还取决于服务商如何部署该协议。一名研究者发现，Mullvad 根据用户密钥确定性地分配 WireGuard 出口 IP 地址，因此同一密钥在各服务器上产生一组可识别的地址，可在密钥轮换前以超过 99% 的置信度关联用户的连接；另外，由于 WireGuard 分配稳定的内部隧道 IP，iOS 应用可将其读取为设备指纹，Proton VPN 通过为所有用户分配相同的内部地址 10.2.0.2 解决了这一问题。<sup>[23](https://www.techradar.com/vpn/vpn-services/some-aspects-are-as-we-intended-and-some-are-not-mullvad-addresses-wireguard-exit-ip-fingerprinting-concern-after-researcher-flags-privacy-risk)</sup><sup> • </sup><sup>[24](https://www.techradar.com/vpn/vpn-services/security-experts-reveal-proton-is-the-only-vpn-to-avoid-internal-tunnel-ip-fingerprinting-on-ios)</sup>

## References

1. [Jason A. Donenfeld (June 28, 2016). [RFC] WireGuard: next generation secure network tunnel, LWN.net](https://lwn.net/Articles/693015/)
2. [Jason A. Donenfeld (December 9, 2019). [ANNOUNCE] WireGuard merged to net-next, on its way to Linux 5.6](https://lists.zx2c4.com/pipermail/wireguard/2019-December/004704.html)
3. [Index of /pub/linux/kernel/v5.x/, kernel.org](https://www.kernel.org/pub/linux/kernel/v5.x/)
4. [WireGuard: fast, modern, secure VPN tunnel, wireguard.com](https://www.wireguard.com/?trk=public_post_reshare-text)
5. [Choosing the Right VPN Protocol in 2026, Tunnel Picks](https://www.tunnelpicks.net/blog/choosing-right-vpn-protocol-2026-wireguard-openvpn-ikev2-lightway)
6. [Choosing a VPN Solution: WireGuard, OpenVPN or IPsec?, ISMS Lite](https://www.ismslite.de/en/blog/choosing-vpn-solution)
7. [Protocol & Cryptography, wireguard.com](https://www.wireguard.com/protocol/?trk=article-ssr-frontend-pulse_little-text-block)
8. [Formal Verification, wireguard.com](https://www.wireguard.com/formal-verification/)
9. [Mesh-VPN Trade-Offs: Performance, Ops & Security Guide, OpenVPN blog](https://blog.openvpn.net/wireguard-mesh-vpn-trade-offs)
10. [Jason A. Donenfeld. WireGuard: Next Generation Kernel Network Tunnel (whitepaper)](https://www.wireguard.com/papers/wireguard.pdf)
11. [Benjamin Dowling, Kenneth G. Paterson. A Cryptographic Analysis of the WireGuard Protocol](https://www.wireguard.com/papers/dowling-paterson-computational-2018.pdf)
12. [Sound Verification of Security Protocols: From Design to Interoperable Implementations, arXiv](https://arxiv.org/abs/2212.04171)
13. [The fastest VPNs for outright speed, TechRadar](https://www.techradar.com/vpn/fastest-vpn)
14. [Windscribe VPN review 2026, TechRadar](https://www.techradar.com/reviews/windscribe)
15. [Lightweight Security for Private Networks: Real-World Evaluation of WireGuard, arXiv](https://arxiv.org/abs/2512.10135)
16. [Evaluating Susceptibility of VPN Implementations to DoS Attacks Using Adversarial Testing, arXiv](https://arxiv.org/abs/2110.00407)
17. [What is NordLynx?, TechRadar](https://www.techradar.com/vpn/what-is-nordlynx)
18. [Proton VPN review, TechRadar](https://www.techradar.com/reviews/protonvpn)
19. [The best VPN service 2026, TechRadar](https://www.techradar.com/vpn/best-vpn)
20. [Cure53. Penetration test and source code audit of Mullvad WireGuard and OpenVPN relay infrastructure (2024)](https://cure53.de/pentest-report_mullvad_2024_v1.pdf)
21. [Known Limitations, wireguard.com](https://www.wireguard.com/known-limitations/)
22. [A WireGuard Exploration, CERIAS, Purdue University](https://www.cerias.purdue.edu/assets/pdf/bibtex_archive/2021-3.pdf)
23. [Mullvad addresses WireGuard exit-IP fingerprinting concern, TechRadar](https://www.techradar.com/vpn/vpn-services/some-aspects-are-as-we-intended-and-some-are-not-mullvad-addresses-wireguard-exit-ip-fingerprinting-concern-after-researcher-flags-privacy-risk)
24. [Proton is the 'only VPN' to avoid internal tunnel IP fingerprinting on iOS, TechRadar](https://www.techradar.com/vpn/vpn-services/security-experts-reveal-proton-is-the-only-vpn-to-avoid-internal-tunnel-ip-fingerprinting-on-ios)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › Network defense and threats › Virtual private networks

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/wireguard

English original: https://www.edgepedia.org/wireguard
