Cisco – time based interface shutdown on cisco router

ciscocisco-commandscisco-eeminterface

Is there a way to shutdown an interface on a Cisco router based on time periods?
I would like to shut the cellular interface when it is not necessary.

Can this be done with the event manager and action in combination of time-based access-list or track?

Best Answer

You can do this with time-based ACL's when talking about ports, or with EEM when talking about interfaces:

interface wlan0
ip address 10.1.1.1 255.255.255.0 
ip access-group 101 in      

access-list 101 permit tcp 10.1.1.0 0.0.0.255 172.16.1.0 0.0.0.255        
eq telnet time-range EVERYOTHERDAY  

time-range EVERYOTHERDAY 
periodic Monday Wednesday Friday 8:00 to 17:00

Source: http://www.cisco.com/en/US/products/sw/secursw/ps1018/products_tech_note09186a00800a5b9a.shtml#timebasedtimerange

When you want to shut down an interface, take a look at the next article:

https://supportforums.cisco.com/thread/202630 (answer Joseph Clarke)

event manager applet shutdown_port
event timer cron cron-entry "0 0 * * *"
action 010 cli command "enable"
action 020 cli command "config t"
action 030 cli command "interface FastEthernet1/0/1"
action 040 cli command "shut"
action 050 cli command "end"
action 060 syslog msg "Interface FastEthernet1/0/1 has been shutdown"

event manager applet noshut_port
event timer cron cron-entry "0 8 * * *"
action 010 cli command "enable"
action 020 cli command "config t"
action 030 cli command "interface FastEthernet1/0/1"
action 040 cli command "no shut"
action 050 cli command "end"
action 060 syslog msg "Interface FastEthernet1/0/1 has been restored"

in the example above: The port will be shutdown every day at midnight, and brought back up every day at 8 am.

You should look into the cron-entry option (like crontabs in linux/unix) reference: http://www.rogerperkin.co.uk/ccie/index.php/eem-2/understanding-cisco-eem-event-timer-cron/

There are 5 values you can specify for the cron timer

  • minute – this controls what minute of the hour the command will fire values between 0 and 59
  • hour – this controls what hour the command will run – specified in the 24 hour clock format 0-23 0=midnight
  • dom – day of month that you want the command to run e.g 20th = 20
  • dow – day of week it can be numeric 0-7 or name of day e.g sat

Examples:

01 * * * * This command is run at one min past every hour
17 8 * * * This command is run daily at 8:17 am
*/1 **** this command runs every minute