0

I understand that private IP is invisible to the internet and only my router can know about it (correct me if I'm wrong), and that my public IP is the one everyone uses to talk to me.

I also understand that we use this method because there simply isn't enough IP addresses to satisfy everyone, so this way two different computers in two different LANs could share the same private IP, the router(for example) knows the private IP addresses of everyone and can use it to communicate with them.

What I don't understand is that we still need to give each computer an individual IP address, so I tested with my two computers that are connected the same wifi and to my surprise they have exactly the same public IP !of course the private IPs are different

so my question is this :

how do we uniquely identify each of the computers if they share the same Public IP and their private IP is unknown to anyone outside of the local LAN

1

1 Answer 1

3

In a home access router the external network interface is usually on the internet, and router can have a publicly routed address on that (a unique, exclusive, internet address which is reachable from the whole internet). The internal network is where the user devices are. On the internal network the ip addresses are private, not publicly routable (there are thousands of homes where the internal network addresses are 192.168.1.x).

On the internet, a packet addresses to a private address would not know where to go. This is why NAT (network address translation) is used. NAT usually happens in the home access router which is the default gateway for all the devices on the private network. the source port and the source address of the private network are "translated" via a dynamic lookup table to a random source port and to the external internet router address. When the answer comes back, the translations happens in the other way around, and packets is delivered to the internal device. NAT simply rewrites port and ip addresses, recalculating appropriately the packet checksums. After some time that traffic is not seen, entries in the NAT tables are deleted, and the ports freed for other uses.

Via the NAT mechanism, any number of internal devices, with non publicly routable addresses, can be allowed to initiate a conversation with any internet host, and get back the replies.

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