6

We all know that PCs on a LAN use private IP addresses such as 192.168.2.3, etc.

Now my question is, how can a PC say mine having a private address of 192.168.2.3 communicate with other LAN PC having a private address of say 192.168.2.5 because not every PCs have public addresses.

To make it more clear let's say I want to ping to your PC having an IP address 192.168.2.5.

So how will my PC or the router know to which PC it must send the message to as there can be many PCs with that same private IP address of 192.168.2.5.

2
  • 4
    "We all know that PCs on a LAN use private IP addresses such as 192.168.2.3 etc." That is not completely accurate. Many LANs use private addressing, but many use public addressing, and with IPv6 most will use public addressing to restore IP end-to-end connectivity that NAT breaks, which is the crux of the problem you raise.
    – Ron Maupin
    Aug 2, 2017 at 14:15
  • 1
    There is a situation where multiple devices on the Internet do have the same public IP address. This is Anycast and the most well known implementation is in the geographic distribution of the root nameservers for the Domain Name System. Anycast (in IPv4) takes advantage of internet routing protocols to provide clients access to the best (usually fastest or nearest) node of the group. Aug 2, 2017 at 19:14

4 Answers 4

11

A PC in a private IP range can't be acccesed from the public internet.

Devices in private range connecting to internet use a proxy or router/NAT device that replaces the local source IP for a single public IP address that redides in your router/NAT.

However, you can make an exception to that, opening a port in the router and allowing that traffic directed to your public IP adddress and that specific port (for example, 80) get through the router and finally to your PC.

Now your PC is public at least on port 80. Internet knows how to get to your PC using the public address and the router translate that public Ip to the private that your device uses.

An example:

Your PC has the private IP address 192.168.2.3 and is connected to an internet router that has the public IP 54.239.25.200.

Now, if you open the port 80 in the router then anyone in the public internet could connect to your PC using the URL http://54.239.25.200:80

The public internet doesn't know your private IP, they know your public IP address.

2
  • 1
    Of course, ping (the protocol in question) uses ICMP, which doesn't have ports.
    – Ron Maupin
    Aug 2, 2017 at 14:16
  • Thanks buddy.. I appreciate for ur time.. I sometimes get some crazy doubts don't mind
    – RRHS
    Aug 9, 2017 at 17:36
2

If you really want to fully communicate using private IP addresses with a remote PC/network, ping etc., across public Internet you'll need a tunnel, usually a VPN connection.

The Internet doesn't route private IP addresses the reasons you've pointed out. So, you need to hide = encapsulate the private IP packets inside public IP packets. On the sender's side packets are encapsulated, and on the receiver's side the original packets are extracted and routed to the destination.

1
  • I didn't know you can do that.. I'll look into that.. Thanks for the time
    – RRHS
    Aug 9, 2017 at 17:36
1

I think the best way to do this, is creating a VPN as Zac67 says, but your question is a bit generic so it is difficult to answer without a topology with the devices involved. Basically you would need to configure a public peer for each host, so you will have a private ip and a public peer wich would be the face on the internet. Besides it would be a more safe way because all the trafic would be encrypted. Opening ports like http/80 on a router and acces it over inet is not recommended.

1
  • I can understand.. My bad.. I didn't frame the question properly.. Anyways thanks for your time.. I appreciate it
    – RRHS
    Aug 9, 2017 at 17:37
-2

It's called static routing. Here is an example of how it works:

"mine having a private address of 192.168.2.3"

"other LAN PC having a private address of say 192.168.2.5"

  1. Add the following configuration to your router

protocols [ static [ route 192.168.2.0/24 [ next-hop 192.168.2.2 [ ] ] ] ]

  1. From your computer's command line ping it as you normally would: ping 192.168.2.5
1
  • 2
    Sorry Leon, but traffic in the same subnet will never reach the router, so static routes have no effect. In actuality, these are disjointed networks separated by the Internet. so you can't route between them unless you use NAT.
    – Ron Trunk
    Nov 1, 2019 at 15:09

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.