Home
Help
Search
Login
Register
OPNsense Forum
»
English Forums
»
General Discussion
»
How to initiate an opnsense action when WAN goes down
« previous
next »
Print
Pages: [
1
]
Author
Topic: How to initiate an opnsense action when WAN goes down (Read 1486 times)
Stuzoo72
Newbie
Posts: 12
Karma: 1
How to initiate an opnsense action when WAN goes down
«
on:
February 06, 2022, 01:10:59 am »
Hi,
I have WAN connection, broadband and a 4G router.
dpinger monitors the gateway on the broadband WAN very well and shows online/offline.
I have separate inbound and outbound connections from Opnsense to the 4G router.
For technical Telco reasons, when the broadband is down I need to disable DHCP on the Opnsnese inbound interface connected to the 4G router. I can't get around this.
I need to setup a job/task that is basically
If Gateway Monitor (broadband) is down then disable DHCP on opnssnese [Net_4G_inbound]
If Gateway Monitor (broadband) is up then enable DHCP on opnssnese [Net_4G_inbound]
Any ideas?
Logged
franco
Administrator
Hero Member
Posts: 17656
Karma: 1611
Re: How to initiate an opnsense action when WAN goes down
«
Reply #1 on:
February 07, 2022, 11:53:33 am »
Hi,
https://github.com/opnsense/core/blob/master/src/etc/rc.syshook.d/monitor/10-dpinger
is a script that hooks into the monitor events. The rc.syshook.d/monitor directory will take any script, maybe you want to add one as 20-dhcp so it triggers after initial dpinger functionality, or maybe you need it ealier as 05-dhcp.
Depending on what "disable DHCP" means the script could end up being relatively complex. I'm happy to provide more hints if needed.
Cheers,
Franco
Logged
Greelan
Hero Member
Posts: 1028
Karma: 72
Re: How to initiate an opnsense action when WAN goes down
«
Reply #2 on:
February 07, 2022, 12:16:52 pm »
Monit could probably also do this job
Logged
franco
Administrator
Hero Member
Posts: 17656
Karma: 1611
Re: How to initiate an opnsense action when WAN goes down
«
Reply #3 on:
February 07, 2022, 12:27:57 pm »
True, good idea.
Cheers,
Franco
Logged
Stuzoo72
Newbie
Posts: 12
Karma: 1
Re: How to initiate an opnsense action when WAN goes down
«
Reply #4 on:
February 13, 2022, 02:14:07 am »
Thanks for the replies. I do like Monit as a solution.
I have enabled Monit and the inbuilt "gateway_alert" service setting. For the moment this does what I need - reporting if one of the gateways is down.
From that I can action start/stop etc.
What I now need is a command to stop (disable) and one to start (enable) DHCP on a specific interface.
From GUI it would be
Services: DHCPv4: [WAN2_Incoming]
Toggle enable/disbale "Enable DHCP server on the WAN2_Incoming interface"
I don't want to turn off DHCP for for all interfaces, just this one.
Can some one help with scripts for the above enable/disable?
Where is the best place to store scripts used by Monit? Somewhere that won't be overwritten during an upgrade.
Logged
Print
Pages: [
1
]
« previous
next »
OPNsense Forum
»
English Forums
»
General Discussion
»
How to initiate an opnsense action when WAN goes down