UDP packets to PC behind NAT

Jean-Paul Calderone exarkun at divmod.com
Fri Sep 15 11:27:58 EDT 2006


On 15 Sep 2006 00:32:49 -0700, Janto Dreijer <jantod at gmail.com> wrote:
>This is probably more of a networking question than a Python one, but
>it would be nice to know if someone has done this with Python's socket
>module. And besides one usually gets more information from c.l.py than
>anywhere else :)
>
>I have a server with a static "public" IP and a client behind a NAT. I
>would like to send UDP packets from the server to the client. So what I
>need to do is open up a "hole" in the NAT and let the server know the
>target IP and port of the client where it can send its packets.
>
>Now I have read somewhere that you can have TCP and UDP running on the
>same port. Not sure if this is true. Would it be a reasonable solution
>to initiate a TCP connection from the client to the server and somehow
>(?) let the server figure out how the client is connecting? And then
>send UDP to client over the same (IP, port)?

You may be interested in Divmod Vertex (<http://divmod.org/trac/wiki/DivmodVertex>) for its NAT traversal techniques, if not for its actual code.

The solution you describe above won't work on any widespread configuration
I am aware of.  In general, most individual solutions are only effective on
a portion of existing configurations.  A robust solution must employ multiple
techniques.

Jean-Paul



More information about the Python-list mailing list