Hi,
I’ve looked at your script and approach, and I recommend switching to a proxy method using socat. Instead of restarting your game servers every time your public IP changes which causes downtime and risks losing player progress using socat lets your game run on a stable internal IP that never changes.
Here’s how it works in practice:
Your game servers bind to a fixed internal IP (e.g., 192.1.1.1) and their ports.
socat listens on your public IP and forwards connections to the internal IP and ports.
When your public IP changes, only socat needs updating or restarting, not the game servers.
This reduces downtime drastically and keeps your internal IP hidden from the public.
Example :
socat TCP-LISTEN:11150,bind=YOUR_PUBLIC_IP,fork TCP:192.1.1.1:11150
This listens on your public IP port 11150 and forwards all traffic to your internal game server on port 11150.