Useful Cisco Switch IOS commands with Examples

This is a short post with a few useful commands for configuring and troubleshooting Cisco switches.

To show the current configuration:

show running-config

 

Show the switches firmware version and model:

show version

 

Show serial numbers:

show inventory

 

To save the current configuration:

copy running-config startup-config

 

Reboot switch:

Reload

 

Show details about the current interface, the below shows you information about port 49 on this switch:

show interface Ethernet1/49/1

 

If your switch port is in a port-channel you will need to show the details for the port-channel interface:

show interface port-channel 21 

 

When troubleshooting it may be necessary to see the MAC addresses of the devices that are connected to the switch port. To do this run the below, it will show you the MAC addresses of all the devices connected to port 49:

show mac address-table interface Ethernet1/49/1

 

Show the MAC address details for a specific MAC address you are looking for:

show mac address-table address 0016.bad8.3fbd 

 

Show all the MAC address entries for VLAN 10:

show mac address-table vlan 10

 

These commands will enable configuration mode, select interface eth1/27, enable terminal monitoring (so we can see the status of the port) and disable the port:

configure terminal
int eth1/27
do term mon
shut

 

These commands will do the same as above but enable the port:

configure terminal
int eth1/27
do term mon
no shut

 

Show all VLANs in the switch database:

show vlan

 

Show all the trunked ports on the switch:

show interface trunk

 

Create VLAN10 and name it ‘CorpVLAN’:

configure terminal
vlan 10
name CorpVLAN

 

Configure a port for access mode – this means there are no trunked VLANs on the switch port but will put the port in one single VLAN that the device connected to it will be in automatically. These commands will select the port, add a description (fileserver), set the port to access mode and put it in VLAN 10:

configure terminal
interface Ethernet1/51/1
description fileserver
switchport access vlan 10

 

Configure a port for trunk mode – this means there are trunked VLANs on the switch port. The device you connect to this port will need to understand the trunked VLANs and will most likely be another switch or something like an ESXi host. These commands will select the port, add a description (fileserver), set the port to trunk mode and put it in VLANs 10,20 and 30:

configure terminal
interface Ethernet1/38
description fileserver
switchport trunk allowed vlan 10,20,30

 

Show other connected switches:

show cdp neighbor

 

Configure the switch management port 0, make it a member of vrf management and give it an IP address of 10.20.0.1:

interface mgmt0
vrf member management
ip address 10.20.0.1/24
line console
line vty

Leave a Reply

Your email address will not be published. Required fields are marked *