Jump to content
  • Advertisement
Sign in to follow this  
jmakitalo

Master server and server behind the same router

This topic is 2499 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have just finished making a master server for my multiplayer game to keep track of servers. It works fine on localhost, I can register a server and a client can retrieve it.

When I try to test it over the internet so that a master server and a server are ran either on the same computer or on two different computers behind the same router, the server is unable to find the master. I have setup port forwarding for the two computers behind the router. For both computers, there are static ip:s that are visible from the internet. Could the problem be due to NAT?

Share this post


Link to post
Share on other sites
Advertisement
the server should use the master servers LAN ip to connect to it and the master server should bind its socket to all interfaces, not just the WAN interface. (Most cheap consumer routers doesn't handle routing all that well when both the sender and reciever are on the LAN, if you're using something like iptables then you can configure it to work properly in this situation aswell though)

Share this post


Link to post
Share on other sites
I'm using UDP and the master listens to a specific port for packets sent from any address. And yes, if I tell a server to connect to the master's LAN ip, then it works. This has the problem that the master will then obtain the LAN address, and this is invalid for any client that obtains the server information from outside the LAN.

Share this post


Link to post
Share on other sites

I'm using UDP and the master listens to a specific port for packets sent from any address. And yes, if I tell a server to connect to the master's LAN ip, then it works. This has the problem that the master will then obtain the LAN address, and this is invalid for any client that obtains the server information from outside the LAN.

Simple workaround:
Have the server send the proper IP to the master server, specify that IP in a configfile or commandline parameter, let the server send 0.0.0.0 by default and have the masterserver use the ip it gets from the socket in that case.

Share this post


Link to post
Share on other sites

Simple workaround:
Have the server send the proper IP to the master server, specify that IP in a configfile or commandline parameter, let the server send 0.0.0.0 by default and have the masterserver use the ip it gets from the socket in that case.


A bit of a hack, but it should work. Though this is really not a way to test that my master server works over the internet. Guess I need someone else to test it over the internet.

Share this post


Link to post
Share on other sites
If this problem only happens when the client and the server are both behind the same firewall/NAT, then the problem is that the firewall/NAT box does not support "hairpin NAT," which is when clients on the inside try to use externally exposed port forwards.

Share this post


Link to post
Share on other sites

If this problem only happens when the client and the server are both behind the same firewall/NAT, then the problem is that the firewall/NAT box does not support "hairpin NAT," which is when clients on the inside try to use externally exposed port forwards.


Ok, so this requires special functionality from the router. I think this is exactly the problem and that my router is a piece of junk.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!