CLI Functionality: JUNOS CLI is a simple to use, text-based command interface. We give various commands on CLI for configuring, troubleshooting and monitoring the software.
JUNOS primarily supports two types of command modes.
a) Operational Mode: When we log in to the router and the CLI starts, we are at the top level of the CLI operational mode. In this mode, we enter the commands for
1. Controlling the CLI environment, and
2. Monitor and troubleshoot network connectivity, and
3. Initiating the Configuration Mode.
Frequently used commands in this mode include ping, show, traceroute, configure, etc.
Operational mode is indicated by the > prompt-for
example, user@switch>
b) Configuration Mode: We use the Configuration mode for configuring the JUNOS software by creating a hierarchy of configuration statements. We enter the configuration mo9+de by using the command "configure" as shown below:
user@host>configure
Entering configuration mode
[edit]
user@host#
Issuing the commands one at a time using CLI can configure a JUNOS™ router or alternately, we can configure by creating a text (ASCII) file that contains the statement hierarchy. Remember to activate the configuration by using the command "commit" on the router.
As shown in the above example, the generic configuration prompt is user@host#. Ofcourse, we can change the prompt by using appropriate command.
Statement Hierarchy: We use the above configuration mode commands to create a statement hierarchy, and then configure the JUNOS software. The term "statement hierarchy" is used to define the sequence of commands used for configuring a particular feature (or features) of the router. An example statement hierarchy is given below:
user@host>configure
Entering configuration mode
[edit] ----Top level
user@host#edit protocols ospf
[edit protocols ospf] ----protocols ospf hierarchy level
user@host#
"set" commands are used to configure specific leaf statements.
Ex: user@host#set hello-interval 14
The command 'set system services web-management' allows us to access our juniper device based on Graphical User Interface (GUI). We can either enable http based and https based web-management on Juniper devices.
CLI Help: The CLI includes several ways to get help about commands. Some examples of how to get help are as below
1. Type ? to show the top-level commands available in operational mode.
root@> ?
Possible completions:
clear - Clear information in the system
configure - Manipulate software configuration information
diagnose - Invoke diagnose script
file - Perform file operations
help - Provide help information monitor
Show - real-time debugging information
mtrace - Trace multicast path from source to receiver
ping - Ping remote target
quit - Exit the management session
request - Make system-level requests
restart - Restart software process
set - Set CLI properties, date/time, craft interface message
show - Show system information
ssh - Start secure shell on another host
start - Start shell
telnet - Telnet to another host
test - Perform diagnostic debugging
traceroute - Trace route to remote host
2. Type file ? to show all possible completions for the file command.
root@> file ?
Possible completions:
<[Enter]> Execute this command
archive - Archives files from the system
checksum - Calculate file checksum
compare - Compare files
copy - Copy files (local or remote)
delete - Delete files from the system
list - List file information
rename - Rename files
show - Show file contents source-address Local address to use in originating the connection
| - Pipe through a command
3. Type file archive ? to show all possible completions for the file archive command.
root@> file archive ?
Possible completions:
compress - Compresses the archived file using GNU gzip
(.tgz)
destination - Name of created archive (URL, local, remote, or floppy)
source - Path of directory to archive
We use 'exit' command to move down into the operational mode hierarchy once we are in configuration mode hierarchy. In other vendor devices, it may be quit, undo, etc. command used to get out of a particular hierarchy.
Configure or edit command takes us from operational mode to the configuration mode hierarchy. Edit command is the hidden command which doesn't show in our operational mode hierarchy when we enter '?' symbol.
Filtering Output: The Junos OS enables you to filter command output by adding the pipe ( | ) symbol when you enter a command. For example
user@host>show rip neighbor ?
Possible completions:
<[Enter]> Execute this command
<name> Name of RIP neighbor
instance Name of RIP instance
logical-system Name of logical system, or 'all'
| Pipe through a command
The following example lists the filters that can be used with the pipe symbol (|):
user@host>show interfaces | ?
For the show configuration command only, an additional compare filter is available:
user@host> show configuration | ?
You can enter any of the pipe filters in conjunction. For example:
user@host>command | match regular-expression | save filename
'Match' option prompts the router to display only lines in the output containing the text string we provide when used with pipe key. There are also other options used with pipe key. They are save, resolve, no-more, repeat, etc.