The script demonstrates the ability to manipulate Static  IP routes, in this case a default route (0.0.0.0/0) based upon the reachability of a given IP address or series of IP addresses.  In today’s networks, carriers provide WAN / METRO connectivity via an Ethernet presentation.  While the local connected Ethernet interface may stay up, a downstream connection may go down and hence overall IP connectivity may not be available. By having an alternative service provider connection, general connectivity could be restored if the default route next hop is changed.

 In this case the script monitors the IP address reachability of 3 addresses and if it detects that all of the IP address are not reachable via the preferred route, it adds an alternate default (0.0.0.0/0)next hop route.  The script continues to monitor the IP reachability via the original preferred route by adding next hop host routes for each of the IP addresses.  When one of the IP address becomes reachable again via the preferred route, the overall default route is restored to the preferred next hop and the host routes are removed.