0

I discovered recently that there is two types of ip, i.e. the Public IP and the Private IP. I know that the Public IP is the one the external world can see and the Private IP is local to our network. It is distributed by the router. But which IP do we need to use the SSH someone.

Suppose my Public IP is 47.144.221.167 and my Private IP is 192.168.1.19 (Be aware that they are fake ip addresses).

  1. Is my Private IP unique? In other words, can my Private IP be distributed by another router?
  2. If I want to SSH another computer, do I need to use the Private IP or the Public IP?
  3. If someone tries to track my IP from China, will he get my Private or Public IP?

1 Answer 1

6

Is my Private IP unique? In other words, can my Private IP be distributed by another router?

Your private IP has no meaning outside your network. There is a 192.168.1.19 on my network that is a machine right behind me.

If I want to SSH another computer, do I need to use the Private IP or the Public IP?

We have no way to know. It depends on whether you need an IP address that is meaningful only on that network or you need a globally unique one. In some cases, only one exists. In some cases, both exist, and which one you need depends on what you are doing.

For example, if I'm trying to ssh from my desktop to a server behind me on the same network, the public IP address would do me no good. Both machines have the same public IP address. If I'm trying to ssh into three different machines on your network, I'm may need both -- the public IP to find your network (maybe to establish a VPN) and either the private IP (or some other method) to find the individual machine.

If someone tries to track my IP from China, will he get my Private or Public IP?

That depends on how they try to track you and what tools and methods they use. They would typically get your public IP and then from that try to map out private IPs inside your network next.

4
  • Related to the second question. Suppose I SSH the IP address of someone in China. For me that IP address is the IP of the modem and that modem is attach to a router. From that router, certain private IP are distributed from the router. How can I SSH one of those three machine if I only use the Public IP? Do I need the Public and the Private IP to access that machine with a command like ssh 47.144.221.167:[email protected] ... just an example
    – J.Doe
    Commented Mar 26, 2020 at 17:35
  • 1
    @J.Doe In general, you can't connect to computers on private IP numbers from the outside. There's an exception, though: routers can be configured to "forward" incoming connections on specific ports to specific internal (private) addresses. So if the person in China had set their router to forward port 22 (the one ssh uses) to 192.168.1.19, then connecting to their public address with ssh would actually get you a connection to that private address. But there's no way for you to connect to, say, their 192.168.1.20, unless they'd configured some other port to forward to that other address. Commented Mar 26, 2020 at 22:00
  • SSH reverse tunnel is not an option?
    – J.Doe
    Commented Mar 26, 2020 at 22:07
  • There are all kinds of options that they could set up including things like VPNs or relaying through a machine with a public IP address that is VPN'd onto the private network. Commented Mar 27, 2020 at 1:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .