Side toggle switch on GL MT-300N v.2 for Wireguard peers

I wanted to have the toggle switch on the GL MT-300n v.2 “Mango” router switch between Wireguard peers rather than just turn it on/off. Thanks to others on this forum, I found the file “/usr/bin/switchaction” which scripts the actions for the toggle switch. I modified the two sections needed (one for the left position on the switch and then ‘else’ part, for the right). It works perfect (I think).

If I am connected to one Wireguard peer ‘VPN -1’, and I want to connect to peer ‘VPN -2’ instead, toggling the switch does:

uci set wireguard.@proxy[0].main_server=“VPN - 2”
uci commit wireguard
/etc/init.d/wireguard reload

Looking at the /etc/config/wireguard file, I see that it does change the profile information correctly. The VPN light on the router does dark then lights up again. Checking the external IP address, it changes as expected.

Is there anything else I should be doing for security or best practice as well? When I change the peer I am connected to from the GUI, what else (if anything) is it doing that I am not including? I do have the Internet Kill Switch enabled as well in case that matters.

OpenWrt version: 19.07.8, r11364-ef56c85848
GLI GUI version: 3.216


Please refer to:

It looks like in your example (thank you) you are doing the same thing, except for using ‘wireguard downup’ instead of reload (or start if not running) that I was. So that answers my question about if I should be doing anything else. Thank you.

1 Like