0

So if i have two routers and each router has lets say 2-3 computer devices.I am connected to the 1st router. So if i want to connect from my device to a device on the 2nd router than I will send the request to the public IP of the 2nd router. How does the router determine for which specific device the request is meant for?

  1. PUBLIC IP 1
  • A->10.0.0.1
  • B->10.0.0.2
  1. PUBLIC IP 2
  • C->10.0.0.1
  • D->10.0.0.2

I want to connect from A to C so how does that work. Does C need to be listening on a port on IP2 or is there some other way ?

One of the way I could find was port forwarding that request to a specific port on the router is forwarded to a specific IP. Does that mean router checks the port which is in the layer 4 or the transport layer segment?

And are there some other way in which the router determines for which specific IP my request is meant for.

1 Answer 1

0

Routers route packets between subnets. In order to do so, they must share a subnet between them. IP addresses are used to direct packets to their destination.

You seem to be referring to NAPT which breaks the original end-to-end paradigm and immensely complicates things. In your own network there's no need to use NA(P)T, however, and you can just forward transparently across routers.

Don't confuse the very common NAT setup with home routers with the normal setup. Businesses don't use NAT within their network, only on their network edge.

if i want to connect from my device to a device on the 2nd router than I will send the request to the public IP of the 2nd router.

Only if they're not directly connected but over a public network.

How does the router determine for which specific device the request is meant for?

For a NAT router to forward anything from public IP to private IP space, the router requires a rule set aka port forwarding, destination NAT (DNAT) or reverse NAT. That rule set defines how to translate and where to forward the translated packet.

Generally, you use DNAT when you want to expose a service inside your private network to the general public. If you want to enable private service access across locations you should seriously consider VPN. Using a VPN tunnel, you can route transparently and securely between remote locations. There should be no address overlap between locations as in your example.

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.