I have a PC at home which I can access over SSH (my router forwards that port). It works fine except when my PC is connected to the VPN, in which case all traffic (including response to incoming connections) goes out the VPN. This is because when the VPN is on and an SSH client tries to connect, my PC sees incoming connection from my SSH client’s public IP address and replies to its public IP address via the VPN interface. So the SSH client trying to connect to my PC at IP address
18.104.22.168 (my router’s public IP address) receives the response from IP address
22.214.171.124 (my VPN’s public IP address) and ignores it.
Is there a way to do either of those
- configure my router (Ubiquiti EdgeRouter X) to masquerade and make incoming connections appear to come from its local IP (as is the case with hairpinning when a client on the LAN connects to the PC via its public IP address)
- configure my PC to send replies to incoming connections via the normal LAN interface rather than the tunnel interface
P.S. This is a duplicate of openvpn routing setup for incoming connections on client but this question has not been solved either.