answered
2015-12-06 23:31:09 +0200
[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:
[Unit]
Description=OpenVPN Robust And Highly Flexible Tunneling Application On MyOpenVPNHost
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/var/run/myopenvpnhost.pid
ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/myopenvpnhost.pid --cd /etc/openvpn/ --config /etc/openvpn/myopenvpnhost.conf
Restart=always
RestartSec=60
ExecStop=killall -9 openvpn
[Install]
WantedBy=multi-user.target
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]