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 18.104.22.168
- The DSL model is IP address 22.214.171.124
- 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 126.96.36.199
- Your e-mail address is email@example.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
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 188.8.131.52 254 name ADSL_BACKUP track 2
ip route 184.108.40.206 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 220.127.116.11 source-interface FastEthernet0/0
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 "18.104.22.168" to "firstname.lastname@example.org" from "email@example.com" 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 "22.214.171.124" to "firstname.lastname@example.org" from "email@example.com" 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.