Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - doucettea

#1
OP, if the reason you want OPNsense to notify you when internet is down is because you want to have it bring the internet back up, consider this thread: https://forum.opnsense.org/index.php?topic=40930.msg226932#new
#2
For monitoring WAN connection, there's another option of a script to call by cron offered here:
https://gist.github.com/mdeweerd/035129a6f90979ba39ec8377e99922f5

In case not familiar with how to accomplish the above:
  • Open an SSH connection to your OPNSense.
  • Choose the option to open the Shell (should be 8, IIRC)
  • Create the file: at the shell prompt enter the following commands:
        sudo mkdir /usr/local/bin/scripts
        sudo touch /usr/local/bin/scripts/opnsense_ping_check.sh
        sudo vi /usr/local/bin/scripts/opnsense_ping_check.sh
        [edit the script text to IP addresses you choose (I used 1.0.0.1 and 8.8.8.8) and the interface for your WAN (mine is igb0)]
        [copy the script text, paste the text of the script into the Putty window (this might be a mouse-right-click)]
        [save the file and exit vi by typing :wq and pressing Enter]
  • Now back to the shell prompt, enter the following commands:
        sudo chmod +x /usr/local/bin/scripts/opnsense_ping_check.sh
        sudo /usr/local/bin/scripts/opnsense_ping_check.sh
  • [exit the shell by typing exit and press enter]
  • [exit the SSH window by typing exit and press enter]
  • Back in the OPNSense web UI, go to System --> Settings --> Cron
        Click the + to add a Cron job
        Set Minutes to */5 and set the other time intervals to * --- this will cause the Cron to execute every five minutes
        On the Command drop-down, select the "ping_check" option
        Give it a description
        Click Save

Done. Hope that helps someone (and hope it works for me!)
#3
A previous thread provided a script that could be called by cron at short intervals (e.g. every minute) to check the WAN interface and toggle it down then up to renew WAN DHCP.
Code it suggests (thanks @ooker):
Quote from: ooker link=msg=83143#!/bin/sh
gatewayIP=$(netstat -4rn | grep default | awk '{print $2}')
wanInterface="em0"

echo "Gateway: $gatewayIP"
echo "WAN Interface: $wanInterface"
if [ -z $gatewayIP ]
then
  echo "NO Gateway"
  #Bring the interface down then up to renew the WAN DHCP
  ifconfig $wanInterface down
  ifconfig $wanInterface up
else
  # if return = 0 then host is reachable
  ping -c 1 $gatewayIP > /dev/null
  if [ $? -eq 0 ]
  then
    echo "Gateway Reachable"
  else
    echo "Gateway Unreachable"
    #Bring the interface down then up to renew the WAN DHCP
    ifconfig $wanInterface down
    ifconfig $wanInterface up
  fi
fi

Could something like this be used by those of us home-users who have less-than-stable ISP connections?

Ari