我目前的Wireguard设置有一个VPS连接到不同本地网络上的两个设备。每个家庭网络设备都使用Wireguard连接到VPS,但没有配置为相互接受连接(它们还没有作为对等点添加到彼此的配置文件中)。
我希望使用类似于反向代理服务器的VPS,这样家庭设备1可以连接到VPS,并将其流量路由到家庭设备2,而不需要在两个家庭设备之间配置直接连接(本质上是一个集线器和轮辐模型)。有办法沿这条路行驶吗?
当前家庭网络设备配置文件:
[Interface]
Address = 10.0.0.2/8
SaveConfig = true
ListenPort = 53910
FwMark = 0xca6c
PrivateKey = <privkey>
[Peer]
PublicKey = <pubkey>
AllowedIPs = 10.0.0.1/32
Endpoint = <IP address>
服务器配置文件:
[Interface]
Address = 10.0.0.1/8
SaveConfig = true
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;
ListenPort = 51820
PrivateKey = <privkey>
[Peer]
PublicKey = <pubkey>
AllowedIPs = 10.0.0.2/32
Endpoint = <IP of home network device 1>
[Peer]
PublicKey = <pubkey>
AllowedIPs = 10.0.0.3/32
Endpoint = <IP of home network device 2>
在这些当前规则下,如果我试图从设备1中ping设备2,我会得到以下错误消息(这似乎表明对等方知道对方,但它们的配置不正确?)
user@device1:~/wireguard$ ping 10.0.0.3
PING 10.0.0.3 (10.0.0.3) 56(84) bytes of data.
From 10.0.0.2 icmp_seq=1 Destination Host Unreachable
ping: sendmsg: Required key not available
谢谢!
发布于 2022-01-06 20:07:14
更新客户端的WireGuard AllowedIPs
设置,以包括您希望每个客户端通过其到VPS的WireGuard连接访问的其他设备的IP地址。例如,这样只允许设备1使用WireGuard连接到设备2:
[Interface]
Address = 10.0.0.2/8
...
[Peer]
PublicKey = <VPS pubkey>
AllowedIPs = 10.0.0.3/32
...
或者像这样允许设备1通过WireGuard连接到设备2以及VPS本身:
[Interface]
Address = 10.0.0.2/8
...
[Peer]
PublicKey = <VPS pubkey>
AllowedIPs = 10.0.0.1/32, 10.0.0.3/32
...
或者像这样允许设备1使用WireGuard连接连接到10.0.0.0/8
块中的任何主机:
[Interface]
Address = 10.0.0.2/8
...
[Peer]
PublicKey = <VPS pubkey>
AllowedIPs = 10.0.0.0/8
...
有关完整的示例,请参阅此有线护卫轮毂和轮辐指南。
https://serverfault.com/questions/1089092
复制相似问题