Basic Network Switch Commands for Troubleshooting and Configuration
Introduction
Managing network switches often involves performing routine tasks such as identifying connected devices, checking VLAN assignments, configuring ports, and reviewing logs. Having a quick reference of commonly used switch commands can simplify day-to-day administration and troubleshooting.
Prerequisites
Before you begin, ensure you have:
- Access to the network switch via SSH, Telnet, or console
- Administrative or privileged (enable) access
- Basic understanding of switch interfaces and VLANs
Implementation
Find the Switch Port Using a MAC Address
show mac address-table address xx:xx:xx:xx:xx:xx
Example output:
Aging time is 300 sec Vlan Mac Address Port Type 100 xx:xx:xx:xx:xx:xx gi1/0/12 dynamic
View the MAC Address Connected to a Switch Port
show mac address-table interface gi1/0/2
Example output:
Aging time is 300 sec Vlan Mac Address Port Type 100 xx:xx:xx:xx:xx:xx gi1/0/2 dynamic
Check the VLAN and Administrative Mode of a Port
show interfaces switchport gi1/0/12
Example output:
Administrative Mode: access Access Mode VLAN: 100
Check the Speed and Status of a Switch Port
show interfaces status gi1/0/12
Example output:
Port Type Duplex Speed State gi1/0/12 1G-Copper Full 100 Up
Change the VLAN of an Access Port
configure interface gi1/0/<port_number> switchport access vlan 100
Configure a Trunk Port
configure interface gi1/0/<port_number> switchport mode trunk switchport trunk allowed vlan add <vlan_number1> <vlan_number2> end
Shut Down a Switch Port
configure interface gi1/0/<port_number> shutdown
Save the Running Configuration
copy running-config startup-config
This saves the current running configuration so it persists after a reboot.
Create a New VLAN
configure vlan database vlan <vlan_number>
View All Ports Assigned to a VLAN
show vlan tag <vlan_number>
This displays all switch ports associated with the specified VLAN.
View Recent Switch Logs
show logging
This command displays the recent system logs, which can help during troubleshooting.
Conclusion
These commands cover many of the common tasks performed during network switch administration, including locating devices, checking interface status, configuring VLANs, managing switch ports, and reviewing logs. Keeping these commands handy can help speed up routine maintenance and troubleshooting activities.
