How to set up Internet connection (WAN) failover in Cisco IOS including e-mail notifications

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:

Network Diagram

Network Diagram

I shall assert the following facts:

  1. The “ISP’s Router” is IP address 1.1.1.1
  2. The DSL model is IP address 2.2.2.2
  3. The source interface that connects to the ISP router is FastEthernet0/0
  4. There is an SMTP server that this router has permission to send via at 99.99.99.99
  5. 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.

  1. track 1 rtr 123 reachability
  2. delay down 20 up 60
  3. track 2 stub-object
  4. 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.

  1. ip route 0.0.0.0 0.0.0.0 1.1.1.1 name FIBRE track 1
  2. ip route 0.0.0.0 0.0.0.0 2.2.2.2 254 name ADSL_BACKUP track 2
  3. 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:

  1. ip sla 123
  2. icmp-echo 1.1.1.1 source-interface FastEthernet0/0
  3. timeout 2000
  4. frequency 4
  5. 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:

  1. event manager applet TRACK-1-TIMEOUT
  2. event track 1 state down
  3. action 1.0 track set 2 state up
  4. 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"
  5. event manager applet TRACK-1-OK
  6. event track 1 state up
  7. action 1.0 track set 2 state down
  8. 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.

 

Leave a Reply

Your email address will not be published. Required fields are marked *