How to remotely conduct 4G Failover testing on a Cisco Router
Prerequisites
test that the cellular interface is up
ping 8.8.8.8 source-interface cellular 0/0/0
if there is no response, then power-cycle the cellular module and test again
test cellular 0/0/0 modem-power-cycle // this is a hidden command so if it doesn't come up, then do the following
conf t
service internal
exit
test cellular 0/0/0 modem-power-cycleping 8.8.8.8 source-interface cellular 0/0/0
Step 1: See what SLAs and Tracks are already defined on the device
show run | include sla // to see what sla's are already defined
show run | include track //to see what Tracks are already defined
Step 2: Configure SLAs
ip sla 2
icmp-echo 1.0.0.1 source-interface interface gig 0/0
frequency 10
ip sla schedule 2 life forever start-time nowip sla 3
icmp-echo 76.76.10.0 source-interface interface gig 0/0
frequency 10
ip sla schedule 3 life forever start-time now
Step 3: Create Track Objects
track 1 ip sla 2 reachability
track 2 ip sla 3 reachability
track 3 list threshold percentage. // a logical AND operation of the 2 objects
object 1
object 2
delay down 15 up 15
Step 4: Create Static Routes
ip route 1.0.0.1 255.255.255.255 interface gig 0/0
ip route 76.76.10.0 255.255.255.255 interface gig 0/0
ip route 0.0.0.0 0.0.0.0 interface gig 0/0 track 3
ip route 0.0.0.0 0.0.0.0 Cellular0/0/0 200
Stage 2: Interface Failover Testing
Step 1: Setup Fall Back plan
write memory
conf t
reload in 30 // just in case something goes wrong, reboot the router in 30 mins, its important to NOT write the config from here UNTIL AFTER the cleanup.
Step 2 Define an Embedded Event Manager Applet
conf t
event manager applet failover
action 1 cli command "enable"
action 2 cli command "config terminal"
action 3 cli command "int interface gig 0/0"
action 4 cli command "shut"
action 5 wait 17 // wait 17 seconds because there is a 15 second delay on the tracking object, + 2 seconds to be safe
action 6 cli command "do ping 142.250.70.206 source <one of the lan interfaces> ". //ping one of Googles IPs and redirect the output to a file (actions 6.3 - 6.5)
action 6.2 wait 10 // wait 10 seconds for the above "cli action" to successfully return. The "$_cli_result" variable in action 6.4 is a callback to action 6, and because these "actions" run asynchronously you have to explicitly wait for the returns. Otherwise action 6.4 will run before action 6.2 actually completes, thus writing nothing (NULL) to the file.
action 6.3 file open fd flash:pings.txt w //write a "flash:pings.txt" file
action 6.4 file write fd "$_cli_result". // write the results of the last action, ie the pings to 142.250.70.206 into the file
action 6.5 file close fd // close the file
action 7 cli command "do show ip route | redirect flash:failover-route.txt" // redirect routing table into file. // print the routing table and redirect the output into a "flash:failover-route.txt" file // if a file of the same name already exits, it will prompt for user input and thus, stall the script.
action 8 cli command "no shut"
action 9 cli command "exit"
event timer cron cron-entry "30 12 * * *" maxrun 55 // similar to unix-like systems eg "05 18 * * *" is 6:05 PM. Default run time is 20 seconds so you to extend that
Step 3: Verify time before scheduled reload
show reload // verify how much time you have before scheduled reload
Step 4: Verify the policy
show event manager policy registered // verify order of commands and that the maxrun is set to 55 seconds
Step 5: Wait for script to run at the desired time
Step 6: Read Files
more flash:failover-route.txt
more flash:pings.txt
Step 7: Cancel the reload
reload cancel
EEM Applet commands without comments
event manager applet failover
action 1 cli command "enable"
action 2 cli command "config terminal"
action 3 cli command "int gig 0/0"
action 4 cli command "shut"
action 5 wait 17
action 6 cli command "do ping 142.250.70.206"
action 6.2 wait 10
action 6.3 file open fd flash:pings.txt w
action 6.4 file write fd "$_cli_result"
action 6.5 file close fd
action 7 cli command "do show ip route | redirect flash:failover-route.txt"
action 8 cli command "no shut"
action 9 cli command "end"
event timer cron cron-entry "30 12 * * *"
event config maxrun 60