I'm trying to configure a VPN with Wireguard, but I'm having problems. The VPN works correctly with the server and the client inside the same network. However, anytime I connect my client to a different network, I lose connection from the server. My server is configured in a Raspberry Pi 3. Here is the wg0.conf:
[Interface]
Address = 10.8.0.1/24
SaveConfig = true
PostUp = iptables -t nat -I POSTROUTING -o wlan0 -j MASQUERADE
PreDown = iptables -t nat -D POSTROUTING -o wlan0 -j MASQUERADE
ListenPort = 51820
PrivateKey = XXXXX
[Peer]
PublicKey = PPPP
AllowedIPs = 10.8.0.2/32
My client is in a Windows 10. Here is the configuration:
[Interface]
PrivateKey = XXXXXX
ListenPort = 51820
Address = 10.8.0.2/24
[Peer]
PublicKey = PPPP
AllowedIPs = 10.8.0.0/24, 192.168.10.0/24
Endpoint = PUBLIC_IP:51820
I also opened the port in my router, but I'm not sure how can I check if it's open
Any advice is welcome. Thank you!