Archived

This topic is now archived and is closed to further replies.

Leaguefun

UDP behind NAT

Recommended Posts

Leaguefun    122
Can I forward message from server (real IP) to remote client (behind NAT) through UDP, without making any configuration changes on the remote machine ?

Share this post


Link to post
Share on other sites
mputters    126
Idea on what? Just setting the NAT tables on the router will fix any problem you might have, you can choose between UDP and TCP for those routes too.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
The client needs to initiate the connection first in order for the NAT to make the mapping between the NAT''s wan port and the client''s port. Otherwise the server can''t tell which port the NAT has opened (if any) to the client''s UDP port. The mapping will hold for about 20-30 seconds after the last sent message; after that the mapping is removed. So you need to come up with a ''ping'' message protocol you need to exchange on a frequent basis to maintain the port mapping alive.

Share this post


Link to post
Share on other sites
Leaguefun    122
I''d try to initialize a UDP connection from client to server, server can receive the client message. When the server reply acknowledge message to that client. It cannot receive the message anyway by the information received by function "recvfrom" in the server ....

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Well, using a debugger and stepping slowly in the code is a sure way to make the NAT close up. Using a different socket for the reply route is another way.

Setting up static UDP routes involves changing the NAT configuration, which was stated can''t be done from the server.

Share this post


Link to post
Share on other sites