1

所以我有一台本地电脑,我想通过wireguard连接到远程网络。我无法在远程网络中打开端口,所以我添加了一个介于两者之间的服务器。

我可以从笔记本电脑和从入口点到远程网络通过 vpn ping 服务器。我可以从服务器 ping 笔记本电脑和入口点

我无法从笔记本电脑 ping 入口点。
我无法从笔记本电脑 ping 远程网络。

配置:
服务器

 [Interface]
Address = 10.5.0.1/24
ListenPort = 1194
PrivateKey = <PrivateKey>    

[Peer]
PublicKey = <PublicKey>
AllowedIPs = 10.5.0.2/32,192.168.1.200/16

[Peer] # Laptop
PublicKey = <PublicKey>
AllowedIPs = 10.5.0.200/32

笔记本电脑:

[Interface]
PrivateKey = <PrivateKey>
Address = 10.5.0.200/32

[Peer]
PublicKey = <PublicKey>
Endpoint = <ServerIP>:1194
AllowedIPs = 10.5.0.0/16,192.168.0.0/16
PersistentKeepalive = 15

远程网络的入口点:

[Interface]
PrivateKey = <PrivateKey>
Address = 10.5.0.2/32

[Peer]
PublicKey = <PublicKey>
Endpoint = <ServerIP>:1194
AllowedIPs = 10.5.0.0/16
PersistentKeepalive = 15

我还在服务器和入口点上设置了 sysctl -w net.ipv4.ip_forward=1

4

1 回答 1

1

解决方案是添加

PostUp   = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT;
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT;

到服务器的[接口]

并添加

PostUp = iptables -t nat -A POSTROUTING -o eno2 -j MASQUERADE
PostDown = iptables -t nat -D POSTROUTING -o eno2 -j MASQUERADE

到入口点的[接口]

于 2019-12-20T20:17:57.533 回答