Watchdog for Dietpi (Auto reboot if Internet is down)

I’m struggling with Wireguard on my raspberry pi4 on Dietpi.

In combination with my Asus Router, i observed after manually restarting the Router, the Raspberry can’t catch up the internet connection.

Everything is connected via Cable, no WiFi involved.

Now I found that script and maybe someone with more expertise can tell, if this script works on Dietpi or not.

Question 1:
Also how should I adjust the script if I want to use the Ethernet connection and not WiFi as Interface.

Question 2:
How should I adjust the script to ping no internal ip but a external website like (www.heise.de)

Thank you guy’s for your help and stay healthy.

Script Source:
https://defgw.wordpress.com/2017/10/24/watchdog-reboot-raspberry-pi-if-network-is-down/

Did you ever tested if your SBC is able to reach the router once internet connection did not work anymore? Because if this is not working, it would be better to ping the router instead of public web site like Heise.

Not really, it’s a fully headless setup without keyboard/monitor or other stuff.

means you are not able to reach the entire system after rooter reboot?

That’s correct. To get everything running again I do the following.

Restart Asus Router → Restart Pi4 (pulling the power plug or restart via poe).

I think it’s not really a problem of Dietpi and the Raspberry. It’s a problem of Asus and DHCP.

That’s why my only solution is to try a easy method to push a reboot if Ethernet is down.

ok in this case it should be totally fine to ping your router IP. This should do it already. The interface for Ethernet is eth0 on a default setup.

Thanks, I’ll try it this weekend and report back if the solution works.

:smiley:

somewhere inside this forum there was a user who build up a solution exactly like you are looking for.

Please mark this Problem as Solved if possible. I setup everything and for me, this solution with a Ping to my local router IP is working.

ok perfect, thx for sharing.