Restart wireguard VPN client on Asus router

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:

  1. Connect to your router via SSH
  2. Navigate to the /jffs/scripts directory:
    cd /jffs/scripts
  3. Create a new script called services-start using the vi text editor (you can also use nano if it’s available on your router):
    vi services-start
  4. 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) &
  5. Save the changes and exit vi by pressing the “Esc” key, then typing :wq and pressing “Enter”.
  6. Make the services-start script executable:
    chmod +x services-start
  7. Create your script in the /jffs/scripts directory:
    vi restart_wireguard_client.sh
  8. Press “i” to enter insert mode in vi, and add your script content.
  9. Put this into the script:
    !/bin/sh
    service restart_wgc
  10. Save the changes and exit vi as described in step 5.
  11. Make your script executable:
    chmod +x restart_wireguard_client.sh
  12. 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.

Leave a comment

Your email address will not be published. Required fields are marked *