OPNsense Forum

Archive => 20.1 Legacy Series => Topic started by: skywalker007 on March 13, 2020, 02:59:14 pm

Title: How to use monit to reboot firewall when VPN gateway is not reachable for X min
Post by: skywalker007 on March 13, 2020, 02:59:14 pm
I am looking for some advise for how to use monit to achieve the following:
I have a remote OPNsense which uses an OPNvpn site to site tunnel to my main site.
Now when the remote OPNsense can't reach the destination gateway, i want to wait for X min and then reboot.
Now after reboot, if it doesn't reconnect  - obviously the problem is somewhere else and I want to add an additional delay before rebooting again and so on. Once connection is established it shoud revert back to the default delay of course.
Do I need to write some shell script for that exercise or can monit do it out of the box?

thanks!
Title: Re: How to use monit to reboot firewall when VPN gateway is not reachable for X min
Post by: cmdr.adama on March 13, 2020, 04:36:13 pm
Under service settings add your VPN service then go to the Service Tests tab.

In the service tests tab, set your preferred condition you want to meet before doing a restart. Set the action to execute, then set the path to /sbin/shutdown -r now.

Then assign the test to your VPN service.