Cisco Switch Cheat Sheet

These are some quick notes I have to refresh my memory on configuring Cisco switches. Feel free to send me any comments or suggestions.

Password Recovery Quick-Links

  • Cisco 2900XL Series switches - tried this on a 2912XL, and instructions didn't quite work. In flash: there is file named word, that needs to be either renamed or deleted as well for the password recovery to work. Also I used no enable secret and no enable password as well. This didn't apply to the 2950XL switches.

Adding an IP address to a switch

  • type enable to enter privilege mode
  • type config terminal
  • type interface vlan 1
  • type ip address 192.168.1.4 255.255.255.0
  • type no shutdown - required to activate the management address
  • type exit
  • type ip default-gateway 192.168.1.1

Removing an IP address from a switch

  • type enable to enter privilege mode
  • type config terminal
  • type interface vlan 1
  • type no ip address

Configuring Interfaces and ports

  • type enable to enter privilege mode
  • type config terminal
  • type interface fastethernet0/{port #} - the port # is essential or else an 'Incomplete Command' will result
  • type duplex auto - auto-detect full duplex/half duplex
  • type speed auto - auto detect 10/100/1000 speeds
  • type spanning-tree portfast - speeds up (a lot) the time it takes for the port to get to forwarding mode. Note: use only if a server/work station is connected to this port, cause it could prevent the Spanning-Tree protocol from detecting and disabling loops in the network.

Configuring Multiple ports at the same time

Turns out there is no way to specify a range of IP addresses for my old IOS switches. However a quick shell script can quickly generate commands for me to copy/paste into the terminal.

 

> i=1;while [ $i -lt 25 ]; do echo "int fast0/$i"; echo speed auto; echo duplex auto; echo span portfast; let i+=1; done;

From: http://www.knowledgenet.com/em/kn/cisco/2002/news1202/index2.html

Can I set the speed and duplex on all Catalyst switch ports simultaneously or do I need to configure each port individually?

This depends upon the switch platform that you are referring to. If you are working with a Cisco switch that runs the Cat OS, then you can. You can both configure ports that are sequential and not sequential all at the same time. Here are some examples to do this.

 

set port duplex 2/1-20, 2/22 full
set port speed 2/2-12, 2/15-16 100

If you are working with a Cisco switch that runs the IOS, then you must be a little creative. You do not have the same CLI options to configure multiple ports simultaneously with a Cisco switch running the IOS. You do have several options though. The easiest way to do this type of configuration is to create a text file, for example in VI or notepad. After creating the statements in your text editor, simply copy and paste the lines into the CLI. Here is an example of the text that can be copied into the CLI.

 

configure terminal
interface fastethernet 1/1
speed 100
duplex full
interface fastethernet 1/2
speed 100
duplex full
interface fastethernet 1/3
speed 100
duplex full
...............text omitted
end
! To return to privileged mode

show running-config
! To verify your configuration

Newer IOS based switches allow multiple ports to be configured at the same time. The interface range command runs on all platforms that support Cisco IOS Release 12.0(7)XE, Release 12.1 E, and Release 12.1(5)T. In interface range configuration mode, you can configure multiple interfaces with the same configuration parameters. Once you enter the interface-range configuration mode, all command parameters you enter are attributed to all interfaces within that range until you exit out of the interface-range configuration mode. Following is an example of using the command. Please note that the space before the dash is required.

 

router(config)# interface range fastethernet 5/1 - 5, gigabitethernet 1/1 - 2
router(config-if)# speed 100
router(config-if)# duplex full
router(config-if)# no shutdown

You can also use SNMP and the switch GUI to complete this configuration. Though I believe the easier path is to create a text file.

Assign ports to a VLAN on 2900 switches

  • From Cisco Documentation
    • configure terminal
    • interface {name}
    • switchport mode access
    • switchport access vlan {num}
    • end
    • show running-config

Setting a telnet password

Enabling SNMP

  • enable privilege mode
  • config terminal
  • snmp-server community {password} RO - sets a community string with Read Only privilege.
  • or no snmp-server community {password} - removes a community string.

Finding MAC Address discovered per port

  • On a Cisco WS-X2948
  • show cam dynamic

Saving Configuration on 2948 Port Switch

 

  • copy config flash
  • Should ask if flashdevice is bootflash, hit Enter
  • Ask if name to copy to is: myswitch.cfg, Enter Y
  • set boot auto-config bootflash:myswitch.cfg
    • There may be warnings like: nvram configuration may be lost during next bootup, and re-configured using the file(s) specified. These can be ignored.
}