this post was submitted on 10 Sep 2025
57 points (100.0% liked)

Selfhosted

60758 readers
143 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

Detailed Rules Post

  1. Be civil.

  2. No spam.

  3. Posts are to be related to self-hosting.

  4. Don't duplicate the full text of your blog or readme if you're providing a link.

  5. Submission headline should match the article title.

  6. No trolling.

  7. Promotion posts require active participation, with an account that is at least 30 days old. F/LOSS without a paywall has exceptions, with requirements. See the rules link for details. Tags [CBH] or [AIP] are required, see the links in Rule 8 for details.

  8. AI-related discussions and AI-involved promotional posts have additional requirements for tagging, as noted in Rule 7 and the AI & Promotional Post Expanded Rules post, and find example disclosures here.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 3 years ago
MODERATORS
57
submitted 10 months ago* (last edited 10 months ago) by smashing3606@feddit.online to c/selfhosted@lemmy.world
 

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:

  1. 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.

  1. 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!

you are viewing a single comment's thread
view the rest of the comments
[–] avidamoeba@lemmy.ca 4 points 10 months ago* (last edited 10 months ago) (2 children)
0 4   *   *   *    /usr/sbin/reboot

Adjust interval as needed.

Or if you want something a bit faster and less disruptive:

#!/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 the logger_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.

[–] smashing3606@feddit.online 2 points 10 months ago

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.

[–] BrianTheeBiscuiteer@lemmy.world 2 points 10 months ago

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.