Restart wireguard VPN client
This is a guide how you restart a wireguard VPN client on an ASUS router running Asuswrt-Merlin automatically, 10 seconds after boot of the router
Create and configure the services-start
script to run your custom script with a 10-second delay:
- Connect to your router via SSH
- Navigate to the
/jffs/scripts
directory:cd /jffs/scripts
- Create a new script called
services-start
using thevi
text editor (you can also usenano
if it’s available on your router):vi services-start
- Press “i” to enter insert mode in
vi
, and add the following lines to the script:#!/bin/sh
(sleep 10 && /jffs/scripts/restart_wireguard_client.sh) &
- Save the changes and exit
vi
by pressing the “Esc” key, then typing:wq
and pressing “Enter”. - Make the
services-start
script executable:chmod +x services-start
- Create your script in the
/jffs/scripts
directory:vi restart_wireguard_client.sh
- Press “i” to enter insert mode in
vi
, and add your script content. - Put this into the script:
!/bin/sh
service restart_wgc - Save the changes and exit
vi
as described in step 5. - Make your script executable:
chmod +x
restart_wireguard_client.sh
- Close the SSH connection by typing
exit
and pressing “Enter”.
Now, when your router boots up and all services have started, the services-start
script will be executed, which in turn will run your restart_wireguard_client.sh script after a 10-second delay.