We have moved to a new Sailfish OS Forum. Please start new discussions there.

Autoconnect to vpn when network goes up

asked 2015-12-06 20:02:30 +0300

Federico gravatar image

updated 2016-08-17 10:55:26 +0300

jiit gravatar image

Has someone managed to configure openvpn on a Jolla phone so that a VPN connection is started whenever the wifi network goes online?

I have tried Securefishnet, but it doesn't reconnect to the VPN if the network goes down and then up again. There is a reference on https://together.jolla.com/question/305/vpn-client/ about the possibility of doing it using the DBus Connman API, but that's all I could find.


edit retag flag offensive close delete

2 Answers

Sort by » oldest newest most voted

answered 2015-12-06 23:31:09 +0300

utkiek gravatar image

updated 2018-08-17 13:34:51 +0300

[Update 17.8.18: The vpn service found in settings is routing ALL TRAFIC through vpn. There was no difference for me with oder without "redirect-gateway" in conf/ovpn-file. This may be good for many peoples but not for me. I deleted my vpn config in settings and use this proven method. Now only my mails are routing about vpn. Testing on Xperia X with 2.2]

I have a systemd service in /etc/systemd/system/

You need root access and you must able to use the terminal. OK? Let's start:

Change to /etc/systemd/system. Create a file myopenvpnhost.service with "myopenvpnhost" is the name of your openvpn configuration found in /etc/openvpn. Type in this new myopenvpnhost.service:

Description=OpenVPN Robust And Highly Flexible Tunneling Application On MyOpenVPNHost
After=syslog.target network.target

ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/myopenvpnhost.pid --cd /etc/openvpn/ --config /etc/openvpn/myopenvpnhost.conf 
ExecStop=killall -9 openvpn


In myopenvpnhost.conf is your openvpn configuration. Now try this systemd service:

systemctl start myopenvpnhost.service 

systemctl status myopenvpnhost.service

Check the log, then stop the test with

systemctl stop myopenvpnhost.service

If all ok type

systemctl enable myopenvpnhost.service

Then openvpn started - with a small delay (see "RestartSec" option above) - every time the network started.
Works by me since February 2014.

[edit 6.12.15 layout]
[edit 17.8.18 path for .service file]

edit flag offensive delete publish link more



Hi. I would like to start it when I'm outdoors(i.e: Mobile Data) and stop it when I'm at home with Wi-Fi. Do you think it is possible? Thanks Regards.

Pasko ( 2016-09-18 13:23:45 +0300 )edit

answered 2016-09-18 22:43:07 +0300

DarkTuring gravatar image

I am using securefishnet and it can reconnect fine, the problem is when the radio switches between wifi to mobile data. It then cannot connect, is there a patch for that or is the solution above ok for sailfish

edit flag offensive delete publish link more


I would also like to use VPN via mobile data ;-) Unfortunatly many mobile provider prohibit VPN connections because they like to track you since it's their business ;-( Using VPN in most Wifi works luckily.

Marti Masa K ( 2016-11-19 20:15:27 +0300 )edit

@Marti Masa K have since figured it out works on.mobile and wifi, but every time radio switches disable DNS queries to VPN , this doesn't work for browsing the web otherwise and most apps dont like that routing either.

DarkTuring ( 2016-11-20 06:21:09 +0300 )edit
Login/Signup to Answer

Question tools



Asked: 2015-12-06 20:02:30 +0300

Seen: 1,592 times

Last updated: Aug 17 '18