We would like to post few random switch commands that we used in our  day to day life.

To get the switch port of a MAC address, use the following command.

# show mac address-table address xx:xx:xx:xx:xx:xx
Aging time is 300 sec

Vlan Mac Address Port Type
——– ——————— ———- ———-

100 xx:xx:xx:xx:xx:xx gi1/0/12 dynamic

To view the MAC address of a switch port, execute the following command.

# show mac address-table interface gi1/0/2
Aging time is 300 sec

Vlan Mac Address Port Type
——– ——————— ———- ———-
100 xx:xx:xx:xx:xx:xx gi1/0/2 dynamic

To view the vlan and administrative mode of a switch port, execute the following command.

#show interfaces switchport gi1/0/12

……..

Administrative Mode: access

Access Mode VLAN: 100

To get the speed of a switch port, use the below command.

# show interfaces status gi1/0/12

Flow Link Back Mdix
Port Type Duplex Speed Neg ctrl State Pressure Mode
——– ———— —— —– ——– —- ———– ——– ——-
gi1/0/12 1G-Copper Full 100 Enabled On Up Disabled Off

To change the VLAN of a switch port, follow the below steps.

#configure

(config)#interface gi1/0/<port number>

(config-if)#switchport access vlan 100

To Trunk a switch port to different vlan, execute the following command.

#configure

(config)#interface gi1/0/<port number>

(config-if)#switchport mode trunk

(config-if)#switchport trunk allowed vlan add <vlan number1> <vlan number2>

(config-if)#end

To shutdown a single port, execute the below commands.

#configure

(config)#interface gi1/0/<port number>

(config-if)# shutdown

To copy the running configuration to startup configuration, execute the mentioned command.

#copy running-config startup-config

To add a new vlan to database, follow the below mentioned steps.

#configure

#vlan database

# vlan <vlan number>

To view all the switch ports belongs to a particular vlan, execute the following command.

show vlan tag <vlan number>

This will list all the switch ports which belongs to a vlan.

To view the recent logs on the switch, execute the following command.

show logging

Leave a Reply