5

In my office there are 2 PC, both of them are behind a router with his own private IP. I'm trying to connect to them via SSH but it only seems to work while my notebook is connected to the same Wifi (meaning, all pc's are in the same network). How can I SSH to work from home?

I guess It's using the public IP (the one that you get from www.whatismyip.com or similar), but I can't find a way to tell the SSH to connect to a specific PC.

Also, I have a dynamic IP, so I set a DNS server (using my.noip.com).

All this is on Ubuntu, btw.

Thanks in advance.

Edit:

I have added some options to the router (it an apple time capsule A1470) under the Internet tab (Enabled NAT Port Mapping Protocol) and I added a Port Mapping Setup using port 22 and the private IP Address of the PC that I'm interested. Still, no clue on how to using public IP to get into the private one.

Edit 2:

Aparently, my port-forwarding is working, but I think I have two IP's, one for the router and a public one, though it seems like the public IP isn't reaching the Router IP. In my router info there's an IP which is like 172.x.x.x; when I ssh through that IP, and specify a port, I cant get into one of the two PC's in my office that Im interested, if I change the port (the one I set previously in the port-forwarding) I can get into the other PC. Problem is that PC's out of the network can't use the IP repoted in router. Public IP isn't working either, not even from the same network.

3
  • I assume you have found the public and internal ip, port forwaded the internal ip on the router, and then connected using the public IP? Easy way to find public ip from command line is; dig +short myip.opendns.com @resolver1.opendns.com
    – f3rn0s
    Commented Aug 11, 2016 at 23:51
  • Else. superuser.com/questions/277218/…
    – f3rn0s
    Commented Aug 11, 2016 at 23:55
  • You may find this question interesting. The other router (like ISP router) may be in your office or somewhere outside it. Commented Aug 12, 2016 at 17:40

2 Answers 2

4

You have to add a port-forward rule in your router and set the destination IP address of the required computers LAN IP and port 22.

You can not specify to SSH which computer you want to connect to, you can only connect to an IP address (or a resolvable domain name) and a port (default 22). Only to those for which you set a port-forward rule on your router.

However, you can add multiple rules to each computer but the WAN side port must be different for each one, ie. you can use port 22 only once.

For example:

  • WAN port 22 ---> LAN IP: 192.168.1.1 PORT: 22
  • WAN port 2220 ---> LAN IP: 192.168.1.2 PORT: 22
  • WAN port 2221 ---> LAN IP: 192.168.1.3 PORT: 22

See my answer to a very similar question: Why can't I access my web server from outside the network?

2
  • Aparently, my port-forwarding is working, but I think I have two IP's, one for the router and a public one, though it seems like the public IP isn't reaching the Router IP. In my router info there an IP which is like 172.x.x.x, when I ssh through that IP, and specifie a port, I cant get into one of the two PC's in my office that Im interested, if I change the port (the one I set previously in the port-forwarding) I can get into the other PC. Problem is that PC's out of the network can't use the IP repoted in router. Public IP isn't working eather, not even from the same network.
    – Cris
    Commented Aug 12, 2016 at 17:10
  • Probably do you get NAT'ed IP address from your ISP? If you compare your router's WAN IP with the one that eg. www.whatsmyip.com displays and the two does not match, probably this is the case. Commented Aug 12, 2016 at 18:10
0

check your modem to see if it is acting as a gateway. Sounds like you have double NAT. See if you can turn off NAT on your modem.(set to bridge mode)

You must log in to answer this question.

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