Run multiple commands at once on a Cisco IOS device

This article shows how you can run multiple commands at once in a Cisco IOS device.
The use case can be to change routes or port speeds when connected from a remote location.

If connected remotely and you change the WAN port speed there is a possibility that you lose the connection to the device.
When you change the port settings from auto to fixed you need to enter 2 commands, speed and duplex. When you change one but not the other the port will go down and you lose the connection.
With the methods below you can change both settings at once.

Please note. When working remote and there is a possibility that you lose the connection. Save the current config and schedule a reboot.
If you lose the connection the router will automatically reboot with the last saved config and you will be able to reconnect.
DO NOT FORGET TO CANCEL THE RELOAD IF THE CONFIG CHANGE IS SUCCESSFUL!

The example below shows how you can change the WAN port speed to 100Mbit autonegotiate OFF.

Normal (connection will drop)

Router1#
Router1#configure terminal
Router1(config)#interface gigabitEthernet 0/0
Router1(config-if)#speed 100
Router1(config-if)#duplex full
Router1(config-if)#^Z
Router1#

With tclsh

Router1#
Router1#tclsh
Router1(tcl)#ios_config “interface gigabitEthernet 0/0” “speed 100” “duplex full”
Router1(tcl)# “Press CTRL+C to get out of tcl”
Router1#

With Event manager

Router1#
Router1#configure terminal
Router1(config)#event manager applet ChangePortSpeed
Router1(config-applet)#event none
Router1(config-applet)#action 0 cli command “enable”
Router1(config-applet)#action 1 cli command “configure terminal”
Router1(config-applet)#action 2 cli command “interface gigabitEthernet 0/0”
Router1(config-applet)#action 3 cli command “speed 100”
Router1(config-applet)#action 4 cli command “duplex full”
Router1(config-applet)# “Press CTRL+C to get out of event manager”
Router1#
Router1#event manager run ChangePortSpeed
Router1#
configure terminal
Router1(config)#no event manager applet ChangePortSpeed
Router1(config)#^Z
Router1#