How to Send A UDP packet via public IP through NAT?

2k views Asked by At

I have a UDP server running on my private network.I have a device which is beyond NAT which sends UDP packets to my server through public IP. I am able to receive the UDP packets, parse them and I can view the pay load, src and dest port. Now I need to send an ACK message to that device so I have captured the ip and port numbers and sending a UDP packet to it. But I could not able to view any UDP packets in that device.

My question is as my Device is beyond NAT the IP address and port number I am getting is NAT's or the actual device's ?

How to send the UDP packet to that device through NAT ?

1

There are 1 answers

0
Kunjan Thadani On

My question is as my Device is beyond NAT the IP address and port number I am getting is NAT's or the actual device's ?

The IP and Port you identify from the packet are those which the NAT created a mapping for the client. In simple words, it is the IP and Port of the NAT to which the device is connected.

How to send the UDP packet to that device through NAT ?

You need to reply on the IP and port detected by the server from the packet it received from client. More clearly you need to implement UDP Holepunching.

I guess you should first understand the networking issues regarding connection to devices working under a NAT. Various RFCs are available for NAT Traversal and UDP Punching.

Here are some sources:

http://en.wikipedia.org/wiki/Network_address_translation

http://en.wikipedia.org/wiki/UDP_hole_punching

https://www.rfc-editor.org/rfc/rfc4787

https://www.rfc-editor.org/rfc/rfc5128