1

Say me and another identical computer are together in a local network (I am 192.168.1.5 or A, and he is 192.168.1.6 or B, for example) behind NAT (say our public IP is 5.5.5.5), and we have a torrent client running. We both have a certain file, let's call it "file.txt". An outside computer (let's call him C) wants to get a piece of the file. So he tries to make a connection (or rather requests the file or something, I'm not so sure how the protocol works) to 5.5.5.5 right?

Now how does NAT know to which one of us (A or B) the packet is supposed to go? I must stress (if it wasn't clear enough already) that the outside packet (coming from C) is the first ever packet from that address, which means that neither me nor B know of the existence of C.

1
  • 1
    NAT simply doesn't allow incoming connections for exactly this reason. Unless you've already made an outbound connection to a server that is open then NAT has no idea what packets are destined for what machines on the inside of the NAT and as such will simply discard them. Unless you've set up port forwarding or DMZ to specifically allow one machine to be contacted then your two machines will not respond. Some modern clients may support UPnP which will automatically set up port forwarding rules on your router which can make them publicly accessible.
    – Mokubai
    Mar 8, 2021 at 12:58

1 Answer 1

3

It doesn't. This packet won't be routed unless you have port forwarding configured for that particular port (in which case all packets arriving to that port would be forwarded to a configured IP). With NAT, the communication must be initiated from the network behind NAT.

4
  • 2
    I've upvoted, but it might be worth mentioning about UPnP which is used by many modern routers to allow automatic port forwarding and can effectively "open" these clients to be accessible on a public network such as the Internet. Two different computers with UPnP clients set up to request different ports can become accessible via this method. Some routers disable this as it is potentially a security risk having unknown devices opening ports your router.
    – Mokubai
    Mar 8, 2021 at 13:02
  • So let's see if I got it right, in my example, torrent clients will simply not allow any upload without some kind of port forwarding, but most client use UPnP, so it's fine? Thank you very much for your answer, by the way.
    – Fabaki
    Mar 8, 2021 at 18:47
  • @Fabaki With most services that's how it works. Torrent is P2P though and I suppose it could be using something different, like hole punching which allows two NAT-ed clients to communicate with each other by first punching through the NAT by connecting to a common 3rd server and using it to exchange information about how NAT translated the connection details.
    – gronostaj
    Mar 8, 2021 at 20:29
  • @gronostaj got it, thank you very much.
    – Fabaki
    Mar 8, 2021 at 22:24

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