I just wanted to see what other selfhosters backup emergency plan is if the primary internet router goes offline but the internet isn’t out (ie a router reboot would fix the problem), leaving you without access to your stuff even via vpn.
the options I’ve considered so far:
- cellular smart plug to reboot router
I tried a ubibot smart plug (SP1) that is supposed to work with cellular, but the device or sim is bad. I’m currently troubleshooting. The problem with this one is it requires a proprietary cloud service, it’s supposedly self hostable, but it’s a pia to setup and their app port can’t be changed easily allowing for a reverse proxy setup on VPS.
- the other option I am considering is cellular wifi router and a wifi smart plug connected to that device to reboot router
what other options have I overlooked? Also, specific models of devices would be helpful info from others doing this already.
TIA!
Edit: also just thought of possibly a cellular internet backup on my opnsense box, but from everything I’ve read that’s also very involved to setup
Edit2: I’ve setup a homeassistant automation to reboot a zigbee smart plug if 2 external hosts are down for 15 mins, will try this out for a bit. I still need tp troubleshoot why the device goes down in General. Thanks for all the responses and ideas!
Adjust interval as needed.
Or if you want something a bit faster:
#!/bin/sh NAME="$0" logger_cmd () { echo $@ logger -p daemon.info -t "$NAME[$$]" $@ } if ! which ncat 1>/dev/null then logger_cmd "ncat not found, installing..." opkg update && opkg install ncat fi chk_conn () { echo "Checking connectivity to $@" if ncat --send-only --recv-only -w 334ms $@ 2>/dev/null; then return 0 fi logger_cmd "Cannot reach $@" return 1 } restart_network_iface() { # TODO: Don't restart every minute COOLDOWN_LOCK=/tmp/internet-connectivity-watchcat.tmp COOLDOWN_SECONDS=300 cooldown_time_end=$(cat $COOLDOWN_LOCK || echo 0) time_now="$(cat /proc/uptime)" time_now="${time_now%%.*}" cooldown_time_left=$((cooldown_time_end - time_now)) if [ "$cooldown_time_left" -lt "1" ] then logger_cmd "Restarting network interface: \"$1\"." ifdown "$1" ifup "$1" cooldown_time_end=$((time_now + COOLDOWN_SECONDS)) echo $cooldown_time_end > $COOLDOWN_LOCK else logger_cmd "Skipping interface \"$1\" restart due to cooldown. Cooldown left: $cooldown_time_left seconds" fi } logger_cmd "Checking internet connectivity..." if chk_conn google.com 443 \ || chk_conn amazon.com 443 \ || chk_conn facebook.com 443 \ || chk_conn cloudflare.com 443 \ || chk_conn telekom.de 443 then logger_cmd "Connected to internet." else logger_cmd "Not connected to internet." restart_network_iface "$1" fi
In
restart_network_iface
use/usr/sbin/reboot
instead of interface up/down and run the script every few minutes via cron or systemd timer. This was written for OpenWrt so if you use that you can use it as-is. For other systems you’d also have to adjust thelogger_cmd
.You can place that on another machine and send a signal to a smart plug instead if you’re worried of a locked up / frozen router. That said if your router freezes like that, you should probably change it and you should be able to run this script on it.
Even if it isn’t an OpenWRT router if you have a hardwired server it can probably do a soft reset of the router or even modem (most modems I’ve used have had a web interface). If your router is in such a bad state it only responds to a hard reset it’s probably reaching EoL.
I will give this a shot. it hasn’t happened in a couple weeks, So I can’t remember if the device freezes completely or an interface reboot would do the trick.