1

I understand how NAT works in case of communication between one, local host and a server with specific public IP address. The host is sending a request, it pushes the packet with destination IP address set to the value of servers IP address to the router . That LAN router "remember" that our host (identified by private IP address) is sending request to the server. So it is able to forward the response from a server to the proper host. (By the way, how does it distinguish responses from the server when multiple LAN hosts send requests at the same time?)

Now, lets say we have two hosts, based on two standard local networks on Internet, which are not related with eachother. Is it possible to these hosts to communicate with each other directly? (without any kind of servers between, providing the services to communicate?) In that situation, we dont need to send any kind of request between them.

2

1 Answer 1

0

how does it distinguish responses from the server when multiple LAN hosts send requests at the same time?

When dynamic NAPT is used from a private LAN to a public server, the NAT router needs to match the response's transport-layer destination port to an entry in its NAT (NAPT) session table. That entry is created with the outgoing request and indicates the source of the original request.

two hosts, based on two standard local networks on Internet, which are not related with each other. Is it possible to these hosts to communicate with each other directly?

I assume your 'local' means 'private' - no, not if either uses a private IP address and there's no NAT. Private-to-public requires source NAT/NAPT, public-to-private requires destination NAT.

Alternatively, you can connect both private networks using a (VPN) tunnel which hides private IP addresses from the public Internet.

2
  • So it is no possible to have two entries indicating to one public addres at the time? For example (192.168.1.1, 156.1.34.2) and (192.168.1.2, 156.1.34.2)? By directly I mean by using NATs, but without any kind of server to which we are sending the response.
    – Bratw
    Aug 10, 2023 at 8:28
  • That's certainly possible, please re-read my answer. As for 'communicate directly', using NAT isn't direct to me as it breaks the end-to-end paradigm. With appropriate NAT setup, it's certainly possible to communicate between remote private IP addresses.
    – Zac67
    Aug 10, 2023 at 9:11

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.