Due to privacy issues I'd like Ubuntu to allow applications to send traffic to the Internet only when the VPN connection is established.

The thing is that there are some applications like Skype or Dropbox that will reconnect after the VPN connection is dropped for some reason. And I don't want that, I want them not to be able to.

Any way to do this?


Try this:

To get your default gateway IP, show your routes with the ip route list command.

Edit your main internet connection to remove the default route: in nm-connection-editor, edit your connection > IPv4 tab > Routes > check Use this connection only for resources on its network.

Then add a specific route to reach your VPN server via your gateway. This will allow your computer to reach only one IP on the internet: your VPN server, so that your VPN connection will still work. (in the Routes window, add a route like: Adress: VPN_SERVER_IP Netmask: Gateway:GATEWAY_IP).

To allow internet access through your VPN, you may also need to edit the Routes of your VPN connection to uncheck "Use this connection only for resources on its network", or add a specific route for a custom gateway of your VPN.

nm-connection-editor edit routes screen

  • 2
    This doesn't seem to work in Ubuntu 13.04. I simply can't connect to my OpenVPN if I follow these instructions. @Marc, could you update your instructions for the latest versino of Ubuntu? – Hengjie Jan 25 '14 at 9:07

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.