Thx a lot for this script!
Question: Do I need to make more changes?
1. I changed my ip address to the fixed ip of the IP-provider (SHAW)
In the scheduler, I added the sctipt and set it to run the script every minute.
In the ethernet connections, for my SHAW connection (ether5), I need to add a comment called "Primary"
Is that All?
Question 2:
The router will reboot when the primary connection fails? And when the primary connection is up again, it will reboot again?
Seemed pretty easy!
That should be all... Just make sure the comments and upstream gateway match the script is all.
I tested this initially with Asterisks but should work just the same for any IP phone system.
There may also be a better way to flush the tables rather than a reboot, but the reboot is so fast and cleans it all out so its a sure thing.
I also use a more modified version that sends me notices on another router...
:global strDate [/system clock get date]
:global strTime [/system clock get time]
:global strSystemName [/system identity get name]
:if ([/ping xx.xx.xx.xx interval=.1 count=10]<5 && [/ping 8.8.4.4 interval=.1 count=10]<5 && [/ip route get [find comment="Default Route"] disabled]=false) do={
:log info "Disabling Primary"; /ip route set [find comment="Primary"] disabled=yes
/tool e-mail send from="noreply@routerdomain.com" to="alert@emaildomain.com" server="MAILSERVERIPHERE" subject="Route Failover - $strDate $strTime - $strSystemName" body="Failover to ISPNAME occurred at $strDate $strTime on $strSystemName"
} else= {
:if ([/ip route get [find comment="Primary"] disabled]=true) do={
:log info "Enabling Primary"; /ip route set [find comment="Primary"] disabled=no
/delay 5
/system reboot
}
}
This was was written also by the same guy... but he was also trying to add email notices to notify.
We have control of the mail server so we were able to add smtp bypass to the sending mail server. Auth will need to be added to the script if you want to add it.