IPad – SSH connection to Mac works from the outside but not locally

ipadNetworkroutersshwifi

I configured SSH access to my Mac in order to use Prompt on my iPad. That way I can use my Mac from anywhere in the world, as long as I can get my home IP address.

Although the SSH connection works fine from a separate external connection (my 3G iPhone, for example), it times out when I try to connect from a separate device on the same home wifi network.

As a result, I spent two whole days trying to debug a connection that actually works fine.

Why does an SSH connection that works fine from a separate external address time out when I try to connect from behind the same router?

Is there a workaround so I can just use a single SSH setting whether I am in my living room or on a different continent?

Note: a useful way to get your home IP address (if it's not fixed) is to log into your Gmail account from afar and look at "Last account activity" on the lower right corner of the screen.

Best Answer

The router does the NAT on the external interface. However when you ssh to your WAN address the router will recognize packets coming in on on the internal interface as being sent to its own address and will just send them to its local port 22. What you want does exist but isn't often supported, it's called "NAT loopback".

See NAT Loopback Routers