Game server (raspberry pi) running a vpn

Hey i have a problem that i am not to sure how to solve.

I have a raspberry pi that is running a vpn. I also have a valheim server running as a docker container which i can connect to on my local network with no issues.
However when trying to connect outside of my home network i cant access it, after som troubleshooting I remembered that the raspberry pi is running a vpn and that is probably why i cannot access it from outside the network.

Is there anyway i can go around this or is the only option to disable the vpn or get another server?

However when trying to connect outside of my home network i cant access it

What can’t you access?

Just use Zerotier (ZT) or Tailscale and alleviate your VPN headaches.

  1. Create free Zerotier account.
  2. Install Zerotier client on Pi and the laptop you’ll be using remotely and join them to your new Zerotier network via it’s ID number.
  3. Login to Zerotier and “approve” the two new devices, labeling each one and assigning each its own ZT IP address.
  4. Profit!

Sure, I’ve got Wireguard running on my firewall, but only for emergencies as I just access everything over Zerotier.
And since I’m lazy, I just built my own hosts file on my laptops and access everything over ZT via name.

The problem in you setup is, like you said, the VPN.

The reason being called “Asynchronous Routing”, which means that your Raspi receives the request of your client correctly, but will send the reply using the VPN (default gateway). And therein lies the problem: Your client receives the reply from the server, but from a different external IP (the IP of your VPN), as a result it will discard this reply and a connection cannot be established. There are 2 solution:

  1. Is only possible if you client has a public static IP and you add a static route on your raspi for this IP that it should route this IP over your normal internet connection and not the VPN.
  2. You have a router/firewall that can do NAT for portforwarding. In this case the request from the client will go to the firewall and the firewall will send your request to your server using the internal IP of your firewall instead of the external IP. The server will then reply to your router and the router will repackage the reply with its external IP and the client will accept the packet.

the valheim server with my external ip

Not when you run your own properly-configured ZeroTier or Headscale controller.
Do more research on it.

Hmm, not sure how to do that. I will read up on it. Thanks for the suggestion

I have done the port forwarding required for the valheim server. But since the server that is running valheim also uses a vpn the external ip gathered from https://whatismyipaddress.com/ wont be the the “correct” ip.
Or have I understood this completely wrong?

you can look up your public ip in your router. with this you should be able to connect if the portforward is set up correctly.

it’s very possible though that your public ip in your home router will change every few days so it might be worth looking into ddns.