1

(Addresses and ports randomly made up for the sake of example)

Suppose we have a machine and it's private IP address is 192.168.1.10.

Suppose the machine's router's public internet IP address is 100.50.100.50.

The machine sends a UDP packet from port 7000 across the internet to some address at port 9000.

This could be translated to: src: 192.168.1.10:7000 -> src: 100.50.100.50:37500

After this, but before the NAT record above is cleaned up, the machine sends a TCP packet from port 7000 again to a different address at port 9500. Will the router translate port 7000 to port 37500 again, or will it randomly choose something else?

I would take the guess that it would use that same port number (37500), because it's important have as many available ports as possible for other machines connected to the router to use.

1 Answer 1

1

It varies. There are a number of different possible behaviours, including but not limited to

  1. Full cone, the mapping depends only on the client IP/port, the same mapping is used for all servers and return packets are allowed from anywhere.
  2. Restricted cone, the mapping depends only on the client IP/port, the same mapping is used for all servers but return packets are only allowed from servers the client has connected to outbound.
  3. Restricted port cone, the mapping depends only on the client IP/port, the same mapping is used for all servers but return packets are only allowed from server/port combinations the client has connected to outbound.
  4. Randomising symmetric, the mapping depends on the full 4-tuple, ports for outgoing connections are chosen randomly.
  5. Port-preservative symmetric, the mapping depends on the full 4-tuple but the NAT only changes the source port if it has to do so to avoid a conflict.

The last type is particularly insidious because under light load it behaves like a restricted port cone but under heavy load the "symmetric" behaviour becomes apparent. Sadly it is one of the most common types.

0

Your Answer

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

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