Exploring Cisco NX-OS CLI
Although the graphical user interface is visually intuitive and easier to understand for beginners, the device command-line interface (CLI) is still the most reliable configuration interface available. It can work on slow and erratic connections, uses simple protocols that are easy to establish, and provides clear and reliable feedback on actions taken. It is the essential tool in data center configuration regardless of whether or not a graphical interface is available.
Exploring NX-OS Command Modes
Once you first access an NX-OS device using either console port or vty lines via telnet or ssh, the Cisco NX-OS software places you in EXEC mode, as shown in Example 2-1. The commands available in EXEC mode include the show commands, which display the device status and configuration information, the clear commands, and other commands that perform actions you do not save in the device configuration.
Example 2-1 EXEC Mode
login as:
admin
Password:******
Cisco Nexus Operating System (NX-OS) Software
TAC support: http://www.cisco.com/tac
Copyright (C) 2002-2020, Cisco and/or its affiliates.
All rights reserved.
The copyrights to certain works contained in this software are
owned by other third parties and used and distributed under their own
licenses, such as open source. This software is provided “as is,” and unless
otherwise stated, there is no warranty, express or implied, including but not
limited to warranties of merchantability and fitness for a particular purpose.
Certain components of this software are licensed under
the GNU General Public License (GPL) version 2.0 or
GNU General Public License (GPL) version 3.0 or the GNU
Lesser General Public License (LGPL) Version 2.1 or
Lesser General Public License (LGPL) Version 2.0.
A copy of each such license is available at
http://www.opensource.org/licenses/gpl-2.0.php and
http://opensource.org/licenses/gpl-3.0.html and
http://www.opensource.org/licenses/lgpl-2.1.php and
http://www.gnu.org/licenses/old-licenses/library.txt.
N9K#
Global configuration mode provides access to the broadest range of commands. The term indicates characteristics or features that affect the device as a whole. You can enter commands in global configuration mode to configure your device globally or to enter more specific configuration modes to configure specific elements such as interfaces or protocols.
Example 2-2 illustrates global configuration mode. The global configuration mode can be enabled using the command configure terminal.
Example 2-2 Global Configuration Mode
Click here to view code image
N9K#
configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
N9K(config)#
To configure interfaces on your device, you must specify the interface and enter interface configuration mode from global configuration mode, as shown in Example 2-3. You can enable many features on a per-interface basis. Interface configuration commands modify the operation of the interfaces on the device, such as Ethernet interfaces or management interfaces (mgmt0).
Example 2-3 Interface Configuration Mode
Click here to view code image
N9K(config)#
interface Ethernet 1/3
N9K(config-if)#
From global configuration mode, you can access a configuration submode for configuring VLAN interfaces called subinterfaces. In subinterface configuration mode, you can configure multiple virtual interfaces on a single physical interface. Subinterfaces appear to a protocol as distinct physical interfaces. Subinterfaces also allow multiple encapsulations for a protocol on a single interface. For example, you can configure IEEE 802.1Q encapsulation to associate a subinterface with a VLAN.
Example 2-4 illustrates subinterface configuration mode, which is enabled by specifying a subinterface from global configuration mode.
Example 2-4 Subinterface Configuration Mode
N9K(config)#
interface Ethernet 1/2.1
N9K(config-subif)#
The Cisco NX-OS software allows you to save the current command mode, configure a feature, and then restore the previous command mode. The push command saves the command mode, and the pop command restores the command mode.
Example 2-5 shows how to save and restore a command mode using the push and pop commands.
Example 2-5 The push and pop Commands
N9K#
configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
N9K(config)#
interface Ethernet 1/2.1
N9K(config-subif)#
push
N9K(config-subif)#
end
N9K#
pop
Enter configuration commands, one per line. End with CNTL/Z.
N9K(config-subif)#
To exit a configuration command mode, you can use either the exit or end command. The exit command exits from the current configuration command mode and returns to the previous configuration command mode, as shown in Example 2-6.
Example 2-6 The exit Command
N9K (config-if)#
exit
N9K (config)#
The end command exits from the current configuration command mode and returns to EXEC mode, as shown in Example 2-7.
Example 2-7 The end Command
Click here to view code image N9K (config-if)#
end
N9K #