Scripts to change wireguard connection not working

Hello,
I have a GL.Inet GL-MT300N-V2 Mango.

I want to use the slide switch to toggle between routing all traffic through wireguard, and disabling wireguard completely.

The wireguard connection works, the slide switch status is registered correctly and the scripts are called properly. Switching from wireguard_off to wireguard_on works as intended, but the script to turn wireguard off does not work. If wireguard is disabled, I can not connect to the web from connected devices, but the router itself is connected to the internet (I can ping websites from the router).

To create the scripts, I copied the exact commands from LuCi, and changing the status works in LuCI, but not using the scripts.

Here are the scripts:

*cat /usr/bin/wireguard_on*
ubus call network.interface.fritzwg up
uci del firewall.cfg0fad58
uci add firewall forwarding # =cfg10ad58
uci set firewall.@forwarding[-1].src='lan'
uci set firewall.@forwarding[-1].dest='wg'
uci del firewall.cfg0e92bd.enabled
uci commit
*cat /usr/bin/wireguard_off*
uci del firewall.cfg0fad58
uci add firewall forwarding # =cfg10ad58
uci set firewall.@forwarding[-1].src='lan'
uci set firewall.@forwarding[-1].dest='wan'
uci set firewall.cfg0e92bd.enabled='0'
ubus call network.interface.fritzwg down
uci commit

cfg0e92db is the "Allow_Wireguard_OUT" rule.

Why does the script not work, but changing the same settings in LuCI does the trick?

Best regards,

Spatz

Are those complete scripts, or did you leave something out ?

1 Like

Those are the full scripts.

tried adding

/etc/init.d/firewall reload
/etc/init.d/network restart

?

1 Like

won't an exit 0 at the end also be needed?

But yhea frollic's answer should do the trick.

it'll terminated w/o the exit 0 too :wink:

1 Like

Sorry for the late reply, I had to solve some other issues first, but now I was able to test your suggestions.

Turns out /etc/init.d/firewall reload did the trick.

/etc/init.d/network restart was not necessary and kicked me out the WiFi.

Thank you!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.