Cisco Switch Configuration basic commands


Cisco switches are widely used in enterprise networks for their reliability and advanced features. However, configuring these switches can be a daunting task for those new to networking. In this article, we will cover some basic commands that are commonly used when configuring Cisco switches.

Accessing the Switch

The first step in configuring a Cisco switch is to access the switch's command-line interface (CLI). This can be done through a console cable or through a Telnet or SSH connection. To access the switch through the console, connect a console cable to the switch and a computer's serial port. Then, open a terminal emulator software such as HyperTerminal on the computer and set the baud rate to 9600. Press Enter and the switch's login prompt will appear.

To access the switch through Telnet or SSH, use the command "telnet [switch IP address]" or "ssh [switch IP address]" on the computer's command prompt. The switch's login prompt will then appear.

Entering Configuration Mode

Once logged in, the switch will be in user mode. To enter configuration mode, use the command "enable" to enter privileged mode and then "configure terminal" to enter configuration mode. The prompt will change to "switch(config)#" indicating that the switch is now in configuration mode.

Setting the Hostname

The hostname is the name assigned to the switch and is used to identify the switch in the network. To set the hostname, use the command "hostname [hostname]" in configuration mode. For example, to set the hostname to "switch1", the command would be "hostname switch1".

Setting the IP Address and Default Gateway

The IP address and default gateway are used to communicate with other devices on the network. To set the IP address and default gateway, use the command "interface [interface number]" to enter interface configuration mode. Then, use the command "ip address [IP address] [subnet mask]" to set the IP address and "ip default-gateway [default gateway]" to set the default gateway. For example, to set the IP address to 192.168.1.1 and the subnet mask to 255.255.255.0, the command would be "ip address 192.168.1.1 255.255.255.0". To set the default gateway to 192.168.1.254, the command would be "ip default-gateway 192.168.1.254".

Enabling and Disabling Interfaces

To enable or disable an interface, use the command "interface [interface number]" to enter interface configuration mode. Then, use the command "shutdown" to disable the interface or "no shutdown" to enable the interface. For example, to disable interface Fa0/1, the command would be "interface Fa0/1" followed by "shutdown". To enable the interface, the command would be "interface Fa0/1" followed by "no shutdown".

Setting the VLAN

VLANs are used to segment a network into smaller logical networks. To set the VLAN, use the command "vlan [VLAN number]" to enter VLAN configuration mode. Then, use the command "name [VLAN name]" to set the VLAN name. For example, to set VLAN 10 with the name "sales", the command would be "vlan 10" followed by "name sales".

Configuring Port Security

Port security is used to restrict access to a switch port by limiting the number of MAC addresses that can be learned on the port. To configure port security, use the command "interface [interface number]" to enter interface configuration mode. Then, use the command "switchport port-security" to enable port security on the interface. To set the maximum number of MAC addresses that can be learned on the port, use the command "switchport port-security maximum [number of addresses]". For example, to enable port security on interface Fa0/1 and set the maximum number of MAC addresses to 2, the commands would be "interface Fa0/1" followed by "switchport port-security" and "switchport port-security maximum 2".

Enabling Spanning Tree Protocol (STP)

STP is used to prevent loops in the network by electing a root bridge and blocking certain ports. To enable STP, use the command "spanning-tree vlan [VLAN number] root primary" in configuration mode. This will set the switch as the primary root bridge for the specified VLAN. To set a specific interface as the root port, use the command "spanning-tree vlan [VLAN number] interface [interface number] root primary". For example, to enable STP on VLAN 10 and set interface Fa0/1 as the root port, the commands would be "spanning-tree vlan 10 root primary" and "spanning-tree vlan 10 interface Fa0/1 root primary".

Saving Configuration Changes

Once all of the desired changes have been made, it is important to save the configuration to the switch's non-volatile memory (NVRAM). This can be done by using the command "copy running-config startup-config" in configuration mode. This command will save the current configuration to the switch's NVRAM so that it will be used when the switch is rebooted.

Conclusion

These are just a few of the basic commands that are commonly used when configuring Cisco switches. With a solid understanding of these commands and a little practice, configuring a Cisco switch can become a simple task. However, it is important to remember that each network is unique and may require additional configuration commands to meet the specific needs of the network. Always refer to the Cisco documentation for additional information and troubleshooting tips.

Updated on: 27-Jan-2023

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements