Unable to access outside service from inside LAN

Given that you mentioned port forwarding, I assume your home gateway is acting as a NAT -- or more specifically NAPT -- gateway. What you're trying to do is called "hairpin NAT" or "NAT hairpinning", in reference to the way a literal hair pin doubles back on itself (the same allusion is used by the term "hairpin turn" for a sharp bend where a road doubles back on itself).

Some NAT gateways are crap and don't support hairpinning. It may be time to explore your upgrade options.


Assuming Spiff is correct, and your router can't handle port forwarding to the external ip from within the network there is a small work around (and it does sound like this is the case);

You can edit the hosts file, which can be found at /etc/hosts in most unix-systems and in C:\Windows\system32\drivers\etc\ on Windows.

if you add

192.168.0.15  example.com

in that file, your computer will go to the ip spesified whenever you try to access example.com. You will of course have to do this on every computer that you wish to use within the network.

You can check the wikipedia article for more details on where to find it: https://en.wikipedia.org/wiki/Hosts_file


There is a real simple answer to this one. The NAT is getting in the way.

  1. Your computer opens a connection to [ExternalIP]
  2. Your Router forwards that connection to [SSHInternalIP]. Your SSH server sees a connection from [YourInternalIP].
  3. Your SSH server sends its packets to [YourInternalIP].
  4. Your computer sees a strange packet coming from an IP it never talked to and discards it.
  5. Your connection to TCP/22 fails because the TCP 3-way handshake never completes.

You're trying to talk to a Public IP, but the replies are coming from an internal IP. Your computer can't make the two work together. The solution is to use the Internal IP whenever you're behind the router. I work around this problem on my laptops by using different ssh connection strings depending on where I am.