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. Commented Jul 3, 2015 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? Commented Jul 4, 2015 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
    Commented Jul 6, 2015 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
    Commented Jul 6, 2015 at 18:48
  • ...also, three seconds on Wikipedia finds... network address translation Commented Jul 9, 2015 at 0:51

2 Answers 2


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
    Commented Jul 1, 2015 at 22:53
  • > The second one is "the loser" and has it changed.
    – Ricky
    Commented Jul 1, 2015 at 23:07

how does the router know which PC to send the reply to?

To answer the above point NAT table generate random port as a reference to souce PC in router and save in NAT table .

Source ip address : Destination ip address Source mac -address Destination mac -address Source port Destination port

So this souce port will destined correctly to return traffic to correct source from where this traffic is generated initially .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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