Stackvora.tech

Cisco IOS Basics: 20 Commands Every Engineer Should Know

Mastering Cisco IOS is fundamental for network engineers, system administrators, and cloud consultants working with Cisco infrastructure. This article…

Mastering Cisco IOS is fundamental for network engineers, system administrators, and cloud consultants working with Cisco infrastructure. This article outlines 20 essential commands across operational and configuration modes, providing practical examples and critical insights for everyday tasks. We'll cover everything from basic device inspection to intricate troubleshooting, focusing on IOS versions 15.x and newer.

Operational Mode: Device Health and Status

1. show version

Provides detailed information about the router/switch's IOS software, hardware, uptime, and configuration register. Essential for verifying software versions, identifying hardware platforms, and checking system stability.

Router# show version
Cisco IOS Software, C1900 Software (C1900-UNIVERSALK9-M), Version 15.4(3)M5, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2015 by Cisco Systems, Inc.
Compiled Wed 21-Oct-15 00:03 by prod_rel_team

ROM: System Bootstrap, Version 15.0(1r)M16, RELEASE SOFTWARE (fc1)

Router uptime is 1 week, 2 days, 4 hours, 32 minutes
System returned to ROM by power-on
System image file is "flash:c1900-universalk9-mz.154-3.M5.bin"
Last reload reason: Power-on

Cisco 1941 (2RU) processor (revision 1.0) with 249856K/26624K bytes of memory.
Processor board ID FTX15228D3E
2 Gigabit Ethernet interfaces
DRAM configuration: 512 Mbytes
NVRAM configuration: 245760 bytes

Configuration register is 0x2102

2. show running-config

Displays the currently active configuration of the device. This is the live configuration. Any changes made are reflected here immediately. Compare this with show startup-config to see if a device will boot with the current configuration after a reload.

Router# show running-config
Building configuration...

Current configuration : 2174 bytes
!
version 15.4
service timestamps debug datetime msec
service timestamps log datetime msec
no service password-encryption
!
hostname Router
!
interface GigabitEthernet0/0
 ip address 192.168.1.1 255.255.255.0
 no shutdown
!
interface GigabitEthernet0/1
 no ip address
 shutdown
!
line con 0
 password cisco
 login
line vty 0 4
 password cisco
 login
!
end

3. show ip interface brief

Provides a concise summary of IP-related information for all interfaces, including IP address, status (up/down), and protocol status (up/down). Quick check for interface state and IP assignment.

4. show interfaces status

For switches, this command shows the operational status and connection type for all physical interfaces. Useful for quickly identifying link status, speed, duplex, and VLAN assignment.

5. show vlan brief

Displays a summary of VLANs configured on a switch, including their ID, name, status, and associated ports. Essential for verifying VLAN assignments and port membership.

Switch# show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Gi1/0/1, Gi1/0/2, Gi1/0/3, Gi1/0/4
10   Marketing                        active    Gi1/0/5, Gi1/0/6
20   Sales                            active    Gi1/0/7, Gi1/0/8
1002 fddi-default                     act/unsup 
1003 token-ring-default               act/unsup 
1004 fddinet-default                  act/unsup 
1005 trnet-default                    act/unsup

6. show mac address-table

Shows the MAC address table (CAM table) on a switch. Displays MAC addresses learned, the VLAN they belong to, and the port they were learned on. Crucial for troubleshooting Layer 2 forwarding issues.

7. show ip route

Displays the IP routing table, showing all known routes, their next hops, and the protocol from which they were learned. Fundamental for understanding how a router forwards traffic.

Router# show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is 192.168.1.254 to network 0.0.0.0

S*    0.0.0.0/0 [1/0] via 192.168.1.254
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/24 is directly connected, GigabitEthernet0/0
L        10.0.0.1/32 is directly connected, GigabitEthernet0/0
      192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.1.0/24 is directly connected, GigabitEthernet0/1
L        192.168.1.100/32 is directly connected, GigabitEthernet0/1

8. show cdp neighbors detail

Cisco Discovery Protocol (CDP) is a proprietary Layer 2 protocol used to discover directly connected Cisco devices. The detail option shows extensive information about neighbors, including device ID, local interface, remote port, platform, and IOS version. Invaluable for network discovery and documentation.

9. show logging

Displays the contents of the device's log buffer. Logs provide critical information about events, errors, and system messages, aiding in troubleshooting and security monitoring.

10. ping <IP_address>

Standard network utility for testing IP connectivity to a host. Use it to verify reachability and measure round-trip time.

Router# ping 8.8.8.8
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms

11. traceroute <IP_address>

Displays the path that packets take to reach a destination, including each hop (router) along the way. Useful for identifying where network connectivity issues might be occurring.

Configuration Mode: Device Setup and Changes

12. configure terminal (or conf t)

Enters global configuration mode, allowing you to make changes to the device's configuration. Most subsequent configuration commands are entered from this mode or a sub-mode thereof.

13. interface <type><slot>/<port>

Enters interface configuration mode for a specific interface. From here, you configure interface-specific parameters like IP addresses, descriptions, and speed/duplex settings.

  • Example for a router: interface GigabitEthernet0/0
  • Example for a switch: interface FastEthernet0/24
  • Example for a Layer 3 switch VLAN interface: interface Vlan10

14. description <text>

Adds a descriptive text to an interface. Crucial for documentation and easy identification of ports in large networks.

15. ip address <IP_address> <subnet_mask>

Assigns an IP address and subnet mask to a Layer 3 interface (e.g., a physical router interface or a switch VLAN interface).

16. no shutdown

Activates an interface. By default, many new interfaces are administratively shut down. This command brings them up.

17. switchport mode <access|trunk>

Configures a switch port's operational mode.

  • access: Configures the port to carry traffic for a single VLAN.
  • trunk: Configures the port to carry traffic for multiple VLANs using 802.1Q tagging.

18. switchport access vlan <VLAN_ID>

Assigns an access mode port to a specific VLAN. Only applicable to ports configured with switchport mode access.

19. switchport trunk allowed vlan <VLAN_list>

Specifies which VLANs are permitted to traverse a trunk port. By default, all VLANs are allowed. Using this command with a specific list helps reduce broadcast domains and improve security.

Switch(config)# interface GigabitEthernet0/1
Switch(config-if)# description Uplink-to-Core
Switch(config-if)# switchport mode trunk
Switch(config-if)# switchport trunk allowed vlan 10,20,30,50-55
Switch(config-if)# no shutdown
Switch(config-if)# end

20. write memory (or copy running-config startup-config)

Saves the currently active configuration (running-config) to NVRAM (startup-config). If you don't save, all changes will be lost after a reload or power cycle. Always confirm successful save.

Router# copy running-config startup-config
Destination filename [startup-config]? 
Building configuration...
[OK]
Router#

Command Modifiers and Filters

Cisco IOS offers powerful filtering capabilities to manage command output, which is especially useful on devices with extensive configurations or log entries. The pipe (|) symbol is used to pass the output of one command as input to a filter.

  • | begin <pattern>: Displays output starting from the first line that matches the pattern.
  • | include <pattern>: Displays only lines that contain the specified pattern.
  • | exclude <pattern>: Displays all lines except those that contain the specified pattern.
  • | section <pattern>: Displays configuration sections that start with or include the pattern. Very useful for drilling down into specific interface or protocol configurations.
Router# show running-config | include hostname
hostname Router
Router# show ip route | begin Gateway
Gateway of last resort is 192.168.1.254 to network 0.0.0.0
S*    0.0.0.0/0 [1/0] via 192.168.1.254
      10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        10.0.0.0/24 is directly connected, GigabitEthernet0/0
L        10.0.0.1/32 is directly connected, GigabitEthernet0/0
      192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C        192.168.1.0/24 is directly connected, GigabitEthernet0/1
L        192.168.1.100/32 is directly connected, GigabitEthernet0/1
Router# show running-config | section interface GigabitEthernet0/0
interface GigabitEthernet0/0
 ip address 192.168.1.1 255.255.255.0
 no shutdown

Common Pitfalls

  • Forgetting to Save: Changes made in configuration mode are only active in RAM (running-config). Always use copy running-config startup-config or write memory to save to NVRAM, otherwise, changes are lost on reboot.
  • Interface Shut Down: New interfaces are often in an administratively down state. Always remember to use no shutdown in interface configuration mode.
  • Incorrect Subnet Masks: A common mistake when assigning IP addresses. Double-check the subnet mask to avoid unexpected routing or host reachability issues.
  • VLAN Mismatches: On trunk links, ensure the allowed VLANs and native VLAN settings are consistent on both ends to prevent connectivity problems.
  • Syntax Errors: IOS commands are particular about syntax. Use the ? (context-sensitive help) to explore available commands and parameters at any point.
  • Privilege Levels: Some commands require higher privilege levels (e.g., enable mode for show commands, global config mode for configuration changes).

Back to the knowledge base · Ask the AI assistant