I have a SSH server running on my local network which is exposed to the public internet via my router's port forwarding. I have also set up a name for the host locally on my machine (via etc/hosts
) and remotely (via dynamic DNS), let's say:
ip name
locally 192.168.0.5 myhost
remotely 11.22.33.44 myhost.example.com
From within my local network, I can access the server via ssh 192.168.0.5
/ ssh myhost
and from outside my network I can access it via ssh 11.22.33.44
/ ssh myhost.example.com
.
To that point, everything works fine. However, using two different hostnames for the same server is a bit cumbersome. I'd like to access the server in a unified way, i.e. using only a single IP / hostname that works both, locally and remotely.
Is there an easy solution to this problem? I'm on macOS if that matters.
BTW: I cannot access my router from the local network using its public IP.