Some useful cisco switch command
Show command on switch
Nepalitservice#show version
Displays software and hardware information
Nepalitservice#show running-config
Displays currently running configuration in DRAM
Nepalitservice#show start
Displays configuration in NVRAM which will be loaded after reboot
Nepalitservice#show flash:
Displays Flash memory information
Nepalitservice#show boot
Displays boot path and image
Nepalitservice#show clock
Displays the system clock
Nepalitservice#show interfaces
Displays all interfaces configuration and status of line
Nepalitservice#show vlan
Displays vlan number, name, status and ports associated with it
Nepalitservice#show vtp status
Displays VTP mode, Number of existing vlans and config revision
Nepalitservice#show interface status
Displays interface status, vlan, Duplex, Speed and type
Nepalitservice#show etherchannel
Displays etherchannel information
Nepalitservice#show cdp neighbors
Displays information of connected devices
Nepalitservice#show cdp neighbors detail
Displays detailed information of connected devices
Nepalitservice#show mac address-table
Displays current MAC address forwarding table
Nepalitservice#show spanning-tree
Displays spanning-tree state information, which interfaces are in active or blocking state etc
Some configuration example of Cisco switch
Resetting the Switch
Nepalitservice#delete flash:vlan.dat
Deletes vlan database from flash memory
Nepalitservice#erase startup-config
Delete start-up file from NVRAM
Nepalitservice#reload
Reboot the Switch
Setting Host Names
Nepalitservice#config t
Nepalitservice(config)#hostname nepalitservice
Setting login credentials:
nepalitservice(config)#username nepalit password cisco
enable username and password for login to the switch
nepalitservice(config)#enable secret test1
Sets encrypted secret password using MD5 algorithm.
nepalitservice(config)#service password-encryption
Encrypt all the passwords using MD5
Console Access:
nepalitservice(config)#line con 0
nepalitservice(config-line)#password cisco
nepalitservice(config-line)#login
SSH/Telnet Access to the switch:
nepalitservice(config)#line vty 0 4
nepalitservice(config-line)#transport input ssh
nepalitservice(config-line)#transport input telnet
nepalitservice(configiline)#password cisco
Setting IP Address
nepalitservice(config)#interface vlan1
Enters vlan1, the native vlan
nepalitservice(config-if)#ip address 192.168.1.254 255.255.255.0
Set IP address which is the management IP of device
nepalitservice(config)#ip default-gateway 192.168.1.1
Interface description
nepalitservice(config)#interface g0/1
nepalitservice(config-if)#description TO SERVER
Duplex and Speed Settings
nepalitservice(config)#interface g0/1
nepalitservice(config-if)#speed 10
Force 10Mbps Speed
nepalitservice(config-if)#speed 100
Force 100Mbps Speed
nepalitservice(config-if)#speed auto
Enable auto speed configuration
nepalitservice(config-if)#duplex auto
Enable auto duplex configuration on switch port
nepalitservice(config-if)#duplex full
Enable full duplex configuration on switch port
nepalitservice(config-if)#duplex half
Enable half duplex configuration on switch port
Setting Web-based interface for configuration (GUI):
nepalitservice(config)#ip http server
Enable HTTP server
nepalitservice(config)#ip http port 80
Set port number for HTTP
Port-Security
nepalitservice(config)#interface g0/1
Enter the interface to set port-security
nepalitservice(config-if)#switchport port-security
Enable port security on the interface
nepalitservice(config-if)#switchport port-security mac-address sticky
Interface converts all MAC addresses to sticky secure addresses
nepalitservice(config-if)#switchport port-security maximum 1
Only one MAC address will be allowed for this port
nepalitservice(config-if)#switchport port-security violation shutdown
Port will shut down if violation occurs
nepalitservice(config-if)#exit
nepalitservice(config)#exit
nepalitservice#show port-security
Verifying Port security
Save current configuration
nepalitservice(config)# copy running-config startup-config
“Portfast” bypasses the Spanning Tree states and brings the port up as quickly as possible. Use it only if you connect a regular host (e.g Computer) on the port. Do not use this command when the port is trunk or if you connect other switches on the specific port.
nepalitservice(config)# interface FastEthernet 0/1
nepalitservice(config-if)# spanning-tree portfast
Configuring VLANs
nepalitservice(config)#vlan 20
nepalitservice(config-vlan)# name nepalitservice
Assigning access ports to a vlan
nepalitservice(config)#interface g0/1
nepalitservice(config-if)#switchport mode access
nepalitservice(config-if)#switchport access vlan 20
Assign the port to vlan 20
nepalitservice(config-if)#exit
The following commands will select a range of interfaces (from 1 to 24) and add all of them to vlan20
nepalitservice(config)#interface range gigabitEthernet 0/1-24
nepalitservice(config-if)#switchport mode access
nepalitservice(config-if)#switchport access vlan 20
nepalitservice(config-if)#exit
Configuring trunk port
nepalitservice(config)#interface g0/2
nepalitservice(config-if)#switchport trunk encapsulation dot1q
nepalitservice(config-if)#switchport mode trunk