2

My scenario-

  1. I have two servers running ubuntu called S1 and S2. S1 has a public IP Address and it runs the openvpn server. S2 has openvpn client installed and it is connected to the open vpn server. S1 public IP(eth1) : 47.88.240.xxx, Openvpn IP(tun0): 10.8.0.1 and S2 OpenvpnIP(tun0): 10.8.0.2

  2. I have a game server running on UDP port 28015 on S2.

  3. I updated the IP Tables on S2 as -

0.0.0.0 via 10.8.0.1

47.88.240.xxx via S2 Default gateway

  1. I routed all the internet traffic from S2 through S1 by using the following command on S1-

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth1 -j MASQUERADE

I checked the IP address at whatismyip.com while browsing internet from S2 and it showed 47.88.240.xxx

I also tracerouted google's dns server from S2 and the first hop was 10.8.0.1 and traceroute was successful.

So, I am pretty sure all internet traffic from S2 is travelling through S1.

  1. I used the following command on S1 to forward port -

    sysctl -w net.ipv4.ip_forward=1

    iptables -t nat -A PREROUTING -d 47.88.240.xxx -p udp --dport 28015 -j DNAT --to-dest 10.8.0.2:28015

    iptables -t nat -A POSTROUTING -d 10.8.0.2 -p udp --dport 28015 -j SNAT --to-source 10.8.0.1

While using this method , if I query the game server(47.88.240.xxx:28015) from my home pc, I can see the game server but after a few times(maybe 5 times) it doesn't respond for some time and again responds after some time.

So, I replaced the SNAT part with the method explained here on S2 - https://www.thomas-krenn.com/en/wiki/Two_Default_Gateways_on_One_System

By doing this , I could query the game server as many times as I wanted and it never stopped responding.

  1. Even though I got a stable connection to the game server by using Two Default Gateways method , the game server does not get listed in the game's master server list but I can connect to the game server manually. I suspect that there is some issue with the outgoing traffic from the game server to the game's master server. Either the correct IP is not being sent or else the game server is not able to contact the master servers for some reason.

Any Idea why it could be happening?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.