Jump to content



Master server and server behind the same router

  • You cannot reply to this topic
6 replies to this topic

#1 jmakitalo   Members   -  Reputation: 122

Like
0Likes
Like

Posted 12 February 2012 - 07:24 AM

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?

Ad:

#2 SimonForsman   Members   -  Reputation: 1199

Like
0Likes
Like

Posted 12 February 2012 - 07:30 AM

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)
I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

#3 jmakitalo   Members   -  Reputation: 122

Like
0Likes
Like

Posted 12 February 2012 - 07:49 AM

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.

#4 SimonForsman   Members   -  Reputation: 1199

Like
0Likes
Like

Posted 12 February 2012 - 08:16 AM

View Postjmakitalo, on 12 February 2012 - 07:49 AM, said:

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.
I don't suffer from insanity, I'm enjoying every minute of it.
The voices in my head may not be real, but they have some good ideas!

#5 jmakitalo   Members   -  Reputation: 122

Like
0Likes
Like

Posted 12 February 2012 - 09:06 AM

View PostSimonForsman, on 12 February 2012 - 08:16 AM, said:

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.

#6 hplus0603   Moderators   -  Reputation: 1805

Like
0Likes
Like

Posted 12 February 2012 - 10:18 PM

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.
enum Bool { True, False, FileNotFound };

#7 jmakitalo   Members   -  Reputation: 122

Like
0Likes
Like

Posted 13 February 2012 - 02:34 PM

View Posthplus0603, on 12 February 2012 - 10:18 PM, said:

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.






We are working on generating results for this topic
PARTNERS