2

Suppose we have 2 networks with 3 PCs in each. As I understand, they can easily have the same IP addresses, but routers have different public IP addresses(e.g. here 158.127.10.3 and 158.127.10.4). So how PC in the left network with IP address 192.168.1.1 can communicate with PC in the right network with the same IP address 192.168.1.1 without knowing his private IP address(even if PC in the left network knows IP address of PC in the right network, it does not make sense to send a packet to the same IP address, so PC in the left network uses 158.127.10.4) and only addressing right network's router public IP address 158.127.10.4. For example packet from the left network will have DEST IP 158.127.10.4 but how to understand which PC of those 3 to send a packet

PC------------|                              |------------PC
(192.168.1.1) |                              |            (192.168.1.1)
|             |                              |
|             |                              |
PC------------Router----------------------Router ---------PC 
(192.168.1.2) (158.127.10.3)               (158.127.10.4) (192.168.1.2)
|             |                              |
|             |                              |
PC------------|                              |-----------PC
(192.168.1.3)                                        (192.168.1.3)

2 Answers 2

2

You are referring to the NAPT variant of NAT. In such a case, you must have NAPT port forwarding configured on the NAPT router. You cannot directly connect to a private address across the public Internet; you can only connect to a public address that way. The NAPT router with the public address must be configured to forward the specific protocol (TCP, UDP) and the port on that protocol to an inside device.


Remember that NAPT is a kludge to extend the life of IPv4 until IPv6 is ubiquitous, and IP was originally designed for end-to-end connectivity where every device has a unique address. IPv6 has enough addressing to restore the IP end-to-end paradigm.

This answer has more information about the IPv4 address shortage, the mitigations, and the solution.

0

Routers route between networks. For them to work correctly you require unambiguous addressing. Duplicate addresses like in your diagram prevent proper operation unless you build workarounds.

The most reasonable thing to do is to renumber one of the networks, so that host and network addresses become unique.

Another option is to hide the remote addresses behind a translation scheme - e.g. you use 192.168.255.0/24 to refer to the right-hand network from the left side, and 192.168.254.0/24 for the opposite direction. The routers in the path then translate the addresses to the ones actually used.

The left 192.168.1.1 would address the right one by using 192.168.255.1 as destination. One of the intermediate routers would translate the destination to 192.168.1.1 and the source to 192.168.254.1 (for the return path). The reply packets would require translation in the reverse way. This option is generally very cumbersome to work with and should be avoided (like NAT in general).

The other problem in your scenario is that the private networks are connected across a public path. If your route packets out to the public with private source addresses they'd either be filtered right away by your ISP or their replies could never find their way back.

To use transparent, private addressing across a public address space you require tunneling: your privately addressed inner packets are encapsulated by publicly addressed outer packets that can be forwarded between the routers. The remote router removes the outer encapsulation, and the private packet can then continue to the destination host. Usually this kind of tunneling is combined with encryption, so you'd have a VPN link.

Another option (that Ron has hinted at) is to hide the private addressing behind a public-to-private translation scheme both ways (aka port forwarding or destination NAT), e.g. the left 192.168.1.1 would use 158.127.10.4:8001 to access 192.168.1.1:80 on the right side, 158.127.10.4:8002 for 192.168.1.2:80 and so on. For more than a small number of exposed services that quickly becomes extremely cumbersome.

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.