Reply
Established Member
Posts: 779
Registered: ‎08-22-2013
Kudos: 230
Solutions: 17

Re: Better way to restart OpenVPN?

That's outstanding. I'll happily alpha-test 2.0. Thanks for the update @UBNT-sandisn

UBRSS, UEWA.


Milwaukee, WI
Highlighted
Established Member
Posts: 779
Registered: ‎08-22-2013
Kudos: 230
Solutions: 17

Re: Better way to restart OpenVPN?


@karogwrote:

In the mean time, one could use this script that seems to work.

 

vtunrestart

#!/bin/vbash

# 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?

UBRSS, UEWA.


Milwaukee, WI
Established Member
Posts: 1,524
Registered: ‎05-03-2016
Kudos: 520
Solutions: 147

Re: Better way to restart OpenVPN?

[ Edited ]

@jeremyk wrote:

 

@karog - I can't seem to get this to work. It works for you?


 Yes, I would not have posted it otherwise.

 

Did you adapt it as instructed?

 

 

Established Member
Posts: 779
Registered: ‎08-22-2013
Kudos: 230
Solutions: 17

Re: Better way to restart OpenVPN?


@karog wrote:

@jeremyk wrote:

 

@karog - I can't seem to get this to work. It works for you?


 Yes

 

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.  

UBRSS, UEWA.


Milwaukee, WI
Established Member
Posts: 779
Registered: ‎08-22-2013
Kudos: 230
Solutions: 17

Re: Better way to restart OpenVPN?

@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. 

UBRSS, UEWA.


Milwaukee, WI
Reply