Automatic reboot of OPNSense if loss of Internet

Started by saintjimmy, September 20, 2023, 12:15:22 PM

Previous topic - Next topic
Hello everyone
I have an issue with my router sometimes after a few days I lose Internet connectivity and everything is fine after a reboot.
I'm in the process of trying to find what causes this but in the meantime I'd like to find a temporary fix.
Is it possible to reboot the opnsense box (or restart the WAN interface) if Internet access is dow ?
Has someone ever done that ?
Thakns for your help !

I've seen some smart plugs that can be set up to interrupt power on connection loss in order to reset something like a modem but I wouldn't recommend it for OPNSense.  I'm not sure if there's anything internal to OPNSense to accomplish what you're wanting.

In terms of troubleshooting your root issue, make sure you test all of the pieces of connectivity.  There are a lot of moving parts and the problem could be at any of them with the same result of "internet is down".

Next time it happens, see if you can still connect to the OPNSense UI.  If not, you can use the local console but it's a bit more complicated.  Verify that OPNSense is still getting an IP, is able to ping the gateway, DNS is working, etc.  That way you can determine if the issue is with your actual connection or with what OPNSense is providing to your network.

Setting up gateway monitoring will also help you keep an eye on your connection.

The reason I bring all of this up is that I've had times where my upstream DNS servers became unreachable, causing the "internet is down."  Temporarily switching to a different set of servers had me back up and running, but until then, nothing was working. :)

I've once done this with Monit by creating a ping test which executes /sbin/reboot if the ping fails. Worked okay.

Cheers
Maurice
OPNsense virtual machine images
OPNsense aarch64 firmware repository

Commercial support & engineering available. PM for details (en / de).

Be careful with such solutions.
If your test host is down for any reason, you should be quick to edit your firewall configuration before it reboots itself.
You also cannot take your firewall offline for safe updates or any fixes.

You're correct, this is definitely not suitable as a long term solution. I only used it as a temporary workaround until I was able to fix the root cause of the connectivity dropouts.

Cheers
Maurice
OPNsense virtual machine images
OPNsense aarch64 firmware repository

Commercial support & engineering available. PM for details (en / de).

Quote from: karlson2k on September 21, 2023, 09:54:03 AM
Be careful with such solutions.
If your test host is down for any reason, you should be quick to edit your firewall configuration before it reboots itself.
You also cannot take your firewall offline for safe updates or any fixes.

The law of unintended consequences has never affected anyone in the technology sector. :D  Like FB being locked out of their own datacenter during an outage because the DC ran the door locks.