Cisco IOS CLI and Basic Device Configuration
Introduction to Cisco IOS and CLI
- Cisco IOS (Internetwork Operating System): The proprietary operating system used on Cisco network devices (routers, switches, firewalls).
- Note: Cisco IOS is completely unrelated to Apple’s iOS used on iPhones.
- CLI (Command-Line Interface): The text-based interface used by network engineers to configure and manage Cisco devices. It is heavily preferred over a GUI (Graphical User Interface) like Cisco ASDM for its efficiency and comprehensive feature access.
Physical Connection to Cisco Devices
To initially configure a device, you must connect physically via the Console Port. Modern Cisco devices (like Catalyst switches) typically feature two console ports: an RJ45 port and a USB mini-b connector.
Connecting via the RJ45 Console Port
- Cable Required: A Rollover Cable (RJ45 to DB9).
- Misconception: A rollover cable is NOT an Ethernet crossover cable.
- Pinout Wiring: The pins are reversed. Pin 1 connects to Pin 8, Pin 2 to Pin 7, Pin 3 to Pin 6, Pin 4 to Pin 5, Pin 5 to Pin 4, Pin 6 to Pin 3, Pin 7 to Pin 2, and Pin 8 to Pin 1.
- Adapter: Since modern laptops lack DB9 serial ports, a DB9-to-USB adapter is required.
- Terminal Emulator: Use software like PuTTY to establish the serial connection.
Default Serial Connection Settings
These settings match the Cisco device defaults. You rarely need to change them, but they are highly testable.
| Parameter | Default Value |
|---|---|
| Speed (Baud Rate) | 9600 bits per second |
| Data Bits | 8 |
| Stop Bits | 1 |
| Parity | None (used for error detection) |
| Flow Control | None (controls data flow between transmitter/receiver) |
Cisco CLI Modes
When you connect, you bypass the initial configuration dialog (press no or Enter) and enter the CLI. The CLI operates in hierarchical modes.
stateDiagram-v2
[*] --> UserEXEC: Boot / Console Connect
UserEXEC --> PrivilegedEXEC: enable
PrivilegedEXEC --> GlobalConfig: configure terminal
GlobalConfig --> PrivilegedEXEC: exit
PrivilegedEXEC --> UserEXEC: exit / disable
| Mode | Prompt Symbol | Access Level | Purpose |
|---|---|---|---|
| User EXEC | > |
Very Limited | View basic status. Cannot make configuration changes. Default hostname is Router. |
| Privileged EXEC | # |
High | View full configuration, restart device, save config, change time. |
| Global Configuration | (config)# |
Full | Make actual changes to the device’s configuration (e.g., set passwords, configure interfaces). |
CLI Navigation, Shortcuts, and Help
- Tab Key: Auto-completes commands. If you type
enand pressTab, it expands toenable. - Shortest Command: You only need to type enough characters to make the command unambiguous.
enworks forenable(only command starting with ‘en’ in User EXEC).efails (ambiguous: could beenableorexit). You must typeexfor exit.
- Question Mark (
?) Help:- No space (
command?): Shows all possible completions for the current word. - With space (
command ?): Shows all possible next arguments/options for the command. - CR (Carriage Return): Indicates no further arguments are required; you can just press Enter.
- No space (
Password Security and Encryption
Passwords in Cisco IOS are strictly case-sensitive. If you enter the wrong password 3 times, you will be denied access with a “bad secrets” message.
Password Commands Comparison
| Command | Purpose | Encryption Type | Security Level | Notes |
|---|---|---|---|---|
enable password <password> |
Protects Privileged EXEC mode. | Type 0 (Plain Text) | Very Low | Visible to anyone viewing the config. |
service password-encryption |
Encrypts plain-text passwords in the config. | Type 7 (Cisco Proprietary) | Low | Easily cracked online. Does NOT affect enable secret. |
enable secret <password> |
Protects Privileged EXEC mode securely. | Type 5 (MD5 Hash) | High | Always encrypted. Takes precedence over enable password if both are configured. |
Crucial Rules for Password Encryption:
- If both
enable passwordandenable secretare configured, the router only asks for theenable secret. Theenable passwordis ignored. - The
service password-encryptioncommand has NO effect on theenable secret(it is always Type 5 encrypted). - If you disable
service password-encryption(no service password-encryption):- Current passwords remain encrypted (they are not decrypted).
- Future passwords will be saved in plain text.
Configuration Files
Cisco devices maintain two separate configuration files in memory.
- Running-Config: The current, active configuration stored in RAM. Changes made in the CLI apply here immediately.
- Startup-Config: The saved configuration stored in NVRAM. This file is loaded into RAM when the device boots up. If not saved, the device loads a blank default config on reboot.
Saving the Configuration
To copy the running-config to the startup-config, use any of these three commands in Privileged EXEC mode:
Router# write
Router# write memory
Router# copy running-config startup-config
Other Essential CLI Commands
do <command>: Allows you to execute Privileged EXEC commands (likeshow running-config) while in Global Configuration mode or other sub-modes.no <command>: Negates, removes, or disables a previously configured command (e.g.,no enable password).
Command Summary
| Command | Mode to Execute | Full Syntax / Purpose |
|---|---|---|
enable |
User EXEC | Enters Privileged EXEC mode. |
configure terminal |
Privileged EXEC | Enters Global Configuration mode (Shortcut: conf t). |
enable password <pass> |
Global Config | Sets a plain-text password for Privileged EXEC mode. |
enable secret <pass> |
Global Config | Sets a secure MD5-hashed password for Privileged EXEC mode. |
service password-encryption |
Global Config | Encrypts current and future plain-text passwords (Type 7). |
no service password-encryption |
Global Config | Stops encrypting future passwords (does not decrypt existing ones). |
show running-config |
Privileged EXEC | Displays the active configuration in RAM (Shortcut: sh run). |
show startup-config |
Privileged EXEC | Displays the saved configuration in NVRAM (Shortcut: sh start). |
write / write memory |
Privileged EXEC | Saves the running-config to the startup-config. |
copy running-config startup-config |
Privileged EXEC | Saves the running-config to the startup-config. |
do <command> |
Any Config Mode | Executes a Privileged EXEC command from a lower mode. |
no <command> |
Global Config | Removes or negates a previously entered configuration command. |
exit |
Any Mode | Moves down one level in the CLI hierarchy (or logs out from User EXEC). |