Hi all,
consider this as documentation of a project and maybe as a starting point for beginners and further development:
I wanted to replace the Gl inet software on my MT1300 with vanilla openwrt without losing the functionality of the small switch on the side to turn on and off my Wireguard tunnel. The MT1300 is intended to be used as travel router with mobile devices like smartphones and tablets. Here’s what I’ve done:
-
First install the package
slide-switchvia Luci or CLI -
Change the gateway metric of the Interfaces wan, wwan and trm_wwan (if you have travelmate installed. This can be done under Network –> Interfaces –> INTERFACE NAME –> Edit –> Advanced Settings –> Use gateway metric. For wwan I set this value to 1, wwan 2 and trm_wwan 3. This is helpful, wenn the Wireguard tunnel is turned off.
-
Set up your wireguard tunnel and test it. I installed the following packages:
wireguard-tools kmod-wireguard luci-proto-wireguard
After installing the packages reboot your router. Then go to Network –> Interfaces –> Add new interface and choose Wireguard. Then enter your wireguard settings and test it. -
Toggle the switch on your router to the mode clear
-
Change to CLI and execute following commands:
touch /etc/rc.button/mode-clear && chmod +x /etc/rc.button/mode-clear
touch /etc/rc.button/mode-dot && chmod +x /etc/rc.button/mode-dotThe name of the files can be determined by studying the * documentation of slide-switch.
-
Open the
mode-dotscript and paste the following content:
nano mode-dot#!/bin/sh
WGIF="WG"
if [ "$ACTION" = "pressed" ] && [ "$BUTTON" = "mode-dot" ]; then
logger -t wg-switch "WireGuard ON (mode-dot pressed → UCI enable + ifup)"
uci -q del network.${WGIF}.disabled 2>/dev/null # Delete Disabled-Flag
uci commit network
/sbin/ifup ${WGIF}
logger -t wg-switch "WG started"
fiPlease change the name of your Wireguard Interface accordingly.
-
Open the
mode-clearscript and paste the following content:
nano mode-clear#!/bin/sh
WGIF="WG"
if [ "$ACTION" = "pressed" ] && [ "$BUTTON" = "mode-clear" ]; then
logger -t wg-switch "WireGuard OFF (mode-clear → ifdown WG + wwan/wan reload)"
/sbin/ifdown ${WGIF}
/sbin/ifup wwan # restart WWAN (Metric 1 → prioritised)
/sbin/ifup wan # restart WAN neu starten (Metric 2 → Backup)
/sbin/ifup trm_wwan # restart Travelmate WAN
logger -t wg-switch "wwan/wan reloaded - Internet via WWAN active again”
fiPlease change the name of your Wireguard Interface accordingly. Please also add the names of your WAN interfaces accordingly and delete or comment out lines you don’t need.
-
Now toggle the switch to the dot position and check, if your wireguard connection works as expected.
-
Change the switch to the clear position and check, if your internet connection persists. The restart of only the WAN interfaces should prevent your mobile devices to disconnect from your router.
That’s all you have to do to make it work. As already mentioned consider this as starting point for beginners and people who want to further develop the scripts.
Have fun.
Maginos