Linux script and cron to monitor ip address

I want:

Neorouter server to change ip address if primary server cannot connect to the internet

Two alternate ip locations checking for neorouter server primary server

First alternate ip (prim_ip)

ping primary neorouter server for active ip
if up do nothing
if down update duckdns.orgwith prim_ip
continue ping primary neorouter server ip
if comes back up then update duckdns.org with primary neorouter server ip
continue ping

Second alternate ip (sec_ip)
checks prim_ip and checks primary neorouter server ip
if both down then second sec_ip updates duckdns.org to itself
if either of the others come back they will update duckdns.org

linux neorouter client
if ping google.com but not duckdns.org
then try to restart neorouter
run as cron job

cron job

https://www.pantz.org/software/cron/croninfo.html

http://alvinalexander.com/linux/unix-linux-crontab-every-minute-hour-day-syntax

ping script

http://www.cyberciti.biz/tips/simple-linux-and-unix-system-monitoring-with-ping-command-and-scripts.html

in the comments

if [[ $(ping -q -c 3 10.1.1.1) == @(*100% packet loss*) ]]; then
 echo “$host is down”
 else
 echo “$host is alive”
 fi

also

ping -qnc 2 google.com > /dev/null 2>&1 && echo ‘Host up!’ || echo ‘Host down!’