I hope you can help me. I would like to switch my Wireguard connections off and on again via the digital input.
Is the digital input 0 = Wireguard Connections switched off
Is the digital input 1 = wireguard connection switched on
How exactly do I have to do this? Can you help me with this?
To toggle WireGuard connections on and off based on a digital input, you can leverage the I/O Juggler feature on your router and configure it to execute scripts depending on the state of the digital input. Here’s an example guide:
Step 1: Prepare the Scripts
Access the Router’s CLI
Log in to the router’s Command-Line Interface (CLI) using SSH or directly through a terminal.
Navigate to the /etc Directory
Run:
cd /etc
Create the Scripts
WireGuard ON Script (wgon.sh):
Create a new file using vi:
vi wgon.sh
Press i to enter insert mode and add the following:
#!/bin/ash
uci set network.<wireguard_interface>.disabled='0'
uci commit network
/etc/init.d/network restart
After making changes, hit Esc and write :wq and press Enter.
Replace <wireguard_interface> with the name of your WireGuard interface. You can find this using the ifconfig command or in WebUI (Services → VPN → Wireguard)
WireGuard OFF Script (wgoff.sh):
Similarly, create another file:
vi wgoff.sh
Press i and add:
#!/bin/ash
uci set network.<wireguard_interface>.disabled='1'
uci commit network
/etc/init.d/network restart
Make the Scripts Executable
Run the following commands to make the scripts executable:
chmod 777 wgon.sh
chmod 777 wgoff.sh
Step 2: Configure I/O Juggler
Access the WebUI
Log in to the router’s web interface.
Navigate to I/O Juggler
Go to Services → Input/Output → I/O Juggler.