Good morning.
I am trying to create a custom script to be used in CRON to periodically check the gateway and reboot the router if there's no connection.
The script I used can be found here: https://forum.netgate.com/topic/64563/pfsense-auto-reboot-script-when-google-is-unreachable/3 (https://forum.netgate.com/topic/64563/pfsense-auto-reboot-script-when-google-is-unreachable/3)
I put the script into the file /usr/local/opnsense/scripts/gatewaycheck.sh. I also created a conf file actions_gatewaycheck.conf:
[check]
command:/usr/local/opnsense/scripts/gatewaycheck.sh
parameters
type:script
message:Check the Gateway
description:Periodically check the gateway and reboot if needed
I ran the command "service configd restart" to restart configd. However, when I run the command "configctl gatewaycheck check", I get the following response:
configd socket missing (@/var/run/configd.socket)
Since I'm new at creating a new script, any assistance would be greatly appreciated.
Hi!
I created a cron script in opnsense along this line:
https://forum.opnsense.org/index.php?topic=10740.msg49328#msg49328
Thanks for this. I can see your setup of your conf file and I see that I can either create a script with the command "/sbin/pfctl -F state" or put the command directly into the conf file.
So the command "/sbin/pfctl -F state" checks the state of the gateway and, if it fails, reboots?
ooops, soory, no, missunderstanding! My script/Cron job kills all states at certain times of day (e.g. after scheduled BLOCK firewall rules kick in, to remove exisitng states).
I just wanted to provide an example how custom Cron jobs can be created. But the author of the post had a script with the same job as you intend, i.e. check gateway and reboot... (see his post). But you may ask him for the script ping_check.sh mentioned in the post.
PS: see here
https://forum.opnsense.org/index.php?topic=13544.msg67170#msg67170
THANK YOU! THANK YOU! THANK YOU! THANK YOU! ;D
This is exactly what I was looking for. Script works like a charm, and was able to set it up as a CRON job.
Thank you so much!