1

I am searching for a way to always enforce a VPN connection with a chosen profile (ovpn or network manager) whenever I use an internet connection. I want to use OpenVPN and Debian 8.

Is there a package or a nice script that does this?

Have I missed some possible configuration within OpenVPN or another utility to accomplish that?

2

I got a simple solution. It works perfect on ethernet or wifi and it even restores the connection on a disconnect.

At first you have to set up a vpn connection with your networkmanger. After that you have to place a file, i named it vpnautoconnect in the /etc/network/if-up.d directory. Do not forget to replace PrivateVPN with the Name of your VPN-Connection you created before.

#!/bin/sh
# vpnautoconnect-script
# Place this file in /etc/network/if-up.d
# Set the ovpn-confgiuration by name
# nmcli con up id <ovpn-name>
nmcli con up id PrivateVPN

If you're having problems with this not working, try running ifup --all -v, it should show you any error messages related to the startup script. In case it shows you the following message:

A password is required to connect to 'PrivateVPN'.

All you need to do is click on the icon on the right hand side of the password field and select Store the password for all users, which will allow nmcli to use the password.

| improve this answer | |
0

vpnautoconnect can do it.

https://sourceforge.net/projects/vpnautoconnect/

Description : vpnautoconnect is a daemon that allow you to reconnect automatically (at startup too) a vpn create with network manager.It can reconnect very quickly and monitor the bandwith, It works with pptp and openvpn connection.

| improve this answer | |

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.