C H A P T E R  2

Using the Command-Line Interface

The command-line interface (CLI) is a text-based way to manage and monitor the switch and system. You can access the CLI by using a direct serial connection or by using a remote logical connection with telnet or SSH.

For detailed information about using the CLI with the switch’s software commands, refer to the Sun Netra CP3240 Switch Software Reference Manual (820-3253).

This chapter describes the CLI syntax, conventions, and modes. It contains the following sections:


Command Syntax

A command is one or more words that might be followed by one or more parameters. Parameters can be required or optional values.

Some commands, such as show network or clear vlan, do not require parameters. Other commands, such as network parms, have parameters for which you must supply a value. Parameters are positional--you must type the values in the correct order. Optional parameters will follow required parameters. Following are two examples.


network parms <ipaddr> <netmask> [gateway]

In the preceding example, <ipaddr> and <netmask> are the required values for the command, and [gateway] is the optional value for the command.


snmp-server location <loc>

In the second example, <loc> is the required parameter for the command.


Command Conventions

The following conventions apply to the command name:

This reference manual lists each command by the command name and provides a brief description of the command. Each command entry contains the following information:

The show commands also contain a description of the information that the command shows.


Parameter Conventions

The following conventions apply to parameters:

Parameter Value Types describes the conventions this document uses to distinguish between value types.

 


TABLE 2-1 Parameter Value Types

Symbol

Example

Description

<> angle brackets

<value>

Indicates that you must enter a value in place of the brackets and text inside them.

[] square brackets

[value]

Indicates an optional parameter that you can enter in place of the brackets and text inside them.

{} curly braces

{choice1 | choice2}

Indicates that you must select a parameter from the list of choices.

| Vertical bars

choice1 | choice2

Separates the mutually exclusive choices.

[{}] Braces within square brackets

[{choice1 | choice2}]

Indicates a choice within an optional element.



Parameter Values

The following conventions apply to the values of the common parameters. Common Parameter Values describes common parameter values and formatting.

 

TABLE 2-2 Common Parameter Values

Parameter

Description

ipaddr

This parameter is a valid IP address. You can enter the IP address in the following formats:

  • a (32 bits)
  • a.b (8.24 bits)
  • a.b.c (8.8.16 bits)
  • a.b.c.d (8.8.8.8)

In addition to these formats, the CLI accepts decimal, hexidecimal and octal formats through the following input formats (where n is any valid hexidecimal, octal or decimal number):

  • 0xn (CLI assumes hexidecimal format)
  • 0n (CLI assumes octal format with leading zeros)
  • n (CLI assumes decimal format)

ipv6-address

FE80:0000:0000:0000:020F:24FF:FEBF
DBCB, or
FE80:0:0:0:20F:24FF:FEBF:DBCB, or
FE80::20F24FF:FEBF:DBCB, or
FE80:0:0:0:20F:24FF:128:141:49:32

For additional information, refer to RFC 3513.

areaid

Enter area IDs in dotted-decimal notation (for example, 0.0.0.1).

  • An area ID of 0.0.0.0 is reserved for the backbone.
  • Area IDs have the same format as IP addresses but are distinct from IP addresses.
  • You can use the IP network number of the sub-netted network for the area ID.

routerid

Enter the value of <routerid> in dotted-decimal notation, such as 0.0.0.1. A router ID of 0.0.0.0 is invalid.

Interface or
slot/port

Valid slot and port number separated by forward slashes. For example, 0/1 represents slot number 0 and port number 1.

Logical Interface

Represents a Logical slot and port number.. This is applicable in the case of a port-channel (LAG). You can use the logical slot/port to configure the port-channel.

Character strings

Use double quotation marks to identify character strings, for example, “System Name with Spaces.” An empty string (“”) is not valid.



Slot/Port Naming Convention

Sun Netra CP3240 switch software references physical entities such as cards and ports by using a slot/port naming convention. The Sun Netra CP3240 switch software also uses this convention to identify certain logical entities, such as Port-Channel interfaces.

The slot number has two uses. In the case of physical ports, it identifies the card containing the ports. In the case of logical and CPU ports, it also identifies the type of interface or port.


TABLE 2-3 Slot Types

Slot Type

Description

Physical slot numbers

Physical slot numbers begin with zero, and are allocated up to the maximum number of physical slots.

Logical slot numbers

Logical slots immediately follow physical slots and identify port-channel (LAG) or router interfaces.

CPU slot numbers

The CPU slots immediately follow the logical slots.


The port identifies the specific physical port or logical interface being managed on a given slot.

 


TABLE 2-4 Port Types

Port Type

Description

Physical Ports

The physical ports for each slot are numbered sequentially starting from zero.

Logical Interfaces

Port-channel or Link Aggregation Group (LAG) interfaces are logical interfaces that are only used for bridging functions.

VLAN routing interfaces are only used for routing functions.

Loopback interfaces are logical interfaces that are always up.

Tunnel interfaces are logical point-to-point links that carry encapsulated packets.

CPU ports

CPU ports are handled by the driver as one or more physical entities located on physical slots.




Note - In the CLI, loopback and tunnel interfaces do not use the slot/port format. To specify a loopback interface, you use the loopback ID. To specify a tunnel interface, you use the tunnel ID.



‘No’ Form of a Command

The no keyword is a specific form of an existing command and does not represent a new or distinct command. Almost every configuration command has a no form.

In general, use the no form to reverse the action of a command or reset a value back to the default. For example, the no shutdown configuration command reverses the shutdown of an interface.

Use the command without the keyword no to re-enable a disabled feature or to enable a feature that is disabled by default.

The behavior of the “?” and the help text are the same for the no keyword:


Command Modes

The CLI groups commands into modes according to the command function. Each of the command modes supports specific Sun Netra CP3240 switch software commands. The commands in one mode are not available until you switch to that particular mode, with the exception of the User EXEC mode commands. You can execute the User EXEC mode commands in the Privileged EXEC mode.

For detailed information about using the CLI with the switch’s software commands and modes, refer to the Sun Netra CP3240 Switch Software Reference Manual (820-3253).

The command prompt changes in each command mode to help you identify the current mode.

TABLE 2-5 lists the command modes, the prompts visible in each mode, and the exit method from that mode.

Topology is described in Mode-Based Topology.

Descriptions and hierarchy of each mode are in Mode-Based Command Hierarchy.


TABLE 2-5 CLI Command Modes

Command Mode

Access Method

Prompt

Exit or Access Previous Mode

User Exec

This is the first level of access for performing basic tasks and listing system information.

Switch>

Enter logout command

Privileged Exec

From the User Exec mode, enter the enable command.

Switch#

Type exit or press Ctrl-Z to exit to the User Exec mode.

Global Config

From the Privileged Exec mode, enter the configure command.

Switch(Config)#

Type exit to exit to the Privileged Exec mode, or press Ctrl-Z to switch to the User Exec mode.

VLAN Config

From the Privileged Exec mode, enter the vlan database command.

Switch(Vlan)#

Type exit to exit to the Privileged Exec mode, or press Ctrl-Z to switch to the User Exec mode.

Interface Config

From the Global Config mode, enter the interface <slot/port> command.

Switch (Interface <slot/port>)#

 

Switch (Interface Loopback <id>)#

 

Switch (Interface Tunnel <id>)#

Type exit to exit to the Global Config mode, or press Ctrl-Z to switch to the User Exec mode.

Line Config

From the Global Config mode, enter the lineconfig command.

Switch (line)#

Type exit to exit to the Global Config mode, or press Ctrl-Z to switch to the User Exec mode.

Policy Map Config

From the Global Config mode, enter the policy-map <policy-name> command.

Switch (Config-policy-map)#

Type exit to exit to the Global Config mode, or press Ctrl-Z to switch to the User Exec mode.

Policy Class Config

From the Policy Map mode, enter the class command.

Switch (Config-policy-class-map)#

Type exit to exit to the Policy Map mode, or press Ctrl-Z to switch to the User Exec mode.

Class Map Config

From the Global Config mode, enter the class-map <class-map-name> command.

Switch (Config-class-map)#

Type exit to exit to the Global Config mode, or press Ctrl-Z to switch to the User Exec mode.

Router OSPF Config

From the Global Config mode, enter the router ospf command.

Switch (Config-router)#

Type exit to exit to the Global Config mode, or press Ctrl-Z to switch to the User Exec mode.

Router OSPFv3 Config

From the Global Config mode, enter the ipv6 router ospf command.

Switch (Config-rtr)#

Type exit to exit to the Global Config mode, or press Ctrl-Z to switch to the User Exec mode.

Router RIP Config

From the Global Config mode, enter the router rip command.

Switch (Config-router)#

Type exit to exit to the Global Config mode, or press Ctrl-Z to switch to the User Exec mode.

Router BGP Config

From the Global Config mode, enter the router bgp <asnumber> command.

Switch (Config-router)#

Type exit to exit to the Global Config mode, or press Ctrl-Z to switch to the User Exec mode.

MAC Access-list
Config

From the Global Config mode, enter mac access-list extended <name>.

Switch (Config-mac-access-list)#

Type exit to exit to the Global Config mode, or press Ctrl-Z to switch to the Privileged EXEC mode.

TACACS Config

From the Global Config mode, enter tacacs-server host <ip-addr>, where <ip-addr> is the IP address of the TACACS server on your network.

Switch (Tacacs)#

Type exit to exit to the Global Config mode, or press Ctrl-Z to switch to the Privileged EXEC mode.

DHCP Pool Config

From the Global Config mode, enter the ip dhcp pool <pool-name> command.

Switch (Config-dhcp-pool)#

Type exit to exit to the Global Config mode, or press Ctrl-Z to switch to the Privileged EXEC mode.

DHCPv6 Pool Config

From the Global Config mode, enter the ip dhcp pool <pool-name> command.

Switch (Config-dhcp6-pool)#

Type exit to exit to the Global Config mode, or press Ctrl-Z to switch to the Privileged EXEC mode.


Mode-Based Topology

The CLI tree is built on a mode concept in which the commands are available according to the interface. Some of the modes in the mode-based CLI are depicted in FIGURE 2-1.



Note - The User Exec commands are also accessible in the Privileged Exec Mode.




Note - Access to all commands in the Privileged Exec mode and below is restricted through a password.


FIGURE 2-1 Mode-based CLI


Mode-Based Command Hierarchy

The commands in one mode are not available until the operator switches to that particular mode, with the exception of the User Exec mode commands. The User Exec mode commands can also be executed in the Privileged Exec mode.

The commands available to the operator at any time depend upon the mode. Entering a question mark (?) at the CLI prompt displays a list of the currently available commands and descriptions of the commands.

User Exec Mode

When the operator logs in to the CLI, the User Exec mode is the initial mode. The User Exec mode contains a limited set of commands. The command prompt shown at this level is $ Switch>

Privileged Exec Mode

To have access to the full suite of commands, the operator must enter the Privileged Exec mode. The Privileged Exec mode requires password authentication. From Privileged Exec mode, the operator can issue any Exec command, enter the VLAN mode or enter the Global Config mode. The command prompt shown at this level is $ Switch#

Global Config Mode

This mode permits the operator to make modifications to the running configuration. General setup commands are grouped in this mode. From the Global Config mode, the operator can enter the System Config mode, the Physical Port Config mode, the Interface Config mode, or the protocol-specific modes. The command prompt at this level is $ Switch (Config)#

From the Global Config mode, the operator can enter the following protocol-specific modes configuration modes.

Interface Config

Many features are enabled for a particular interface. The Interface commands enable or modify the operation of an interface.

This mode allows you to enable or modify the operation of an interface and provides access to the router interface configuration commands.

Use this mode to set up a physical port for a specific logical connection operation.

In this mode, a physical port is set up for a specific logical connection operation. The Interface Config mode provides access to the router interface configuration commands. The command prompt at this level is $ Switch (Interface <slot/port>)#

The resulting prompt for the interface configuration command entered in the Global Configuration mode is $ Switch (Interface Loopback <id> and $ Switch (Interface Tunnel <id>.

Line Config

This mode allows the operator to configure the console interface. The operator can configure the interface from the directly connected console or the virtual terminal used with Telnet. The command prompt at this level is $ Switch(line)#

Policy Map Config

Use the policy-map <policy-name> command to access the QoS policy map configuration mode to configure the QoS policy map.

$ Switch (Config)# policy map <policy-name>

$ Switch (Config-policy-map)#

Policy Class Config

Use the class <class-name> command to access the QoS policy-classmap mode to attach or remove a diffserv class to a policy and to configure the QoS policy class.

$ Switch (Config policy-map)# class <class-name>

$ Switch (Config-policy-classmap)#

Class Map Config

This mode consists of class creation, deletion, and matching commands. The class match commands specify layer 2, layer 3, and general match criteria. Use the class-map <class-map-name> commands to access the QoS class map configuration mode to configure QoS class maps.

$ Switch (Config)# class-map <class-map-name>

$ Switch (Config class-map)#

Router OSPF Config

In this mode, the operator is allowed to access the router OSPF configuration commands. The command prompt at this level is:

$ Switch (Config)# router ospf

$ Switch (Config-router) #

Router OSPFv3 Config

In this mode, the operator is allowed to access the router OSPFv3 configuration commands. The command prompt at this level is:

$ Switch (Config)# rtr ospf

$ Switch (Config-rtr) #

Router RIP Config

In this mode, the operator is allowed to access the router RIP configuration commands. The command prompt at this level is:

$ Switch (Config)# router rip

$ Switch (Config router)#

Router BGP Config

In this mode, the operator is allowed to access the router BGP-4 configuration commands. The command prompt at this level is:

$ Switch (Config)# router bgp <1-65535>

$ Switch (Config-routerbgp)#

MAC Access-list Config

In this mode, the operator is allowed to create a MAC Access-list and to enter the mode containing Mac Access-list configuration commands. The command prompt at this level is:

$ Switch (Config)# mac access-list extended <name>

$ Switch (Config-mac-access-list) #

TACACS Config

In this mode, the operator is allowed to configure properties for the TACACS servers. The command prompt at this level is:

$ Switch (Config)# tacacs-server host <ip-addr>

$ Switch (Tacacs) #

DHCP Pool Config

Use the ip dhcp pool <pool-name> command to access the DHCP Pool Config mode.

$ Switch (Config)# ip dhcp pool <pool-name>

$ Switch (Config-dhcp-pool)#

DHCPv6 Pool Config

Use the ip dhcp pool <pool-name> command to access the DHCP Pool Config mode.

$ Switch (Config)# ip dhcpv6 pool <pool-name>

$ Switch (Config-dhcp6-pool)#

VLAN Mode

This mode groups all the commands pertaining to VLANs. The command prompt shown at this level is $ Switch (Vlan)#


Operation Flow

This section captures the flow of operation for the CLI.

1. The operator logs in to the CLI session and enters the User Exec mode. In the User Exec mode, the $(exec)> prompt is displayed on the screen.

The parsing process is initiated whenever the operator types a command and presses Enter. The command tree is searched for the command of interest. If the command is not found, the output message indicates where the offending entry begins. For instance, if command node A has the command show arp brief but the operator attempts to execute the command show arpp brief, the output message is $(exec)> show arpp brief^. $%Invalid input detected at '^' marker.

If the operator has given an invalid input parameter in the command, the message conveys to the operator that an invalid input was detected. The layout of the output is:


(exec) #show arpp brief
                ^
%Invalid input detected at ‘^’ marker.

After all the mandatory parameters are entered, any additional parameters entered are treated as optional parameters. If any of the parameters are not recognized, a syntax error message is displayed.

2. After the command is successfully parsed and validated, the control of execution goes to the corresponding CLI callback function.

3. For mandatory parameters, the command tree extends until the mandatory parameters make the leaf of the branch. The callback function is invoked only when all the mandatory parameters are provided. For optional parameters, the command tree extends until the mandatory parameters and the optional parameters make the leaf of the branch. However, the callback function is associated with the node where the mandatory parameters are fetched. The callback function then takes care of the optional parameters.

4. Once the control has reached the callback function, the callback function has complete information about the parameters entered by the operator.


Command Completion and Abbreviation

Command completion finishes spelling the command when you have typed enough letters of a command to uniquely identify the command word. You can execute the command by pressing the Enter key (command abbreviation) or you can complete the command word by pressing the Tab or spacebar keys (command completion).

The value “Er” designates that the requested value was not internally accessible. This should not happen and indicates that the software is not handling this instance correctly.

The value of “-----” designates that the value is unknown.


CLI Error Messages

If you enter a command and the system is unable to execute it, an error message appears. CLI Error Messages describes the most common CLI error messages.

 


TABLE 2-6 CLI Error Messages

Message Text

Description

% Invalid input detected at '^' marker.

Indicates that you entered an incorrect or unavailable command. The carat (^) shows where the invalid text is detected. This message also appears if any of the parameters or values are not recognized.

Command not found / Incomplete command. Use ? to list commands.

Indicates that you did not enter the required keywords or values.

Ambiguous command

Indicates that you did not enter enough letters to uniquely identify the command.



CLI Line-Editing Conventions

CLI Editing Conventions describes the key combinations you can use to edit commands or increase the speed of command entry. You can access this list from the CLI by entering help from the User or Privileged EXEC modes.

 


TABLE 2-7 CLI Editing Conventions

Key Sequence

Description

DEL or Backspace

Delete previous character

Ctrl-A

Go to beginning of line

Ctrl-E

Go to end of line

Ctrl-F

Go forward one character

Ctrl-B

Go backward one character

Ctrl-D

Delete current character

Ctrl-U, X

Delete to beginning of line

Ctrl-K

Delete to end of line

Ctrl-W

Delete previous word

Ctrl-T

Transpose previous character

Ctrl-P

Go to previous line in history buffer

Ctrl-R

Rewrites or pastes the line

Ctrl-N

Go to next line in history buffer

Ctrl-Y

Prints last deleted character

Ctrl-Q

Enables serial flow

Ctrl-S

Disables serial flow

Ctrl-Z

Return to root command prompt

Tab, <SPACE>

Command-line completion

Exit

Go to next lower command prompt

?

List available commands, keywords, or parameters



Using CLI Help

Enter a question mark (?) at the command prompt to display the commands available in the current mode.


(switch) >?
 
enable                   Enter into user privilege mode.
help                     Display help for various special keys.
logout                   Exit this session. Any unsaved changes are lost.
ping                     Send ICMP echo packets to a specified IP address.
quit                     Exit this session. Any unsaved changes are lost.
show                     Display Switch Options and Settings.
telnet                   Telnet to a remote host.

Enter a question mark (?) after each word you enter to display available command keywords or parameters.


(switch) #network ?
 
javamode                 Enable/Disable.
mgmt_vlan                Configure the Management VLAN ID of the switch.
parms                    Configure Network Parameters of the router.
protocol                 Select DHCP, BootP, or None as the network config
                         protocol.

If the help output shows a parameter in angle brackets, you must replace the parameter with a value.


(switch) #network parms ?
 
<ipaddr>                 Enter the IP Address.

If there are no additional command keywords or parameters, or if additional parameters are optional, the following message appears in the output:


<cr>                     Press Enter to execute the command

You can also enter a question mark (?) after typing one or more characters of a word to list the available command or parameters that begin with the letters, as shown in the following example:


(switch) #show m?
 
mac-addr-table           mac-address-table        monitor


Accessing the CLI

You can access the CLI by using a direct-console connection or by using a telnet or SSH connection from a remote management host.

For the initial connection, you must use a direct connection to the console port. You cannot access the system remotely until the system has an IP address, subnet mask, and default gateway. You can set the network configuration information manually, or you can configure the system to accept these settings from a BOOTP or DHCP server on your network. For more information, see Network Interface Commands.


Comments

The CLI enables the user to type single-line annotations at the command prompt for use when writing test or configuration scripts and for better readability. The exclamation point (!) character flags the beginning of a comment. The comment flag character can begin a word anywhere on the command line and all input following this character is ignored. Any command line that begins with the character ! is recognized as a comment line and ignored by the parser.

Some examples of comments are provided in the following code.


! Script file for displaying the ip interface
! Display information about interfaces
show ip interface 0/1 !Displays the information about the first interface
! Display information about the next interface
show ip interface 0/2
! End of the script file