Chapter 4 Using The Command-Line Interface
Chapter 4 Using The Command-Line Interface
• The switch does what the command says, and in some cases, the
switch replies with some messages stating the results of the
command.
CLI
• Cisco Catalyst switches also support other methods to both monitor
and configure a switch.
• Each switch series includes several specific models of switches that have
similar features, similar price-versus-performance tradeoffs, and similar
internal components.
• For example, at the time this book was published, the Cisco 2960-XR series
of switches was a current switch model series.
• Each switch series includes several models, with a mix of features. For
example, some of the switches have 48 RJ-45 unshielded twisted-pair
(UTP) 10/100/1000 ports, meaning that these ports can
autonegotiate the use of 10BASE-T (10 Mbps), 100BASE-T (100
Mbps), or 1000BASE-T (1 Gbps) Ethernet.
• Cisco refers to a switch’s physical connectors as either interfaces or
ports, with an interface type and interface number. The interface
type, as used in commands on the switch, is either Ethernet, Fast
Ethernet, Gigabit Ethernet, and so on for faster speeds.
• Cisco IOS Software for Catalyst switches implements and controls logic and
functions performed by a Cisco switch. Besides controlling the switch’s
performance and behavior, Cisco IOS also defines an interface for humans
called the CLI.
• The Cisco IOS CLI allows the user to use a terminal emulation program,
which accepts text entered by the user. When the user presses Enter, the
terminal emulator sends that text to the switch. The switch processes the
text as if it is a command, does what the command says, and sends text
back to the terminal emulator.
• The switch CLI can be accessed through three popular methods—the
console, Telnet, and Secure Shell (SSH).
• Two of these methods (Telnet and SSH) use the IP network in which
the switch resides to reach the switch. The console is a physical port
built specifically to allow access to the CLI. Figure 4-2 depicts the
options.
• Console access requires both a physical connection between a PC (or
other user device) and the switch’s console port, as well as some
software on the PC.
• Telnet and SSH require software on the user’s device, but they rely on
the existing TCP/IP network to transmit data.
• The next few pages detail how to connect the console and set up the
software for each method to access the CLI.
CABLING THE CONSOLE CONNECTION
• The physical console connection, both old and new, uses three main
components:
• Cisco has been including USB ports as console ports in newer routers
and switches as well.
• All you have to do is look at the switch to make sure you have the
correct style of USB cable end to match the USB console port.
• In the simplest form, you can use any USB port on the PC, with a USB
cable, connected to the USB console port on the switch or router, as
shown on the far right side of Figure 4-3.
Original Rollover cable
Rollover cable and USB Converter
USB Console Cable
• Older console connections use a PC serial port that pre-dates USB, a
UTP cable, and an RJ-45 console port on the switch, as shown on the
left side of Figure 4-3. The PC serial port typically has a D-shell
connector (roughly rectangular) with nine pins (often called a DB-9).
• The console port looks like any Ethernet RJ-45 port (but is typically
colored in blue and with the word console beside it on the switch).
• The 2960-XR series, for instance, supports both the older RJ-45
console port and a USB console port.
• Figure 4-4 points to the two console ports; you would use only one or
the other. Note that the USB console port uses a mini-B port rather
than the more commonly seen rectangular standard USB Type A port.
• After the PC is physically connected to the console port, a terminal
emulator software package must be installed and configured on the
PC. The terminal emulator software treats all data as text.
• It accepts the text typed by the user and sends it over the console
connection to the switch. Similarly, any bits coming into the PC over
the console connection are displayed as text for the user to read.
• The emulator must be configured to use the PC’s serial port to match
the settings on the switch’s console port settings. The default console
port settings on a switch are as follows.
Note that the last three parameters are referred to collectively as 8N1:
■ 9600 bits/second
■ No hardware flow control
■ 8-bit ASCII
■ No parity bits
■ 1 stop bit
• In this example I am using PuTTy as the emulator
ACCESSING THE CLI WITH TELNET AND SSH
• Terminal emulators support a variety of TCP/IP applications as well,
including Telnet and SSH.
• Telnet and SSH both allow the user to connect to another device’s CLI,
but instead of connecting through a console cable to the console
port, the traffic flows over the same IP network that the networking
devices are helping to create.
• Think of SSH as the much more secure Telnet cousin. SSH encrypts
the contents of all messages, including the passwords, avoiding the
possibility of someone capturing packets in the network and stealing
the password to network devices.
USER AND ENABLE (PRIVILEGED) MODES
• All three CLI access methods covered so far (console, Telnet, and SSH) place the user in
an area of the CLI called user EXEC mode.
• User EXEC mode, sometimes also called user mode, allows the user to look around but
not break anything. The “EXEC mode” part of the name refers to the fact that in this
mode, when you enter a command, the switch executes the command and then displays
messages that describe the command’s results.
• Cisco IOS supports a more powerful EXEC mode called enable mode (also known as
privileged mode or privileged EXEC mode). Enable mode gets its name from the enable
command, which moves the user from user mode to enable mode, as shown in Figure 4-
6.
• The other name for this mode, privileged mode, refers to the fact that powerful (or
privileged) commands can be executed there. For example, you can use the reload
command, which tells the switch to reinitialize or reboot Cisco IOS, only from enable
mode.
• Example 4-1 demonstrates the differences between user and enable
modes.
PASSWORD SECURITY FOR CLI ACCESS FROM THE
CONSOLE
• The enable secret Cisco123 configuration command defines the
password that all users must use to reach enable mode.
• You can use several very easy, convenient tools to help remember commands and
save time typing. As you progress through your Cisco certifications, the exams will
cover progressively more commands. However, you should know the methods of
getting command help.
• Table 4-2 summarizes command-recall help options available at the CLI. Note
that, in the first column, command represents any command. Likewise, parm
represents a command’s parameter.
• For example, the second row lists command ?, which means that commands such
as show ? and copy ? would list help for the show and copy commands,
respectively.
• When you enter the ?, the Cisco IOS CLI reacts immediately; that is,
you don’t need to press the Enter key or any other keys.
• The device running Cisco IOS also redisplays what you entered before
the ? to save you some keystrokes. If you press Enter immediately
after the ?, Cisco IOS tries to execute the command with only the
parameters you have entered so far.
• The CLI allows you to move backward and forward in the historical list
of commands and then edit the command before reissuing it.
• These key sequences can help you use the CLI more quickly on the
exams. Table 4-3 lists the commands used to manipulate previously
entered commands.
THE DEBUG AND SHOW COMMANDS
• By far, the single most popular Cisco IOS command is the show
command. The show command has a large variety of options, and
with those options, you can find the status of almost every feature of
Cisco IOS.
• Essentially, the show command lists the currently known facts about
the switch’s operational status. The only work the switch does in
reaction to show commands is to find the current status and list the
information in messages sent to the user.
• For example, consider the output from the show mac address-table
dynamic command listed in Example 4-3.
• This show command, issued from user mode, lists the table the
switch uses to make forwarding decisions.
• A switch’s MAC address table basically lists the data a switch uses to
do its primary job.
• The debug command also tells the user details about the operation of
the switch. However, while the show command lists status
information at one instant of time—more like a photograph— the
debug command acts more like a live video camera feed.
• Configuration mode is another mode for the Cisco CLI, similar to user mode and
privileged mode. User mode lets you issue nondisruptive commands and displays
some information.
• Figure 4-7 illustrates the relationships among configuration mode, user EXEC
mode, andprivileged EXEC mode.
CONFIGURATION SUBMODES AND CONTEXTS
• Configuration mode itself contains a multitude of commands. To help
organize the configuration, IOS groups some kinds of configuration
commands together.
• To do that, when using configuration mode, you move from the initial
mode—global configuration mode—into subcommand modes.
Context-setting commands move you from one configuration
subcommand mode, or context, to another.
DEMONSTRATE
• When you begin practicing with the CLI with real equipment, the
navigation between modes can become natural.
• The text inside parentheses in the command prompt identifies the
configuration mode. For example, the first command prompt after
you enter configuration mode lists (config), meaning global
configuration mode.
• Cisco switches contain random access memory (RAM) to store data while
Cisco IOS is using it, but RAM loses its contents when the switch loses
power or is reloaded.
• To store information that must be retained when the switch loses power or
is reloaded, Cisco switches use several types of more permanent memory,
none of which has any moving parts.
• However, if the switch lost power right after that example, all that
configuration would be lost. If you want to keep that configuration,
you have to copy the running-config file into NVRAM, overwriting the
old startup-config file.
COPYING AND ERASING CONFIGURATION FILES
• The configuration process updates the running-config file, which is
lost if the router loses power or is reloaded.
• write erase
• erase startup-config
• erase nvram:
• Once the startup-config file is erased, you can reload or power off/on
the switch, and it will boot with the now-empty startup configuration.
• Note that Cisco IOS does not have a command that erases the
contents of the running-config file. To clear out the running-config
file, simply erase the startup-config file, and then reload the switch,
and the running-config will be empty at the end of the process.
THE END.