I've read RFC 4787, 5382 and 5128 and I just need a bit of clarification.

Assume a NAT has Endpoint Independent Mapping behavior for both UDP and TCP.

Although I understand that if a machine would send a UDP datagram to one destination and port and then send another UDP datagram to a different destination and port, it would get the same mapping for both (assuming it sent those UDP packets from the same port number), I am unsure of how the NAT would behave if the protocols being used are different for these two different destinations.

In other words, if a machine assigned the source port number 7000 to any layer-4 datagram it sends out, and it starts off by sending a UDP datagram to some destination Y1:y1 (IP:port) and then sends a TCP segment to some destination Y2:y2, where Y1:y1 != Y2:y2, would the NAT mapped port number for the UDP datagram end up being the same actual number as the NAT mapped number for the TCP segment?

  • 1
    TCP port X is not the same as UDP port X.
    – Ron Maupin
    Sep 25, 2017 at 3:03
  • Do you mean that I would not be able to send a TCP packet from the same port on my computer that I sent a UDP packet from?
    – HeyM8
    Sep 25, 2017 at 3:04
  • My point is that they are not the same port. A port is an address used by some layer-4 protocols (contained in the layer-4 protocol header, and TCP and UDP are different layer-4 protocols). Comparing TCP and UDP ports is like trying to compare IPv4 and IPv6 or IPX addresses; the address for each protocol is only for that protocol, even if the address number is the same number.
    – Ron Maupin
    Sep 25, 2017 at 3:08
  • Okay I understand. So would it be fair to assume then that the NAT would see these two ports differently enough to create a different mapping for the machine? In other words, it's unlikely that it would map the same actual number for both?
    – HeyM8
    Sep 25, 2017 at 3:21
  • NAT, by itself, doesn't have port numbers, and it will not map UDP to TCP because that will not work. NAT maps TCP to TCP, and UDP to UDP You seem to have this idea that there is only one set of ports, but ports are specific to the layer-4 protocol. For example, you can NAT ICMP, which doesn't use port numbers, and NAT doesn't use a port number with ICMP because ICMP doesn't use ports. NAT doesn't change the layer-4 protocol.
    – Ron Maupin
    Sep 25, 2017 at 3:32

1 Answer 1


NAT stands for Network Address Translation, and it translates addresses, not protocols. Some layer-4 protocols (TCP and UDP) have addresses called ports, which coincidentally use the same set of address numbers, but the addresses (ports) are per protocol; TCP port 9876 is not the same port as UDP port 9876.

NAT can translate either or both the source and destination IP addresses, and, in some NAT versions, some layer-4 protocol addressing. If NAT translates a UDP datagram source port 7000 to UDP port 37500, that has nothing to do with TCP, and any TCP segment source port 7000, which could be simultaneously translated to TCP port 37500.

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.