2

Here is an example use case; I am curious to see how this is suppose to work and why:

Someone has a NAT router from their ISP.

Behind the router are 2 PCs running Linux and using ntpd. ntpd sends UDP messages to servers with source and destination port both set to 123.

When the packets come out of the router (WAN port) and go to the NTP server, what should their src port be?

Is the router suppose to map the src on the LAN to a different src on the WAN so it knows how to map the responses?

If not, and they carry src 123 out to the internet, how does the router know which PC to send the reply to?

  • Sadly home / consumer networking is off-topic. – Mike Pennington Jul 3 '15 at 21:30
  • Can this be edited to remove the reference to home networking so it's just a basic NAT question that should be on-topic? – generalnetworkerror Jul 4 '15 at 8:09
  • I can edit it to make it more general (although I don't know why this question as-is doesn't fall under umbrella of network engineering). Would there have been a better place to ask this? – hooby3dfx Jul 6 '15 at 16:23
  • 2
    @hooby3dfx, NE is a site for network professionals to ask and provide answers about professional networks. Questions about consumer devices are considered off topic by this community because they don't always operate they way a network device should, aren't well documented and generally don't provide information/visibility into what they are doing. However, I am not going to close this at this time as I believe you are asking more of a general NAT question. Please edit your question to remove mention of consumer devices or home networking and ask strictly about NAT operation. – YLearn Jul 6 '15 at 18:48
  • ...also, three seconds on Wikipedia finds... network address translation – Craig Constantine Jul 9 '15 at 0:51
3

This depends on the NAT implementation.

In general, most NAT engines prefer to make as few modifications as necessary. So, the first one there gets to keep their src port. The second one is "the loser" and has it changed. The map entry doesn't depend on anything changing; it tracks whatever is used, changed or not. As long as they aren't both talking to the same server, they can both use the same src port, because the map includes the destination:

[(inside){src}PC A:123 {dst}Server A:123 :: (outside){src}ISP:123 {dst}Server A:123]
[(inside){src}PC B:123 {dst}Server B:123 :: (outside){src}ISP:123 {dst}Server B:123]
                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The outside details are different, thus a unique key to find the inside match.

  • Thanks! What would happen if both PCs were talking to the same server? – hooby3dfx Jul 1 '15 at 22:53
  • > The second one is "the loser" and has it changed. – Ricky Beam Jul 1 '15 at 23:07

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.