Ubuntu – Always on VPN connection

12.04vpn

I have a working VPN connection. Works like a dream.

What isn't working though, is the 'Connect Automatically' option in the Network Connections Manager Panel. It never connects automatically, not at boot, and not after disconnect. I'm not quite sure what that option is for. And I'll get disconnected from the VPN with no warning whatsoever.

Is there a way to make sure my computer only connects to the internet through a VPN? So that if the VPN connection isn't established, my computer can't reach the internet. And is there a way to get ubuntu to attempt to reconnect to the VPN automatically if for some reason the connection drops?

Best Answer

Unfortunately "Connect Automatically" allows the VPN to connect when you try to visit a service that's not otherwise reachable, which means it won't work for maintaining VPN connections used only (or even primarily) for privacy purposes.

The only way I've found to keep VPN up is to have a crontab entry that runs

nmcli con on id YourVPNName

This assumes you've got your VPN configured via NetworkManager, which you probably do.