What's new

Wan Down Event and/or Notification?

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Kal1975

Regular Contributor
Is there an event that occurs when the WAN goes down? I'm looking to write a script when it goes down. Tried searching but didn't find anything.

I have the situation where my WAN connection sometimes goes down. When I notice it, I typically just turn the WAN off, wait a few seconds, turn it back on and then everything is fine again.

I was hoping to write a script that would automate that until I can determine exactly what's going on and/or follow up with my ISP.
 
Maybe something like this?

Code:
#!/bin/sh
#

# loggninginfo in syslog
scr_name="$(basename $0)[$$]"

# Check to see if this script already is running...?
if [ ! -d /tmp/CheckInternet ];
then
  echo "CheckIfInternet is missing, will create map." | logger -t $scr_name
  mkdir /tmp/CheckInternet
else
  echo "CheckIfInternet, will exit this process." | logger -t $scr_name
  exit
fi
#
# Never ending loop...
while [ 1 ]
do
# IP numbers below is MY installation - it will for sure differ for other peoples installation - so PLEASE change!!
# The wget statement is for calling my HomeSeer server for home automation - so you can change that to whatever you need.
# If WAN ip is 178.78.x.x then online, if 192.168.x.x then it is backup
  if ifconfig | grep -q 178.78; then
      wget -qO- "xxx/JSON?request=controldevicebylabel&ref=743&label=Online" >/dev/null 2>&1
  elif ifconfig | grep -q 192.168; then
      wget -qO- "xxx/JSON?request=controldevicebylabel&ref=743&label=Backup" >/dev/null 2>&1
  else
      wget -qO- "xxx/JSON?request=controldevicebylabel&ref=743&label=Offline" >/dev/null 2>&1
  fi
# 
  sleep 60
#
done

echo "CheckIfInternet exits, this should not happen this way..." | logger -t $scr_name
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top