toggle openvpn using WPS button

3 posts / 0 new
Last post
nikon56's picture
toggle openvpn using WPS button


after considering it  for a while, i finally jumped in and joined you guys in the ddwrt world with a R7000, and i might say i enjoy it.

one of my main use is openvpn client for my network, however, i don't want to run ittt all the time, especially ince it  impacts my DL speed a lot (steady 100Mbs without, 15 with vpn on, and i have a LOT of steam games)

so i switch the vpn off when updating, but it's not "user friendly" having to go in the web server, loggin, etc... so i decided to try using the WPS button to toggle the vpn.


after playing and reading a lot, i came up with this solution:


create a script "vpn_toggle.sesbutton"', store it in /jffs and copy it to "/tmp/etc/config" using startup script

startup script:

mkdir /tmp/etc/config
cp -f /jffs/vpn_toggle.sesbutton /tmp/etc/config/

vpn_toggle.sesbutton script:

if [ $(cat /sys/class/net/tun1/carrier) -eq 1 ]; then
   killall openvpn
   gpio disable 14
   openvpn --config /tmp/openvpncl/openvpn.conf --route-up /tmp/openvpncl/ --route-pre-down /tmp/openvpncl/ --daemon &
   gpio enable 14

and it works...well, kinda.

it does actually toggle on or off the vpn & WPS led, as expected, BUT once toggled OFF, the vpn is somehow restarted after a few minutes.


so obviously, something is watching about the vpn and restarts it.

so i am wondering how to actually properly toggle it off from a script, so if anyone has a clue or better, a solution, i'd be glad to hear about it :)

mesteele101's picture
There is definitly a problem

There is definitly a problem if you are seeing that much of a gap in speed. If your VPN provider is not helping you with the problem, try using Torguard, they have a great support staff.

nikon56's picture
hi and thx for the advice,

hi and thx for the advice, the speed issue will be dealt with, either from help with the provider support or switching to another provider, altough i doubt any provider be able to provide 100Mb/s openvpn tunnel.

but my question remains, regardless of the speed issue, i still want the ability for other purposes to switch easily the vpn on and off