This is a super simple bash script that will ping Googles DNS servers every 10 minutes and if there is no response, try an interface down/up before it rebooting the machine.
NOTE:
You will probably need to update the script where it says igc0 with your WAN interfaces name (you can find this easily through the GUI or by running ifconfig).
- Copy the ping_check.sh file to /usr/local/etc/rc.d
- Make it executable with chmod 755 ping_check.sh
- Copy the actions_pingcheck.conf file to /usr/local/opnsense/service/conf/actions.d
- Reload configd so it knows about the new action with service configd restart
- Head to the web GUI and go to System > Settings > Cron. Add a new job, enter */10in the minutes field and asterisks in the rest, and select your newly created "Check WAN access and reboot if offline" command.