EEM: Time based static default route

Supposed you want to let user use lower bandwidth after office hours which is 1800hrs, from monday to friday.

EEM configuration

2651-1#sh run | s event manager applet test
event manager applet test
event timer cron name cronjob1 cron-entry “0 18 * * 0-6”
action 1.0 cli command “enable”
action 2.0 cli command “conf t”
action 3.0 cli command “int se0/1”
action 4.0 cli command “shut”
event manager applet test2
event timer cron name cronjob cron-entry “0 9 * * 0-6”
action 1.0 cli command “enable”
action 2.0 cli command “conf t”
action 3.0 cli command “int se0/1”
action 4.0 cli command “no shut”

Test the EEM applet

Feb  3 18:00:41.748: %SYS-5-CONFIG_I: Configured from console by vty0
2651-1#
Feb  3 18:00:43.523: %LINK-5-CHANGED: Interface Serial0/1, changed state to administratively down
Feb  3 18:00:44.524: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1, changed state to down
2651-1#
Feb  3 18:00:51.115: %TRACKING-5-STATE: 200 rtr 200 reachability Up->Down
Feb  3 18:00:51.211: %SYS-5-CONFIG_I: Configured from console by vty0

2651-1#sh ip route | b Gateway
Gateway of last resort is 0.0.0.0 to network 0.0.0.0

1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
C    200.20.20.0/24 is directly connected, Serial0/2
C    192.168.1.0/24 is directly connected, FastEthernet0/1
S*   0.0.0.0/0 is directly connected, Serial0/2

The cron has triggered the action which is shutting down serial 0/1, in turn will trigger another EEM applet which will install the route to another ISP.

Cron format

You will need to understand the crontab format, which can be found in Crontab-Quick Reference.

In short the format is:

[minutes] [hours] [day of the month] [month] [day of the week 0-6, 0 being Sunday]

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s