I have installed OpenVPN (interested in client only) and it starts automatically on computer boot. As the connection needs user and password, Ubuntu it even asks for them on computer startup.

I noticed that it imposes a problem when I am in the same network to which I am connecting to. My OpenVPN config has a 'route' command that makes me feel like I am in my network when I am away, but it somehow leads to bad connection when I am in that very network physically.

The precise question is how do I configure OpenVPN to activate a connection only when my ip address changes from my home network to some other, or detect that I am away by any other means.

Additional Q#1: Ideally the desired setting should cope with situation when my 4G USB stick assigns me an IP but I still don't have access to my OpenVPN server, because I have to activate internet on it manually: the OpenVPN client fails to connect and never retries.

Additional Q#2: I'd wish to store the user/password in some safe plsce so that it doesn't ask when automatically connects.

I don't have OpenVPN GUI. If the above settings are too hard to implement I will just install it and activate connections when needed...



with network-manager-openvpn-gnome you can solve this problem:

You can configure your network connections to enable a vpn profile if you connect to the network: gnome-networkmanager vpn at network

it's in german, but you should get a clue where to search ..

open your network configuration where you want to have vpn enabled automatically and on general tab switch on the check mark where it says "connect to vpn automatically when this network is used" and select your pre-defined vpn profile.

  • This plugin and a Network Manager is a handy thing. I can control OpenVPN connections from standard interface and tell it to connect to my VPN when I am on a certain WiFi connection. However, what I was looking for was an ability NOT to connect when I am on a certain WiFi or ethernet connection. Is it possible? – fedd Jul 30 '16 at 7:31
  • Rephrasing: However, what I was looking for an ability NOT to connect when I am on a certain WiFi or ethernet connection, but start automatically for all other connections. Is it possible? – fedd Jul 30 '16 at 7:33
  • Sure: just set all others to connect except for those that should not. It's a little more effort, but should do the trick. – Phillip -Zyan K Lee- Stockmann Jul 30 '16 at 8:04
  • sad. What about ethernet connections? How can it use one set of settings at home, another at work and the third in the hotels? I need to invoke VPN only when I use ehternet in hotels, and not when I use ethernet at the office. – fedd Jul 30 '16 at 9:44
  • You could set up different Ethernet profiles for each location. :-D – Phillip -Zyan K Lee- Stockmann Jul 30 '16 at 11:39

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.