Cisco IOS IP SLA and EEM Script
Cisco IOS IP SLA and EEM Script
PNETLAB Store
PNETLab.com
https://user.pnetlab.com/store/labs/detail?id=16035330023569
Lab Objective:
The objective of this lab exercise is for you to learn and understand IP SLA and EEM Script on Cisco
IOS.
Task:
We have 4 routers: R1 and R2 are our DC, R3 is ISP 1 and R4 is ISP2. We will setup ISP1 is Primary
Path to reach prefix 8.8.8.8/32, Path to ISP2 will be disable. When ISP 1 down, R2 will automatic
enable ISP2. That we will do.
Solution
Basic Configuration:
1
Download PNETLab Platform
PNETLAB Store
PNETLab.com
Router R1 R2
Configuration interface Ethernet0/0 interface Ethernet0/0
no shutdown no shutdown
ip address 10.1.12.1 255.255.255.0 ip address 10.1.12.2 255.255.255.0
! !
ip route 0.0.0.0 0.0.0.0 10.1.12.2 interface Ethernet0/1
no shutdown
ip address 10.1.23.2 255.255.255.0
!
interface Ethernet0/2
no shutdown
ip address 10.1.24.2 255.255.255.0
!
ip route 8.8.8.8 255.255.255.255
10.1.23.3
Router R3 R4
Configuration interface Loopback0 interface Loopback0
no shutdown no shutdown
ip address 8.8.8.8 255.255.255.255 ip address 8.8.8.8 255.255.255.255
! !
interface Ethernet0/0 interface Ethernet0/0
no shutdown no shutdown
ip address 10.1.23.3 255.255.255.0 ip address 10.1.24.4 255.255.255.0
! !
ip route 0.0.0.0 0.0.0.0 10.1.23.2 ip route 0.0.0.0 0.0.0.0 10.1.24.2
R2(config)#ip sla 1
R2(config-ip-sla)#icmp-echo 10.1.23.3 source-ip 10.1.23.2
R2(config-ip-sla-echo)#frequency 10
R2(config-ip-sla-echo)#exit
R2(config)#ip sla schedule 1 life forever start-time now
It’s a simple configuration where R2 will keep sending ICMP echoes to R3 forever. To combine IP
SLA with EEM, we’ll need to track it somehow. We can do this with object tracking:
1. Enable Router
We’ll also configure an action that will be performed when the object is up again:
3
Download PNETLab Platform
PNETLAB Store
PNETLab.com
R1#traceroute 8.8.8.8
Type escape sequence to abort.
Tracing the route to 8.8.8.8
VRF info: (vrf in name/id, vrf out name/id)
1 10.1.12.2 2 msec 1 msec 0 msec
2 10.1.23.3 1 msec 3 msec *
So, it is running via R3. I ‘ll shutdown interface e0/0 of R3 in order to simulate a failure. Now, we
enable EEM debugging:
R2#
*Oct 24 09:29:01.127: %TRACK-6-STATE: 1 ip sla 1 reachability Up -> Down
*Oct 24 09:29:01.128: %HA_EM-6-LOG: TRACK_DOWN : DEBUG(cli_lib) : : CTL : cli_open called.
*Oct 24 09:29:01.134: %HA_EM-6-LOG: TRACK_DOWN : DEBUG(cli_lib) : : OUT : R2>
*Oct 24 09:29:01.134: %HA_EM-6-LOG: TRACK_DOWN : DEBUG(cli_lib) : : IN : R2>enable
*Oct 24 09:29:01.261: %HA_EM-6-LOG: TRACK_DOWN : DEBUG(cli_lib) : : OUT : R2#
*Oct 24 09:29:01.261: %HA_EM-6-LOG: TRACK_DOWN : DEBUG(cli_lib) : : IN : R2#conf t
*Oct 24 09:29:01.379: %HA_EM-6-LOG: TRACK_DOWN : DEBUG(cli_lib) : : OUT : Enter
configuration commands, one per line. End with CNTL/Z.
*Oct 24 09:29:01.379: %HA_EM-6-LOG: TRACK_DOWN : DEBUG(cli_lib) : : OUT : R2(config)#
*Oct 24 09:29:01.379:
R2#%HA_EM-6-LOG: TRACK_DOWN : DEBUG(cli_lib) : : IN : R2(config)#ip route 8.8.8.8
255.255.255.255 10.1.24.4
*Oct 24 09:29:01.604: %HA_EM-6-LOG: TRACK_DOWN : DEBUG(cli_lib) : : OUT : R2(config)#
*Oct 24 09:29:01.604: %HA_EM-6-LOG: TRACK_DOWN : DEBUG(cli_lib) : : IN : R2(config)#no ip
route 8.8.8.8 255.255.255.255 10.1.23.3
*Oct 24 09:29:01.827: %HA_EM-6-LOG: TRACK_DOWN : DEBUG(cli_lib) : : OUT : R2(config)#
*Oct 24 09:29:01.827: %HA_EM-6-LOG: TRACK_DOWN : DEBUG(cli_lib) : : CTL : cli_close called.
*Oct 24 09:29:01.828:
*Oct 24 09:29:01.828: tty is now going through its death sequence
You can see that EEM is working. Let’s traceroute from R1 again:
R1#traceroute 8.8.8.8
Type escape sequence to abort.
4
Download PNETLab Platform
PNETLAB Store
PNETLab.com
R1#traceroute 8.8.8.8
Type escape sequence to abort.
Tracing the route to 8.8.8.8
VRF info: (vrf in name/id, vrf out name/id)
1 10.1.12.2 0 msec 1 msec 1 msec
2 10.1.23.3 1 msec 2 msec *
Now, it go via R3. That’s great!