It seems the easiest way to have a dynamic dual wan failover is to add 2 dhcp clients with distances of 1 and 2. When the first goes down, the second goes up, etc.
The issue is dynamic dhcp routes have no option to ping the gateway, so if the physical connection remains intact, but the internet feed goes down, the router thinks the wan is still up and does not switch to the backup #2.
I found on the forums this command that allows a dynamic dhcp route to ping the gateway:
Watch out to only check your gateway. I’m also looking for a solution to this.
Here in Belgium one of the biggest ISP Telenet has an modem/router witch assigns public IP’s with DHCP.
But if the connection goes offline but the modem is still powered on the modem assigns private 192.168.0.0/24 IP’s. This results in that the gateway is stil reachable.
So the solution you posted wil not work if your ISP does the same
The only good solution is to check if you can reach an IP on the internet, preferably multiple IP’s
I ended up deploying a scripted solution. Pinging the gateway is useless if your gateway is up but their link is down (which is what happens when by fibre link goes down).
I actually prefer the scripted solution as it gives you much better control.
The script i have switches gateway on more than 80% packet loss to 2 different ip addresses over 5 pings each.
It will resume the main gateway on < 20% packet loss.
It also sends me emails when switching gateways.
I found the original script via google and then tweaked it to suit my needs.
So far it’s been working really well.