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?
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
This assumes you've got your VPN configured via NetworkManager, which you probably do.
As long as the automatic reconnect is concerned, you can try this - VPNautoconnect. It seems to be working pretty well (and reconnects immediately after the VPN is dropped for some reason) and has a GUI (no need to use the command line). It works with connections from the Network Manager.
I have my 12.04 connecting automatically about 1 minutes after I log in. I suspect part of the issue is that the VPN password is stored in an encrypted home folder, which is unavailable until a user is logged in, so it fails at start-up. So, I made crontab
I put greg's suggestion in a new script (/etc/NetworkManager/script.sh) after a 1-min delay:
I then added a crontab (crontab -e) that calls the script on start-up:
This is probably not the most elegant way to do it. It might mean a user has to log in within 60 seconds of start-up or the VPN connection will fail. Also, if you do anything online in the first 60 seconds, that won't go over the VPN. So... yeah, that's what I did.