UDP behind NAT

Started by
7 comments, last by Leaguefun 20 years, 9 months ago
Can I forward message from server (real IP) to remote client (behind NAT) through UDP, without making any configuration changes on the remote machine ?
Advertisement
Yes
Would you give me any idea ? Since I''d gathered many related material and finally got confused .... (e.g. RPC, portmap....)
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.
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.
You can setup static UDP routes..
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 ....
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.
Can I do it just only on programming level ? Since it''s not a best practice to change client''s configuration....

This topic is closed to new replies.

Advertisement