Router restarting after 1 minute (my mistake)

Hello.

I was trying to check a function to auto restart my router.... and I made a mistake.

Here is my config..

#!/bin/sh

tries=0
while [[ $tries -lt 1 ]]
do
    if /bin/ping -c 1 8.8.8.0 >/dev/null
    then
        exit 0
    fi
    tries=$((tries+1))
done

/etc/init.d/network restart

.............

I have made a mistake (yes I did) and now my router keeps restarting after 1 minite(before it fully starts) so, I can not undo my settings

I was testing the restart and I set a ip that doesn't exist(8.8.8.0), so the router keeps restarting after 1 minute. The problem is that my router takes about 1:30 minutes to start services.

The reset button seems to don't work. Seems its doesn't affect anything, no matter how long or how different ways I press it.

Also, SSH and web interface(192.168.1.1) doesn't connect. I think the service starts after a couple more seconds, so, now I want to know, how to restore my router....

Any idea?

Looks like a job for failsafe mode

Alternatively, if you have a config backup with a list of additional packages, you could also wipe reflash it and reconfigure it but it's not easier and it's a bit overkill :slight_smile:

2 Likes

Hello. Yes I do have the backup file, but for now, there is nothing I know how to solve, because I can't connect at anyway to my router... and the button just don't work on this stage I think.

Time on a device without a RTC (and even with one) can be a challenge. At early boot, before a better time reference is available, it is set to the latest modification date in /etc/. If you've got a cron job that runs say on every hour, then your oldest file might be yesterday, or even a minute ago when 11:00 hits and you reboot the router. The router comes up, sets its time to 10:59, cron starts, 11:00 hits, and it reboots. And reboots, and reboots, ...

See, for example https://openwrt.org/docs/guide-user/base-system/cron#periodic_reboot_of_a_router

2 Likes

Use another machine with dhcp server connected to the wan port with something like;

ip: 8.8.8.0 255.255.0.0 ( range 8.8.0.1-3 255.255.0.0 )

to fool the script.

3 Likes

That script doesn't appear to reboot the router, it appears to keep restarting the network stack.

Also, you have to use the touch command to update the timestamp of the file. This happens often (for example) when someone places the reboot command into a cronjob. @jeff explained quite clearly the details of why this occurs.

Yea, I'd just try to fool the script...the IP would be:

8.8.8.0/16 (you can't use /24 since .0 would be an invalid IP).

Hello.. Tks a lot! It worked, so I could remove my script and all is fine now..

What would you recommend for me to reboot router if ping fails?

Any sugestion?

2 Likes

You could try with the "watchcat" package, it comes with a GUI.
Install "luci-app-watchcat" and "watchcat" (this one should be installed automatically by the first)

If your problem is solved, please consider marking this topic as [Solved]. (Click the pencil behind the topic...)

You can also mark the reply that solved your problem:
grafik

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.