Topic 7A. Configuring A CISCO IOS Switch
Topic 7A. Configuring A CISCO IOS Switch
Typos are a pain, and typing out long commands is tedious. Fortunately, Cisco’s IOS has
features that can help you avoid typos and work faster:
1. Command Line completion. Once you type enough of a command that it is unique, you
can just hit enter. For example, instead of typing “configure terminal”, you can use the
command “config t” like this:
Switch#config t
[Enter configuration commands, one per line. End with “CNTL/Z”.]
Switch(config)#
2. Tab completion. Hitting the tab key once you have enough unique text on the screen will
auto-complete a command. For example, hitting tab after “conf” auto-completes to “configure”:
3. Command scrolling with up/down keys. Need to rerun a command? You can scroll
through your command history with the up/down arrows on your keyboard.
4. Bonus! Use “?” for added help. Hitting “?” at the beginning of a command prompt will
show you all the commands that are available in the current context. Hitting “?” after a
command will show you all the parameters that are available in that context.
Note: This example commands and output based on Cisco Packet Tracer’s default 2960
switch running SW version 15.0(2)SE4.
Step 1: Connect to the console
If you’re doing a lab with a simulator/emulator or accessing the CLI via SSH, you can skip this
step.
You need to start with a connection to the console port. That means configuring your terminal
emulator software and connecting your rollover cable between your switch’s console port and
your PC.
Many Cisco switches use these serial settings:
Baud rate: 9600
Data bits: 8
Stop bits: 1
Parity: None
Assuming your PC’s serial port is COM1, if you use Putty and Windows, you can set the session
up like this (under the “Serial” options in the menu):
Once your cable is connected and the session is set up, click open. Then press enter to get a
response at the terminal window.
Switch>enable
Switch#
From there, we enter Global Configuration mode with “config t” (or “configure terminal”):
Switch#config t
[Enter configuration commands, one per line. End with “CNTL/Z”.]
Switch(config)#
Switch(config)#interface vlan 1
Switch(config-if)#
Now, we can assign the management IP and subnet. In this example, we will assign
10.10.11.11 with a 255.255.255.0 subnet. Be sure to replace this with the correct values
for your switch!
We can exit interface configuration mode and assign a default gateway for the switch from
global configuration mode.
Switch(config-if)#exit
Switch(config)#ip default-gateway 10.10.11.1
Switch(config)#
Switch(config)#hostname S1
S1(config)#
Similarly, we can also add a domain name with the domain command:
S1(config)#ip domain-name jm.local
S1(config)#
S1(config)#line vty 0 15
S1(config-line)#password BigSecretDon'tT3ll@ny1
S1(config-line)#
Next, we’ll exit the VTY configuration, access console line 0, and assign it a separate password:
S1(config-line)#exit
S1(config)#line console 0
S1(config-line)#password BigSecretForConsoleDon'tT3ll@ny1
S1(config-line)#
S1(config-line)#exit
S1(config)#enable secret Top$ecretPrivEXECpassWORD
S1(config)#
Note: Because switch security is a complex topic, and we’re focused on the basics, we won’t go
into user management here. However, be sure to properly configure users or remote
authentication servers before a production deployment.
S1(config)#
Now, we can set SSH up on specific VTY lines. I’ll use the first 6 lines here:
S1(config)#line vty 0 5
S1(config-line)#transport input ssh
Finally, we’ll tell the switch to check the local users’ database to authenticate users:
S1(config-line)#login local
S1(config-line)#
S1(config-line)#vlan 2
S1(config-vlan)#name staff
S1(config-vlan)#
You can now exit, and repeat these steps for as many VLANs as you need.
S1(config-vlan)#exit
S1(config)#interface range fast
S1(config)#interface range fastEthernet 0/5-7
S1(config-if-range)#switchport mode access
S1(config-if-range)#switchport access vlan 2
S1(config-if-range)#
S1(config-if-range)#exit
S1(config)#interface fastEthernet 0/2
S1(config-if)#switchport mode trunk
S1(config-if)#
S1(config-if)#exit
S1(config)#exit
S1#
%SYS-5-CONFIG_I: Configured from console by console
Almost all Cisco devices use Cisco IOS to operate and Cisco CLI to be managed. The basic
CLI commands for all of them are the same, which simplifies Cisco device management.
Here is a Cisco commands cheat sheet that describes the basic commands for configuring,
securing and troubleshooting Cisco network devices.
Command Purpose
Troubleshooting Commands
switchport access vlan Sets the VLAN that the interface belongs
to.
DHCP Commands
Security Commands