Here's my scenario.

I've got a VPS running on the cloud and it works fine. I recently signed up with a VPN and I've been using it on my machines. I wanted my VPS to also use the VPN but once I connect the VPS to the VPN the connection drops because the IP address has changed, which makes perfect sense.

However, is there a way for me to still access the VPS after it has connected to the VPN?

I'm not too familiar with networking and routing tables, but ideally I would like to have it that once its connected to the VPN, I can still access it through its old IP, but everything else connects through the VPN.

Is that possible?

Thanks in advance.


When your server connects to your VPN, it becomes "multi-homed". If your VPN pushes its router as the default gateway, but inhibit forwarding of packets with external IP (in this case the public IP of your server), you loose connectivity to the "old IP".

The solution to this problem is "source based routing". Very briefly, on Linux you can create two or more distinct routing tables, in which you have different default gateways. With iproute2 rules you can then choose which table to apply depending on the originating src IP.

More info here: http://www.tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.rpdb.multiple-links.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.