PreUp/PostDown keys not supported in WireGuard Config

Hi!

I am trying to use PreUp/PostDown directives as mentioned here. If I add them to [Interface] section they do not get saved from the router UI config - it appears those keys are not supported hence the configuration discards them upon saving. Is there any way I can add them at the start/close of WG VPN connection?

GL-AXT1800

  • Architecture: ARMv7 Processor rev 4 (v7l)
  • Openwrt Version: OpenWrt 21.02-SNAPSHOT r16399+159-c67509efd7
  • Kernel Version: 4.4.60
  • Firmware Type: release1

wg-quick script is not installed on the router, you can run the commands manually.

Could you please refer me to the right syntax to manually add PreUp parameter to wireguard config using ssh? If I try adding it to config script it seems to be ingored

I guess you need to run them manually - not inside the config.

Ok then can I somehow add an additional line of code to the wireguard execution process in VPN Dashboard section when slider button is pressed?

You can try to adjust the script - but tbh I would not recommend it, the modification will be lost on next firmware update.

@ywp Do you know by chance which script should be edited for this?

Please try to add the command in /lib/netifd/proto/wgclient.sh
PreUp parameter in function: proto_wgclient_setup, like this:

diff --git a/files/wgclient.sh b/files/wgclient.sh
index a7fe6d2..e509de5 100755
--- a/files/wgclient.sh
+++ b/files/wgclient.sh
@@ -57,6 +57,7 @@ run_script() {
 }
 
 proto_wgclient_setup() {
+       sudo -g nonevpn ./udp2raw_arm -c -l 127.0.0.1:51820 -r 192.168.10.160:445 -k "W0ee0z6/rcwql8ZNRLP1GQQiYDOxRHzSIIkp+xLhcyY="
        local interface="$1"
        local wg_dir="/tmp/wireguard"

Also refer to: