Lal*_*hav 8 networking vpn wireguard
背景:
我已在本地(专用)网络上配置了 Wireguard VPN 服务器。[假设专用网络:192.168.1.0/24] Wireguard 客户端具有相同的 IP 网络 192.168.1.X
我的网络中存在一些具有静态本地 IP 地址的非 Wireguard 兼容设备(IP 摄像机、DVR)。
查询:
当我作为 Wireguard 客户端连接到 Wireguard 服务器(从本地网络外部)时,我想使用其本地静态 IP 地址访问那些非 Wireguard 兼容设备。我已经确保不会有任何IP冲突。
小智 10
当您想要通过 WireGuard 将各个外部主机连接到 LAN 时,您需要做的三件关键事情是:
\nAllowedIPs上的 WireGuard 配置设置中包含 LAN 的 IP 块(或至少是要访问的每个 LAN 端主机的 IP 地址)sysctl -w net.ipv4.ip_forward=1)iptables规则完成)这里有一个完整的例子:
\nhttps://www.procustodibus.com/blog/2020/11/wireguard-point-to-site-config/
\n在该示例中,LAN 的子网为192.168.200.0/24,因此这就是AllowedIPs外部主机(示例中的端点 A)的 WireGuard 配置中的设置:
AllowedIPs = 192.168.200.0/24\nRun Code Online (Sandbox Code Playgroud)\n在该示例中,数据包转发和伪装是通过将以下内容添加到 LAN 端 WireGuard 主机(示例中的 Host \xce\xb2)上的 WireGuard 配置来完成的:
\n# IP forwarding\nPreUp = sysctl -w net.ipv4.ip_forward=1\n# IP masquerading\nPreUp = iptables -t mangle -A PREROUTING -i wg0 -j MARK --set-mark 0x30\nPreUp = iptables -t nat -A POSTROUTING ! -o wg0 -m mark --mark 0x30 -j MASQUERADE\nRun Code Online (Sandbox Code Playgroud)\n当wg0LAN 端 WireGuard 主机上的 WireGuard 接口启动时,外部主机可以通过其 LAN 地址连接到 LAN 上的任何主机 - 在示例中,外部主机(端点 A)可以连接到 LAN 主机(端点B) 通过端点 B 的本地地址192.168.200.22。
| 归档时间: |
|
| 查看次数: |
54573 次 |
| 最近记录: |