Cisco IOS Switch Commands Cheatsheet

This is a cheat sheet for basic Cisco IOS Switch Commands

Command Modes

ModeSample PromptWhat is Allowed
User EXECSwitch1>View Settings
Privilege EXECSwitch1#View and change settings
Global ConfigurationSwitch1(config)#Change settings for the whole router (global)
Other/Sub ConfigurationSwitch1(config-if)#
Change settings specific to interfaces, terminal lines, sub-interfaces, etc.,

Navigating from User EXEC to Privilege EXEC

Switch1> enable

(If password has been set you will be asked for it when you type enable)

Navigating from Privilege EXEC to Global Configuration Mode

Switch1# configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.

Setting Password for Privilege EXEC (Enable Password)

Switch1(config)# enable password abcd1234

(Password is visible in cleartext when running configuration is displayed)

Setting Password with Encryption

Switch1(config)# enable secret abcd1234

(Password is encrypted and is not human readable when running configuration is displayed)

Changing hostname

Switch1(config)# hostname OTGSwitch

Save configuration changes

OTGSwitch# copy running-config startup-config

View running configuration

OTGSwitch# show running-config

Setting an alias

OTGSwitch(config)# alias exec c configure terminal
This sets an alias for the command 'configure terminal' as simply 'c'

Getting help

OTGSwitch# ?

This gives general help

OTGSwitch# show ?

This gives the options available for show command.

Configuring the Switch Management Interface

OTGSwitch# configure terminal
Enter configuration commands, one per line.  End with CNTL/Z
OTGSwitch(config)# interface vlan1
OTGSwitch(config-if)# ip address

This sets IP Address of management interface vlan1

Configure an interface

OTGSwitch(config)# interface FastEthernet0/1
OTGSwitch(config-if)# speed 100
OTGSwitch(config-if)# duplex full

This sets the speed and duplex of interface FastEthernet0/1

Configuring a VLAN

OTGSwitch(config)# interface vlan 2
OTGSwitch(config-if)# description OTGLab VLAN
OTGSwitch(config-if)# exit
OTGSwitch(config)# interface range FastEthernet 0/1 , FastEthernet 0/5
OTGSwitch(config-if-range)# switchport mode access
OTGSwitch(config-if-range)# switchport access vlan 2

This creates a new vlan vlan2, configures FastEthernet interfaces 1 to 5 as access ports and assigns them to vlan2.

Configuring an access port

OTGSwitch(config)# interface FastEthernet 0/10
OTGSwitch(config-if)# switchport mode access
OTGSwitch(config-if)# switchport access vlan10

This configures FastEthernet 0/10 as access port and assigns it to vlan10

Configuring a trunk port

OTGSwitch(config)#interface FastEthernet 0/11
OTGSwitch(config-if-range)#switchport mode trunk

This configures Fastethernet 0/11 as a trunk port (can carry traffic for all the VLANs and usually connects switch to another switch)

Configuring etherchannel

of access ports:

OTGSwitch(config)# interface range FastEthernet0/12 -14 
OTGSwitch(config-if-range)# switchport mode access
OTGSwitch(config-if-range)# switchport access vlan 10
OTGSwitch(config-if-range)# channel-group 5 mode desirable

This configures FastEthernet 12-14 as access ports in vlan10 and makes them an etherchannel group 5 and PAgP negotiation desirable. You have to do similar aggregation of the ports at the device at the other end.

of trunk ports:

OTGSwitch(config)# interface port-channel 4
OTGSwitch(config-if)# switchport trunk encapsulation dot1q
OTGSwitch(config-if)switchport mode trunk
OTGSwitch(config)# interface range gigabitethernet0/1-2
OTGSwitch(config-if)# switchport trunk encapsulation dot1q
OTGSwitch(config-if)# switchport mode trunk
OTGSwitch(config-if)# channel-group 4 mode on

This configures GigabitEthernet 1-2 as trunk ports and makes them etherchannel group 4 and mode as on. Same configuration has to be mirrored on other end.

Enable or disable Spanning Tree Protocol (STP)

OTGSwitch(config)# spanning-tree vlan 2
OTGSwitch(config)# no spanning-tree vlan 2

Enables or disables spanning tree for vlan 2 (default is enabled)

Configure STP mode

OTGSwitch(config)# spanning-tree mode rapid-pvst

This sets spanning tree mode as Rapid PVST.

View STP configuration

OTGSwitch# show spanning-tree
Enable portfast on a port
OTGSwitch(config)# interface FastEthernet 0/1
OTGSwitch(config-if)# spanning-tree portfast

This makes the interface come up fast bypassing STP states and can only be used for regular switch port not for trunk, etherchannel etc.

Post a comment


Your Comment

Email (We dont publish it)


Keith | February 12, 2015 9:53 AM |

Where can I find one for Cisco CatOS...?