I have a question about NAT, and this question has answered most of it : How NAT / PortForwarding / TCP/IP works?
What I am left confused on, is in this part of the question:
Why does this work? Now when a packet comes back, the Router simply checks the destination port number and changes the destination IP address and the destination port number according to the pre-mentioned mapping and the packet gets delivered successfully.
My question is the following: What happens if a random computer (computer A) tries to connect on a random port of a computer on a LAN (computer B) behind the router using NAT? For example, what happens if computer A wants to connect via TCP on port 42534 on computer B? The packet sent to the LAN would be the following:
source_address: computer A's public address
source_port: computer A's port
destination_address: the LAN's public address
destination_port: 42534
How will the router know to which computer it should send the packet? Is there a mapping that would allow the router to know to which computer on the LAN to send it to?