Remote Connection Issues

My Raspberry Pi 3 B+ is connected to the internet via OpenVPN and I can SSH to it using PuTTY on my Windows machine and Termius on my Android machine when they are on the LAN. But when I take either of my machines to the cellular network, they can no longer connect to the Pi.

I have configured my router to forward requests from a port of the external IP to port 22 of the (static) internal IP assigned to the Pi. The logs from my router indicate that the router is, in fact, successfully forwarding requests to the Pi.

If it helps, I am trying to configure everything so that I can access files on my Pi-connected hard drive from outside of my LAN using SFTP; SFTP also works between machines on the LAN.

Any guidance for how to accomplish this or what other checks I should make would be greatly appreciated.

This will not work. Your SSH request would come in from outside the VPN Tunnel while you answer will come via the Tunnel

That makes sense. Disabling the VPN revealed the response. Thanks.

Is there a clever way to talk with a machine connected to the internet via VPN from outside of that machine’s LAN?

Application/Port based routing

So, something like the script suggested in this?

https://www.reddit.com/r/raspberry_pi/comments/4ahjgq/is_it_possible_to_route_only_torrent_traffic/

Or is there a better method?

I think that I get the basic premise of port-based routing, but I am just a wee bit foggy on the implementation.

Something along that lines. Iptables is definitely your friend.

Seems like powerful stuff. The mind boggles at the possibilities.

Thanks for your help, fzinken.