I need to create a script that does the following:
Condition 1
check if primary ISP connection is unreachable and secondary ISP connection is reachable and primary ISP connection distance is 1
If primary ISP connection is unreachable and second reachable, change distance of primary connection to 4, clear all firewall connections and invoke certain http links. These links will reboot the phones so they can register using the failover ISP connection.
Condition 2
check if primary ISP connection is reachable and primary ISP connection distance is 4
If primary ISP connection is reachable and primary ISP connection distance is 4, change distance of primary connection to 1, clear all firewall connections and invoke certain http links. These links will reboot the phones so they can register using the primary ISP connection.
That eliminates the need to change distances dynamically.
Also you can query if a route is active or not.
Then make your script work on
If active then, else then.
You could alternatively set a static route to a host using your primary ISP and firewall it from reaching it over the secondary. Then a netwatch could monitor it.
You would set the netwatch to clear connections on any change between up or down.
(This is what I do for my router. Since both my ISPs are dynamic… I have a script on the dhcp-client to add the gateway to my recursive routes. Then I have a route set to use the primary ISP to reach a DNS service. There is a firewall output rule to drop the connection if that DNS is called via the secondary ISP. A netwatch pings that host. On Up: clear firewall connections. On Down: clear firewall connections. Been solid for almost a year.)