I have a few machines on different local networks that I need to SSH into from time to time. None of the networks have static IPs so I use a DynDNS to map each machine to a hostname, then with port forwarding I can just use the hostname as the SSH target.
When I'm connected to the same local network as one of the machines and I SSH into it using its hostname, does my connection pass through the public internet or does my router know that traffic is being routed to its own IP?