I have been having great trouble logging to my Raspberry Pi server via ssh via a remote ip address.

Currently I can login to the network via the command $ ssh pi@192.168.2.25. Where 192.168.2.25 is the local ip address. However whenever I try to connect to my Raspberry Pi via a remote server with the command $ ssh pi@<external ip address> -p port number I cannot connect.

Notes

  • I have activated port forwarding on my router (Bell Home Hub 2000) ports 22 and 10747. An example of my settings are below (note the external and internal ports are the same). Example Settings for port forwarding
  • I also have the No-Ip DUC installed and running, but I have not been able to login via $ ssh pi@<hostname.ddns.net> -p port number either. Also pinging fails as ping <hostname.ddns.net> and ping <external ip address> has 100% packet loss. Note that I have only tried to connect by using the external ip address while still in the home intranet network.
  • I tried following the instructions here and here. But neither helped me solve my problem.
  • Raspberry Pi is connected to the internet (apt-get and web browsers work). Currently my Raspberry Pi acts as a DNS server via Pi-hole but I plan to expand functionality once I can work remotely.

Additional Information

Routing table

$  sudo route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.2.1     0.0.0.0         UG    202    0        0 eth0
192.168.2.0     0.0.0.0         255.255.255.0   U     202    0        0 eth0

Linux distribution

$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 8.0 (jessie)
Release:    8.0
Codename:   jessie

Ports enabled in /etc/ssh/sshd_config

# What ports, IPs and protocols we listen for
Port 22
Port 10474

Port scan results from Open Port Check Tool:

enter image description here

If there is any other information that is needed just tell me the command to run.

  • @Sparhawk In the current setup it is difficult. Is there a way that I can test my router to see if this is the case? If it helps I have also posted the results of scan all common ports from yougetsignal.com/tools/open-ports – AzJ Feb 21 '17 at 3:15
  • @Sparhawk Would the client or server need to have a VPN connection? – AzJ Feb 21 '17 at 3:26
  • I setup the vpn on the client side. Now using the command ssh pi@<external ip> I get the error message ssh: Could not resolve hostname <external ip>: nodename nor servname provided, or not known – AzJ Feb 21 '17 at 3:49
  • Ha I figured it out. The error ssh: Could not resolve hostname <external ip> was caused by a misspelled ip address. I figured out that in order to use the external ip login I have to be outside of the local network. Thank you @Sparhawk – AzJ Feb 21 '17 at 3:56
up vote 2 down vote accepted

Some routers won't let you use your external IP address. That is, they won't let you send a signal "out" then back "in".

You can test this by connecting to your home box from a different network. If that is physically difficult, then you can try connecting via a VPN, which should produce a similar result. (If you don't have an account, Mullvad provide a free one for ~3 hours, I think.)

Just connect the client to the VPN, and don't touch the router. Essentially, you connect your "normal" computer to the network via a VPN server, which routes all traffic from that computer through an external network. The signal then approaches your home network "externally", so you can exclude any intranet oddness.

If you really want to use the external IP address via your intranet, then you'd need to investigate a router that supports "NAT loopback". Having said that, doing a traceroute on my home server (via its external IP) seems to connect to my ISPs node, then back into my house. This suggests that this functionality could be provided by your ISP too.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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