Skip to content

Instantly share code, notes, and snippets.

@dantheman213
Last active January 30, 2024 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dantheman213/55c3f8de985b4bbcb40d007f9d4d99cc to your computer and use it in GitHub Desktop.
Save dantheman213/55c3f8de985b4bbcb40d007f9d4d99cc to your computer and use it in GitHub Desktop.
Create game proxy server to forward traffic to your home network through VPN
#!/usr/bin/env bash
# Create game proxy server to forward traffic to your home network through VPN.
# Great for a cheap Linode, Digital Ocean, etc $5/mo server for modest traffic.
# Keep your home network and IP safe by setting up an isolated VPN to connect your public external proxy to your protected home network
# Keep costs down by using a server you already have at home instead of paying large sums every month just to host some games with your friends.
# Example diagram
# User / Game Client -> Internet -> Your cheap VPS proxy server -> OpenVPN -> Your home network -> Your home server
# Connect to VPN in the background
openvpn --config client3.ovpn &
# Proxy traffic to your VPN protected home server
# This example is for Palworld but could easily be adapted to Minecraft, pretty much any other server hosted game
# Below redirects traffic coming from port 21235 and forwards it to 192.168.10.100 (presumably available on your VPN) on port 8211
# This allows a home server with the IP 192.168.10.100 to have a local Palworld server running on its default port 8211
iptables -t nat -A PREROUTING -p udp --dport 21235 -j DNAT --to-destination 192.168.10.100:8211
iptables -t nat -A POSTROUTING -j MASQUERADE
echo "1" > /proc/sys/net/ipv4/ip_forward
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment