04-16-2018 08:22 AM
In the mean time, one could use this script that seems to work.
# SET FOR YOUR VTUN !! VTUN="vtun2" if [ -f "/var/run/openvpn-$VTUN.pid" ]; then sudo kill $(cat "/var/run/openvpn-$VTUN.pid") fi
# CHANGE THIS COMMAND keeping sudo !! sudo /usr/sbin/openvpn --daemon --verb 3 --writepid /var/run/openvpn-$VTUN.pid --status /var/run/openvpn/status/$VTUN.status 30 --config /config/openvpn/pia/128/US\ East.ovpn --dev-type tun --dev $VTUN
To find your command, do (after adjusting for vtun). The command will vary depending on how you configured the interface.
$ ps aux | grep -v grep | grep vtun2 root 2025 0.2 0.5 6456 2720 ? Ss 12:45 0:01 /usr/sbin/openvpn --daemon --verb 3 --writepid /var/run/openvpn-vtun2.pid --status /var/run/openvpn/status/vtun2.status 30 --config /config/openvpn/pia/128/US East.ovpn --dev-type tun --dev vtun2
This shows you the command line ( it starts with /usr/sbin/openvpn to the end of line ) that was used to start your openvpn instance. It is what you will need in the above script. Beware any spaces in your .ovpn filename if such is used as they will not be quoted here. Just add a \ before each space. PIA uses spaces in its .ovpn filenames which motivated me to mention it.
@karog - I can't seem to get this to work. It works for you?
04-16-2018 09:23 AM - edited 04-16-2018 09:23 AM
04-16-2018 09:25 AM
Did you adapt it as instructed?
@karog - My fault, I didn't realize I was still in a failover situation at the moment I tried to run it. I did make the necessary customizations for my config. I'll test again and report back. Thanks.
04-16-2018 03:02 PM
@karog - It works. thanks, and my apologies. Everything you suggest functions wonderfully at killing the openvpn tunnel and restarting it with a fresh PID.
It wasn't working for me after a WAN-failover and fail-back event earlier today. I think it may be related to my use of openvpn-option --persist-tun. Going to play with that a bit. Anyway thanks.
4 weeks ago
@karog Thanks for the script. it seems to work as it keeps my AirVPN connection flowing.
Just some error message seen:
openvpn: Options error: option 'dhcp-option' cannot be used in this context ([PUSH-OPTIONS])
openvpn: Options error: option 'redirect-gateway' cannot be used in this context ([PUSH-OPTIONS])
I further edited my AirVPN.ovpn file to comment out ovpn option "persist-tun" and add in ovpn option "keepalive 10 60". Hope this helps.