WireGuard AllowedIPs 实际做什么?
Wireguard 的 allowed_ips 字段做两件不同的事。让我们考虑以下 WireGuard 配置(由 WireguardConfig Site2Site 示例生成):
wg_config_example.conf
[Interface]
# Name = office1.mydomain.org
PrivateKey = ......
Address = 10.82.85.1/24
ListenPort = 19628
[Peer]
# Name = office2.mydomain.org
PublicKey = ...
AllowedIPs = 10.82.85.2/32, 192.168.200.0/24
PersistentKeepalive = 60我们可以看到对于对等方 office2.mydomain.org,AllowedIPs 字段设置为 10.82.85.2/32, 192.168.200.0/24。
AllowedIPs 做两件事:
- 它添加路由到给定网络,即发往
10.82.85.2/32或192.168.200.0/24的数据包将通过 WireGuard 接口路由到该对等方 - 它将允许源 IP 为
10.82.85.2/32或192.168.200.0/24的数据包从给定对等方在 WireGuard 接口上路由
特别注意第二点。来自给定对等方且源 IP 地址未列在 AllowedIPs **中的任何数据包将被丢弃!**虽然这不替代防火墙,但它作为 Wireguard 安全模型的组成部分。
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow