My question is somewhat extending on this discussion: NAT and UDP replies

Scenario: Machine A behind NAT Machine B on the internet

  1. machine A:Port M sends a UDP packet to Machine B:PortN
  2. Machine B:Port N sends reply to machine A:Port M (I know that there is a NAT translation in the middle which is transparent to both machines)

Will the NAT mechanism on machine A's public router work, if the source port of machine B is different. That is, replacing step 2 with the following still work and machine A receive UDP reply from machine B:
2. Machine B: Port Z sends reply to machine A:Port M

This probably won't work or else it will be a security risk? OR Depends on how NAT is configured?


Normally you have a statefull inspections router or firewall. This means the device "sees" a new connection and remembers the connection partners, the ports and the protocol. So if you start a new connection request the router recongnize that this is udp connection and an answer will be expected. So when the answer commes back the router will nat the back going backages as well. So if you change the source port of machine B, the replay would not work.

ciao ryder

  • Thank you! That's what I expected.To make it work, port forwarding needs to be setup using say STUN, IGD, Port Control Protocol or manual configuration. – guest_1234 Feb 20 '15 at 2:42

NAT isn't completely standardized, so it is impossible to say what will or will not work. Having said that, there are protocols for this sort of thing that usually work. I'd suggest using something like STUN (Session Traversal Utilities for NAT) to handle the setup of the network translations in the NAT box to enable your communications to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.