What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Wireguard Wireguard_Server_Stops_Working

!!..PD..!!

New Around Here
Hello, my wireguard server sometimes stop working after auto reboot schedule. The switch for wireguard server stays ON but the clients aren't able to connect. The fix I found is to manually turn off the wireguard server and then start it again after which my devices are able to connect to the router.
I'm a noob in the art of scripting and linux but thanks to the wonderful guide I was able to install amtm, entware and scMerlin (since it has a restart switch for services) but I found that the VPN servers tab only include OpenVPN profiles (server 1 and 2) with restart option and lack the Wireguard servers.
Is there something which I can do on my router to make it restart on its own and/or add a switch for wireguard server in the scMerlin addon?
 

Attachments

  • Screenshot_2025_1006_173009.png
    Screenshot_2025_1006_173009.png
    312.3 KB · Views: 24
Last edited by a moderator:
s there something which I can do on my router to make it restart on its own
Guess you could make a cron job to restart Wireguard server say 30min after your reboot timer.


add a switch for wireguard server in the scMerlin addon?
Why would a switch in scMerlin be better than the button already in the gui?

Anyhow, as you are getting used to ssh, the command
Code:
service "restart_wgs 1"
Should do the trick.

There are phone apps that you can setup to run ssh commands, like Apple "Shortcuts" or Andriod "SSH button"
 
That cron job looks promising @ZebMcKayhan. Can you tell me if it'll be possible make it run 5 minutes after BOOT instead of only reboot?

I am pretty fond of the restart wan button as my ISP provides Dynamic IP and different series have different upstreams which helps me choose the one which I need.
That is certainly why I thought of a single button instead of doing 2 clicks on wireguard server page.

Thanks for the ssh command. I've only dived in for amtm so far and it'll certainly help me understand more about router as well as linux.

Forgive me but I'm new to forums and I don't know how to highlight the questions or answers in my replies.

I appreciate your patience with me and grateful for your help.
 
Last edited by a moderator:
That cron job looks promising @ZebMcKayhan. Can you tell me if it'll be possible make it run 5 minutes after BOOT instead of only reboot?

I am pretty fond of the restart wan button as my ISP provides Dynamic IP and different series have different upstreams which helps me choose the one which I need.
That is certainly why I thought of a single button instead of doing 2 clicks on wireguard server page.

Thanks for the ssh command. I've only dived in for amtm so far and it'll certainly help me understand more about router as well as linux.

Forgive me but I'm new to forums and I don't know how to highlight the questions or answers in my replies.

I appreciate your patience with me and grateful for your help.
@!!..PD..!! Please stop using color in your posts. It makes the post very hard to read.
 
That cron job looks promising @ZebMcKayhan. Can you tell me if it'll be possible make it run 5 minutes after BOOT instead of only reboot?
cron itself are based on system time so to use cron for such thing would mean snatch system time, divide hours, minutes, seconds. Add 5 to minutes and watch for overflow and create the job.

But it would be quite simple to make something like if your reboot always happens at say Sunday morning at 2am we could set a restart wgs1 on Sunday morning 2:30am, like:
Code:
cru a RestartWgs "30 2 * * Sun service 'restart_wgs 1'"
but since this itself won't servive a reboot since you have scmerlin installed you likely have the hook file
Code:
/jffs/scripts/post-mount
You could add it last in that file.


if you always want this to happen once like 5 min after each boot you can use something like:
Code:
sleep 300
service 'restart_wgs 1'
but you will need to put this in a hook script that always executes once during boot and are not a blocking script:
https://github.com/RMerl/asuswrt-merlin.ng/wiki/User-scripts
post-mount looks like such candidate.
 
Last edited:
post-mount looks like such candidate.
If you decide to use the sleep 300 variant it could be a good idea to make the command itself non blocking. If for example you use post-mount where Entware gets initiated if things ever gets in the wrong order Entware would need to wait the 300sek for initiation which may break things. Running both the sleep and the restart in background would solve that:
Code:
sleep 300 && service 'restart_wgs 1' &
 
But it would be quite simple to make something like if your reboot always happens at say Sunday morning at 2am we could set a restart wgs1 on Sunday morning 2:30am, like:
Code:
cru a RestartWgs "30 2 * * Sun service 'restart_wgs 1'"
but since this itself won't servive a reboot since you have scmerlin installed you likely have the hook file
Code:
/jffs/scripts/post-mount
You could add it last in that file.
Thanks for pointing me out in the right direction. As a beginner it will be better for me to go with a fixed time.

As I understand, I'll be using it like this,
Code:
cru a RestartWgs "05 00 * * Sun service 'restart_wgs 1'"
But this will restart wgs on Sunday at 12:05 am. Can you tell me what I should modify in this code to make it everyday instead of Sunday?
Thanks to you who have me the exact code and Vivek Gite who simplified the cron jobs on cyberciti biz website I found that it goes like this:
Code:
 cru a {id} min hour day month week command
But since I need it every day at same time should I change Day to some number or add days in it?

Once I get it right, I'll add it to the end of post-mount and able to fix my wireguard issue.
 
But this will restart wgs on Sunday at 12:05 am. Can you tell me what I should modify in this code to make it everyday instead of Sunday?
Sure:
Code:
cru a RestartWgs "05 00 * * * service 'restart_wgs 1'"
Would execute every day at 5min passed midnight.
 
Last edited:
...
I'm a noob in the art of scripting and linux but thanks to the wonderful guide I was able to install amtm, entware and scMerlin (since it has a restart switch for services) but I found that the VPN servers tab only include OpenVPN profiles (server 1 and 2) with restart option and lack the Wireguard servers.
To make things crystal clear, I have changed the titles and messages in scMerlin WebUI and shell script to explicitly indicate that the current "VPN" functionality applies only to OpenVPN servers and clients, *not* WireGuard.

scMerlin_WebUI_OpenVPN_Server&Clients.jpg


scMerlin_CLI_Menu_OpenVPN_Server&Clients.jpg

The above changes are currently found only in my local repository. I'll submit a PR to the ATMTM OSR repo when I have fully verified the changes.

Is there something which I can do on my router to make it restart on its own and/or add a switch for wireguard server in the scMerlin addon?
I'm thinking about adding WireGuard support, especially in the shell script menu, since typically, over an SSH session is when most users have difficulty remembering the correct command to restart a specific service, so that's where it would be most useful, IMO.
 
To make things crystal clear, I have changed the titles and messages in scMerlin WebUI and shell script to explicitly indicate that the current "VPN" functionality applies only to OpenVPN servers and clients, *not* WireGuard.
True, currently it mentions VPN server which is confusing for the users who are using protocol other than openvpn.
I'm thinking about adding WireGuard support, especially in the shell script menu, since typically, over an SSH session is when most users have difficulty remembering the correct command to restart a specific service, so that's where it would be most useful, IMO.
Idk about others but it will definitely help people who are new to Asuswrt Merlin and don't know much about ssh, linux or scripts.

I was actually facing bufferbloat issues on my 100 mbps symmetric FTTH connection with ISP ONT+Router combo device. I then bought Mercusys MR60X and made PPPOE on it by putting my ONT in bridge mode which also failed me. I googled and found out about openwrt supported router which is too complicated as I have never done it.

At last a friend of mine referred me to Asuswrt Merlin which is super easy to install and has CAKE. It was like an Oasis in the desert so I got the cheapest model to try. I set it up and tried cake which isn't working for some reason but the adaptive QoS did work like a charm and finally I got rid of the bufferbloat issue.

Since I have installed the Asuswrt Merlin, I plan on learning linux and ssh hoping I'll be able to understand the scripts one day.

I appreciate you, SNB forum and this community who make it easier for beginners like me (hoping they exist 🤣).
 
...
Idk about others but it will definitely help people who are new to Asuswrt Merlin and don't know much about ssh, linux or scripts.
I have added the front-end WebUI tabs and the shell script menu options to support restarting the WireGuard server and clients. Sample screenshots:

scMerlin_WebUI_WireGuard_Server&Clients.jpg


scMerlin_CLI_WireGuard_Server&Clients.jpg

All that remains is to add the back-end functions that send the actual command(s) to restart, and then run tests and validation. I should be able to finish this sometime during the coming weekend.

FYI.
 
There are phone apps that you can setup to run ssh commands, like Apple "Shortcuts" or Andriod "SSH button"
I came back to verify the ssh wgs restart command and noticed that I missed the last line.
I have installed this button app, set it up and one click restarted the VPN server. Its wonderful.
I've been using Termux so far but this app just blew me away.

I have added the front-end WebUI tabs and the shell script menu options to support restarting the WireGuard server and clients.
Those are looking good. I wish I had focused more on Javascript in the HTML classes during my school days.

All that remains is to add the back-end functions that send the actual command(s) to restart, and then run tests and validation. I should be able to finish this sometime during the coming weekend.

FYI.
Looking forward to its complete form. 🥰
 

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Staff online

Back
Top