3

I live in an isolated house, where the only Internet access is thru a telephone operator. So I have an antenna (Zyxel 4G LTE-A Outdoor Router,PoE LTE7460), and thanks to the (5G!) service and an unlimited data-plan subscrition, I enjoy quite a good service. However,...

The antenna sometimes unexplicably freezes, and the only way to restart it is by cutting the (PoE) power. It is unaccessible from inside the LAN, outside the lan, and no error messages are ever logged. This also means that no ssh/Web session is possible. Apparently, it is a well-known problem.

When I am at home, no big deal, but occasionally I am away from home, and I cannot access my data until someone (me) returns. As a work-around, I thought that I might plug the PoE injector into a smart, mqtt-compatible plug, and programmatically control this from my (debian) server the usual way, i.e. when the canary (ping -c1 8.8.8.8) does not reply, cut off the power, wait for 5 minutes, restart, rinse, repeat.

Is there a better way? Maybe a managed, PoE switch? Is there anyone who has faced a problem like this?

MariusMatutiae
  • 48,517
  • 12
  • 86
  • 136

2 Answers2

4

A point that wasn't clear in Cpt.Whales comment was that if you do regular scheduled restarts it may not be necessary to do one off restarts/monitoring at all - meaning that if the router is crashing because it is running out of some resource, by rebooting it regularly (say at 3:00 AM) it may not do so any more.

Cpt.Whales main point is also valid - that if it works, doing regular/scheduled soft restarts rather than pulling the power, may be better long term for the hardware (it may last longer).

If you are going to monitor the router, you said "It is unaccessible from inside the LAN" so you may choose to monitor the router itself, rather than an external site - that way if service goes down for any reason you won't be rebooting the router constantly until service returns.

DavidT
  • 1,242
1

You mentioned "Maybe a managed, PoE switch?" and yes, that's certainly one possible way to accomplish what you'e after. I do something vaguely similar with security cameras: When I leave the house, the security cameras turn on automatically via a bash script that connects to the PoE switches and toggles power state.

The process to accomplish this will vary by hardware type obviously, but for my Ubiquity switches (USW-Lite-16-PoE, USW-Lite-8-PoE and USW-Flex-XG) the following works:

In the UniFi Network Web Console (which you can install yourself), upload an SSH key for the automation under "System > Advanced > Device Authentication". You can upload multiple SSH keys, so I recommend generating a key to use just for this purpose. You can upload your personal key as well if you want to SSH in to the hardware and look around.

UniFi Network Console SSH Settings Screenshot

Once connected to an Unity switch via SSH, you can control the power state of a PoE port using the /usr/bin/swctrl poe set command:

powerState=off # "off" to turn off, "auto" to turn on
portNumber=1   # Number of the port, 1-based index

/usr/bin/swctrl poe set $powerState id $portNumber

To automate all of this, I have a bash script which lives on a linux server, which has the specific private key configured and I allow automation to call this script via an SSH ForceCommand:

#!/bin/bash

if [[ $# != 3 ]]; then echo "usage: $0 <switch> <port> <power setting>" exit 1 fi

switchName="switch$1" port=$2 power=$3

ssh -o "IdentitiesOnly=yes" -i /root/.ssh/id_switch-poe-ctl admin@${switchName}.mynetwork "/usr/bin/swctrl poe set $power id $port"

You could adapt the above and then call that script from a watchdog which uses a ping or curl check and then powers off the port, sleeps a period and turns it back on.

Josh
  • 9,947