What's new

how to make asus router automatically reboot, if Internet goes offline

  • 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!

Donaufisch

New Around Here
Hello,
I have an 4G-AC55U ASUS Router. My Provider cuts the LTE Connection once a day. After that cut, the router indicates still "online" but is offline and doesnt goes online again.
Therefore I need to reconnect the connection manually or just restart the router.

I found a Skript to restart the router once a day or every some hours.
"/usr/sbin/cru a ScheduledReboot "0 4 * * * reboot"....

That doesnt work for my problem. In worst case, the router restarts and some minutes after, my provider cuts the connection. The router would then be offline for nearly 24hours.

I need a script to check weather there is a Internet Connection or not. If not, then restart.
That Skript should check every 10 mintes or any other short Intervall. Is that possible?

There is no Merlin Firmware for that router. How can I activate/open SSH Support? I can logon with TELNET

Can anyone help me ?

greetings Roland
 
Last edited:
thank you! thats it!
My 4g-Ac55u has TELNET available. I can logon and can write sh Skripts. Yet I dont know where to save scripts in that router to keep them permanently
 
Hello,
There is no 3rd Party Firmware for the 4G-ac55U router. Maybe because of the inbuild LTE Modem.
I can connect with putty /Telnet and I can save scripts in different places.
I think one of these commands would work. "Service restrat_wan" couses the connection to stop but doesnt reconnect. I have to open the WebUI /WAN and klick on "Apply". That click makes the router to connect again. Do you know how to reconnect by skript?
Or I just restart the router by "reboot". reboot works but takes more time, I would perfer to restart the connection and reconnect.

Code:
if ! ping -w 10 -c 10 www.google.com > /dev/null; then
    service restart_wan
   
    if ! ping -w 10 -c 10 www.google.com > /dev/null; then
        reboot
    fi

I think cronjobs should work on my firmware. Right now I try to get used to "cron" but dont know how to start a Skript "jffs/scripts/check.sh" with cron.
The cron code to run that script every 5 minutes should be "

Code:
*/5 * * * * /jffs/scripts/check.sh

Where and how do I have to enter and save that code to activate a cronjob?

Maybe you can help!
greetings
roland
 
my cron directory should be "/var/spool/cron/crontabs/roland"
I can open the file "roland" with "vi".
do I have to enter the Code "*/5 * * * * /jffs/scripts/check.sh" in that file?

I am affraid my router will not boot anymore if I do anything wrong. Is there any possibility to create a log file from the script, so I can see when the router reconnects or reboots?
 
Sorry @Donaufisch, I should have been more precise. AFAIK you can only automatically run scripts using 3rd party firmware. I believe commands like "cru" are unique the Merlin's firmware. I'm happy to be proved wrong though.

That cron command looks correct, but as the directory exists in a temporary filesystem it will be lost after a reboot.
 
Hello,

yes, but it should be possible to mount a script Directory at Startup while any usb stick is installed!!
Code:
nvram set script_usbmount="/jffs/scriptname"
 nvram commit

So I just need an old small USB Stick installed to mount the jffs directory at any reboot while the usb stick is mounted and with "cp /jffs/<admin user name> /var/spool/cron/crontabs" I can us one of these scripts. (renew_wan or reboot ) controlled by cron.


Code:
#!/bin/sh
sleep 500    # delay till LTE connection is online
if ! ping -w 10 -c 10 www.google.com > /dev/null; then
    date >> /jffs/reboot-log                #log reboot time
    reboot
fi


Code:
#!/bin/sh
sleep 500    # delay till LTE connection is online
if ! ping -w 10 -c 10 www.google.com > /dev/null; then
    date >> /jffs/reboot-log                #log restart/reboot
    sleep 3
    service restart_wan
   # missing code to renew usb LTE connection or reboot
fi



Now I need any comand to renew the IP or reconnect the "usb Modem". I think the intern 4G modem is handled like an extern usb modem.
Or in case I use the reboot option, can I use "sleep 500"? I want to wait about 5 Minutes until the router has fully booted and established the LTE Connection.
Otherwise the router would hang up in a reboot Loop.

please take a look at this and help!

Information regarding cron and asus I have found at:
https://www.securityforrealpeople.com/2015/08/cron-on-asus.html

Roland
 

Similar threads

Sign Up For SNBForums Daily Digest

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