Your Gateway to a Career in Network Engineering
Basic Router/Switch Configuration via CLI
Welcome to the Command Line Interface (CLI). While graphical user interfaces (GUIs) are user-friendly, the CLI is the preferred tool for network professionals. It is faster, more powerful, scriptable, and provides granular control over every aspect of a network device. This guide will walk you through your first interaction with a router or switch CLI.
Accessing the CLI
There are three primary ways to access a device's CLI:
- Console: A direct physical connection using a special console cable (usually a light-blue rollover cable). This is required for the initial setup of a new device.
- SSH (Secure Shell): A secure, encrypted method to access the CLI remotely over the network. This is the preferred method for daily management.
- Telnet: An older, insecure method for remote access. Telnet sends all data, including passwords, in plain text and should be avoided.
Navigating the CLI Modes
The Cisco IOS CLI has a hierarchical structure with different "modes." Think of it like a secure building: you start in the lobby, then pass through security to gain more access, and finally enter specific offices to make changes.
| Mode Name | Prompt | Purpose | How to Enter |
|---|---|---|---|
| User EXEC Mode | Router> | (Lobby) Basic monitoring. You can look but not touch. Used for simple show commands. | Default mode after connecting. |
| Privileged EXEC Mode | Router# | (Security Desk) Full monitoring and access. Allows all show commands, debugging, and file management. | From User mode, type enable. |
| Global Configuration Mode | Router(config)# | (Manager's Office) Make changes that affect the entire device. | From Privileged mode, type configure terminal. |
| Specific Configuration Mode | Router(config-if)# | (Specific Department) Make changes to a specific feature, like an interface or a protocol. | From Global Config mode (e.g., interface g0/0/0). |
To move back one level, type exit. To go all the way back to Privileged EXEC mode from any sub-configuration mode, type end or press Ctrl+Z.
Essential First-Step Configurations
These are the five commands you should run on almost any new device. All are done from Global Configuration Mode.
Switch> enable
Switch# configure terminal
Switch(config)# hostname MCA-SW-01
MCA-SW-01(config)# enable secret your-secure-password
MCA-SW-01(config)# line console 0
MCA-SW-01(config-line)# password your-console-password
MCA-SW-01(config-line)# login
MCA-SW-01(config-line)# exit
MCA-SW-01(config)# line vty 0 15
MCA-SW-01(config-line)# password your-remote-password
MCA-SW-01(config-line)# login
MCA-SW-01(config-line)# exit
MCA-SW-01(config)# banner motd # Unauthorized Access is Prohibited! #
MCA-SW-01(config)# end
MCA-SW-01#
Interface Configuration: Making the Device Useful
Now let's configure an interface. The commands differ slightly based on whether it's a router (Layer 3) or a switch (Layer 2).
Router Interface (Layer 3)
The goal is to assign an IP address to make the router participate in a network.
Router# configure terminal
Router(config)# interface GigabitEthernet0/0/0
Router(config-if)# description Link to Main LAN
Router(config-if)# ip address 192.168.1.1 255.255.255.0
Router(config-if)# no shutdown
Router(config-if)# end
no shutdown command is essential to activate the interface.Switch Interface (Layer 2)
The goal is to configure the port for a user device and assign it to a VLAN.
Switch# configure terminal
Switch(config)# interface GigabitEthernet0/1
Switch(config-if)# description Connection to User PC
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 10
Switch(config-if)# no shutdown
Switch(config-if)# end
The Most Important Command: The Question Mark `?`
The CLI has built-in, context-sensitive help. Typing ? will show you all available commands in the current mode or all possible options to complete a command you've started.
show ?- Shows all commands that start with "show".show ip ?- Shows all options for the "show ip" command.sh?(no space) - Shows commands starting with "sh".
Saving Your Configuration
Changes made in configuration mode are applied immediately to the **running-config** (the configuration currently active in RAM). However, this configuration will be lost if the device reboots. To save your changes permanently, you must copy them to the **startup-config** (the configuration stored in NVRAM).
MCA-SW-01# copy running-config startup-config
Destination filename [startup-config]? [Press Enter]
Building configuration...
[OK]
MCA-SW-01#
copy run start. Forgetting to save is the most common mistake beginners make!