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?
New contributor
J.Doe is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
4

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.

|improve this answer|||||
  • 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:username@192.168.1.19 ... just an example – J.Doe Mar 26 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. – Gordon Davisson Mar 26 at 22:00
  • SSH reverse tunnel is not an option? – J.Doe Mar 26 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. – David Schwartz Mar 27 at 1:20

Your Answer

J.Doe is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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