nautilusopera
Posts: 2
Joined: Sun May 06, 2018 7:29 pm

Skript openvpn client connecting when wifi is connected

Sun May 06, 2018 7:35 pm

hello together,

i want to create a script that automatically connect to a openvpn server when it detected that wifi is connected.
when the wifi disconnected the openvpn process have to exit.
so you have an idea how to create it ?
i am not good in programming .
:D

i hope you can help me

thanks

regards

dave

epoch1970
Posts: 5203
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Skript openvpn client connecting when wifi is connected

Mon May 07, 2018 9:29 am

Long story short: wrong angle. The machine state is quite complex (please define "wifi is connected"), so making a script do the right thing is going to be fiddly.

Instead, look at OpenVPN options in the man page.
You can configure how frequently it tries to reach the server, you can run scripts when the tunnel goes up or down, you can use its management facilities to get a status. A small companion script could go a long way.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

ejolson
Posts: 5474
Joined: Tue Mar 18, 2014 11:47 am

Re: Skript openvpn client connecting when wifi is connected

Mon May 07, 2018 5:07 pm

epoch1970 wrote:
Mon May 07, 2018 9:29 am
Instead, look at OpenVPN options in the man page. You can configure how frequently it tries to reach the server, you can run scripts when the tunnel goes up or down, you can use its management facilities to get a status. A small companion script could go a long way.
Network connections could also be through the wired connection, in which case WiFi is not connected but the server is visible. Presumably the person making the original post wants to distinguish between the two cases and only bring the VPN up when connecting over WiFi.

nautilusopera
Posts: 2
Joined: Sun May 06, 2018 7:29 pm

Re: Skript openvpn client connecting when wifi is connected

Mon May 07, 2018 7:18 pm

Hi,

I want the Pi to save 10 wifi networks.
When one of the network is connected , the pi have to start the tunnel and connect it.
Is it possible ?
The network manager on ubuntu can connect automaticly to an openvpn tunnel when wifi is connected.
LAN is always connected but only to connect other network devices.
So i have to use wifi as default network

I dont know how.

Return to “General programming discussion”