As a revision to my earlier post on the matter, here’s a better constructed way to achieve the same effect with a little more accuracy.
Here’s a diagram of the approximate topology that this will cater to:
I shall assert the following facts:
- The “ISP’s Router” is IP address 1.1.1.1
- The DSL model is IP address 2.2.2.2
- The source interface that connects to the ISP router is FastEthernet0/0
- There is an SMTP server that this router has permission to send via at 99.99.99.99
- Your e-mail address is you@mail.com
First we use “track” to create 2 track entries to do route tracking. The first defines a “reachability” track which will be used to monitor for and perform actions on the failure of the primary route. This also delays the actions it performs on failure and restore by 20 and 60 seconds respectively to negate the effect of temporary blips. The second is a stub which allows us to take the secondary route up or down.
delay down 20 up 60
track 2 stub-object
default-state down
Next we add the routes. There’s 2 default gateways added, each associated with the track entries. There is also a route to ensure that all traffic to the “ISP’s Router” is sent out of the fa0/0 interface. This is for monitoring.
ip route 0.0.0.0 0.0.0.0 2.2.2.2 254 name ADSL_BACKUP track 2
ip route 1.1.1.1 255.255.255.255 FastEthernet0/0
Now we use ip sla to provide the details for our reachability track regarding what it should test. In this case, it pings the “ISP’s Router” every 4 seconds:
icmp-echo 1.1.1.1 source-interface FastEthernet0/0
timeout 2000
frequency 4
ip sla schedule 123 life forever start-time now
Finally we add some event handling to perform some actions on the failure and restore of the primary line. These bring up the second route and e-mail you a notification:
event track 1 state down
action 1.0 track set 2 state up
action 1.1 mail server "99.99.99.99" to "you@mail.com" from "monitor@router.local" subject "IP SLA 123 Timeout" body "Timeout on the primary line"
event manager applet TRACK-1-OK
event track 1 state up
action 1.0 track set 2 state down
action 1.1 mail server "99.99.99.99" to "you@mail.com" from "monitor@router.local" subject "IP SLA 123 Restored" body "Primary line restored"
That’s largely it. It contrasts with my earlier post in such that it ignores the effect of temporary blips in the line and also sends e-mail notifications.