Raspberry port forwarding to VPN client?

Da
- in Servers
5

I have a Raspberry Pi 4 Model B with 4 GB Ram. I use it for everything: web server, NextCloud, Minecraft server, etc.

A WireVPN server has been running for a few days, installed with PiVPN on it. Everything flawless.

Now, however, I have a Minecraft server running on my PC (UPD and TCP on port 25566) and when I'm in the VPN network it no longer works that my router forwards the ports to my PC (192.168.178.62/24). I don't have much idea about network technology, I'm still just 16. I guess it must now be that when I'm connected to the VPN, my router then has to forward the port to my Raspberry, and this one then forward to my PC in the VPN (10.6.0.3/24).

As far as I found it on the Internet, it works with iptables, etc. I just have no idea about it and I haven't really got any smarter from the stuff that I found on the Internet.

Hope there's someone here who can help me!

po

I don't quite understand what you're doing. Are you connected via VPN and trying to access the Minecraft server via your public IP address? Hm. You are in your internal VPN network 10.6.0.0/24 if you are connected via VPN. Then you can access the Minecraft server directly and do not need port forwarding. However, the routing must fit. Port forwarding only works if you come from the Internet.

Da

If I'm in the VPN and the server is to be accessed via the Internet, the packets have to be sent to the Raspi and to me via the router, right? If so, I can make it to Raspi, I don't know how I will do it there, I would need help.

po

You come from the Internet and connect via VPN. So you are already virtually behind the router, i.e. In your home network.

Your computer has an IP address 10.6.0.3/24. With this address you must now reach the Minecraft server 192.168.178.62. I do this with iptables in the form that I have entered in / etc / network / interfaces for the tunnel interface:

PostUp = iptables -I FORWARD 1 -i% i -j ACCEPT; iptables -I FORWARD 1 -o% i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i% i -j ACCEPT; iptables -D FORWARD -o% i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

What do you mean by WireVPN? PiVPN is based on OpenVPN, WireVPN sounds a bit like Wireguard. That just confuses me.

Da

I'm not sure if we understand each other: /

The Minecraft server is running on my PC (router 192.168.178.62 | VPN 10.6.0.3)

and on the Raspi the VPN server is running.

My PC is in the VPN. The server should be reached by my friend over the Internet, which is not in the VPN.

You come from the Internet and connect via VPN.

So that's not the case, since the friend comes from the Internet, but has nothing to do with my VPN or?

WireVPN is wrong yes my WireGuard and apparently it is also possible and recommended by PiVPN to install WireGuard and not OpenVPN.

po

Correctly recognized, I did not understand correctly.

Then the scenario looks like this: Let's say your friend has the IP address 192.0.2.33. He is now accessing your Minecraft server. The router forwards this to port 192.168.178.62. The Minecraft server now replies to 192.0.2.33. However, the VPN is probably configured to send all network traffic over the VPN. The answer of the Minecraft server ends up with the Pi. It gets it out of the VPN and would have to send it to the Fritzbox so that it sends it out. I assume that something is stuck here.

Why is your computer connected to the VPN? I don't quite understand the intention.

In fact, Wireguard is the better alternative compared to OpenVPN. I also changed some time ago.