Monday, March 3, 2014

Learning & understanding Cisco CLI and setting up for easy handling.



Introduction

This article explains how to navigate and setup up Cisco CLI (command-line interface) for better handling and ease of configuration.

To get CLI of Cisco router

There are 2-3 ways you can get into the Cisco router's CLI, the most common is to connect Cisco console cable between router's console port and PC serial port. Open a hyper terminal (or any other serial terminal software) and connect with 9600-8-N-1 settings. AUX port, Telnet and SSH options are also available depending on the network topology.

OK Let's say we are connected to Cisco router with console, hit enter several times to get to "Router>" prompt. (After booting up router may ask you, "Would you like to enter the initial configuration dialog? [yes/no]:" just say "no" and hit enter)

CLI command modes

Cisco CLI has several command modes and each mode supports specific commands only. Most important CLI modes are as follows:

User EXEC mode:

If you see "Router>" on your terminal then you are in "user EXEC" mode. Just after the router boots-up it'll present you with "user EXEC" mode. You can execute very few show commands in this mode. Use "exit" or "logout" to come out of this mode and hence come out of CLI.

Privileged EXEC mode:
Issue "enable" command in "user EXEC" mode to navigate to "privileged EXEC" mode. Router will present you with "Router#" prompt on terminal. In this mode you can : Issue show and debug commands, copy IOS images, reload, manage configuration files and file systems. Use "exit" command to come out of this mode.

Global configuration mode:
Issue "configure terminal" in "Privileged EXEC" mode to navigate to "Global configuration" mode. Router will present you with "Router(config)#" prompt on terminal. All configuration will be done in this mode. To go back to the previous mode issue "exit" command, to go back to the "User EXEC" mode use "Ctrl + z".
    
Cisco command structure is hierarchical and hence the CLI modes are nested inside one another. As we'll dive deep in configuration, terminal prompt will change. These are advanced CLI modes and will be addressed in subsequent tutorials, following text shows few of the CLI modes available.

Router>enable
Router#exit
Router>
Router>enable
Router#configur terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#line con 0
Router(config-line)#exit
Router(config)#interface fastEthernet 0/0
Router(config-if)#exit
Router(config)# exit
Router#

One point to note here is "show" commands are available with "privileged EXEC" and not in "Global config." mode, but you can run it with “do” command in “Global config.” We’ll discuss this later in this tutorial.



Getting help from CLI

                Getting help from CLI about commands and its use is very simple, just remember the most powerful tool “?”. Following table shows how to use “?”.

Examples

# Help with “?” - List all the available command in current CLI mode.

Router#?
Exec commands:
  access-enable        Create a temporary Access-List entry
  access-profile       Apply user-profile to interface
  access-template      Create a temporary Access-List entry
  alps                 ALPS exec commands
#-- output truncated

# Help with <partial string>? - To get all possible commands after particular string.

Router(config)#
Router(config)#rout?
route-map  router

# Help with command ? - To list all possible parameters available after command.

Router(config)#router ?
  bgp       Border Gateway Protocol (BGP)
  eigrp     Enhanced Interior Gateway Routing Protocol (EIGRP)
  isis      ISO IS-IS
#-- output truncated

# Help with <partial string><TAB> - To complete command (If string is unique)

Router#
Router#conf<TAB>
Router#configure
Router#

Note: If you see “<CR>” after hitting “?” on CLI it means “carriage return” in short hit “enter” key.

Line console 0

                Line con 0 is the entity where Cisco IOS holds the user session connected via console port. Execute “show user” command in “privileged EXEC” mode to see the number of users logged in to Cisco router. * mark show the current active login. Here is an example of “show users” command.

Router#show users
    Line       User       Host(s)              Idle       Location
*  0 con 0                idle                 00:00:00

  Interface    User               Mode         Idle     Peer Address

To see the settings of the line console 0 type command “show line console 0” on Router# prompt. It shows detailed information about console settings, I’ve truncated the output here.

Router#show line console 0
   Tty Typ     Tx/Rx    A Modem  Roty AccO AccI   Uses   Noise  Overruns   Int
*     0 CTY              -    -      -    -    -      0       1     0/0       -

Line 0, Location: "", Type: ""
Length: 24 lines, Width: 80 columns
Status: PSI Enabled, Ready, Active, Automore On
Capabilities: none
Modem state: Ready
Group codes:    0
Special Chars: Escape  Hold  Stop  Start  Disconnect  Activation
                ^^x    none   -     -       none
Timeouts:      Idle EXEC    Idle Session   Modem Answer  Session   Dispatch
                never         never                        none     not set
                            Idle Session Disconnect Warning
                              never
                            Login-sequence User Response
                             00:00:30
                            Autoselect Initial Wait
                              not set
#--Output truncated.
Router#

         To see the configuration of the “line console 0” use following command in “privileged EXEC” mode.
Router#show running-config | begin line
line con 0
 stopbits 1
line aux 0
line vty 0 4

          By default Cisco router will terminate the console session after 10 minute of the idle time and some logging messages may come up while you are typing commands on CLI. We’ll configure router to avoid it.

Router#show configuration
#--Output truncated.
!
line con 0                                    # Go to line console 0
exec-timeout 0 0                          # Never terminate console session
logging synchronous                      # Sync messages on CLI prompt
#--Output truncated.

Disclaimer

I'm not authorized CISCO guy and I don't have any of the CISCO certifications. This blog is result of my enthusiasm, desire and hard work to lean networking and share my leanings. Most of the times I’ll be using GNS3 network simulator. All I've here is collection of my findings, thanks to Google. Please do not ask for any of the software from CISCO, it's better to Google it and try your luck.