Junos® OS
CLI User Guide for Junos OS
Published
2024-07-12
Juniper Networks, Inc.
1133 Innovaon Way
Sunnyvale, California 94089
USA
408-745-2000
www.juniper.net
Juniper Networks, the Juniper Networks logo, Juniper, and Junos are registered trademarks of Juniper Networks, Inc.
in the United States and other countries. All other trademarks, service marks, registered marks, or registered service
marks are the property of their respecve owners.
Juniper Networks assumes no responsibility for any inaccuracies in this document. Juniper Networks reserves the right
to change, modify, transfer, or otherwise revise this publicaon without noce.
Junos® OS CLI User Guide for Junos OS
Copyright © 2024 Juniper Networks, Inc. All rights reserved.
The informaon in this document is current as of the date on the tle page.
YEAR 2000 NOTICE
Juniper Networks hardware and soware products are Year 2000 compliant. Junos OS has no known me-related
limitaons through the year 2038. However, the NTP applicaon is known to have some diculty in the year 2036.
END USER LICENSE AGREEMENT
The Juniper Networks product that is the subject of this technical documentaon consists of (or is intended for use
with) Juniper Networks soware. Use of such soware is subject to the terms and condions of the End User License
Agreement ("EULA") posted at hps://support.juniper.net/support/eula/. By downloading, installing or using such
soware, you agree to the terms and condions of that EULA.
ii
Table of Contents
About This Guide | xi
1
Overview
About the CLI Guide | 2
CLI Overview | 2
Introducing the Command-Line Interface | 3
CLI Modes, Commands, and Statement Hierarchies—An Overview | 5
Other Tools to Congure and Monitor Juniper Networks Devices | 7
Congure Junos OS in a FIPS Environment | 7
2
Geng Started
Geng Started: A Quick Tour of the CLI | 10
Get Started with the Command-Line Interface | 10
Switch Between Operaonal Mode and Conguraon Mode | 12
Use Keyboard Sequences to Navigate and Edit the CLI | 14
Congure a User Account on a Juniper Networks Device | 16
Use the CLI Editor in Conguraon Mode | 19
Check the Status of a Juniper Networks Device | 22
Roll Back Conguraon Changes | 25
Congure a Roung Protocol | 27
Shortcut | 28
Longer Conguraon | 28
Make Changes to a Roung Protocol Conguraon | 31
Online Help in the CLI | 35
Get Online Help from the Command-Line Interface | 35
CLI Online Help Features | 39
CLI Explorer Overview | 41
iii
CLI Environment Sengs | 42
Customize the CLI Environment | 42
Set the CLI Screen Length and Width | 46
Enable Conguraon Breadcrumbs | 47
3
Using Conguraon Statements to Congure a Device
CLI Conguraon Mode Overview | 51
Understanding CLI Conguraon Mode | 51
Enter and Exit CLI Conguraon Mode | 58
Relave Conguraon Mode Commands | 61
Command Compleon in Conguraon Mode | 61
Notaonal Convenons Used in Conguraon Hierarchies | 64
Overview of the Configure Command | 65
Forms of the configure Command | 65
How to Use the configure Command | 67
How to Use the configure exclusive Command | 68
How to Work with the Correct Conguraon | 71
Modify the Conguraon of a Device | 71
Display Users Currently Eding the Conguraon | 72
How to Modify the Juniper Networks Device Conguraon | 73
How to Add Conguraon Statements and Ideners | 75
How to Delete a Statement from a Device Conguraon | 76
Example: Delete a Statement from the Device Conguraon | 79
Copy a Statement in the Conguraon | 81
Example: Copy a Statement in the Conguraon | 81
Requirements | 81
Overview | 82
Conguraon | 82
iv
Example: Replace a Conguraon | 85
Requirements | 85
Overview | 85
Conguraon | 86
Insert a New Idener in a Device Conguraon | 92
Example: Insert a New Idener in a Device Conguraon | 92
Requirements | 93
Overview | 94
Conguraon | 94
Deacvate and Reacvate Statements and Ideners in a Device Conguraon | 97
Example: Deacvate and Reacvate Statements and Ideners in a Device Conguraon | 98
Requirements | 98
Overview | 98
Conguraon | 98
How to Make Global Changes in the Device Conguraon | 100
Common Regular Expressions to Use with the replace Command | 101
Example: How to Use Global Replace in a Device Conguraon—the \n Back Reference | 103
Requirements | 103
Overview | 104
Conguraon | 105
Example: Global Replace in a Device Conguraon—Replacing an Interface Name | 106
Requirements | 107
Overview | 107
Conguraon | 107
Example: Global Replace in a Device Conguraon—the upto Opon | 109
Add Comments in a Device Conguraon | 112
Add Comments in the CLI | 112
Add Comments in a File | 113
Example: Include Comments in a Device Conguraon by Using the CLI | 114
Requirements | 115
v
Overview | 115
Conguraon | 115
Example: Use the Wildcard Command with the Range Opon | 117
Requirements | 118
Overview | 118
Conguraon | 118
Use Conguraon Groups to Quickly Congure Devices | 127
Conguraon Groups Overview | 128
Congure Conguraon Groups | 129
Create a Conguraon Group | 129
How to Apply a Conguraon Group | 131
Example: Create and Apply Conguraon Groups | 132
Example: Disable Inheritance of a Conguraon Group | 134
Example: Use the junos-defaults Conguraon Group | 136
Example: Use Wildcards with Conguraon Groups | 139
How to Improve Commit Time When Using Conguraon Groups | 142
Example: Congure Sets of Statements with Conguraon Groups | 143
Example: Congure Interfaces Using Conguraon Groups | 144
Example: Use Conguraon Groups to Congure a Consistent IP Address for the Management
Interface | 147
Example: Use Conguraon Groups to Congure Peer Enes | 149
Example: Use Conguraon Groups to Establish Regional Conguraons | 151
Example: Congure Wildcard Conguraon Group Names | 152
Example: Reference the Preset Statement from the Defaults Group | 154
Example: View Default Statements That Have Been Applied to the Conguraon | 155
Set Up Roung Engine Conguraon Groups | 156
How to Use Condions to Apply Conguraon Groups | 158
vi
Example: Congure Condions for Applying Conguraon Groups | 159
Requirements | 159
Overview | 159
Conguraon | 160
View the Conguraon | 163
Display the Current Conguraon | 163
Example: Display the Current Conguraon | 164
Display Addional Informaon About the Conguraon | 166
Display set Commands from the Conguraon | 169
Verify the Device Conguraon | 173
Commit the Conguraon | 174
The Commit Model for Conguraons | 174
Commit a Device Conguraon | 176
Commit Operaon When Mulple Users Congure the Soware | 177
Commit Preparaon and Acvaon Overview | 178
Commit Device Conguraons in Two Steps: Preparaon and Acvaon | 180
Acvate a Device Conguraon with Conrmaon | 182
Schedule a Commit Operaon | 183
Monitor the Commit Process | 184
Add a Comment to Describe the Commied Conguraon | 186
Batch Commits Overview | 187
Example: Congure Batch Commit Server Properes | 188
Requirements | 188
Overview | 188
Conguraon | 189
Vericaon | 192
Back Up the Commied Conguraon on the Alternate Boot Drive | 199
4
Managing
Conguraons
vii
Conguraon Files Overview | 201
Conguraon Files Overview | 201
Device Conguraon Storage Overview | 203
Managing Conguraons | 203
The show | compare | display xml Command Output | 204
Returning to the Most Recently Commied Conguraon | 213
Returning to a Previously Commied Conguraon | 214
Example of Returning to a Previous Conguraon | 214
Example of Displaying Previous Conguraons | 214
About Comparing Conguraon Versions | 216
Using Conguraon Revision Ideners | 218
Saving a Conguraon to a File | 220
About Compressing the Current Conguraon File | 221
Free Up System Storage Space | 222
Clean Up Files with the CLI | 224
Autoinstallaon of Conguraon Files Overview | 226
Conguraon File Autoinstallaon—An Overview | 226
Conguring Autoinstallaon of Conguraon Files (CLI Procedure) | 229
Loading Conguraon Files | 231
Examples for Loading a Conguraon from a File or the Terminal | 232
How Character Encoding Works on Juniper Networks Devices | 235
About Specifying Statements and Ideners | 237
About Loading a Conguraon from a File | 241
Upload a Conguraon File | 245
Load JSON Conguraon Data With Unordered List Entries | 246
Back Up Conguraons to an Archive Site | 249
Congure the Transfer of the Acve Conguraon | 250
viii
Factory Default Conguraon Overview | 252
Restore the Default Factory Conguraon | 252
Rescue Conguraon | 253
Creang and Returning to a Rescue Conguraon | 253
Encrypt and Decrypt Conguraon Files | 255
Encrypt Conguraon Files | 255
Decrypt Conguraon Files | 257
Modify the Encrypon Key | 258
Example: Protecng the Junos OS Conguraon from Modicaon or Deleon | 259
Requirements | 259
Overview | 260
Protecng a Parent-Level Hierarchy | 260
Protecng a Child Hierarchy | 261
Protecng a Conguraon Statement Within a Hierarchy | 262
Protecng a List of Ideners for a Conguraon Statement | 263
Protecng an Individual Member from a Homogenous List | 264
Unprotecng a Conguraon | 265
Vericaon | 266
Synchronizing Conguraons Across Roung Engines | 270
Roung Engine Synchronizaon Overview | 270
Congure Mulple Roung Engines to Synchronize Commied Conguraons Automacally | 274
5
Using Operaonal Commands to Monitor Devices
CLI Operaonal Mode Overview | 278
CLI Operaonal Mode Command Overview | 278
Display Opons of the show Command—An Overview | 281
Interface Naming Convenons Used in Operaonal Commands | 282
About Group Interface Names Using Wildcard Characters | 284
ix
Using Operaonal Commands to Monitor a Device | 285
CLI Command Compleon Example | 286
Operaonal Mode Commands: Overview of Controlling the Scope | 287
Viewing Files and Directories on a Device | 289
Directories on the Device | 289
List Files and Directories | 290
Filenames and URLs | 293
Display Operang System Informaon | 295
Managing Programs and Processes Using Operaonal Mode Commands | 295
Show Soware Processes | 296
Restart the Soware Process | 297
Stop the Soware | 298
Reboot the Soware | 299
CLI Comment Character # for Operaonal Mode Commands | 300
Filtering Operaonal Command Output | 301
About Using the Pipe ( | ) Symbol to Filter Command Output | 301
Example: Use Regular Expressions with the Pipe ( | ) Symbol to Filter Command Output | 303
Example: Pipe ( | ) Filter Funcons in the Command-Line Interface | 304
Filter Operaonal Mode Command Output in a QFabric System | 318
Use Suppress-Zero Filter with the Pipe ( | ) Symbol to Filter Zero Values in Command Output | 319
6
Conguraon Statements and Operaonal Commands
Junos CLI Reference Overview | 324
x
About This Guide
The Junos OS command-line interface (CLI) is a command shell specic to Juniper Networks. This
command shell runs on top of the FreeBSD UNIX-based operang system kernel for Junos OS. Using
industry-standard tools and ulies, the CLI provides a powerful set of commands that you can use to
monitor and congure Juniper Networks devices running Junos OS. This guide contains informaon
about the CLI for Junos OS.
RELATED DOCUMENTATION
Day One: Exploring the Junos CLI
Day One: Junos for IOS Engineers
xi
1
CHAPTER
Overview
About the CLI Guide | 2
CLI Overview | 2
About the CLI Guide
The Junos OS CLI Guide explains how to use the command-line interface (CLI). This guide also describes
advanced concepts and device conguraon when working with Juniper Networks devices running
Junos OS.
In this guide, you will learn about:
Using conguraon statements to congure network devices
Managing device conguraons
Using operaonal commands to monitor devices
Syntax for conguraon statements, operaonal commands, and environmental commands
For a basic introducon to Junos OS, see the Geng Started Guide for Junos OS. It provides a high-level
descripon of Junos OS, describes how to access devices, and provides simple step-by-step instrucons
for inial device conguraon.
For a technical and detailed exploraon of Junos OS, see the Overview for Junos OS. It further explains
how Junos OS works and describes the security, conguraon, monitoring, and management of network
devices.
Another useful learning resource is Day One: Exploring the Junos CLI.
CLI Overview
IN THIS SECTION
Introducing the Command-Line Interface | 3
CLI Modes, Commands, and Statement Hierarchies—An Overview | 5
Other Tools to Congure and Monitor Juniper Networks Devices | 7
Congure Junos OS in a FIPS Environment | 7
2
The CLI is the soware interface used to access your device. You use the CLI to congure the device,
monitor its operaons, and adjust the conguraon as needed. You access the CLI through a console
connecon interface or through a network connecon.
Introducing the Command-Line Interface
IN THIS SECTION
Key Features of the CLI | 3
The Junos OS CLI is a command shell
specic to Juniper Networks that runs on top of the operang
system kernel. Through industry-standard tools and ulies, the CLI provides a powerful set of
commands that you can use to monitor and to congure devices running Junos OS.
The CLI has two modes:
Operaonal mode—Use this mode to display the current status of the device. In operaonal mode,
you enter commands to monitor and to troubleshoot the network operang system, devices, and
network connecvity.
Conguraon mode—Use this mode to congure the device. In this mode, you enter statements to
congure all properes of the device, including interfaces, general roung informaon, roung
protocols, user access, and several system and hardware properes. Junos OS stores a conguraon
as a hierarchy of conguraon statements.
When you enter conguraon mode, you are viewing and changing a le called the
candidate
conguraon
. You use the candidate conguraon le, you make conguraon changes without
causing operaonal changes to the current operang conguraon, called the
acve conguraon
.
The device does not implement the changes you added to the candidate conguraon le unl you
commit the changes. Comming the conguraon changes acvates the revised conguraon on
the device. Candidate conguraons enable you to alter your conguraon without damaging your
current network operaons.
Key Features of the CLI
The CLI commands and statements follow a hierarchical organizaon and have a regular syntax. The CLI
provides the following features to simplify CLI use:
3
Consistent command names—Commands that provide the same type of funcon have the same
name, regardless of the specic device type on which you are operang. For example, all show
commands display soware informaon and stascs, and all clear commands erase various types of
system informaon.
Lists and short descripons of available commands—The CLI provides informaon about available
commands t each level of the command hierarchy. If you type a queson mark (?) at any level, you
see a list of the available commands along with a short descripon of each. This means that if you are
already familiar with Junos OS or with other roung soware, you can use many of the CLI
commands without referring to the documentaon.
Command compleon—Command compleon for command names (keywords) and for command
opons is available at each level of the hierarchy. To complete a command or opon that you have
parally typed, press the Tab key or the Spacebar. If the parally typed leers begin a string that
uniquely idenes a command, the complete command name appears. Otherwise, a beep indicates
that you have entered an ambiguous command, and the CLI displays possible compleons.
Compleon also applies to other strings, such as lenames, interface names, usernames, and
conguraon statements.
If you have typed the mandatory arguments for execung a command in operaonal mode or
conguraon mode, the CLI displays <[Enter]> as one of the choices when you type a queson mark
(?). This output indicates that you have entered the mandatory arguments and can execute the
command at that level without specifying any further opons. Likewise, the CLI also displays <[Enter]>
when you reach a specic hierarchy level in the conguraon mode and do not need to enter any
more mandatory arguments or statements.
Industry-standard technology—With FreeBSD UNIX as the kernel, a variety of UNIX ulies are
available on the CLI. For example, you can:
Use regular expression matching to locate and to replace values and ideners in a conguraon,
to lter command output, and to examine log le entries.
Use Emacs-based key sequences to move around on a command line and scroll through the
recently executed commands and command output.
Store and archive Junos OS device les on a UNIX-based le system.
Use standard UNIX convenons to specify lenames and paths.
Exit the CLI environment and create a UNIX C shell or Bourne shell to navigate the le system,
manage router processes, and so on.
4
CLI Modes, Commands, and Statement Hierarchies—An Overview
IN THIS SECTION
CLI Command Hierarchy | 5
Conguraon Statement Hierarchy | 5
Move Among Hierarchy Levels | 6
The Junos OS CLI commands and statements are organized under two command modes and various
hierarchies. The following secons provide an overview of the CLI command modes and the command
and statement hierarchies.
CLI Command Hierarchy
CLI commands are organized in a hierarchy. Commands that perform a similar funcon are grouped
together under the same level of the hierarchy. For example, all commands that display informaon
about the system and the system soware are under the show system command. All commands that
display informaon about the roung table are under the show route command.
To execute a command, enter the full command name, starng at the top level of the hierarchy. For
example, to display a brief view of the routes in the roung table, use the command show route brief.
Conguraon Statement Hierarchy
The
conguraon statement
hierarchy has two types of statements:
Container statements
, which are
statements that contain other statements, and
leaf statements
, which do not contain other statements.
All the container statements and leaf statements together form the
conguraon hierarchy
.
The following illustraon shows a part of the hierarchy tree. The protocols statement is a top-level
statement at the trunk of the conguraon tree. The ospf, area, and interface statements are all
subordinate container statements of a higher statement; that is, they are branches of the hierarchy tree.
The hello-interval statement is a leaf on the tree.
Figure 1: Conguraon Statement Hierarchy Example
5
Move Among Hierarchy Levels
The following table shows the CLI commands you use to navigate the levels of the conguraon
statement hierarchy.
Table 1: CLI
Conguraon Mode Navigaon Commands
Command Descripon
edit
hierarchy-level
Moves to an exisng conguraon statement hierarchy or creates a hierarchy and moves
to that level.
exit
Moves up the hierarchy to the previous level where you were working. This command is,
in eect, the opposite of the edit command. Alternavely, you can use the quit command.
The exit command and the quit command are interchangeable.
up
Moves up the hierarchy one level at a me.
top
Moves directly to the top level of the hierarchy.
6
Other Tools to Congure and Monitor Juniper Networks Devices
Apart from the CLI, Junos OS also supports the following applicaons, scripts, and ulies that enable
you to congure and monitor Juniper Networks devices:
J-Web GUI—Available on select Juniper Networks devices, the J-Web GUI enables you to monitor,
congure, troubleshoot, and manage the device by means of a browser with HTTP or HTTPS
enabled. For more informaon, see the
J-Web Interface User Guide
.
Junos XML management protocol—The Junos XML management protocol enables you to monitor
and congure Juniper Networks devices. For more informaon, see the
Junos XML Management
Protocol Developer Guide
.
NETCONF API—You can also use the NETCONF XML management protocol to monitor and
congure Juniper Networks devices. For more informaon, see the NETCONF XML Management
Protocol Developer Guide.
Commit scripts and self-diagnosis features—You can dene scripts to enforce custom conguraon
rules, use commit script macros to provide simplied aliases for frequently used conguraon
statements, and congure diagnosc event policies and acons associated with each policy. For more
informaon, see the Junos OS Automaon Scripng User Guide.
MIBs—You can use enterprise-specic and standard MIBS to retrieve informaon about the hardware
and soware components on a Juniper Networks device. For more informaon about MIBs, see the
Junos OS Network Management Administraon Guide for Roung Devices.
Congure Junos OS in a FIPS Environment
With Junos-FIPS you can congure a network of Juniper Networks devices in a FIPS 140-2
environment.
The Junos-FIPS soware environment requires the installaon of FIPS soware by a Crypto Ocer. In
Junos-FIPS, some Junos OS commands and statements have restricons and some addional
conguraon statements are available. For more informaon, see the following resources:
Common Criteria and FIPS Cercaons—Provides links to guidelines for conguring Juniper
Networks devices so the secure environment complies with the requirements of public sector
cercaons such as Common Criteria and FIPS cercaon.
Compliance Advisor—A Web applicaon that provides regulatory compliance informaon about
Common Criteria, FIPS, Homologaon, ROHS2, and USGv6 for Juniper Networks products.
7
SEE ALSO
IPsec Requirements for Junos-FIPS
Conguring IPsec for Enabling Internal Communicaons Between Roung Engines for Junos OS in
FIPS Mode
8
2
CHAPTER
Geng Started
Geng Started: A Quick Tour of the CLI | 10
Online Help in the CLI | 35
CLI Environment Sengs | 42
Geng Started: A Quick Tour of the CLI
IN THIS SECTION
Get Started with the Command-Line Interface | 10
Switch Between Operaonal Mode and Conguraon Mode | 12
Use Keyboard Sequences to Navigate and Edit the CLI | 14
Congure a User Account on a Juniper Networks Device | 16
Use the CLI Editor in Conguraon Mode | 19
Check the Status of a Juniper Networks Device | 22
Roll Back Conguraon Changes | 25
Congure a Roung Protocol | 27
The following topics can help you (the network administrator) get started with the Junos OS CLI to
perform conguraon changes, switch between operaonal mode and conguraon mode, create a user
account, and execute some of the basic commands.
NOTE: If you need a basic introducon to Junos OS, see the Geng Started Guide for Junos OS.
For more in-depth informaon, as well as to learn how to use Junos OS with Juniper Networks
devices, see the Overview for Junos OS.
This Junos OS CLI Guide assumes that you are familiar with Junos OS concepts and operaon
principles.
Get Started with the Command-Line Interface
This topic shows you how to start the Junos OS CLI, view the command hierarchy, and make minor
conguraon changes.
10
NOTE: Before you begin, make sure that your device hardware is set up and Junos OS is
installed. You must have a direct console connecon to the device or network access using SSH
or Telnet. If your device is not set up, follow the installaon instrucons provided with the device
before proceeding.
To log in to a device and start the CLI:
1. Log in as root.
The root login account has superuser privileges, with access to all commands and statements.
2. Start the CLI:
root# cli
root@>
The > command prompt shows that you are in operaonal mode. Later, when you enter conguraon
mode, the prompt will change to #.
NOTE: If you are using the root account for the rst me on the device, remember that the
device ships with no password required for root. The rst me you commit a conguraon, you
must set a root password. Root access is not allowed over a telnet session. To enable root access
over an SSH connecon, you must congure the system services ssh root-login allow statement.
CLI commands can vary by plaorm and soware release. The CLI includes several ways to get help
about available commands. This secon demonstrates some examples showing how to get help:
1. Type ? to show the top-level commands available in operaonal 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
11
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 compleons 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 compleons 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
Switch Between Operaonal Mode and Conguraon Mode
When you monitor and congure a device running Junos OS, you may need to switch between modes .
When you switch between operaonal mode and conguraon mode, the command prompt also
12
changes. The operaonal mode prompt is a right-angle bracket (>). The conguraon mode prompt is a
pound or hash sign (#).
To switch between operaonal mode and conguraon mode:
1. When you log in to the device and type the cli command and press Enter, you are automacally in
operaonal mode:
---JUNOS 17.2B1.8 built 2018-05-09 23:41:29 UTC
% cli
user@host>
2. To enter conguraon mode, type the configure command or the edit command in CLI operaonal
mode. The prompt in brackets ([edit]), also known as a
banner
, shows that you are in conguraon
mode at the top of the hierarchy. For example:
user@host> configure
Entering configuration mode
[edit]
user@host#
The CLI prompt changes from user@host> to user@host#, showing that you are in conguraon mode,
and a banner appears to indicate the hierarchy level.
3. You can exit conguraon mode and return to operaonal mode in one of the following ways:
To commit the conguraon and exit:
[edit]
user@host# commit and-quit
commit complete
Exiting configuration mode
user@host>
To exit without comming:
[edit]
user@host# exit
13
Exiting configuration mode
user@host>
When you exit conguraon mode, the CLI prompt changes from user@host# to user@host>, and the
banner no longer appears. You can enter or exit conguraon mode as many mes as you wish
without comming your changes.
4. To display the output of an
operaonal mode command
such as show while in conguraon mode,
issue the run conguraon mode command. Then, specify the operaonal mode command:
[edit]
user@host# run
operational-mode-command
For example, to display the currently set priority value of the Virtual Router Redundancy Protocol
(VRRP) primary device while you are modifying the VRRP conguraon for a backup device:
[edit interfaces xe-4/2/0 unit 0 family inet vrrp-group 27]
user@host# show
virtual-address [ 192.168.1.15 ];
[edit interfaces xe-4/2/0 unit 0 family inet vrrp-group 27]
user@host# run show vrrp detail
Physical interface: xe-5/2/0, Unit: 0, Address: 192.168.29.10/24
Interface state: up, Group: 10, State: backup
Priority: 190, Advertisement interval: 3, Authentication type: simple
Preempt: yes, VIP count: 1, VIP: 192.168.29.55
Dead timer: 8.326, Master priority: 201, Master router: 192.168.29.254
[edit interfaces xe-4/2/0 unit 0 family inet vrrp-group 27]
user@host# set priority ...
Use Keyboard Sequences to Navigate and Edit the CLI
You can use keyboard sequences in the Junos OS CLI to navigate and edit the command line. You can
also use keyboard sequences to scroll through a list of recently executed commands. The following table
lists some of the CLI keyboard sequences. They are the same as those used in Emacs.
14
Table 2: CLI Keyboard Shortcuts
Keyboard sequence Acon
Ctrl+b Move the cursor back one character.
Esc+b or Alt+b Move the cursor back one word.
Ctrl+f Move the cursor forward one character.
Esc+f or Alt+f Move the cursor forward one word.
Ctrl+a Move the cursor to the beginning of the command line.
Ctrl+e Move the cursor to the end of the command line.
Ctrl+h, Delete,
or Backspace
Delete the character before the cursor.
Ctrl+d Delete the character at the cursor.
Ctrl+k Delete the all characters from the cursor to the end of the command line.
Ctrl+u or Ctrl+x Delete the all characters from the command line.
Ctrl+w, Esc+Backspace,
or Alt+Backspace
Delete the word before the cursor.
Esc+d or Alt+d Delete the word aer the cursor.
Ctrl+y Insert the most recently deleted text at the cursor.
Ctrl+l Redraw the current line.
Ctrl+p Scroll backward through the list of recently executed commands.
15
Table 2: CLI Keyboard Shortcuts
(Connued)
Keyboard sequence Acon
Ctrl+n Scroll forward through the list of recently executed commands.
Ctrl+r Search the CLI history incrementally in reverse order for lines matching the search
string.
Esc+/ or Alt+/ Search the CLI history for words for which the current word is a prex.
Esc+. or Alt+. Scroll backward through the list of recently entered words in a command line.
Esc+
number
sequence
or Alt+
number
sequence
Specify the number of mes to execute a keyboard sequence.
Congure a User Account on a Juniper Networks Device
This topic describes how to use a root account to log in to a Juniper Networks device and congure a
new user account. You can congure an account for your own use or create a test account.
To congure a new user account on the device:
1. Log in as root and enter conguraon mode:
root@host> configure
[edit]
root@host#
The ([edit]) prompt banner shows that you are in conguraon edit mode at the top of the
hierarchy.
2.
Change to the [edit system login] secon of the conguraon:
[edit]
root@host# edit system login
16
[edit system login]
root@host#
The prompt in brackets changes to [edit system login] to show that you are at a new level in the
hierarchy.
3. Now add a new user account. In the example, user1 represents a username:
[edit system login]
root@host# edit user user1
This example adds an account user1.
NOTE: User account names can contain a period (.). For example, you can have a user
account user.1. However, the username cannot begin or end with a period.
4. Congure a full name for the account. If the name includes spaces, enclose the enre name in
quotaon marks (" "):
[edit system login user user1]
root@host# set full-name "User One"
5. Congure an account class. The account class sets the user access privileges for the account:
[edit system login user user1]
root@host# set class super-user
6. Congure an authencaon method and password for the account:
[edit system login user user1]
root@host# set authentication plain-text-password
New password:
Retype new password:
When the new password prompt appears, enter a clear-text password that the system can encrypt,
and then conrm the new password.
17
7. Commit the conguraon:
[edit system login user user1]
root@host# commit
commit complete
Conguraon changes are not acve unl you commit the conguraon. If the commit is
successful, a commit complete message appears.
8. Return to the top level of the conguraon, and then exit:
[edit system login user user1]
root@host# top
[edit]
root@host# exit
Exiting configuration mode
9. Log out of the device:
root@host> exit
% logout Connection closed.
10. To test your changes, log back in with the user account and password you just congured:
login: user1
Password:
password
---JUNOS 17.2B1.8 built 2018-05-09 23:41:29 UTC
user1@host>
When you log in, you should see the new username at the command prompt.
You have successfully used the CLI to view the device status and perform a simple conguraon change.
NOTE: For complete informaon about the commands to issue to congure your device,
including examples, see the Junos OS conguraon guides.
18
Use the CLI Editor in Conguraon Mode
This topic describes basic commands that you can use to enter conguraon mode in the CLI editor. The
topic also describes commands that you use to navigate the conguraon hierarchy, get help, and
commit or revert the changes that you make during the conguraon session.
Task Command/
Statement
Example
Edit Your Conguraon
Enter conguraon mode.
When you start the CLI, the device is
in operaonal mode. You must
explicitly enter conguraon mode.
When you do, the CLI prompt changes
from user@host> to user@host#, and the
hierarchy level appears in square
brackets.
configure
user@host> configure
[edit]
user@host#
Create a statement hierarchy.
You can use the edit command to
simultaneously create a hierarchy and
move to that new level in the
hierarchy. You cannot use the edit
command to change the value of
ideners.
edit
hierarchy-
level value
[edit]
user@host# edit security zones security-zone myzone
[edit security zones security-zone myzone]
user@host#
Create a statement hierarchy, and set
idener values.
The set command is like edit, except
that your current level in the hierarchy
does not change.
set
hierarchy-
level value
[edit]
user@host# set security zones security-zone myzone
[edit]
user@host#
Navigate the Hierarchy
19
(Connued)
Task Command/
Statement
Example
Navigate down to an exisng
hierarchy level.
edit
hierarchy-
level
[edit]
user@host# edit security zones
[edit security zones]
user@host#
Navigate up one level in the hierarchy.
up [edit security zones]
user@host# up
[edit security]
user@host#
Navigate to the top of the hierarchy.
top [edit security zones]
user@host# top
[edit]
user@host#
Commit or Revert Changes
Commit your conguraon.
commit [edit]
user@host# commit
commit complete
20
(Connued)
Task Command/
Statement
Example
Roll changes back from the current
session.
Use the rollback command to revert all
changes from the current
conguraon session. When you run
the rollback command before you exit
your session or commit changes, the
soware loads the most recently
commied conguraon onto the
device. You must enter the rollback
statement at the edit level in the
hierarchy.
rollback [edit]
user@host# rollback
load complete
Exit Conguraon Mode
Commit the conguraon, and exit
conguraon mode.
commit and-quit [edit]
user@host# commit and-quit
user@host>
Exit conguraon mode without
comming your conguraon.
You must navigate to the top of the
hierarchy using the up or top
commands before you can exit
conguraon mode.
exit [edit]
user@host# exit
The configuration has been changed but not
committed
Exit with uncommitted changes? [yes,no] (yes)
Get Help
21
(Connued)
Task Command/
Statement
Example
Display a list of valid opons for the
current hierarchy level.
? [edit ]
user@host# edit security zones ?
Possible completions:
<[Enter]> Execute this command
> functional-zone Functional zone
> security-zone Security zones
| Pipe through a
command
[edit]
SEE ALSO
Understanding CLI Conguraon Mode | 51
Check the Status of a Juniper Networks Device
In operaonal mode, you can use show commands to check the status of the device and monitor the
acvies on the device.
To help you become familiar with show commands:
Type show ? to display the list of show commands you can use to monitor the router:
root@> show ?
Possible completions:
accounting Show accounting profiles and records
aps Show Automatic Protection Switching information
arp Show system Address Resolution Protocol table entries
as-path Show table of known autonomous system paths
bfd Show Bidirectional Forwarding Detection information
22
bgp Show Border Gateway Protocol information
chassis Show chassis information
class-of-service Show class-of-service (CoS) information
cli Show command-line interface settings
configuration Show current configuration
connections Show circuit cross-connect connections
dvmrp Show Distance Vector Multicast Routing Protocol info
dynamic-tunnels Show dynamic tunnel information information
esis Show end system-to-intermediate system information
firewall Show firewall information
helper Show port-forwarding helper information
host Show hostname information from domain name server
igmp Show Internet Group Management Protocol information
ike Show Internet Key Exchange information
ilmi Show interim local management interface information
interfaces Show interface information
ipsec Show IP Security information
ipv6 Show IP version 6 information
isis Show Intermediate System-to-Intermediate System info
l2circuit Show Layer 2 circuit information
l2vpn Show Layer 2 VPN information
lacp Show Link Aggregation Control Protocol information
ldp Show Label Distribution Protocol information
link-management Show link management information
llc2 Show LLC2 protocol related information
log Show contents of log file
mld Show multicast listener discovery information
mpls Show Multiprotocol Label Switching information
msdp Show Multicast Source Discovery Protocol information
multicast Show multicast information
ntp Show Network Time Protocol information
ospf Show Open Shortest Path First information
ospf3 Show Open Shortest Path First version 3 information
passive-monitoring Show information about passive monitoring
pfe Show Packet Forwarding Engine information
pgm Show Pragmatic Generalized Multicast information
pim Show Protocol Independent Multicast information
policer Show interface policer counters and information
policy Show policy information
ppp Show PPP process information
rip Show Routing Information Protocol information
ripng Show Routing Information Protocol for IPv6 info
route Show routing table information
23
rsvp Show Resource Reservation Protocol information
sap Show Session Announcement Protocol information
security Show security information
services Show services information
snmp Show Simple Network Management Protocol information
system Show system information
task Show routing protocol per-task information
ted Show Traffic Engineering Database information
version Show software process revision levels
vpls Show VPLS information
vrrp Show Virtual Router Redundancy Protocol information
Use the show chassis routing-engine command to view the Roung Engine status:
root@> show chassis routing-engine
Routing Engine status:
Slot 0:
Current state Master
Election priority Master (default)
Temperature 31 degrees C / 87 degrees F
CPU temperature 32 degrees C / 89 degrees F
DRAM 768 MB
Memory utilization 84 percent
CPU utilization:
User 0 percent
Background 0 percent
Kernel 1 percent
Interrupt 0 percent
Idle 99 percent
Model RE-2.0
Serial ID b10000078c10d701
Start time 2005-12-28 13:52:00 PST
Uptime 12 days, 3 hours, 44 minutes, 19 seconds
Load averages: 1 minute 5 minute 15 minute
0.02 0.01 0.00
Use the show system storage command to view available storage on the device:
root@> show system storage
Filesystem Size Used Avail Capacity Mounted on
24
/dev/ad0s1a 865M 127M 669M 16% /
devfs 1.0K 1.0K 0B 100% /dev
devfs 1.0K 1.0K 0B 100% /dev/
/dev/md0 30M 30M 0B 100% /packages/mnt/jbase
/dev/md1 158M 158M 0B 100% /packages/mnt/jkernel-9.3B1.5
/dev/md2 16M 16M 0B 100% /packages/mnt/jpfe-M7i-9.3B1.5
/dev/md3 3.8M 3.8M 0B 100% /packages/mnt/jdocs-9.3B1.5
/dev/md4 44M 44M 0B 100% /packages/mnt/jroute-9.3B1.5
/dev/md5 12M 12M 0B 100% /packages/mnt/jcrypto-9.3B1.5
/dev/md6 25M 25M 0B 100% /packages/mnt/jpfe-common-9.3B1.5
/dev/md7 1.5G 196K 1.4G 0% /tmp
/dev/md8 1.5G 910K 1.4G 0% /mfs
/dev/ad0s1e 96M 38K 88M 0% /config
procfs 4.0K 4.0K 0B 100% /proc
/dev/ad1s1f 17G 2.6G 13G 17% /var
SEE ALSO
Managing Programs and Processes Using Operaonal Mode Commands | 295
Viewing Files and Directories on a Device | 289
Roll Back Conguraon Changes
This topic shows how to use the rollback command to return your uncommied but revised
conguraon to the state of the most recently commied Junos OS conguraon. The rollback
command is useful if you make conguraon changes and then decide not to keep them.
The following procedure shows how to congure an SNMP health monitor on a Juniper Networks
device and then return to the most recently commied conguraon that does not include the health
monitor. When congured, the SNMP health monitor provides the network management system (NMS)
with predened monitoring for le system usage, CPU usage, and memory usage on the device.
1. Enter conguraon mode:
user@host> configure
entering configuration mode
[edit]
user@host#
25
2. Show the current conguraon (if any) for SNMP:
[edit]
user@host# show snmp
No snmp statements appear because SNMP has not been congured on the device.
3. Congure the health monitor:
[edit]
user@host# set snmp health-monitor
4. Show the new conguraon:
[edit]
user@host# show snmp
health-monitor;
The health-monitor statement indicates that SNMP health monitoring is congured on the device.
5. Enter the rollback conguraon mode command to return to the most recently commied
conguraon:
[edit]
user@host# rollback
load complete
6. Show the conguraon again to make sure your change is no longer present:
[edit]
user@host# show snmp
No snmp conguraon statements appear. The health monitor is no longer congured.
7.
Enter the commit command to acvate the conguraon to which you rolled back:
[edit]
user@host# commit
26
8. Exit conguraon mode:
[edit]
user@host# exit
Exiting configuration mode
You can also use the rollback command to return to earlier conguraons.
SEE ALSO
Returning to the Most Recently Commied Conguraon | 213
Congure a Roung Protocol
IN THIS SECTION
Shortcut | 28
Longer Conguraon | 28
Make Changes to a Roung Protocol Conguraon | 31
This topic provides a sample conguraon that describes how to congure an OSPF backbone area that
has two SONET interfaces.
The nal conguraon looks like this:
[edit]
protocols {
ospf {
area 0.0.0.0 {
interface so-0/0/0 {
hello-interval 5;
dead-interval 20;
}
interface so-0/0/1 {
27
hello-interval 5;
dead-interval 20;
}
}
}
}
Shortcut
You can create a shortcut for this enre conguraon with the following two commands:
[edit]
user@host# set protocols ospf area 0.0.0.0 interface so-0/0/0 hello-interval 5 dead-interval 20
[edit]
user@host# set protocols ospf area 0.0.0.0 interface so-0/0/1 hello-interval 5 dead-interval 20
Longer Conguraon
This secon provides a longer example of creang the previous OSPF conguraon. In the process, it
illustrates how to use the dierent features of the CLI.
1. Enter conguraon mode by issuing the configure command:
user@host> configure
entering configuration mode
[edit]
user@host#
Noce that the prompt has changed to a pound or hash sign (#) to indicate conguraon mode.
2. To create the above conguraon, you start by eding the protocols ospf statements:
[edit]
user@host# edit protocols ospf
[edit protocols ospf]
user@host#
3. Now add the OSPF area:
[edit protocols ospf]
user@host# edit area 0.0.0.0
28
[edit protocols ospf area 0.0.0.0]
user@host#
4. Add the rst interface:
[edit protocols ospf area 0.0.0.0]
user@host# edit interface so-0/0/0
[edit protocols ospf area 0.0.0.0 interface so-0/0/0]
user@host#
You now have four nested statements.
5. Set the hello and dead intervals.
[edit protocols ospf area 0.0.0.0 interface so-0/0/0]
user@host# set hello-interval 5
user@host# set dead-interval 20
user@host#
6. You can see what is congured at the current level with the show command:
[edit protocols ospf area 0.0.0.0 interface so-0/0/0]
user@host# show
hello-interval 5;
dead-interval 20;
[edit protocols ospf area 0.0.0.0 interface so-0/0/0]
user@host#
7. You are nished at this level, so go up a level and view what you have done so far:
[edit protocols ospf area 0.0.0.0 interface so-0/0/0]
user@host# up
[edit protocols ospf area 0.0.0.0]
user@host# show
interface so-0/0/0 {
hello-interval 5;
dead-interval 20;
}
[edit protocols ospf area 0.0.0.0]
user@host#
29
The interface statement appears because you have moved to the area statement.
8. Add the second interface:
[edit protocols ospf area 0.0.0.0]
user@host# edit interface so-0/0/1
[edit protocols ospf area 0.0.0.0 interface so-0/0/1]
user@host# set hello-interval 5
[edit protocols ospf area 0.0.0.0 interface so-0/0/1]
user@host# set dead-interval 20
[edit protocols ospf area 0.0.0.0 interface so-0/0/1]
user@host# up
[edit protocols ospf area 0.0.0.0]
user@host# show
interface so-0/0/0 {
hello-interval 5;
dead-interval 20;
}
interface so-0/0/1 {
hello-interval 5;
dead-interval 20;
}
[edit protocols ospf area 0.0.0.0]
user@host#
9. Move up to the top level and review what you have:
[edit protocols ospf area 0.0.0.0]
user@host# top
[edit]
user@host# show
protocols {
ospf {
area 0.0.0.0 {
interface so-0/0/0 {
hello-interval 5;
dead-interval 20;
}
interface so-0/0/1 {
hello-interval 5;
dead-interval 20;
}
30
}
}
}
[edit]
user@host#
This conguraon now contains the statements that you want.
10. Before comming the conguraon (and thereby acvang it), verify that the conguraon is
correct:
[edit]
user@host# commit check
configuration check succeeds
[edit]
user@host#
11. Commit the conguraon to acvate it on the device:
[edit]
user@host# commit
commit complete
[edit]
user@host#
Make Changes to a Roung Protocol Conguraon
Suppose you decide to use dierent dead intervals and hello intervals on interface so-0/0/1. You can
make changes to the conguraon.
1. Go directly to the appropriate hierarchy level by typing the full hierarchy path to the statement that
you want to edit:
[edit]
user@host# edit protocols ospf area 0.0.0.0 interface so-0/0/1
[edit protocols ospf area 0.0.0.0 interface so-0/0/1]
user@host# show
hello-interval 5;
dead-interval 20;
[edit protocols ospf area 0.0.0.0 interface so-0/0/1]
user@host# set hello-interval 7
[edit protocols ospf area 0.0.0.0 interface so-0/0/1]
31
user@host# set dead-interval 28
[edit protocols ospf area 0.0.0.0 interface so-0/0/1]
user@host# top
[edit]
user@host# show
protocols {
ospf {
area 0.0.0.0 {
interface so-0/0/0 {
hello-interval 5;
dead-interval 20;
}
interface so-0/0/1 {
hello-interval 7;
dead-interval 28;
}
}
}
}
[edit]
user@host#
2. If you decide not to run OSPF on the rst interface, delete the statement:
[edit]
user@host# edit protocols ospf area 0.0.0.0
[edit protocols ospf area 0.0.0.0]
user@host# delete interface so-0/0/0
[edit protocols ospf area 0.0.0.0]
user@host# top
[edit]
user@host# show
protocols {
ospf {
area 0.0.0.0 {
interface so-0/0/1 {
hello-interval 7;
dead-interval 28;
}
}
}
}
32
[edit]
user@host#
Everything inside the statement you deleted was deleted with it. You can also eliminate the enre
OSPF conguraon by simply entering delete protocols ospf while at the top level.
3. Maybe you decide to use the default values for the hello intervals and dead intervals on your
remaining interface but want OSPF to run on that interface. In that case, delete the hello interval
mer and dead interval mer:
[edit]
user@host# edit protocols ospf area 0.0.0.0 interface so-0/0/1
[edit protocols ospf area 0.0.0.0 interface so-0/0/1]
user@host# delete hello-interval
[edit protocols ospf area 0.0.0.0 interface so-0/0/1]
user@host# delete dead-interval
[edit protocols ospf area 0.0.0.0 interface so-0/0/1]
user@host# top
[edit]
user@host# show
protocols {
ospf {
area 0.0.0.0 {
interface so-0/0/1;
}
}
}
[edit]
user@host#
You can set mulple statements at the same me as long as they are all part of the same hierarchy.
The hierarchy consists of the path of statements from the top inward, as well as one or more
statements at the boom of the hierarchy. Seng mulple statements at the same me can reduce
considerably the number of commands you must enter.
4.
To go back to the original hello interval mer and dead interval mer on interface so-0/0/1, enter:
[edit]
user@host# edit protocols ospf area 0.0.0.0 interface so-0/0/1
[edit protocols ospf area 0.0.0.0 interface so-0/0/1]
user@host# set hello-interval 5 dead-interval 20
[edit protocols ospf area 0.0.0.0 interface so-0/0/1]
user@host# exit
33
[edit]
user@host# show
protocols {
ospf {
area 0.0.0.0 {
interface so-0/0/1 {
hello-interval 5;
dead-interval 20;
}
}
}
}
[edit]
user@host#
5. You also can re-create the other interface, as you had it before, with only a single entry:
[edit]
user@host# set protocols ospf area 0.0.0.0 interface so-0/0/0 hello-interval 5 dead-interval 20
[edit]
user@host# show
protocols {
ospf {
area 0.0.0.0 {
interface so-0/0/0 {
hello-interval 5;
dead-interval 20;
}
interface so-0/0/1 {
hello-interval 5;
dead-interval 20;
}
}
}
}
[edit]
user@host#
34
Online Help in the CLI
IN THIS SECTION
Get Online Help from the Command-Line Interface | 35
CLI Online Help Features | 39
CLI Explorer Overview | 41
Get Online Help from the Command-Line Interface
IN THIS SECTION
Geng Help About Commands | 35
Geng Help About a String in a Statement or Command | 37
Geng Help About Conguraon Statements | 38
Geng Help About System Log Messages | 38
The CLI has a context-sensive online help feature that enables you to access informaon about
commands and statements.
Geng Help About Commands
CLI commands and opons can vary by plaorm and soware release. Each level of the CLI command
hierarchy provides informaon about available commands. You can type a queson mark (?) to get
context-relevant help about commands.
If you type the queson mark at the command-line prompt, the CLI lists the available commands and
opons. For example, to view a list of top-level operaonal mode commands, this is the result:
user@host> ?
Possible completions:
35
clear Clear information in the system
configure Manipulate software configuration information
file Perform file operations
help Provide help information
mtrace Trace mtrace packets from source to receiver.
monitor Real-time debugging
ping Ping a remote target
quit Exit the management session
request Make system-level requests
restart Restart a software process
set Set CLI properties, date, time, craft display text
show Show information about the system
ssh Open a secure shell to another host
start Start a software process
telnet Telnet to another host
test Diagnostic debugging commands
traceroute Trace the route to a remote host
user@host>
If you type the queson mark aer entering the complete name of a command or command opon,
the CLI lists the available commands and opons and then re-displays the command names and
opons you typed.
user@host> clear ?
Possible completions:
arp Clear address-resolution information
bgp Clear BGP information
chassis Clear chassis information
firewall Clear firewall counters
igmp Clear IGMP information
interfaces Clear interface information
ilmi Clear ILMI statistics information
isis Clear IS-IS information
ldp Clear LDP information
log Clear contents of a log file
mpls Clear MPLS information
msdp Clear MSDP information
multicast Clear Multicast information
ospf Clear OSPF information
pim Clear PIM information
rip Clear RIP information
route Clear routing table information
36
rsvp Clear RSVP information
snmp Clear SNMP information
system Clear system status
vrrp Clear VRRP statistics information
user@host> clear
If you type the queson mark in the middle of a command name, the CLI lists possible command
compleons that match the leers you have entered so far. It then re-displays the leers that you
typed. For example, to list all operaonal mode commands that start with the leer
c
, type the
following:
user@host> c?
Possible completions:
clear Clear information in the system
configure Manipulate software configuration information
user@host> c
For introductory informaon on using the queson mark or the help command, you can also type help
and press Enter:
user@host> help
Geng Help About a String in a Statement or Command
You can use the help command to display help about a text string contained in a statement or command
name:
help apropos
string
string
is a text string about which you want to get help. Use the string to match statement or command
names as well as to match the help strings that are displayed for the statements or commands.
If the string contains spaces, enclose it in quotaon marks (" "). You can also specify a regular expression
for the string, using standard UNIX-style regular expression syntax.
For statements or commands that need input data type as STRING, the supported characters set is as
follows:
Any printable ASCII characters
For characters with space, enclose it in double-quotes.
37
To have double-quote as the input, it should be escaped with ‘\.
NOTE: No escape characters are supported in a string other than to escape from double
quotes.
The range of supported characters for aributes is 0 through 65499 characters.
The range of supported characters for string type ideners is 1 through 255 characters.
In conguraon mode, this command displays statement names and help text that match the string
specied. In operaonal mode, this command displays command names and help text that match the
string specied.
Geng Help About Conguraon Statements
You can display help based on text contained in a statement name using the help topic and help reference
commands:
help topic
word
help reference
statement-name
The help topic command displays usage guidelines for the statement based on informaon that appears
in the Junos OS conguraon guides. The help reference command displays summary informaon about
the statement based on the summary descripons that appear in the Junos OS conguraon guides.
Geng Help About System Log Messages
You can display help based on a system log tag using the help syslog command:
help syslog
syslog-tag
The help syslog command displays the contents of a system log message.
38
CLI Online Help Features
IN THIS SECTION
Help for Omied Statements | 39
Using CLI Command Compleon | 39
Using Command Compleon in Conguraon Mode | 40
Displaying Tips About CLI Commands | 40
Help for Omied Statements
If you have omied a required statement at a specic hierarchy level, when you aempt to move from
that hierarchy level or when you issue the show command in conguraon mode, a message indicates
which statement is missing. For example:
[edit protocols pim interface so-0/0/0]
user@host# top
Warning: missing mandatory statement: 'mode'
[edit]
user@host# show
protocols {
pim {
interface so-0/0/0 {
priority 4;
version 2;
# Warning: missing mandatory statement(s): 'mode'
}
}
}
Using CLI Command Compleon
The Junos OS CLI provides you a command compleon opon that enables the operang system to
recognize commands and opons based on the inial few leers you typed. That is, you do not always
have to remember or type the full command or opon name for the CLI to recognize it.
39
To display all possible command or opon compleons, type the paral command followed
immediately by a queson mark.
To complete a command or opon that you have parally typed, press Tab or Space. If the parally
typed leers begin a string that uniquely idenes a command, the complete command name
appears. Otherwise, a prompt indicates that you have entered an ambiguous command, and the
possible compleons display.
Command compleon also applies to other strings, such as lenames, interface names, and usernames.
To display all possible values, type a paral string followed immediately by a queson mark. To complete
a string, press Tab.
Using Command Compleon in Conguraon Mode
The CLI command compleon funcons also apply to the commands in conguraon mode and to
conguraon statements. Specically, to display all possible commands or statements, type the paral
string followed immediately by a queson mark. To complete a command or statement that you have
parally typed, press Tab or Space.
Displaying Tips About CLI Commands
To get ps about CLI commands, issue the help tip cli command. Each me you enter the command, a
new p appears. For example:
user@host> help tip cli
Junos tip:
Use 'request system software validate' to validate the incoming software
against the current configuration without impacting the running system.
user@host> help tip cli
Junos tip:
Use 'commit and-quit' to exit configuration mode after the commit has
succeeded. If the commit fails, you are left in configuration mode.
You can also enter help tip cli
number
to associate a p with a number. This enables you to recall the p
later. For example:
user@host> help tip cli 10
JUNOS tip:
Use '#' in the beginning of a line in command scripts to cause the
rest of the line to be ignored.
40
user@host> help tip cli
JUNOS tip:
Use the 'apply-groups' statement at any level of the configuration
hierarchy to inherit configuration statements from a configuration group.
user@host>
SEE ALSO
CLI Command Compleon Example | 286
CLI Explorer Overview
CLI Explorer is a Web applicaon that helps you to explore Junos OS conguraon statements and
commands. CLI Explorer lists all the conguraon statements and commands the Junos OS supports
across dierent plaorms and soware releases.
To view the available conguraon statements and commands, you can use any of the following ltering
opons:
Filter by product family—To nd the CLI reference informaon by product family, you can either
select “All products” or select any specic product.
For example: ACX Series, EX Series.
Filter by number or leerTo nd the CLI reference informaon by number or leer, you can either
select “All” or lter by numbers “3” or “8” or any of the leers (“A”, “B”, “C”...).
For example, if you select the leer “A”, commands such as aaa, aaa clients (TDF), aaa-access-profile
(L2TP LNS) appear.
Filter by the normal search opon—To use this opon to lter the commands and statements, you
enter your search criteria.
For example, if you enter the number “3”, all the commands and statements containing the number
“3” appear in the search results.
When you click on the link in the search results, you are directed to a page describing the command or
statement that is referenced in a user guide.
To explore the Junos OS conguraon statements and commands, see the CLI Explorer.
41
CLI Environment Sengs
IN THIS SECTION
Customize the CLI Environment | 42
Set the CLI Screen Length and Width | 46
Enable Conguraon Breadcrumbs | 47
In operaonal mode, you (the network administrator) can customize the Junos OS CLI environment to
suit your specic preferences and requirements.
Customize the CLI Environment
IN THIS SECTION
Display the Current CLI Sengs | 43
Set the Terminal Type | 43
Set the CLI Prompt | 44
Set the CLI Directory | 44
Set the CLI Timestamp | 44
Set the Idle Timeout | 45
Set the CLI to Prompt for Restart Aer a Soware Upgrade | 45
Set CLI Command Compleon | 45
42
In operaonal mode, you can customize the CLI environment by using the set cli command. For
example, you can specify the number of lines that are displayed on the screen or your terminal type. The
following output lists the available opons:
user@host>set cli ?
Possible completions:
complete-on-space Set whether typing space completes current word
directory Set working directory
idle-timeout Set maximum idle time before login session ends
logical-system Set default logical system
prompt Set CLI command prompt string
restart-on-upgrade Set whether CLI prompts to restart after software upgrade
screen-length Set number of lines on screen
screen-width Set number of characters on a line
tenant Set default tenant
terminal Set terminal type
timestamp Timestamp CLI output
NOTE: Some values are already set when you use SSH to log in to the device or log in from the
console when its terminal type is already congured: your terminal type, screen length, and
screen width.
Display the Current CLI Sengs
To display the current CLI sengs, use the show cli command:
user@host> show cli
CLI screen length set to 24
CLI screen width set to 80
CLI complete-on-space set to on
Set the Terminal Type
To set the terminal type, use the set cli terminal command:
user@host> set cli terminal
terminal-type
43
The
terminal type
can be one of the following: ansi, vt100, small-xterm, or xterm.
Set the CLI Prompt
The default CLI prompt is user@host>. To change this prompt, use the set cli prompt command. If the
prompt string contains spaces, enclose the string in quotaon marks (" " ).
user@host> set cli prompt
string
NOTE: Changing the CLI prompt is not persistent across CLI sessions. When you exit the CLI and
restart it, the prompt defaults to user@host.
Set the CLI Directory
To set the current working directory, use the set cli directory command:
user@host> set cli directory
directory
The
directory
must be the full pathname of the desired working directory. Aer entering this command,
the CLI switches to the specied directory.
Set the CLI Timestamp
By default, CLI output does not include a mestamp. To include a mestamp in CLI output, use the set
cli timestamp command:
user@host> set cli timestamp [format
time-date-format
| disable]
Enclose the format in single quotaon marks ( ‘ ). If you do not specify a mestamp format, the default
format is
'Mmm dd hh:mm:ss’
(for example, Feb 08 17:20:49).
44
Set the Idle Timeout
By default, a CLI session never mes out aer extended idle me unless you have included the idle-
timeout statement in the user’s login class conguraon. To set the maximum me an individual session
can be idle before the user is logged o the device, use the set cli idle-timeout command:
user@host> set cli idle-timeout
timeout
The
meout
can be 0 through 100,000 minutes. Seng the
meout
to 0 disables the idle meout.
Set the CLI to Prompt for Restart Aer a Soware Upgrade
By default, the CLI prompts users to restart aer a soware upgrade. To disable the prompt, use the set
cli restart-on-upgrade off command:
user@host>set cli restart-on-upgrade off
To reenable the prompt, use the set cli restart-on-upgrade on command:
user@host> set cli restart-on-upgrade on
Set CLI Command Compleon
By default, you can press Tab or the spacebar to have the CLI complete a command.
To have the CLI allow only Tab to complete a command, use the set cli complete-on-space off command:
user@host> set cli complete-on-space off
Disabling complete-on-space
user@host>
To enable the use of the spacebar (as well as Tab) for command compleon, use the set cli complete-on-
space on command:
user@host> set cli complete-on-space on
Enabling complete-on-space
user@host>
45
Set the CLI Screen Length and Width
IN THIS SECTION
Set the Screen Length | 46
Set the Screen Width | 46
You can set the Junos OS CLI screen length and width according to your specic preferences and
requirements.
Set the Screen Length
The default CLI screen length is 24 lines. If output is longer than this, the display scrolls to the
congured screen length and then displays a more prompt. You can press Enter to display the next line, or
press the Spacebar to show the next full screen. Alternavely, you can press h to view all the available
opons, which include navigaon, searching, and saving.
To change the screen length, use the set cli screen-length command:
user@host> set cli screen-length
length
Seng the screen length to 0 lines disables the use of “one screen at a me” output. This seng causes
the screen to scroll all the way through to compleon without displaying the more prompt. Disabling this
UNIX more-type interface can be useful when you are issuing CLI commands from scripts.
Set the Screen Width
The value of CLI screen width can be 0 or in the range of 40 through 1024. The default CLI screen width
is 80 characters. Using a CLI screen width value of 0 disables the display of the output screen, which
may be desirable when using scripts. To change the width, use the set cli screen-width command:
user@host> set cli screen-width
width
46
Enable Conguraon Breadcrumbs
You can congure the output of show configuration operaonal mode commands and show conguraon
mode commands to display conguraon breadcrumbs. These breadcrumbs help you idenfy the exact
locaon in the conguraon hierarchy for the output you are viewing.
Before you enable the conguraon breadcrumbs feature, check the output of the show configuration
command.
user@host> show configuration
...
}
}
}
}
}
fe-4/1/2 {
description "FA4/1/2: mxxj1-mr6 (64.12.137.160/27) (T=bblan, bbmail, bbowmtc)";
unit 0 {
family inet {
filter {
output 151mj;
}
address 64.12.137.187/27 {
vrrp-group 1 {
virtual-address 64.12.137.189;
---(more 18%)-----------------------------------------------------
The output does not clearly indicate the secon of the conguraon being viewed.
To enable the conguraon breadcrumbs feature:
1. Launch conguraon mode in the CLI.
2. Dene a class at the [edit system login] hierarchy level, and set an idle meout value of 10 minutes.
[edit system login]
user@host# set class breadclass idle-timeout 10
47
3. Include the configuration-breadcrumbs statement at the [edit system login class
<class name>
] hierarchy
level.
[edit system login class breadclass]
user@host# set configuration-breadcrumbs
4. Add a user to the dened login class to enable the breadcrumb output view when this user runs the
show configuration operaonal mode command.
[edit system login user user1]
user@host# set class breadclass
5. Commit the conguraon.
[edit]
user@host# commit
Upon enabling conguraon breadcrumbs in the CLI, user1 (the user added to the login class) can
verify the feature in the output by entering the show configuration command.
user1@host> show configuration
...
}
}
}
}
}
fe-4/1/2 {
description "FA4/1/2: mxxj1-mr6 (64.12.137.160/27) (T=bblan, bbmail, bbowmtc)";
unit 0 {
family inet {
filter {
output 151mj;
}
address 64.12.137.187/27 {
vrrp-group 1 {
virtual-address 64.12.137.189;
48
---(more 18%)---[groups main interfaces fe-4/1/2 unit 0 family inet address 64.12.137.187/27
vrrp-group 1]---
The new output indicates the exact locaon of the conguraon hierarchy the user is viewing. In this
case, user1 is currently viewing the interface conguraon of a group.
NOTE: If you enable conguraon breadcrumbs for your own user account, log out and then
log in again to see the changes.
49
3
CHAPTER
Using Conguraon Statements to
Congure a Device
CLI Conguraon Mode Overview | 51
Overview of the Configure Command | 65
Modify the Conguraon of a Device | 71
Use Conguraon Groups to Quickly Congure Devices | 127
View the Conguraon | 163
Verify the Device Conguraon | 173
Commit the Conguraon | 174
CLI Conguraon Mode Overview
IN THIS SECTION
Understanding CLI Conguraon Mode | 51
Enter and Exit CLI Conguraon Mode | 58
Relave Conguraon Mode Commands | 61
Command Compleon in Conguraon Mode | 61
Notaonal Convenons Used in Conguraon Hierarchies | 64
The conguraon mode of the Junos OS CLI enables you to congure a device, using conguraon
statements to set, manage, and monitor device properes.
Understanding CLI Conguraon Mode
IN THIS SECTION
Conguraon Mode Commands | 52
Conguraon Statements and Ideners | 54
Conguraon Statement Hierarchy | 55
You can congure all Junos OS properes, including interfaces, general roung informaon, roung
protocols, and user access, as well as several system hardware properes.
As "Understanding the Junos OS CLI Modes, Commands, and Statement Hierarchies" on page 5
describes, a device conguraon is stored as a hierarchy of statements. In conguraon mode, you
create a set of conguraon statements to use. When you nish entering the conguraon statements
and are certain they are complete and correct, you commit them, which acvates the conguraon on
the device.
51
You can create the conguraon interacvely, or you can create an ASCII text le containing the
conguraon, load it on the device, and commit it.
Conguraon Mode Commands
The following table summarizes each CLI conguraon mode command. The commands are organized
alphabecally.
Table 3: Summary of Conguraon Mode Commands
Command Descripon
activate Remove the inactive: tag from a statement. Statements or ideners that have been acvated
take eect when you next issue the commit command.
annotate
Add comments to a conguraon. You can add comments only at the current hierarchy level.
commit
Commit the set of changes to the database and cause the changes to take operaonal eect.
copy
Make a copy of an exisng statement in the conguraon.
deactivate Add the inactive: tag to a statement, eecvely commenng out the statement or idener
from the conguraon. Statements or ideners marked as inacve are ignored when you issue
the commit command.
delete
Delete a statement or idener. All subordinate statements and ideners contained within the
specied statement path are deleted with it.
edit
Move inside the specied statement hierarchy. If the statement does not exist, it is created.
exit
Exit the current level of the statement hierarchy, returning to the level before the last edit
command, or exit from conguraon mode. The quit and exit commands are equivalent.
extension
Manage conguraons that SDK applicaon packages contribute. Manage them by either
displaying or deleng user-dened conguraons that the named SDK applicaon package
contributed. A conguraon dened in any nave Junos OS package is never deleted by the
extension command.
52
Table 3: Summary of Conguraon Mode Commands
(Connued)
Command Descripon
help
Display help about available conguraon statements.
insert
Insert an idener into an exisng hierarchy.
load
Load a conguraon from an ASCII conguraon le or from terminal input. Your current
locaon in the conguraon hierarchy is ignored when the load operaon occurs.
quit
Exit the current level of the statement hierarchy, returning to the level before the last edit
command, or exit from conguraon mode. The quit and exit commands are equivalent.
rename
Rename an exisng
conguraon statement
or idener.
replace
Replace ideners or values in a conguraon.
rollback
Return to a previously commied conguraon. The soware saves the last 10 commied
conguraons, including the rollback number, date, me, and name of the user who issued the
commit configuration command.
run
Run a CLI command without exing from conguraon mode.
save
Save the conguraon to an ASCII le. The conguraon statements up to and including the
current level of the statement hierarchy are saved, along with the statement hierarchy
containing it. This acon allows a secon of the conguraon to be saved, while fully
specifying the statement hierarchy.
set Create a statement hierarchy and set idener values. This command is similar to edit, except
that your current level in the hierarchy does not change.
show
Display the current conguraon.
status
Display the users currently eding the conguraon.
53
Table 3: Summary of Conguraon Mode Commands
(Connued)
Command Descripon
top Return to the top level of conguraon command mode, which is indicated by the [edit]
banner.
up
Move up one level in the statement hierarchy.
update
Update a private database.
wildcard delete
Delete a statement or idener. All subordinate statements and ideners contained within the
specied statement path are deleted with it. You can use regular expressions to specify a
paern. Based on this paern, the operang system searches for items that contain these
paerns and deletes them.
Conguraon Statements and Ideners
You can congure device properes by including the corresponding statements in the conguraon.
Typically, a statement consists of a system-dened keyword, which is xed text, and an oponal
idener. An idener is an idenfying name that you can dene, such as the name of an interface or a
username, which enables you and the CLI to dierenate among a collecon of statements.
Table 4 on page 54 lists top-level conguraon statements. See CLI Explorer for informaon about
each conguraon statement.
Table 4:
Conguraon Mode Top-Level Statements
Statement Descripon
access
Congure the Challenge Handshake Authencaon Protocol (CHAP).
accounting-options
Congure accounng stascs data collecon for interfaces and rewall lters.
chassis
Congure properes of the router chassis, including condions that acvate alarms and
SONET/SDH framing and concatenaon properes.
54
Table 4: Conguraon Mode Top-Level Statements
(Connued)
Statement Descripon
class-of-service
Congure class-of-service parameters.
firewall
Congure lters that select packets based on their contents.
forwarding-options
Congure forwarding opons, including trac sampling opons.
groups
Congure conguraon groups.
interfaces
Congure interface informaon, such as encapsulaon, interfaces, virtual channel ideners
(VCIs), and data-link connecon ideners (DLCIs).
policy-options
Congure roung policies, which enable you to lter and set properes in incoming and
outgoing routes.
protocols
Congure roung protocols, including BGP, IS-IS, LDP, MPLS, OSPF, RIP, and RSVP.
routing-instances
Congure one or more roung instances.
routing-options
Congure protocol-independent roung opons, such as stac routes, autonomous system
numbers, confederaon members, and global tracing (debugging) operaons to log.
security
Congure IP Security (IPsec) services.
snmp
Congure SNMP community strings, interfaces, traps, and nocaons.
system
Congure systemwide properes, including the hostname, domain name, Domain Name
System (DNS) server, user logins and permissions, mappings between hostnames and
addresses, and soware processes.
Conguraon Statement Hierarchy
The Junos OS conguraon consists of a hierarchy of statements. There are two types of statements:
55
Container statements, which are branches that can contain other statements (including addional
container statements or leaf statements). Container statements at the top of the hierarchy are
considered to be the trunk of the hierarchy tree.
Leaf statements (contained by container statements), which do not contain other statements.
The container and leaf statements form the conguraon hierarchy. Each statement at the top level of
the conguraon hierarchy resides at the trunk of a hierarchy tree. These top-level statements are
container statements, containing other statements that form the tree branches. The leaf statements are
the leaves of the hierarchy tree. An individual hierarchy of statements, which starts at the trunk of the
hierarchy tree, is called a statement path.
The following illustraon shows the hierarchy tree, illustrang a statement path for the part of the
protocol conguraon hierarchy responsible for conguring the hello-interval statement on an interface
in an OSPF area.
Figure 2: Conguraon Mode Hierarchy of Statements
The protocols statement is a top-level statement at the trunk of the conguraon tree. The ospf, area, and
interface statements are all subordinate container statements of a higher statement (they are branches of
the hierarchy tree). The hello-interval statement is a leaf on the tree, which in this case contains a data
value, namely the length of the hello-interval, in seconds.
The following conguraon example illustrates the statement hierarchy as shown in Figure 2 on page
56:
56
[edit protocols ospf area
area-number
interface
interface-name
]
The command displays the conguraon as follows:
protocols {
ospf {
area 0.0.0.0 {
interface so-0/0/0 {
hello-interval 5;
}
interface so-0/0/1 {
hello-interval 5;
}
}
}
}
The CLI indents each level in the hierarchy to indicate each statement’s relave posion in the hierarchy.
Addionally, in general, it sets o each level with braces, using an open brace at the beginning of each
hierarchy level and a closing brace at the end. If the statement at a hierarchy level is empty, the braces
are not printed.
Each leaf statement ends with a semicolon. If the hierarchy does not extend as far as a leaf statement,
the last statement in the hierarchy ends with a semicolon.
The conguraon hierarchy can also contain “oneliners” at the lowest level in the hierarchy. Oneliners
remove one level of braces in the syntax and display the container statement, its ideners, the child or
leaf statement, and its aributes all on one line.
For example, dynamic-profile
dynamic-profile-name
aggregate-clients; is a oneliner because the dynamic-profile
statement, its idener
dynamic-profile-name
, and leaf statement aggregate-clients all appear on one line
when you run the show command in conguraon mode:
[edit forwarding-options]
user@host# show
dhcp-relay {
dynamic-profile
dynamic-profile-name
aggregate-clients;
}
57
Enter and Exit CLI Conguraon Mode
You congure Junos OS by entering conguraon mode and creang a hierarchy of conguraon mode
statements.
To enter conguraon mode, use the configure command.
When you enter conguraon mode, the following conguraon mode commands are available:
user@host>configure
entering configuration mode
[edit]
user@host#?
possible completions:
<[Enter]> Execute this command
activate Remove the inactive tag from a statement
annotate Annotate the statement with a comment
commit Commit current set of changes
copy Copy a statement
deactivate Add the inactive tag to a statement
delete Delete a data element
edit Edit a sub-element
exit Exit from this level
help Provide help information
insert Insert a new ordered data element
load Load configuration from ASCII file
quit Quit from this level
rename Rename a statement
replace Replace character string in configuration
rollback Roll back to previous committed configuration
run Run an operational-mode command
save Save configuration to ASCII file
set Set a parameter
show Show a parameter
status Show users currently editing configuration
top Exit to top level of configuration
up Exit one level of configuration
wildcard Wildcard operations
[edit]
user@host>
58
NOTE: When making conguraon changes, commit them before you exit. If you exit
conguraon mode without comming conguraon changes, you lose the intended
changes.
You must have congure permission to view and use the configure command. When in conguraon
mode, you can view and modify only those statements for which you have access privileges.
If you enter conguraon mode and another user is also in conguraon mode, a message shows the
user’s name and the part of the conguraon the other user is viewing or eding:
user@host> configure
Entering configuration mode
Users currently editing the configuration:
root terminal d0 (pid 4137) on since 2008-04-09 23:03:07 PDT, idle 7w6d 08:22
[edit]
The configuration has been changed but not committed
[edit]
user@host#
Up to 32 users can be in conguraon mode simultaneously, and they all can make changes to the
conguraon at the same me.
To exit conguraon mode, use the exit configuration-mode conguraon mode command from any
level, or use the exit command from the top level. For example:
[edit protocols ospf area 0.0.0.0 interface so-0/0/0]
user@host# exit configuration-mode
exiting configuration mode
user@host>
[edit]
user@host# exit
exiting configuration mode
user@host>
59
If you try to exit fconguraon mode using the exit command and the conguraon contains changes
that you have not commied, you see the following message and prompt:
[edit]
user@host# exit
The configuration has been changed but not committed
Exit with uncommitted changes? [yes,no] yes
Exiting configuration mode
user@host>
To exit with uncommied changes without having to respond to a prompt, use the exit configuration-
mode command. This command is useful when you are using scripts to perform remote conguraon.
[edit]
user@host# exit configuration-mode
The configuration has been changed but not committed
Exiting configuration mode
user@host>
SEE ALSO
Switch Between Operaonal Mode and Conguraon Mode | 12
How to Use the congure exclusive Command Do you want to make this (and the other command
topics) user focused by referring to the main acon users want to do? Example: "How to Prevent
Conicts Using the congure exclusive Command" or "How to Prevent Conguraon Conicts." |
68
How to Work with the Correct ConguraonIf you want to make the tle user focused, this is one
opon (but prey long). You may have a beer idea. What is the main reason a user would use this
command? That goal can become the tle. | 71
How to Modify the Juniper Networks Device Conguraon | 73
Display set Commands from the Conguraon | 169
Commit Operaon When Mulple Users Congure the Soware | 177
Managing Programs and Processes Using Operaonal Mode Commands | 295
60
Relave Conguraon Mode Commands
The top or up command followed by another conguraon command—such as edit, insert, delete,
deactivate, annotate, or show—enables you to quickly move to the top of the hierarchy or to a level above
the area you are conguring.
To issue conguraon mode commands from the top of the hierarchy, use the top command and specify
a conguraon command. For example:
[edit interfaces fxp0 unit 0 family inet]
user@host# top edit system login
[edit system login]
user@host#
To issue conguraon mode commands from a locaon higher up in the hierarchy, use the up
conguraon mode command. Specify the number of levels you want to move up in the hierarchy, and
then specify a conguraon command. For example:
[edit protocols bgp]
user@host# up 2 activate system
SEE ALSO
Display the Current Conguraon | 163
Command Compleon in Conguraon Mode
This topic shows you how to access command help and to use basic command compleon in CLI
conguraon mode. In each case, you access help by using the queson mark (?) character, either alone
or with a paral command or conguraon statement.
To list the conguraon mode commands, use the ? command alone:
[edit]
user@host# ?
<[Enter]> Execute this command
activate Remove the inactive tag from a statement
61
annotate Annotate the statement with a comment
commit Commit current set of changes
copy Copy a statement
deactivate Add the inactive tag to a statement
delete Delete a data element
edit Edit a sub-element
exit Exit from this level
extension Extension operations
help Provide help information
insert Insert a new ordered data element
load Load configuration from ASCII file
quit Quit from this level
rename Rename a statement
replace Replace character string in configuration
rollback Roll back to previous committed configuration
run Run an operational-mode command
save Save configuration to ASCII file
set Set a parameter
show Show a parameter
status Show users currently editing configuration
top Exit to top level of configuration
up Exit one level of configuration
wildcard Wildcard operations
[edit]user@host#
To list all the statements available at a parcular hierarchy level, use ? aer the name of the hierarchy
level you wish to view. In this example, see the edit and edit protocols hierarchies:
[edit]
user@host# edit ?
Possible completions:
> accounting-options Accounting data configuration
> chassis Chassis configuration
> class-of-service Class-of-service configuration
> firewall Define a firewall configuration
> forwarding-options Configure options to control packet sampling
> groups Configuration groups
> interfaces Interface configuration
> policy-options Routing policy option configuration
> protocols Routing protocol configuration
> routing-instances Routing instance configuration
> routing-options Protocol-independent routing option configuration
62
> snmp Simple Network Management Protocol
> system System parameters
user@host# edit protocols ?
Possible completions:
<[Enter]> Execute this command
> bgp BGP options
> connections Circuit cross-connect configuration
> dvmrp DVMRP options
> igmp IGMP options
> isis IS-IS options
> ldp LDP options
> mpls Multiprotocol Label Switching options
> msdp MSDP options
> ospf OSPF configuration
> pim PIM options
> rip RIP options
> router-discovery ICMP router discovery options
> rsvp RSVP options
> sapSession Advertisement Protocol options
> vrrp VRRP options
| Pipe through a command
To list all commands that start with a parcular string or leer, enter the string, leer, or both, and then
enter the ? character. This example shows all the routing-options commands starng with the leer “a”:
user@host# edit routing-options a?
Possible completions:
> aggregate Coalesced routes
> autonomous-system Autonomous system number
This example shows all congured xe- interfaces. You can display these interfaces by using the rst two
leers of the abbreviaon (ex) and the ? character:
user@host# edit interfaces ex?
<interface_name> Interface name
ex-0/2/0 Interface name
ex-0/2/1 Interface name
[edit]
63
You can also show a list of all congured policy statements:
user@host# show policy-options policy-statement ?
user@host# show policy-options policy-statement
<policy_name> Name to identify a policy filter
lo0only-v4 Name to identify a policy filter
lo0only-v6 Name to identify a policy filter
lo2bgp Name to identify a policy filter
SEE ALSO
How to Add Conguraon Statements and Ideners | 75
Notaonal Convenons Used in Conguraon Hierarchies
When you are working in CLI conguraon mode, the banner on the line preceding the prompt indicates
the current hierarchy level. In the following example, the level is [edit protocols ospf]:
[edit protocols ospf]
user@host#
NOTE: Junos OS documentaon uses user@host# as the standard conguraon mode prompt. In a
CLI session, the prompt shows your user ID and the congured name of the Juniper Networks
device you are working on.
Use the set ? command to display the statements that you can include in the conguraon at the current
level. The help apropos command is also context-sensive, displaying matching statements only at the
current command hierarchy level and below.
Statements are listed alphabecally within each hierarchy and subhierarchy. An excepon occurs if a
subhierarchy is so long that it might be dicult to determine where it ends and its next peer statement
begins. In case of a very long subhierarchy, the subhierarchy appears at the end of its parent hierarchy
instead of in alphabecal order. In this excepon scenario, a placeholder appears in the alphabecal
posion where the subhierarchy would have been listed.
64
For example, at the [edit interfaces
interface-name
unit
logical-unit-number
] hierarchy level, the
family
family-name
subhierarchy has more than 20 child statements, including several subhierarchies with
child statements of their own. The full family
family-name
hierarchy appears at the end of its parent
hierarchy ([edit interfaces
interface-name
unit
logical-unit-number
]), and the following placeholder appears
at its alphabecal posion:
family
family-name
{
...
the
family
subhierarchy appears after the main
[edit interfaces
interface-name
unit
logical-unit-number
]
hierarchy
...
}
Another excepon to alphabecal order is that the disable statement always appears rst in any
hierarchy that includes it.
Overview of the Configure Command
IN THIS SECTION
Forms of the configure Command | 65
How to Use the configure Command | 67
How to Use the configure exclusive Command | 68
How to Work with the Correct Conguraon | 71
You (the network administrator) use the
configure command to enter CLI conguraon mode. You can
also use it to gather other informaon, such as which other users are currently in conguraon mode.
Forms of the configure Command
Junos OS supports three forms of the configure command: configure, configure private, and configure
exclusive. These forms control how users edit and commit conguraons. You can use this command to
coordinate the work of mulple users who manage the network and device conguraon.
65
Table 5: Forms of the configure Command
Command Edit Access Commit Access
configure
No one can lock the conguraon. All users can
make conguraon changes.
When you enter conguraon mode, the CLI
displays the following informaon:
A list of other users eding the
conguraon
Hierarchy levels the users are viewing or
eding
Whether the conguraon has been
changed, but not commied
When more than one user makes changes to a
conguraon, the most recent changes take
precedence when the conguraon is
commied.
All users can commit any changes
to the conguraon.
If you and another user make
changes and the other user
commits changes, your changes
are commied as well.
configure
exclusive
One user locks the conguraon and makes
changes without interference from other users.
If you enter conguraon mode while another
user has locked the conguraon (with the
configure exclusive command), the CLI displays
the user’s PID and the hierarchy level the user is
viewing or eding.
If you enter conguraon mode when another
user has locked the conguraon, you can
aempt to forcibly log out that user using the
request system logout operaonal mode
command. For details, see the CLI Explorer.
Only the user who has locked the
conguraon can commit it.
Other users can enter and exit
conguraon mode, but they
cannot commit any changes they
aempt to make to the
conguraon unl it is unlocked.
66
Table 5: Forms of the configure Command
(Connued)
Command Edit Access Commit Access
configure private
Mulple users can edit the conguraon at the
same me.
Each user has a private candidate conguraon
to edit independently of other users.
When mulple users enter conicng
conguraons, the rst commit operaon takes
precedence over subsequent commit
operaons.
When you commit the
conguraon, the device does not
immediately accept your private
candidate conguraon as the
new operaonal conguraon.
Before the device accepts your
conguraon, it veries that no
other user has modied the
operaonal (running)
conguraon .
If another user has modied the
conguraon, you can merge the
modicaons into your private
candidate conguraon and
aempt to commit again.
SEE ALSO
Commit a Device Conguraon | 176
Display set Commands from the Conguraon | 169
Display Users Currently Eding the Conguraon | 72
How to Use the configure Command
Up to 32 users can work in conguraon mode simultaneously; all can make changes to the
conguraon at the same me. When you commit changes to the conguraon, you may be comming
a combinaon of changes that you and other users have made. For this reason, you must keep track of
who is in conguraon mode with you.
To see other users currently logged in to the same device in conguraon mode:
Use the configure command to enter CLI conguraon mode.
67
If other users are in conguraon mode, the message displayed indicates who the users are and what
poron of the conguraon each person is viewing or eding.
user@host> configure
Entering configuration mode
Current configuration users:
root terminal p3 (pid 1088) on since 2018-05-13 01:03:27 EDT
[edit interfaces so-3/0/0 unit 0 family inet]
The configuration has been changed but not committed
[edit]
user@host#
How to Use the configure exclusive Command
If you enter conguraon mode using the configure exclusive command, you lock the candidate global
conguraon for as long as you remain in conguraon mode. (The candidate global conguraon is also
known as the shared conguraon or shared conguraon database.) Using the configure exclusive
command, you can make changes without interference from other users. Other users can enter and exit
conguraon mode, but they cannot make any permanent changes to the conguraon. Also, any
aempted changes by other users while the conguraon is in the locked state are discarded as soon as
the other users exit conguraon mode.
If another user has locked the conguraon, and you need to forcibly log them out, use the operaonal
mode command request system logout pid
pid_number
. You can locate the
pid_number
in the nocaon you
receive upon entering conguraon mode when someone else has locked it for exclusive access.
If you enter conguraon mode while another user is also in conguraon mode and has locked the
conguraon, a message idenes the user. The message also idenes the poron of the conguraon
that the user is viewing or eding. For example, in the following example, the
pid_number
of the user
who has locked the conguraon for exclusive access is 1088:
user@host> configure
Entering configuration mode
Users currently editing the configuration:
root terminal p3 (pid 1088) on since 2018-10-30 19:47:58 EDT, idle 00:00:44
exclusive [edit interfaces so-3/0/0 unit 0 family inet]
68
In configure exclusive mode, any uncommied changes are discarded when you exit:
user@host> configure exclusive
warning: uncommitted changes will be discarded on exit
Entering configuration mode
[edit]
user@host# set system host-name cool
[edit]
user@host# quit
The configuration has been changed but not committed
warning: Auto rollback on exiting 'configure exclusive'
Discard uncommitted changes? [yes,no]yes
warning: discarding uncommitted changes
load complete
Exiting configuration mode
When you use the yes opon to exit configure exclusive mode, Junos OS discards any uncommied
changes and rolls backs the conguraon to its previously commied state. The no opon enables you to
connue eding or to commit your changes in configure exclusive mode.
When one user exits configure exclusive mode while another user is in configure private mode, Junos OS
rolls back any uncommied changes in the private mode session.
Another rollback can happen if you enter conguraon mode with the configure exclusive command and
issue the commit confirmed command, but without conrming the commit within the specied interval. By
not conrming the commit within the specied interval, you trigger an automac rollback. Aer an
automac rollback occurs, the operang system removes the exclusive lock from your session. As a
result, the error message “access has been revoked” appears. This error message appears because the
session is no longer an exclusive session. This means that the conguraon is back to the default state:
anyone with access can edit the conguraon, commit it, or both. To re-lock the conguraon, you must
use the configure exclusive command again.
user@host>configure exclusive
warning: uncommitted changes will be discarded on exit
Entering configuration mode
[edit]
user@host# commit confirmed 1
commit confirmed will be automatically rolled back in 1 minutes unless confirmed
69
commit
# commit confirmed will be rolled back in 1 minute
Commit was not confirmed; automatic rollback complete.
[edit]
user@host# commit
error: access has been revoked.
user@host# commit check
error: access has been revoked.
user@host>configure exclusive
warning: uncommitted changes will be discarded on exit
Entering configuration mode
If you iniate a configure exclusive session, issue the commit confirmed command, and conrm the commit,
your session retains the exclusive lock. You can connue to make changes to the conguraon while sll
in a locked exclusive session.
user@host> configure exclusive
warning: uncommitted changes will be discarded on exit
Entering configuration mode
[edit]
user@host# commit confirmed 1
commit confirmed will be automatically rolled back in 1 minutes unless confirmed
commit complete
# commit confirmed will be rolled back in 1 minute
[edit]
user@host# commit
commit complete
SEE ALSO
How to Add Conguraon Statements and Ideners | 75
70
How to Work with the Correct Conguraon
When you are in configure private mode, you must work with a copy of the most recently commied
shared conguraon. If the global conguraon changes, you can issue the update command to update
your private candidate conguraon. When you update your private candidate conguraon, that
conguraon contains a copy of the most recently commied conguraon with your private changes
merged in.
NOTE: Merge conicts can occur when you issue the update command.
You can also issue the rollback command to discard your private candidate conguraon changes and
obtain the most recently commied conguraon.
NOTE: Junos OS does not support using the configure private command to congure statements
corresponding to third-party YANG data models such as OpenCong data models or custom
YANG data models.
Modify the Conguraon of a Device
IN THIS SECTION
Display Users Currently Eding the Conguraon | 72
How to Modify the Juniper Networks Device Conguraon | 73
How to Add Conguraon Statements and Ideners | 75
How to Delete a Statement from a Device Conguraon | 76
Example: Delete a Statement from the Device Conguraon | 79
Copy a Statement in the Conguraon | 81
Example: Copy a Statement in the Conguraon | 81
Example: Replace a Conguraon | 85
Insert a New Idener in a Device Conguraon | 92
Example: Insert a New Idener in a Device Conguraon | 92
71
Deacvate and Reacvate Statements and Ideners in a Device Conguraon | 97
Example: Deacvate and Reacvate Statements and Ideners in a Device Conguraon | 98
How to Make Global Changes in the Device Conguraon | 100
Common Regular Expressions to Use with the replace Command | 101
Example: How to Use Global Replace in a Device Conguraon—the \n Back Reference | 103
Example: Global Replace in a Device Conguraon—Replacing an Interface Name | 106
Example: Global Replace in a Device Conguraon—the upto Opon | 109
Add Comments in a Device Conguraon | 112
Example: Include Comments in a Device Conguraon by Using the CLI | 114
Example: Use the Wildcard Command with the Range Opon | 117
The CLI enables you to modify an exisng Junos OS conguraon. This secon explains the specics of
adding a statement, deleng a statement, copying a statement, and inserng a new idener, including
examples.
Display Users Currently Eding the Conguraon
To display the users currently eding the conguraon, use the status conguraon mode command:
user@host# status
Users currently editing the configuration:
rchen terminal p0 (pid 55691) on since 2018-03-01 13:17:25 PST
[edit interfaces]
The system displays who is eding the conguraon (rchen), where the user is logged in (terminal p0), the
date and me the user logged in (2018-03-01 13:17:25 PST), and what level of the hierarchy the user is
eding ([edit interfaces]).
If you issue the status conguraon mode command and a user has scheduled a candidate conguraon
to become acve for a future me, the system displays who scheduled the commit (
root
), where the user
72
is logged in (terminal d0), the date and me the user logged in (2018-10-31 14:55:15 PST), and that a commit
is pending (commit at).
[edit]
user@host# status
Users currently editing the configuration:
root terminal d0 (pid 767) on since 2018-10-31 14:55:15 PST, idle 00:03:09
commit at
If you issue the status conguraon mode command and a user is eding the conguraon in congure
exclusive mode, the system displays who is eding the conguraon (root), where the user is logged in
(terminal d0), the date and me the user logged in (2018-11-01 13:05:11 PST), and that a user is eding the
conguraon in congure exclusive mode (exclusive [edit]).
[edit]
user@host# status
Users currently editing the configuration:
root terminal d0 (pid 2088) on since 2018-11-01 13:05:11 PST
exclusive [edit]
SEE ALSO
Forms of the congure Command | 65
Schedule a Commit Operaon | 183
How to Use the congure Command | 67
How to Modify the Juniper Networks Device Conguraon
To congure a Juniper Networks device or to modify an exisng conguraon, you add statements to
the conguraon using the edit and set commands. For each statement hierarchy, you create the
hierarchy starng with a statement at the top level. You then connue creang the hierarchy with
statements that move progressively lower in the hierarchy.
To modify the hierarchy, you use two conguraon mode commands. Select the relevant command
based on what you want to accomplish:
73
edit—Moves to a specied hierarchy level. If that hierarchy level does not exist, the edit command
creates it. The edit command has the following syntax:
edit <
statement-path
>
set—Creates a conguraon statement and sets idener values. Aer you issue a set command, you
remain at the same level in the hierarchy. The set command has the following syntax:
set <
statement-path
>
statement
<
identifier
>
The hierarchy to the conguraon statement and the statement itself is
statement-path
. If you have
already moved to the statement’s hierarchy level, you can omit the statement path. The conguraon
statement itself is
statement
. The
identifier
string idenes an instance of a statement.
Statements can be either container statements or leaf statements. A container statement can include
addional container statements within it, as well as leaf statements. A leaf statement, however, stands
alone. The command edit? displays the container statements, while set? displays both the container and
leaf statements, using > to dierenate between them.
NOTE: You cannot use the edit command to change the value of ideners. You must use the set
command.
SEE ALSO
Relave Conguraon Mode Commands | 61
How to Use the congure exclusive Command Do you want to make this (and the other command
topics) user focused by referring to the main acon users want to do? Example: "How to Prevent
Conicts Using the congure exclusive Command" or "How to Prevent Conguraon Conicts." | 68
How to Work with the Correct ConguraonIf you want to make the tle user focused, this is one
opon (but prey long). You may have a beer idea. What is the main reason a user would use this
command? That goal can become the tle. | 71
Display the Current Conguraon | 163
74
How to Add Conguraon Statements and Ideners
You congure all properes of a Juniper Networks device by including statements in the conguraon. A
statement consists of a keyword, which is xed text. You can also include an idener in a statement. An
idener is an idenfying name that you dene, such as the name of an interface or a username, and
that enables you and the CLI to discriminate among a collecon of statements.
For example, the following list shows the statements available at the top level in conguraon mode:
user@host# set ?
Possible completions:
> accounting-options Accounting data configuration
+ apply-groups Groups from which to inherit configuration data
> chassis Chassis configuration
> class-of-service Class-of-service configuration
> firewall Define a firewall configuration
> forwarding-options Configure options to control packet sampling
> groups Configuration groups
> interfaces Interface configuration
> policy-options Routing policy option configuration
> protocols Routing protocol configuration
> routing-instances Routing instance configuration
> routing-options Protocol-independent routing option configuration
> snmp Simple Network Management Protocol
> system System parameters
An angle bracket ( > ) before the statement name indicates that it is a container statement and that you
can dene other statements at levels below it. If there is no angle bracket ( > ) before the statement
name, the statement is a leaf statement; you cannot dene other statements at hierarchy levels below it.
A plus sign (+) before the statement name indicates that it can contain a set of values. To specify a set,
include the values in brackets. For example:
[edit]
user@host# set policy-options community my-as1-transit members [65535:10 65535:11]
In some statements, you can include an idener. For some ideners, such as interface names, you
must specify the idener in a precise format. For example, the interface name so-0/0/0 refers to a
SONET/SDH interface that is on the Flexible PIC Concentrator (FPC) in slot 0, in the rst PIC locaon,
and in the rst port on the Physical Interface Card (PIC).
75
For other ideners, such as interface descripve text and policy and rewall term names, you can
specify any name, including special characters, spaces, and tabs.
You must enclose ideners in quotaon marks (double quotes). You must also use quotaon marks to
enclose ideners and any strings that include a space, a tab character, or any of the following
characters:
( ) [ ] { } ! @ # $ % ^ & | ' = ?
If you do not type an opon for a statement that requires one, a message indicates the type of
informaon required. In this example, you must type an area number to complete the command:
[edit]
user@host# set protocols ospf area
^
syntax error, expecting <identifier>
SEE ALSO
Display the Current Conguraon | 163
About Specifying Statements and Ideners | 237
How to Delete a Statement from a Device Conguraon
You delete a statement or idener from a device conguraon using the delete conguraon mode
command. Deleng a statement or an idener eecvely "uncongures" the funconality associated
with that statement or idener, returning that funconality to its default condion.
user@host# delete <
statement-path
> <
identifier
>
When you delete a statement, the statement and all its subordinate statements and ideners are
removed from the conguraon.
For statements that can have more than one idener, when you delete one idener, only that
idener is deleted. The other ideners in the statement remain.
76
To delete the enre hierarchy starng at the current hierarchy level, use the delete command without
specifying a statement or an idener. When you omit the statement or idener, you are prompted to
conrm the deleon:
[edit]
user@host# delete
Delete everything under this level? [yes, no] (no)
Possible completions:
no Don't delete everything under this level
yes Delete everything under this level
Delete everything under this level? [yes, no] (no)
NOTE: You cannot delete mulple statements or ideners within a hierarchy using a single
delete command. You must delete each statement or idener individually, using mulple delete
commands. For example, consider the following conguraon at the [edit system] hierarchy level:
system {
host-name
host-211
;
domain-name
domain-122
;
backup-router
192.168.71.254
;
arp;
authentication-order [ radius password tacplus ];
}
To delete the domain-name, host-name, and backup-router from the conguraon, you must delete each
statement individually.
user@host delete system host-name
host-211
user@host delete system domain-name
domain-122
user@host delete system backup-router
192.168.71.254
You cannot issue a single delete command. For example, the following command would not work:
user@host> delete system hostname
host-211
domain-name
domain-122
backup-router
192.168.71.254
You can delete related conguraon items simultaneously, such as channelized interfaces or stac
routes, by using a single command and regular expressions. Deleng a statement or an idener
eecvely “uncongures” the funconality associated with that statement or idener, returning that
funconality to its default condion.
77
You can delete only certain parts of the conguraon where you normally put mulple items, such as
interfaces. However, you cannot delete "groups" of dierent items, as shown in this example:
user@host# show system services
ftp;
rlogin;
rsh;
ssh {
root-login allow;
}
telnet;
[edit]
user@host# wildcard delete system services *
syntax error.
When you delete a statement, the statement and all its subordinate statements and ideners are
removed from the conguraon.
To delete related conguraon items, issue the wildcard conguraon mode command with the delete
opon and specify the statement path, the items to be summarized with a regular expression, and the
regular expression, as follow:
user@host# wildcard delete <
statement-path
> <
identifier
>
<regular-expression>
NOTE: When you use the wildcard command to delete related conguraon items, the regular
expression must be the nal statement.
If the Junos OS matches more than eight related items, the CLI displays only the rst eight items.
How to Delete Interfaces from the Conguraon
You can delete mulple T1 interfaces in the range from t1-0/0/0:0 through t1-0/0/0:23 by using this
syntax:
user@host# wildcard delete interfaces t1-0/0/0:.*
matched: t1-0/0/0:0
matched: t1-0/0/0:1
matched: t1-0/0/0:2
Delete 3 objects? [yes,no] (no) no
78
How to Delete Routes from the Conguraon
You can delete stac routes in the range from 172.0.0.0 to 172.255.0.0 by using this syntax:
user@host# wildcard delete routing-options static route 172.*
matched: 172.16.0.0/12
matched: 172.16.14.0/24
matched: 172.16.100.0/24
matched: 172.16.128.0/19
matched: 172.16.160.0/24
matched: 172.17.12.0/23
matched: 172.17.24.0/23
matched: 172.17.28.0/23
...
Delete 13 objects? [yes,no] (no)
Example: Delete a Statement from the Device Conguraon
The following example shows how to delete the ospf statement, eecvely unconguring OSPF on the
router:
[edit]
user@host# set protocols ospf area 0.0.0.0 interface so-0/0/0 hello-interval 5
[edit]
user@host# show
protocols {
ospf {
area 0.0.0.0 {
interface so-0/0/0 {
hello-interval 5;
}
}
}
}
[edit]
user@host# delete protocols ospf
[edit]
user@host# show
79
[edit]
user@host#
Delete all statements from the current level down:
[edit]
user@host# edit protocols ospf area 0.0.0.0
[edit protocols ospf area 0.0.0.0]
user@host# set interface so-0/0/0 hello-interval 5
[edit protocols ospf area 0.0.0.0]
user@host# delete
Delete everything under this level? [yes, no] yes
[edit protocols ospf area 0.0.0.0]
user@host# show
[edit]
user@host#
Uncongure a specic property. In this example, remove the interface speed seng:
[edit]
user@host# set interfaces so-3/0/0 speed 100mb
[edit]
user@host# show
interfaces {
so-3/0/0 {
speed 100mb;
}
}
[edit]
user@host# delete interfaces so-3/0/0 speed
[edit]
user@host# show
interfaces {
so-3/0/0;
}
80
Copy a Statement in the Conguraon
When you have many similar statements in a device conguraon, you can add one statement and then
make copies of that statement. Copying a statement duplicates that statement and the enre hierarchy
of statements congured under that statement. Copying statements is useful when you are conguring
many physical or logical interfaces of the same type.
To make a copy of an exisng statement in the conguraon:
1. Use the conguraon mode copy command:
user@host# copy
existing-statement
to
new-statement
2. Immediately aer you have copied a poron of the conguraon, check the validity of the new
conguraon.
3. If the conguraon is invalid, modify either the copied poron or the original poron to produce a
valid conguraon.
Example: Copy a Statement in the Conguraon
IN THIS SECTION
Requirements | 81
Overview | 82
Conguraon | 82
This example shows how you can create one virtual connecon (VC) on an interface by copying an
exisng VC.
Requirements
No special conguraon beyond device inializaon is required before conguring this example.
81
Before you begin this example, congure the following inial conguraon:
[edit interfaces]
user@host# show
at-1/0/0 {
description "PAIX to MAE West"
encapsulation atm-pvc;
unit 61 {
point-to-point;
vci 0.61;
family inet {
address 10.0.1.1/24;
}
}
}
To quickly congure the inial conguraon for this example, copy the following commands, paste them
into a text le, remove any line breaks and change any details necessary to match your network
conguraon, copy and paste this command into the CLI at the [edit] hierarchy level, and then enter
commit in conguraon mode.
set interfaces at-1/0/0 description "PAIX to MAE West"
set interfaces at-1/0/0 encapsulation atm-pvc
set interfaces at-1/0/0 unit 61 point-to-point
set interfaces at-1/0/0 unit 61 vci 0.61
set interfaces at-1/0/0 unit 61 family inet address 10.0.1.1/24
Overview
In this example illustrang how to copy statements, you add a virtual connecon that is very similar to a
virtual connecon already congured.
Conguraon
IN THIS SECTION
CLI Quick Conguraon | 83
Congure by Copying | 83
Results | 84
82
CLI Quick Conguraon
Start at the [edit interfaces at-1/0/0] hierarchy level.
copy unit 61 to unit 62
set unit 62 vci 0.62
edit unit 62
replace pattern 10.0.1.1 with 10.0.2.1
Congure by Copying
Step-by-Step Procedure
To congure by copying a conguraon:
1. Go to the [edit interfaces at-1/0/0] hierarchy level and copy unit 61.
[edit interfaces at-1/0/0]
user@host# copy unit 61 to unit 62
2. Take a look at the new conguraon and see what you need to change to make the conguraon
valid.
user@host# show interfaces at-1/0/0
description "PAIX to MAE West"
encapsulation atm-pvc;
unit 61 {
point-to-point;
vci 0.61;
family inet {
address 10.0.1.1/24;
}
}
unit 62 {
point-to-point;
vci 0.61;
family inet {
address 10.0.1.1/24;
83
}
}
3. Change the conguraon to make it valid.
In this example you want to recongure the virtual circuit idener (VCI) and virtual path idener
(VPI).
[edit interfaces at-1/0/0]
user@host# set unit 62 vci 0.62
You also want to replace the IP address of the new interface with its own IP address.
[edit interfaces at-1/0/0]
user@host# edit unit 62
user@host# replace pattern 10.0.1.1 with 10.0.2.1
Results
[edit]
show interfaces
at-1/0/0 {
description "PAIX to MAE West"
encapsulation atm-pvc;
unit 61 {
point-to-point;
vci 0.61;
family inet {
address 10.0.1.1/24;
}
}
unit 62 {
point-to-point;
vci 0.62;
family inet {
address 10.0.2.1/24;
}
84
}
}
Example: Replace a Conguraon
IN THIS SECTION
Requirements | 85
Overview | 85
Conguraon | 86
If you need to make changes to the conguraon of a device, you can always remove the original
conguraon sengs using the delete command and add your new conguraon sengs using the set
command. However, there are other ways of modifying a conguraon that are more ecient and easier
to use.
This example shows how to use the following conguraon mode commands to update an exisng
conguraon:
rename—Rename an exisng conguraon seng, such as an interface name. This command can be
useful when you are adding new interfaces to a device.
copy—Copy a conguraon seng and the enre hierarchy of statements congured under that
seng. Copying conguraon statements is useful when you are conguring many physical or logical
interfaces of the same type.
replace—Make global changes to text paerns in the conguraon. For example, if you consistently
misspell a word common to the descripon statement for all of the interfaces on your device, you
can x this mistake with a single command.
Requirements
No special conguraon beyond device inializaon is required before conguring this example.
Overview
During the rst example in this topic, you make the following conguraon changes:
Create a new interface with a descripon that contains a typing error.
85
Copy the conguraon from the interface that you created to create a new interface.
Rename one of the interfaces that you created.
Fix the typing error in the descripon for the interfaces that you created.
In the second, shorter example, you try some of the same commands under slightly dierent
circumstances.
Conguraon
IN THIS SECTION
Use the Copy, Rename, and Replace Commands to Modify a Loopback Interface Conguraon | 86
Compare the Copy Command at the Top-Level Conguraon Hierarchy Level | 89
Use the Copy, Rename, and Replace Commands to Modify a Loopback Interface Conguraon
Step-by-Step Procedure
CAUTION: If your exisng conguraon uses any of the loopback interface unit
numbers used in this example, you must substute dierent unused loopback interface
unit numbers. Otherwise, following these steps could damage the exisng operaonal
status of your device.
To create and modify a conguraon of a loopback interface using the copy, rename, and replace
commands:
1. Create a new loopback interface unit number and include a descripon.
The mistakes in the spelling of loopback in the descripon are intenonal.
[edit]
user@host# set interfaces lo0 unit 100 description "this is a lopbck interface"
86
2. Display the conguraon for the loopback interface you have just added.
[edit]
user@host# show interfaces lo0 unit 100
description "this is a lopbck interface";
3. Duplicate the loopback interface you have just created, errors included, from unit 100 to unit 101.
[edit]
user@host# copy interfaces lo0 unit 100 to unit 101
4. Display the conguraons for loopback interfaces lo0 unit 100 and lo0 unit 101.
[edit]
user@host# show interfaces lo0 unit 100
description "this is a lopbck interface";
[edit]
user@host# show interfaces lo0 unit 101
description "this is a lopbck interface";
The copy command duplicates an interface including any child statements, such as description.
5. Rename the loopback interface lo0 unit 100 to loopback interface lo0 unit 102.
[edit]
user@host# rename interfaces lo0 unit 100 to unit 102
6. Display the conguraon for loopback interface lo0 unit 100.
[edit]
user@host# show interfaces lo0 unit 100
[edit]
user@host#
You should not see any results from this command. The loopback interface lo0 unit 100 is now gone.
The rename command replaces the conguraon statement indicated with the new conguraon.
87
7. Fix the misspelling of the word
loopback
in the descripons for loopback interfaces lo0 unit 101 and
lo0 unit 102.
[edit]
user@host# replace pattern lopbck with loopback
8. Display the conguraon for loopback interfaces lo0 unit 101 and lo0 102 to verify that the word
loopback
is now spelled correctly.
[edit]
user@host# show interfaces lo0 unit 101
description "this is a loopback interface";
[edit]
user@host# show interfaces lo0 unit 102
description "this is a loopback interface";
The replace command replaces all instances of the paern specied in the command, unless limited in
some way. The next example in this topic shows one way to limit the eect of the replace command.
9. In conguraon mode, use the rollback command to returnthe device conguraon to the state it was
in before you executed the previous steps.
[edit]
user@host# rollback
Results
In conguraon mode, use the show interfaces lo0 unit 101 and show interfaces lo0 unit 102 commands to
ensure that the device conguraon is in the state it was in before you executed the steps in this
example.
[edit]
user@host: show interfaces lo0 unit 101
[edit]
user@host#
88
You should not see any results from this command.
[edit]
user@host# show interfaces lo0 unit 102
[edit]
user@host#
You should not see any results from this command.
Compare the Copy Command at the Top-Level Conguraon Hierarchy Level
Step-by-Step Procedure
The previous example shows the copy, rename, and replace commands at the [edit interfaces
interface-name
unit
logical-interface-number
] hierarchy level. This example shows how some of these commands work at
the top level of the CLI conguraon mode hierarchy.
The following example requires you to navigate to various levels in the conguraon hierarchy. For
informaon about navigang the CLI, see "Using the CLI Editor in Conguraon Mode" on page 19 .
1. Create an Ethernet interface.
[edit]
user@host# set interfaces et-2/0/0 unit 0 family inet address 192.0.2.2
2. Copy the interface you just created to another interface.
[edit]
user@host# copy interfaces et-2/0/0 to et-2/1/0
Compare this copy command to the one in the previous example, where the copy command takes the
keyword unit before the value to be copied:
[edit]
user@host# copy interfaces lo0 unit 100 to unit 101
Noce that the keyword interfaces is not repeated aer the preposion to and before the value to be
copied. This happens in some top-level statements with the copy command.
89
TIP: Similarly, in the rename command, you do not repeat the keyword part of the statement
before the new idener in some top-level statements.
3. Show your conguraon so far.
[edit]
user@host# show interfaces
et-2/0/0 {
unit 0 {
family inet {
address 192.0.2.2/32;
}
}
}
et-2/1/0 {
unit 0 {
family inet {
address 192.0.2.2/32;
}
}
}
4. Replace the address for et-2/1/0 with another IP address.
[edit interfaces et-2/1/0 unit 0 family inet]
user@host# replace pattern 192.0.2.2 with 192.0.2.40
Noce that if you want to change only a specic occurrence of a paern instead of all occurrences,
youmust navigate to that specic hierarchy level before using the replace command.
5. Show the interfaces again.
[edit]
user@host# show interfaces
et-2/0/0 {
unit 0 {
family inet {
address 192.0.2.2/32;
}
90
}
}
et-2/1/0 {
unit 0 {
family inet {
address 192.0.2.40/32;
}
}
}
6. In conguraon mode, use the rollback command to return the device conguraon to the state it
was in before you executed the previous steps.
[edit]
user@host# rollback
Results
In conguraon mode, use the show interfaces et-2/0/0 and show interfaces et-2/1/0 commands to ensure
that the device conguraon is in the state it was in before you executed the steps in this example.
[edit]
user@hostshow interfaces et-2/0/0
[edit]
user@host#
You should not see any results from this command.
[edit]
user@R1# show interfaces et-2/1/0
[edit]
user@host#
You should not see any results from this command.
91
Insert a New Idener in a Device Conguraon
When conguring a Juniper Networks device, you can enter most statements and ideners in any
order. Regardless of the order in which you enter the conguraon statements, the CLI always displays
the conguraon in a strict order. However, in a few cases the order of the statements maers because
the conguraon statements create a sequence that is analyzed in order.
For example, in a roung policy or rewall lter, you dene terms that are analyzed sequenally. Also,
when you create a named path in dynamic MPLS, you dene an ordered list of the transit routers in the
path, starng with the rst transit router and ending with the last one.
To modify a poron of the conguraon in which the statement order maers, use the insert
conguraon mode command:
user@host#insert <
statement-path
>
identifier1
(before | after)
identifier2
If you do not use the insert command but instead congure the idener, the idener is placed at the
end of the list of similar ideners.
Example: Insert a New Idener in a Device Conguraon
IN THIS SECTION
Requirements | 93
Overview | 94
Conguraon | 94
This example shows the use of the insert command.
Whereas a term added using the set command is placed at the end of the exisng list of terms, you use
the insert command to add a term in the order you specify. Specifying the order of statements is
important in the cases in which the order maers because the conguraon statements create a
sequence that is analyzed in order.
As this example shows, you must create the term (or it must already exist) before you can use it with the
insert command. The reference point for placing the term must also exist; for example, to place the term
92
T1 before the term T2, both T1 and T2 must already exist and be populated. Junos OS removes empty
terms automacally.
Requirements
Before you can insert a term, you must congure an inial policy. To quickly congure the inial policy
for this example, copy the following commands, paste them into a text le, remove any line breaks and
change any details necessary to match your network conguraon, copy and paste the commands into
the CLI at the [edit policy-options] hierarchy level, and then enter commit from conguraon mode.
set policy-statement statics term term1 from route-filter 192.168.0.0/16 orlonger
set policy-statement statics term term1 from route-filter 224.0.0.0/3 orlonger
set policy-statement statics term term1 then reject
set policy-statement statics term term2 from protocol direct
set policy-statement statics term term2 then reject
set policy-statement statics term term3 from protocol static
set policy-statement statics term term3 then reject
set policy-statement statics term term4 then accept
Now check to verify that you have the hierarchy congured correctly:
[edit policy-options]
user@host# show
policy-statement statics {
term term1 {
from {
route-filter 192.168.0.0/16 orlonger;
route-filter 224.0.0.0/3 orlonger;
}
then reject;
}
term term2 {
from protocol direct;
then reject;
}
term term3 {
from protocol static;
then reject;
}
term term4 {
then accept;
93
}
}
Overview
To modify a poron of the conguraon in which the statement order maers, you must use the insert
conguraon mode command. If you use the set command instead, the added statement or idener
will be in the wrong place sequenally. The only other way to get the terms of the command in the
correct order is to dismantle the conguraon and start over.
Conguraon
IN THIS SECTION
CLI Quick Conguraon | 94
Congure to Insert Terms | 95
Results | 96
CLI Quick Conguraon
To quickly congure this example, copy the following commands, paste them into a text le, remove any
line breaks and change any details necessary to match your network conguraon, copy and paste the
commands into the CLI at the [edit policy-opons] hierarchy level, and then enter commitin conguraon
mode.
[edit]
user@host# rename policy-options policy-statement statics term term4 to term term6
[edit]
user@host# set policy-options policy-statement statics term term4 from protocol local
[edit]
user@host# set policy-options policy-statement statics term term4 then reject
[edit]
user@host# set policy-options policy-statement statics term term5 from protocol aggregate
[edit]
user@host# set policy-options policy-statement statics term term5 then reject
[edit]
user@host# insert policy-options policy-statement statics term term4 after term term3
94
[edit]
user@host# insert policy-options policy-statement statics term term5 after term term4
Congure to Insert Terms
Step-by-Step Procedure
1. Determine the order in which your conguraon terms need to go. Consider both the original terms
and the new terms you plan to add.
In the original conguraon, the policy is named statics, and there are four terms. Each of the rst
three terms matches on a dierent match criteria, and the resulng matches are rejected. The last
term accepts all the rest of the trac.
In this example, you need to add two terms that eliminate addional types of trac. Both these
terms need to go before the last term in the original conguraon.
2. Rename original term4 to term6.
[edit]
user@host# rename policy-options policy-statement statics term term4 to term term6
This step preserves the original last term, now renamed term6, as the last term.
3. Create a new term4.
[edit]
user@host# set policy-options policy-statement statics term term4 from protocol local
user@host# set policy-options policy-statement statics term term4 then reject
A new term is added that matches trac from local system addresses and rejects it.
4. Create new term5.
[edit]
user@host# set policy-options policy-statement statics term term5 from protocol aggregate
user@host# set policy-options policy-statement statics term term5 then reject
A new term is added that matches trac from aggregate routes and rejects it.
95
5. Insert term4 aer term3.
[edit]
user@host# insert policy-options policy-statement statics term term4 after term term3
6. Insert term5 aer term4.
[edit]
user@host# insert policy-options policy-statement statics term term5 after term term4
Results
[edit]
user@host# show policy-options policy-statement statics
term term1 {
from {
route-filter 192.168.0.0/16 orlonger;
route-filter 224.0.0.0/3 orlonger;
}
then reject;
}
term term2 {
from protocol direct;
then reject;
}
term term3 {
from protocol static;
then accept;
}
term term4 {
from protocol local;
then reject;
}
term term5 {
from protocol aggregate;
then reject;
}
term term6 {
96
then accept;
}
Deacvate and Reacvate Statements and Ideners in a Device
Conguraon
In a Junos OS conguraon, you can deacvate statements and ideners so they do not take eect
when you issue the commit command. Any deacvated statements and ideners are marked with the
inactive tag. They remain in the conguraon but are not acvated when you issue a commit command.
To deacvate a statement or idener, use the deactivate conguraon mode command:
user@host# deactivate( statement | identifier )
To reacvate a statement or idener, use the activate conguraon mode command:
user@host# activate ( statement | identifier )
In both commands, the
statement
and the
identifier
you specify must be at the current hierarchy level.
When you deacvate a statement, that specic statement is ignored and is not applied at all when you
issue a commit command.
To disable a statement, use the disable conguraon mode command.
In some porons of the conguraon hierarchy, you can include a disable statement to disable
funconality. One example is disabling an interface by including the disable statement at the [edit
interface
interface-name
] hierarchy level. When you disable a funcon, it is reacvated when you issue a
commit command but is treated as though it is down or administravely disabled.
97
Example: Deacvate and Reacvate Statements and Ideners in a
Device Conguraon
IN THIS SECTION
Requirements | 98
Overview | 98
Conguraon | 98
This example shows a common use case in which you use the deactivate and activate conguraon mode
commands. It involves dual Roung Engines, primary and backup, that have graceful Roung Engine
switchover (GRES) congured. The soware on both Roung Engines needs to be upgraded. This can
easily be accomplished by deacvang GRES, updang the Roung Engines, and then reacvang
GRES.
NOTE: You can also perform a similar upgrade using the same setup, except that nonstop acve
roung (NSR) is congured instead of GRES. You would need to deacvate NSR and then
upgrade the Roung Engines before reacvang NSR.
Requirements
This example requires the use of a device with dual Roung Engines that can be upgraded.
Before you begin this example, make sure that you have GRES congured.
Overview
In this example, there are two Roung Engines. GRES is congured, and the Roung Engines need to be
upgraded. To accomplish the upgrade, you need to deacvate the GRES feature, upgrade each of the
Roung Engines, and then acvate GRES again.
Conguraon
IN THIS SECTION
Congure the Deacvaon and Reacvaon of GRES | 99
98
Congure the Deacvaon and Reacvaon of GRES
Step-by-Step Procedure
To deacvate and reacvate GRES for Roung Engine upgrade:
1. Show that GRES is enabled for the router.
[edit]
user@host# show chassis
redundancy {
graceful-switchover;
}
fpc 2 {
pic 0 {
tunnel-services {
bandwidth 1g;
}
}
}
2. Deacvate GRES.
[edit]
user@host# deactivate chassis redundancy graceful-switchover
user@host# commit
3. Show that GRES is deacvated.
[edit]
user@host# show chassis
redundancy {
inactive: graceful-switchover;
}
fpc 2 {
pic 0 {
tunnel-services {
bandwidth 1g;
}
99
}
}
4. Upgrade the Roung Engines one by one.
For instrucons on upgrading Junos OS on dual Roung Engines, see Installing the Soware Package
on a Device with Redundant Roung Engines.
5. Reacvate GRES.
[edit]
user@host# activate chassis redundancy graceful-switchover
user@host# commit
Results
Verify that GRES feature is acvated again.
[edit]
user@host# show chassis
redundancy {
graceful-switchover;
}
fpc 2 {
pic 0 {
tunnel-services {
bandwidth 1g;
}
}
}
How to Make Global Changes in the Device Conguraon
You can make global changes to variables and ideners in the device conguraon by using the replace
conguraon mode command. This command replaces a paern in a conguraon with another paern.
100
For example, you can use this command to nd and replace all occurrences of an interface name when a
PIC is moved to another slot in the router.
user@host# replace pattern
pattern1
with
pattern2 <
upto
n>
The pattern
pattern1
opon is a text string or regular expression that denes the ideners and values you
want to replace in the conguraon.
The
pattern2
opon is a text string or regular expression that replaces the ideners and values located
within
pattern1
.
The CLI uses standard UNIX-style regular expression syntax (as dened in POSIX 1003.2). If the regular
expression contains spaces, operators, or wildcard characters, enclose the expression in quotaon
marks. Greedy qualiers (match as much as possible) are supported. Lazy qualiers (match as lile as
possible) are not supported.
The upto
n
opon species the number of objects replaced. The value of
n
controls the total number of
objects that are replaced in the conguraon (not the total number of mes the paern occurs). Objects
at the same hierarchy level (siblings) are replaced rst. Mulple occurrences of a paern within a given
object are considered a single replacement. For example, if a conguraon contains a 010101 text string,
the command replace pattern 01 with pattern 02 upto 2 replaces 010101 with 020202 (instead of 020201).
Replacement of 010101 with 020202 is considered a single replacement (
n
= 1), not three separate
replacements (
n
=3).
If you do not specify an upto opon, all ideners and values in the conguraon that match
pattern1
are
replaced.
The replace command is available in conguraon mode at any hierarchy level. All matches are case-
sensive.
Common Regular Expressions to Use with the replace Command
Table 6: Common Regular Expressions to Use with the replace Command
Operator Funcon
|
Indicates that a match can be one of the two terms on either side of the pipe.
^
Used at the beginning of an expression, denotes where a match should begin.
101
Table 6: Common Regular Expressions to Use with the replace Command
(Connued)
Operator Funcon
$
Used at the end of an expression, denotes that a term must be matched exactly up to the point of the
$ character.
[ ]
Species a range of leers or digits to match. To separate the start and end of a range, use a hyphen
( - ).
( ) Species a group of terms to match. Stored as numbered variables. Use for back references as \1
\2 .... \9.
*
Denotes 0 or more terms.
+
Denotes one or more terms.
.
Denotes any character except for a space (" ").
\ A backslash escapes special characters to suppress their special meaning. For example, \. matches .
(period symbol).
\
n
Back reference that matches the
n
th group.
&
Back reference that matches the enre match.
The following table lists some replacement examples.
Table 7: Replacement Examples
Command Result
replace pattern myrouter with router1 Match: myrouter
Result: router1
102
Table 7: Replacement Examples
(Connued)
Command Result
replace pattern "192\.168\.(.*)/24" with "10.2.\1/28" Match: 192.168.3.4/24
Result: 10.2.3.4/28
replace pattern "1.\1" with "abc&def" Match: 1.1
Result: abc1.1def
replace pattern 1.1 with " abc\&def" Match: 1#1
Result: abc&def
Example: How to Use Global Replace in a Device Conguraon—the \n
Back Reference
IN THIS SECTION
Requirements | 103
Overview | 104
Conguraon | 105
This example shows how you can use a back reference to replace a paern.
Requirements
No special conguraon beyond device iniaon is required before conguring this example.
Before you begin, congure the following:
[edit]
user@host# show interfaces
103
xe-0/0/0 {
unit 0;
}
fe-3/0/1 {
vlan-tagging;
unit 0 {
description "inet6 configuration. IP: 2000::c0a8::1bf5";
vlan-id 100;
family inet {
address 17.10.1.1/24;
}
family inet6 {
address 2000::c0a8:1bf5/3;
}
}
}
To quickly congure this inial conguraon, copy the following commands and paste them in a text le,
remove any line breaks, change any details necessary to match your network conguraon, and then
copy and paste the commands into the CLI at the [edit] hierarchy level:
set interfaces xe-0/0/0 unit 0
set interfaces fe-3/0/1 vlan-tagging
set interfaces fe-3/0/1 unit 0 description "inet6 configuration IP: 2000::c0a8::1bf5"
set interfaces fe-3/0/1 unit 0 vlan-id 100
set interfaces fe-3/0/1 unit 0 family inet address 17.10.1.1/24
set interfaces fe-3/0/1 unit 0 family inet6 address 2000::c0a8:1bf5/3
Overview
One of the most useful features of regular expressions is the back reference. Backreferences provide a
convenient way to idenfy a repeated character or substring within a string. Once you nd the paern,
you can repeat it without wring it again. You refer to the previously captured paern with just \#
(where # is a numeral that indicates the number of mes you want the paern matched).
You can use backreferences to recall, or nd, data and replace it with something else. In this way you can
reformat large sets of data with a single replace command, thus saving you the me it would take to look
for and replace the paern manually.
104
Conguraon
IN THIS SECTION
Conguring a Replacement Using a Back Reference in the Command | 105
Results | 105
Conguring a Replacement Using a Back Reference in the Command
Step-by-Step Procedure
To replace a paern in a Junos OS conguraon using a back reference:
Use the replace command.
[edit]
user@host# replace pattern
pattern1
with
pattern2
In this case, we want to replace :1bf5with 1bf5.
[edit]
user@host# replace pattern "(.*):1bf5" with "\11bf5"
Noce the back reference (\1), which indicates the paern should be searched for and replaced only
once.
Results
Here is the resulng conguraon:
[edit]
user@host# show interfaces
xe-0/0/0 {
unit 0;
}
fe-3/0/1 {
vlan-tagging;
105
unit 0 {
description "inet6 configuration. IP: 2000::c0a8:1bf5";
vlan-id 100;
family inet {
address 17.10.1.1/24;
}
family inet6 {
address 2000::c0a8:1bf5/3;
}
}
}
In this example, the paern 2000::c0a8::1bf5 is replaced with 2000::c0a8:1bf5 once.
Example: Global Replace in a Device Conguraon—Replacing an
Interface Name
IN THIS SECTION
Requirements | 107
Overview | 107
Conguraon | 107
This example shows how to replace an interface name globally in a conguraon by using the replace
command.
Using the replace command can be a faster and beer way to change a conguraon. For example, a PIC
might be moved to another slot in a router, which changes the interface name. With one command you
can update the whole conguraon. Or you might want to quickly extend the conguraon with other
similar conguraons, for example, similar interfaces.
By using a combinaon of the copy and replace commands, you can add to a conguraon and then
replace certain aspects of the newly copied conguraons. The replace command works with regular
expressions. Regular expressions are quick, exible, and ubiquitous. You can fashion just about any
paern you might need to search for, and most programming languages support regular expressions.
106
Requirements
No special conguraon beyond device inializaon is required before conguring this example.
Before you begin, congure the following hierarchy on the router. To quickly congure this hierarchy,
see "CLI Quick Conguraon" on page 108 .
user@host# show interfaces
so-0/0/0 {
dce;
}
user@host# show protocols
ospf {
area 0.0.0.0 {
interface so-0/0/0.0 {
hello-interval 5;
}
}
}
Overview
This example shows how to replace an interface name globally in a conguraon by using the replace
command. It is a simple example.
The previous conguraon is the starng point for this conguraon update. In the course of this
example, you change the name of the inial interface throughout the conguraon with one command.
Conguraon
IN THIS SECTION
CLI Quick Conguraon | 108
Conguring an Interface Name Change | 108
Results | 108
107
CLI Quick Conguraon
To quickly congure the inial conguraon for this example, copy the following commands, paste them
into a text le, remove any line breaks and change any details necessary to match your network
conguraon, copy and paste these commands into the CLI at the [edit] hierarchy level, and then enter
commit from conguraon mode.:
set interfaces so-0/0/0 dce
set protocols ospf area 0.0.0.0 interface so-0/0/0.0 hello-interval 5
Conguring an Interface Name Change
Step-by-Step Procedure
To change an interface name:
1. Make sure that you are at the top of the conguraon mode hierarchy.
user@host# top
2. Replace so-0/0/0 with so-1/1/0 using the replace command, which uses the pattern keyword.
user@host# replace pattern so-0/0/0 with so-1/1/0
Results
Aer making the required changes, verify the conguraon by using the show interfaces and show protocols
conguraon mode commands.
[edit]
user@host# show interfaces
so-1/1/0 {
dce;
}
user@host# show protocols
ospf {
area 0.0.0.0 {
108
interface so-1/1/0.0 {
hello-interval 5;
}
}
}
Aer you have conrmed that the conguraon is correct, enter the commit command.
Example: Global Replace in a Device Conguraon—the upto Opon
Consider the hierarchy shown in Figure 3 on page 110. The text string 010101 appears in three places: the
descripon secons of ge-0/0/0, ge-0/0/0.0, and fe-0/0/1. These three instances are three objects. The
following example shows how you can use the upto opon to perform replacements in a device
conguraon:
109
Figure 3: Replacement by Object
An upto 2 opon in the replace command converts 01 to 02 for two object instances. The objects under the
main interfaces ge-0/0/0 and fe-0/0/1 will be replaced rst (since these are siblings in the hierarchy level).
Because of the upto 2 restricon, the replace command replaces paerns in the rst and second instance
in the hierarchy (siblings), but not the third instance (child of the rst instance).
user@host# show interfaces
ge-0/0/0 {
description "mkt 010101"; #First instance in the hierarchy
unit 0 {
110
description "mkt 010101"; #Third instance in the hierarchy (child of the first
instance)
}
}
fe-0/0/1 {
description "mkt 010101"; #second instance in the hierarchy (sibling of the first
instance)
unit 0 {
family inet {
address 200.200.20.2/24;
}
}
}
[edit]
user@host# replace pattern 01 with 02 upto 2
[edit]
user@host# commit
commit complete
[edit]
user@host# show interfaces
ge-0/0/0 {
description "mkt 020202"; #First instance in the hierarchy
unit 0 {
description "mkt 010101"; #Third instance in the hierarchy (child of the first
instance)
}
}
fe-0/0/1 {
description "mkt 020202"; #second instance in the hierarchy (sibling of the first
instance)
unit 0 {
family inet {
address 200.200.20.2/24;
}
}
}
111
Add Comments in a Device Conguraon
IN THIS SECTION
Add Comments in the CLI | 112
Add Comments in a File | 113
You can include comments in a device conguraon to describe any statement in the conguraon. You
can add comments interacvely in the CLI and by eding the ASCII conguraon le.
When conguring interfaces, you can add comments about the interface by including the description
statement at the [edit interfaces
interface-name
] hierarchy level. Any comments you include appear in the
output of the show interfaces commands..
Add Comments in the CLI
When you add comments in conguraon mode, they are associated with a statement at the current
level. Each statement can have one single-line comment associated with it. Before you can associate a
comment with a statement, the statement must exist. The comment is placed on the line preceding the
statement.
To add comments to a conguraon, use the annotate conguraon mode command:
user@host# annotate
statement
"
comment-string
"
statement
is the conguraon statement to which you are aaching the comment; it must be at the
current hierarchy level. If a comment for the specied
statement
already exists, it is deleted and replaced
with the new comment.
comment-string
is the text of the comment. The comment text can be any length, and you must type it on a
single line. If the comment contains spaces, you must enclose it in quotaon marks. In the comment
string, you can include the comment delimiters /* */ or #. If you do not specify any, the comment string
is enclosed with the /* */ comment delimiters.
To delete an exisng comment, specify an empty comment string:
user@host# annotate
statement
""
112
If you add comments with the annotate command, you can view the comments within the conguraon
by entering the show conguraon mode command or the show configuration operaonal mode
command.
NOTE: Junos OS supports annotaon up to the last level in the conguraon hierarchy, including
oneliners. However, annotaon of parts (the child statements or ideners within the oneliner)
of the oneliner is not supported. For example, in the following sample conguraon hierarchy,
annotaon is supported up to the level 1 parent hierarchy, but not supported for the metric child
statement:
[edit protocols]
isis {
interface ge-0/0/0.0 {
level 1 metric
10
;
}
}
}
Add Comments in a File
When you edit the ASCII conguraon le and add comments, they can be one or more lines and must
precede the statement they are associated with. If you place the comments in other places in the le,
such as on the same line following a statement or on a separate line following a statement, they are
removed when you use the load command to open the conguraon into the CLI.
The following excerpt from a conguraon example illustrates how to place and how not to place
comments in a conguraon le:
/* This comment goes with routing-options */
routing-options {
/* This comment goes with routing-options traceoptions */
traceoptions {
/* This comment goes with routing-options traceoptions tracefile */
tracefile rpd size 1m files 10;
/* This comment goes with routing-options traceoptions traceflag task */
traceflag task;
/* This comment goes with routing-options traceoptions traceflag general */
traceflag general;
}
autonomous-system 10458; /* This comment is dropped */
}
113
routing-options {
rib-groups {
ifrg {
import-rib [ inet.0 inet.2 ];
/* A comment here is dropped */
}
dvmrp-rib {
import-rib inet.2;
export-rib inet.2;
/* A comment here is dropped */
}
/* A comment here is dropped */
}
/* A comment here is dropped */
}
When you include comments in the conguraon le directly, you can format comments in the following
ways:
Start the comment with a /* and end it with a */. The comment text can be on a single line or can
span mulple lines.
Start the comment with a # and end it with a new line (carriage return).
Example: Include Comments in a Device Conguraon by Using the CLI
IN THIS SECTION
Requirements | 115
Overview | 115
Conguraon | 115
Adding comments to a device conguraon makes the conguraon le readable and more readily
understood by users. You can include comments as you congure by using the annotate statement. In this
example, comments are added by using the CLI for an already exisng conguraon:
114
Requirements
No special conguraon beyond device inializaon is required before conguring this example.
Before you add a comment, you must congure the following hierarchy on the router.
To quickly congure the inial conguraon for this example, copy the following command, paste it into
a text le, remove any line breaks and change any details necessary to match your network
conguraon, copy and paste this command into the CLI at the [edit] hierarchy level, and then enter
commit from conguraon mode.
set protocols ospf area 0.0.0.0 interface so-0/0/0.0 hello-interval 5
Now verify that you have this hierarchy congured.
user@host# show protocols
ospf {
area 0.0.0.0 {
interface so-0/0/0 {
hello-interval 5;
}
}
}
Overview
When you add comments by using the CLI, you do so in conguraon mode using the annotate
statement. Each comment you add is associated with a statement at the current level. Each statement
can have one single-line comment associated with it.
To congure the annotate statement, move to the level of the statement with which you want to associate
a comment. To view the comments, go to the top of the conguraon hierarchy and use the show
command.
Conguraon
IN THIS SECTION
CLI Quick Conguraon | 116
Including Comments in the CLI Conguraon Mode | 116
115
Results | 117
CLI Quick Conguraon
To quickly congure the comments for this example, copy the following commands, paste them into a
text le, remove any line breaks and change any details necessary to match your network conguraon,
copy and paste the commands into the CLI, starng at the [edit] hierarchy level, and then enter commit
from conguraon mode.
edit protocols ospf
annotate area 0.0.0.0 "Backbone area configuration added June 15, 2018"
edit area 0.0.0.0
annotate interface so-0/0/0.0 "Interface from router sj1 to router sj2"
Noce that the commands are moving you down the hierarchy as you annotate dierent secons of the
hierarchy.
Including Comments in the CLI Conguraon Mode
Step-by-Step Procedure
This procedure assumes that you have already congured the inial conguraon.
To add comments to a conguraon:
1. Move to the rst hierarchy level to which you need to add a comment.
[edit]
user@host# edit protocols ospf
2.
Add a comment to the area conguraon statement by using the annotate statement.
[edit protocols ospf]
user@host# annotate area 0.0.0.0 "Backbone area configuration added June 15, 1998"
116
3. Move down a level to the interface conguraon statement.
[edit protocols ospf]
user@host# edit area 0.0.0.0
4. Add a comment to interface so-0/0/0.0 by using the annotate statement.
[edit protocols ospf area 0.0.0.0]
user@host# annotate interface so-0/0/0.0 "Interface from router sj1 to router sj2"
Results
Move to the top of the hierarchy and use the show command to see the comments you added. The
comments precede the statement they are associated with.
[edit]
user@host# show protocols
ospf {
/* Backbone area configuration added June 15, 2018 */
area 0.0.0.0 {
/* Interface from router sj1 to router sj2 */
interface so-0/0/0.0 {
hello-interval 5;
}
}
}
Aer you have conrmed that the conguraon is correct, enter the commit command.
Example: Use the Wildcard Command with the Range Opon
IN THIS SECTION
Requirements | 118
Overview | 118
117
Conguraon | 118
If you need to make changes to the conguraon of a device, you can always remove the original
conguraon sengs using the delete command and add your new conguraon sengs using the set
command. However, there are other ways of modifying a conguraon that are more ecient and easier
to use.
This example shows how to use the wildcard command along with ranges in acvate, deacvate, delete,
protect, set, show, and unprotect conguraon commands.
NOTE: The wildcard command cannot create a conguraon hierarchy. You use it to modify
exisng statements. Expect CLI errors of the form warning: statement not found when you try to set
parameters, such as deacvate, on an empty hierarchy.
Requirements
Junos OS Release 12.1 or later running on the device.
Overview
The range opon with the wildcard command enables you to specify ranges in acvate, deacvate,
delete, protect, set, show, and unprotect commands. You can use ranges to specify a range of interfaces,
logical units, VLANs, and other numbered elements. The wildcard range opon expands the command
you entered into mulple commands, each of which corresponds to one item in the range.
The wildcard range opon enables you to congure mulple conguraon statements using a single set
command, instead of conguring each of them individually. For example, to congure 24 Gigabit
Ethernet interfaces with dierent port numbers, you can use a single wildcard range set command
instead of 24 individual set interfaces commands.
Similarly, to deacvate a group of 30 logical interfaces, you can use the wildcard range deacvate
command instead of deacvang each logical interface individually.
Conguraon
IN THIS SECTION
Use the wildcard command with range statements for a variety of conguraon tasks. | 119
118
Using the Range Opon for Conguring a Series of Named Ideners for a Conguraon
Statement | 120
Specifying Mulple Ranges in the Syntax | 121
Specifying a Range and Unique Numbers In the Syntax | 123
Excluding Some Values from a Range | 124
Specifying a Range with a Step Number | 125
Use Wildcard to Delete Policies p1-p10 | 126
Use the wildcard command with range statements for a variety of conguraon tasks.
Step-by-Step Procedure
1. You can use wildcard range with the acve, deacvate, delete, protect, set, show, and unprotect
conguraon commands.
[edit]
user@host# wildcard range ?
Possible completions:
activate Remove the inactive tag from a statement
annotate Annotate the statement with a comment
deactivate Add the inactive tag to a statement
delete Delete a data element
protect Protect the statement
set Set a parameter
show Show a parameter
unprotect Unprotect the statement
2. The wildcard statement can be qualied with a full conguraon hierarchy. When parked at a
conguraon hierarchy, the wildcard command is relave to the opons supported at that hierarchy.
[edit]
user@host# wildcard range set interfaces ?
Possible completions:
<interface-name> Interface name
+ apply-groups Groups from which to inherit configuration data
+ apply-groups-except Don't inherit configuration data from these groups
119
> interface-range Interface ranges configuration
> interface-set Logical interface set configuration
lo0 Interface name
> stacked-interface-set Stacked interface set configuration
> traceoptions Interface trace options
xe-0/0/0:0 Interface name
xe-0/0/0:1 Interface name
user@host# edit interfaces
[edit interfaces]
wildcard range set ?
Possible completions:
<interface-name> Interface name
+ apply-groups Groups from which to inherit configuration data
+ apply-groups-except Don't inherit configuration data from these groups
> interface-range Interface ranges configuration
> interface-set Logical interface set configuration
lo0 Interface name
> stacked-interface-set Stacked interface set configuration
> traceoptions Interface trace options
xe-0/0/0:0 Interface name
xe-0/0/0:1 Interface name
In the rst case the full path to the interfaces hierarchy is specied with the wildcard statement. In
the second, the user is parked at the interfaces hierarchy. The opons supported are the same with
either method.
Using the Range Opon for Conguring a Series of Named Ideners for a Conguraon Statement
Step-by-Step Procedure
To congure a series of the same type of interface with dierent port numbers (0 through 23), specify
the range for the port numbers with the following format.
1. [edit]
user@host# wildcard range set interfaces ge-0/0/[0-23] unit 0 family vpls
2. Display the result. The range wildcard range is expanded to 24 dierent set commands to congure
interfaces with port numbers ranging from 0 through 23. In this case the interfaces are created in
120
order to add the vpls protocol family. If the interfaces are already dened then just the family is
added.
root@R1# show | compare
[edit interfaces]
+ ge-0/0/0 {
+ unit 0 {
+ family vpls;
+ }
+ }
+ ge-0/0/1 {
+ unit 0 {
+ family vpls;
+ }
+ }
+ ge-0/0/2 {
+ unit 0 {
+ family vpls;
+ }
+ }
. . .
+ ge-0/0/23 {
+ unit 0 {
+ family vpls;
+ }
Specifying Mulple Ranges in the Syntax
Step-by-Step Procedure
You can have mulple ranges specied in a wildcard range command. Each range must be separated by a
comma. You can also have overlapping ranges.
NOTE: For the remaining examples you create a temporary copy of your conguraon with ten
policy statements. Having these statements avoids CLI errors that are reported when you try to
manipulate aributes in a null poron of the hierarchy.
[edit]
user@device# set policy-options policy-statement p1 then reject
121
set policy-options policy-statement p10 then reject
set policy-options policy-statement p2 then reject
set policy-options policy-statement p3 then reject
set policy-options policy-statement p4 then reject
set policy-options policy-statement p5 then reject
set policy-options policy-statement p6 then reject
set policy-options policy-statement p7 then reject
set policy-options policy-statement p8 then reject
set policy-options policy-statement p9 then reject
[edit]
user@device# save temp
Wrote 254 lines of configuration to 'temp'
1. To specify more than one range in the syntax, include the minimum and maximum values for each
range, separated by a comma.
[edit]
user@host# wildcard range deactivate policy-options policy-statement p[1-3,5-7,6-9]
2. Display the result. The wildcard range expands to add the deactivate statement to policies that have
names matching the specied ranges. Of note is the absence of
p4
and
p10
in the list of changes to
the candidate conguraon.
NOTE: An error is returned if the policy name specied does not already exist in the
conguraon. This is because you cannot add the deacvate statement to an empty poron
of the conguraon hierarchy.
[edit]
show | compare
[edit policy-options]
! inactive: policy-statement p1 { ... }
! inactive: policy-statement p2 { ... }
! inactive: policy-statement p3 { ... }
! inactive: policy-statement p5 { ... }
! inactive: policy-statement p6 { ... }
! inactive: policy-statement p7 { ... }
122
! inactive: policy-statement p8 { ... }
! inactive: policy-statement p9 { ... }
Specifying a Range and Unique Numbers In the Syntax
Step-by-Step Procedure
You can specify a combinaon of a range and unique numbers in the syntax of the wildcard range
command.
1. Reload the "temporary conguraon" on page 121.
[edit]
user@host# load override temp
load complete
1. To specify a range and a unique number, separate them with a comma. In this example 10 is added as
a unique number to a series of ranges.
[edit]
user@host# wildcard range deactivate policy-options policy-statement p[1-3,5,7,10]
2. Display the result. The wildcard range expands to add the deactivate statement to policies that have
names matching the specied ranges and also to the unique number. As a result the
p10
policy is also
deacvated in this example.
NOTE: An error is returned if the policy name specied does not already exist in the
conguraon. This is because you cannot add the deacvate statement to a empty
conguraon hierarchy.
[edit]
user@host# show | compare
[edit policy-options]
! inactive: policy-statement p1 { ... }
! inactive: policy-statement p10 { ... }
! inactive: policy-statement p2 { ... }
! inactive: policy-statement p3 { ... }
123
! inactive: policy-statement p5 { ... }
! inactive: policy-statement p7 { ... }
Excluding Some Values from a Range
Step-by-Step Procedure
You can exclude certain values from a range by marking the numbers or the range of numbers to be
excluded by using an exclamaon mark.
1. Reload the "temporary conguraon" on page 121.
[edit]
user@host# load override temp
load complete
2. To exclude certain values from a range, include the poron to be excluded with ! in the syntax.
[edit]
user@host# wildcard range deactivate policy-options policy-statement p[1-5,!3-4]
3. Display the result. The wildcard range expands to add the deactivate statement to policies that have
names matching the specied ranges. Note that policies
p3
and
p4
are absent in the list of
modicaons made to the candidate conguraon. They have been excluded from the wildcard
range.
NOTE: An error is returned if the policy name specied does not already exist in the
conguraon. This is because you cannot add the deacvate statement to a empty
conguraon hierarchy.
[edit]
user@host# show | compare
[edit policy-options]
! inactive: policy-statement p1 { ... }
! inactive: policy-statement p2 { ... }
! inactive: policy-statement p5 { ... }
124
Specifying a Range with a Step Number
Step-by-Step Procedure
You can provide a step number to have a constant interval in the range. The step value counts the rst
match, and then skips subsequent matches up to the specied step value.
1. Reload the "temporary conguraon" on page 121.
[edit]
user@host# load override temp
load complete
2. To provide a step, include the step value in the syntax preceded by a forward slash (/). Here we
specify a range of 1-10, skipping 1 number between each match using a step value of 2. The eect is
to skip all even numbered matches as we begin by matching an odd number (1).
[edit]
user@host# wildcard range deactivate policy-options policy-statement p[1-10/2]
3. Display the result. The wildcard range expands to add the deactivate statement to every other
matching statement, starng with the rst match.
NOTE: An error is returned if the policy name specied does not already exist in the
conguraon. This is because you cannot add the deacvate statement to a empty
conguraon hierarchy.
[edit]
user@host# show | compare
[edit policy-options]
! inactive: policy-statement p1 { ... }
! inactive: policy-statement p3 { ... }
! inactive: policy-statement p5 { ... }
! inactive: policy-statement p7 { ... }
! inactive: policy-statement p9 { ... }
125
To beer illustrate the step funcon, the temporary conguraon is restore and the wildcard
command is repeated, this me with a step value of 4. Now 3 entries are skipped aer each inial
match.
[edit]
user@host# load override temp
load complete
user@host## wildcard range deactivate policy-options policy-statement p[1-10/4]
\
4. Display the result. The wildcard range expands to add the deactivate statement to every fourth
matching statement, starng with the rst match.
[edit]
user@host# show | compare
[edit policy-options]
! inactive: policy-statement p1 { ... }
! inactive: policy-statement p5 { ... }
! inactive: policy-statement p9 { ... }
Use Wildcard to Delete Policies p1-p10
Step-by-Step Procedure
Delete the temporary policies added to test the wildcard funcon.
1. Use the delete statement with a wildcard range statement to delete policies
p1
through
p10
.
[edit]
user@host# wildcard range delete policy-options policy-statement p[1-10]
2.
Display the result. Our policy-options stanza contained only policies
p1
through
p10
. This results in an
empty policy-optionsconguraon hierarchy.
[edit]
user@host# show policy-options
126
Use Conguraon Groups to Quickly Congure
Devices
IN THIS SECTION
Conguraon Groups Overview | 128
Congure Conguraon Groups | 129
Create a Conguraon Group | 129
How to Apply a Conguraon Group | 131
Example: Create and Apply Conguraon Groups | 132
Example: Disable Inheritance of a Conguraon Group | 134
Example: Use the junos-defaults Conguraon Group | 136
Example: Use Wildcards with Conguraon Groups | 139
How to Improve Commit Time When Using Conguraon Groups | 142
Example: Congure Sets of Statements with Conguraon Groups | 143
Example: Congure Interfaces Using Conguraon Groups | 144
Example: Use Conguraon Groups to Congure a Consistent IP Address for the Management
Interface | 147
Example: Use Conguraon Groups to Congure Peer Enes | 149
Example: Use Conguraon Groups to Establish Regional Conguraons | 151
Example: Congure Wildcard Conguraon Group Names | 152
Example: Reference the Preset Statement from the Defaults Group | 154
Example: View Default Statements That Have Been Applied to the Conguraon | 155
Set Up Roung Engine Conguraon Groups | 156
How to Use Condions to Apply Conguraon Groups | 158
Example: Congure Condions for Applying Conguraon Groups | 159
Use conguraon groups to set up and apply common elements that are reused within the same
conguraon.
127
Conguraon Groups Overview
IN THIS SECTION
How Conguraon Groups Work | 128
Inheritance Model | 128
This topic provides an overview of conguraon groups and the inheritance model in the Junos OS CLI.
How Conguraon Groups Work
Conguraon groups enable you to create a group containing conguraon statements and to direct the
inheritance of that group’s statements in the rest of the conguraon. The same group can be applied to
dierent secons of the conguraon. Dierent secons of one groups conguraon statements can
be inherited in dierent places in the conguraon.
Conguraon groups enable you to create smaller, more logically constructed conguraon les, making
it easier to congure and maintain Juniper Networks devices. For example, you can group statements
that are repeated in many places in the conguraon, such as when conguring interfaces. By grouping
statements, you can limit conguraon updates to just the group.
You can also use wildcards in a conguraon group. Any object that matches the wildcard expression
inherits the group conguraon data.
The conguraon group mechanism is separate from the grouping mechanisms used elsewhere in the
conguraon, such as BGP groups. Conguraon groups provide a generic mechanism that you can use
throughout the conguraon but that are known only to the CLI. The individual soware processes that
perform the acons directed by the conguraon receive the expanded form of the conguraon; they
have no knowledge of conguraon groups.
Inheritance Model
Conguraon groups use true inheritance, which involves a dynamic, ongoing relaonship between the
source of the conguraon data and the target of that data. The target automacally inherits data values
that you change in the conguraon group. The target does not need to contain the inherited
informaon. However, the inherited values can be overridden in the target without aecng the source
from which they were inherited.
This inheritance model enables you to see only the instance-specic informaon without seeing the
inherited details. A command pipe in conguraon mode enables you to display the inherited data.
128
Congure Conguraon Groups
For areas of your conguraon to inherit conguraon statements, you must rst put the statements
into a conguraon group. You then apply that group to the levels in the conguraon hierarchy that
require the statements.
For areas of your conguraon to inherit conguraon statements:
1. Congure statements into a conguraon group. To congure conguraon groups and inheritance,
you can include the groups statement at the [edit] hierarchy level:
[edit]
groups {
group-name
{
configuration-data
;
}
}
2. Apply the conguraon group from step 1 to the levels in the conguraon hierarchy that require the
statements.
Include the apply-groups [
group-names
] statement anywhere in the conguraon where the
conguraon statements contained in a conguraon group are needed.
Create a Conguraon Group
The Junos OS CLI enables you to create re-usable groups containing conguraon statements. You can
apply these groups to to dierent secons of the conguraon where the same conguraon
statements are repeated mulple mes.
When you apply the group in dierent secons of the conguraon, that part of the conguraon
inherits the statements congured in the group. Conguraon groups follow the rule of inheritance
where the dynamic, ongoing relaonship is set between the source of the conguraon data and the
target of that data. If you change the data values in the conguraon group, the inherited target reects
the changes automacally.
You can overwrite the values in the target conguraon if required, which does not aect the source in
the group.
129
This inheritance model enables you to see only the instance-specic informaon without seeing the
inherited details. A command pipe in conguraon mode enables you to display the inherited data. For
example, you may want to congure all of your ge-0/0/1 interfaces for the MTU value of 1500.
To do congure all of your ge-0/0/1 interfaces for the MTU value of 1500:
1. Create a group with MTU value 1500:
[edit groups group-1]
lab@vSRX3-05# show
interfaces {
ge-0/0/1 {
unit 0 {
family inet {
mtu 1500;
}
}
}
}
2. Next, you apply the group in the interface conguraon.
[edit interfaces ge-0/0/1]
lab@vSRX3-05# set apply-groups group-1
3. View the inherited conguraon.
[edit]
lab@vSRX3-05# show interfaces ge-0/0/1 | display inheritance
unit 0 {
family inet {
##
## '1500' was inherited from group 'group-1'
##
mtu 1500;
address 5.0.0.254/24;
}
}
130
If you want to congure MTU value for interface ge-0/0/1 in dierent parts of the conguraon, you can
apply the group statement using the apply-groups opon. If you do this manually and later want to
increase the MTU, you may have to manually change every interface. If you use a conguraon group,
you can change the group conguraon, thereby automacally updang all associated interfaces.
You can also use wildcards in a conguraon group to allow conguraon data to be inherited by any
object that matches a wildcard expression. For example:
[edit groups group-1]
lab@vSRX3-05# show
interfaces {
ge-* {
unit 0 {
family inet {
mtu 1500;
}
}
}
}
How to Apply a Conguraon Group
If you want a Juniper Networks device conguraon to inherit the statements from a conguraon
group, include the apply-groups statement in the conguraon.
apply-groups [
group-names
];
If you specify more than one group name, you must list the names in order of inheritance priority. The
conguraon data in the rst group takes priority over the data in subsequent groups.
For devices that support mulple Roung Engines, you can specify re0 and re1 group names. The
conguraon specied in group re0 is applied only if the current Roung Engine is in slot 0. Likewise, the
conguraon specied in group re1 is applied only if the current Roung Engine is in slot 1. Therefore,
both Roung Engines can use the same conguraon le, each using only the conguraon statements
that apply to it. Each re0 or re1 group contains at a minimum the conguraon for the hostname and the
management interface (fxp0). If each Roung Engine uses a dierent management interface, the group
also should contain the conguraon for the backup router and stac routes.
131
You can include only one apply-groups statement at each specic level of the conguraon hierarchy. The
apply-groups statement at a specic hierarchy level lists the conguraon groups to be added to the
containing statement’s list of conguraon groups.
Values specied at the specic hierarchy level override values inherited from the conguraon group.
Groups listed in nested apply-groups statements take priority over groups in outer statements. In the
following example, the BGP neighbor 10.0.0.1 inherits conguraon data from group one rst. It then
inherits conguraon data from group two and group three. Conguraon data in group one overrides data
in any other group. Data from group ten is used only if a statement is not contained in any other group.
apply-groups [ eight nine ten ];
protocols {
apply-groups seven;
bgp {
apply-groups [ five six ];
group some-bgp-group {
apply-groups four;
neighbor 10.0.0.1 {
apply-groups [ one two three ];
}
}
}
}
The root level is the default logical system. When you congure a group dened for the root level, you
cannot successfully apply that group to a nondefault logical system under the [edit logical-systems
logical-system-name
] hierarchy level. Although the device accepts the commit if you apply the group, the
conguraon group does not take eect for the nondefault logical system. You can instead create an
addional conguraon group at the root level and apply it within the logical system. Alternavely, you
can modify the original group so that it includes conguraon for both the default and nondefault logical
system hierarchy levels.
Example: Create and Apply Conguraon Groups
This example illustrates the creaon and applicaon of conguraon groups. In this example, the SNMP
conguraon is divided between the group basic and the normal conguraon hierarchy.
You gain mulple advantages by placing the system-specic conguraon (SNMP contact) into a
conguraon group, thus separang it from the normal conguraon hierarchy:
132
You can replace either secon without discarding data from the other, by using the load replace
command.
You can set a contact for a specic box because the group data is hidden by the device-specic data.
[edit]
groups {
basic { # User-defined group name
snmp { # This group contains some SNMP data
contact "My Engineering Group";
community BasicAccess {
authorization read-only;
}
}
}
}
apply-groups basic; # Enable inheritance from group "basic"
snmp { # Some normal (non-group) configuration
location "West of Nowhere";
}
This conguraon is equivalent to the following:
[edit]
snmp {
location "West of Nowhere";
contact "My Engineering Group";
community BasicAccess {
authorization read-only;
}
}
133
Example: Disable Inheritance of a Conguraon Group
You can disable inheritance of a conguraon group at any level except the top level of the hierarchy. To
disable inheritance, you include the apply-groups-except statement in the conguraon:
apply-groups-except [
group-names
];
This statement is useful when you use the apply-group statement at a specic hierarchy level but also
want to override the values inherited from the conguraon group for a specic parameter.
Example: Disable Inheritance on Interface so-1/1/0
In the following example, the apply-groups statement is applied globally at the interfaces level. The apply-
groups-except statement is also applied at interface so-1/1/0 so that it uses the default values for the hold-
time and link-mode statements.
[edit]
groups { # "groups" is a top-level statement
global { # User-defined group name
interfaces {
<*> {
hold-time down 640;
link-mode full-duplex;
}
}
}
}
apply-groups global;
interfaces {
so-1/1/0 {
apply-groups-except global; # Disables inheritance from group "global"
# so-1/1/0 uses default value for “hold-time”
# and "link-mode"
}
}
Conguraon groups can add some confusion regarding the actual values used by the device, because a
device can inherit conguraon data from conguraon groups. To view the actual values used by the
device, you use the display inheritance command aer the pipe ( | ) in a show command. This command
134
displays the inherited statements at the level at which they are inherited and the group from which they
have been inherited:
[edit]
user@host# show | display inheritance
snmp {
location "West of Nowhere";
##
## 'My Engineering Group' was inherited from group 'basic'
##
contact "My Engineering Group";
##
## 'BasicAccess' was inherited from group 'basic'
##
community BasicAccess {
##
## 'read-only' was inherited from group 'basic'
##
authorization read-only;
}
}
To display the expanded conguraon (the conguraon, including the inherited statements) without
the ## lines, you use the except command aer the pipe in a show command:
[edit]
user@host# show | display inheritance | except ##
snmp {
location "West of Nowhere";
contact "My Engineering Group";
community BasicAccess {
authorization read-only;
}
}
NOTE: Using the display inheritance | except ## opon removes all the lines with ##. Therefore, you
may not be able to view informaon about passwords or other important data where ## is used.
To view the complete conguraon details with all the informaon (without just the comments
marked with ##), you use the no-comments opon with the display inheritance command:
135
[edit]
user@host# show | display inheritance no-comments
snmp {
location "West of Nowhere";
contact "My Engineering Group";
community BasicAccess {
authorization read-only;
}
}
Example: Use the junos-defaults Conguraon Group
Junos OS provides a hidden and immutable conguraon group called junos-defaults that is automacally
applied to the conguraon of your device. The junos-defaults group contains precongured statements
that contain predened values for common applicaons. Some of the statements must be referenced to
take eect, such as denions for applicaons (for example, FTP or telnet sengs). Other statements
are applied automacally, such as terminal sengs.
NOTE: Many ideners included in the junos-defaults conguraon group begin with the name
junos-. Because ideners beginning with the name junos- are reserved for use by Juniper
Networks, you cannot dene any conguraon objects using this name.
You cannot include junos-defaults as a conguraon group name in an apply-groups statement.
To view the full set of available preset statements from the junos-defaults group, you issue the show groups
junos-defaults conguraon mode command at the top level of the conguraon. The following example
displays a paral list of Junos defaults groups:
user@host# show groups junos-defaults
# Make vt100 the default for the console port
system {
ports {
console type vt100;
}
}
applications {
136
# File Transfer Protocol
application junos-ftp {
application-protocol ftp;
protocol tcp;
destination-port 21;
}
# Trivial File Transfer Protocol
application junos-tftp {
application-protocol tftp;
protocol udp;
destination-port 69;
}
# RPC port mapper on TCP
application junos-rpc-portmap-tcp {
application-protocol rpc-portmap;
protocol tcp;
destination-port 111;
}
# RPC port mapper on UDP
}
To reference statements available from the junos-defaults group, you include the selected junos-
default-
name
statement at the applicable hierarchy level.
To view the list of applicaons from the junos-defaults group, you issue the show configuration groups junos-
defaults applications. The applicaons that begin with junos- are congured by Juniper Networks by
default. The following example displays a paral list of Junos defaults groups applicaons.
user@host>show configuration groups junos-defaults applications
## protect: groups junos-defaults
##
#
# File Transfer Protocol
#
application junos-ftp {
application-protocol ftp;
protocol tcp;
destination-port 21;
}
#
# Trivial File Transfer Protocol
#
137
application junos-ftp-data {
application-protocol ftp-data;
protocol tcp;
destination-port 20;
}
application junos-tftp {
application-protocol tftp;
protocol udp;
destination-port 69;
}
#
# Two-Way Active Measurement Protocol
#
application junos-twamp {
application-protocol twamp;
protocol tcp;
destination-port 862;
}
#
# Real Time Streaming Protocol
#
application junos-rtsp {
application-protocol rtsp;
protocol tcp;
destination-port 554;
}
#
# Network Basic Input Output System - networking protocol used on
# Windows networks session service port
#
application junos-netbios-session {
protocol tcp;
destination-port 139;
}
application junos-smb-session {
protocol tcp;
destination-port 445;
}
application junos-ssh {
protocol tcp;
destination-port 22;
}
application junos-telnet {
138
protocol tcp;
destination-port 23;
}
Example: Use Wildcards with Conguraon Groups
You can use wildcards to idenfy names and allow one statement to provide data for a variety of
statements.
Using wildcards in normal conguraon data is done in a style that is consistent with that used with
tradional UNIX shell wildcards. In this style, you can use the following metacharacters:
Asterisk ( * )—Matches any string of characters.
Queson mark ( ? )—Matches any single character.
Open bracket ( [ )—Introduces a character class.
Close bracket ( ] )—Indicates the end of a character class. If the close bracket is missing, the open
bracket matches an open bracket [ rather than introducing a character class.
A character class matches any of the characters between the square brackets. Within a conguraon
group, you must enclose in quotaon marks an interface name that includes a character class.
Hyphen ( - )—Species a range of characters.
Exclamaon point ( ! )—You can complement the character class by making an exclamaon point the
rst character of the character class. To include a close bracket (]) in a character class, make it the
rst character listed (aer the !, if any). To include a minus sign, make it the rst or last character
listed.
NOTE: If using an idener inside the groups hierarchy, start the idener name with something
other than <. However, if you are dening a wildcard statement, you can use < because the
wildcard statement must have a closing >.
Using wildcards in conguraon groups follows the same rules as using them for normal conguraon.
However, < and > have a special meaning when used under the groups hierarchy. In the groups hierarchy,
139
you must enclose in angle brackets any term using a wildcard paern <
paern
> to dierenate it from
other wildcards in the conguraon le.
[edit]
groups {
sonet-default {
interfaces {
<so-*> {
sonet-options {
payload-scrambler;
rfc-2615;
}
}
}
}
}
Wildcard expressions match (and provide conguraon data for) exisng statements in the conguraon
that match their expression only. In the previous example, the expression <so-*> passes its sonet-options
statement to any interface that matches the expression so-*.
The following example shows how to specify a range of interfaces:
[edit]
groups {
gigabit-ethernet-interfaces {
interfaces {
"<ge-1/2/[5-8]>" {
description "These interfaces reserved for Customer ABC";
}
}
}
}
Angle brackets enable you to pass normal wildcards through without modicaon. In any matching
within the conguraon, whether it is done with or without wildcards, the rst item encountered in the
conguraon that matches is used. In the following example, data from the wildcarded BGP groups is
inherited in the order in which the groups are listed.
The preference value from <*a*> overrides the preference in <*b*>.
The p value from <*c*> overrides the one from <*d*>
140
Data values from any of these groups override the data values from abcd:
[edit]
user@host# show
groups {
one {
protocols {
bgp {
group <*a*> {
preference 1;
}
group <*b*> {
preference 2;
}
group <*c*> {
out-delay 3;
}
group <*d*> {
out-delay 4;
}
group abcd {
preference 10;
hold-time 10;
out-delay 10;
}
}
}
}
}
protocols {
bgp {
group abcd {
apply-groups one;
}
}
}
[edit]
user@host# show | display inheritance
protocols {
bgp {
group abcd {
##
141
## ’1’ was inherited from group ’one’
##
preference 1;
##
## ’10’ was inherited from group ’one’
##
hold-time 10;
##
## ’3’ was inherited from group ’one’
##
out-delay 3;
}
}
}
How to Improve Commit Time When Using Conguraon Groups
You use conguraon groups to apply conguraons across other hierarchies without re-entering
conguraon data. You can specify every conguraon detail in a conguraon groups. You can also use
wildcards in conguraon groups to congure ranges of data, without detailing each conguraon line.
Another way to use conguraon groups is to create an inheritance path that includes a long string of
conguraons to be applied.
When a conguraon that uses conguraon groups is commied, the commit process expands and
reads all the conguraon data of the group into memory to apply the conguraons as intended. The
commit performance can be negavely aected if many conguraon groups are being applied,
especially if the conguraon groups use wildcards extensively.
If your system uses many conguraon groups that use wildcards, you can congure the persist-groups-
inheritance statement at the [edit system commit] hierarchy level to improve commit me performance.
Using this opon enables the system to build the inheritance path for each conguraon group inside
the database rather than in the process memory. This change can improve commit me performance.
However, it can also increase the database size.
142
Example: Congure Sets of Statements with Conguraon Groups
When sets of statements exist in conguraon groups, all values are inherited. For example:
[edit]
user@host# show
groups {
basic {
snmp {
interface so-1/1/1.0;
}
}
}
apply-groups basic;
snmp {
interface so-0/0/0.0;
}
[edit]
user@host# show | display inheritance
snmp {
##
## ’so-1/1/1.0’ was inherited from group ’basic’
##
interface [ so-0/0/0.0 so-1/1/1.0 ];
}
For sets that are not displayed within brackets, all values are also inherited. For example:
[edit]
user@host# show
groups {
worldwide {
system {
name-server {
10.0.0.100;
10.0.0.200;
}
}
}
}
apply-groups worldwide;
143
system {
name-server {
10.0.0.1;
10.0.0.2;
}
}
[edit]
user@host# show | display inheritance
system {
name-server {
##
## ’10.0.0.100’ was inherited from group ’worldwide’
##
10.0.0.100;
##
## ’10.0.0.200’ was inherited from group ’worldwide’
##
10.0.0.200;
10.0.0.1;
10.0.0.2;
}
}
Example: Congure Interfaces Using Conguraon Groups
You can use conguraon groups to separate the common interface media parameters from the
interface-specic addressing informaon. The following example places conguraon data for ATM
interfaces into a group called atm-options.
[edit]
user@host# show
groups {
atm-options {
interfaces {
<at-*> {
atm-options {
vpi 0 maximum-vcs 1024;
}
unit <*> {
144
encapsulation atm-snap;
point-to-point;
family iso;
}
}
}
}
}
apply-groups atm-options;
interfaces {
at-0/0/0 {
unit 100 {
vci 0.100;
family inet {
address 10.0.0.100/30;
}
}
unit 200 {
vci 0.200;
family inet {
address 10.0.0.200/30;
}
}
}
}
[edit]
user@host# show | display inheritance
interfaces {
at-0/0/0 {
##
## "atm-options" was inherited from group "atm-options"
##
atm-options {
##
## "1024" was inherited from group "atm-options"
##
vpi 0 maximum-vcs 1024;
}
unit 100 {
##
## "atm-snap" was inherited from group "atm-options"
##
encapsulation atm-snap;
145
##
## "point-to-point" was inherited from group "atm-options"
##
point-to-point;
vci 0.100;
family inet {
address 10.0.0.100/30;
}
##
## "iso" was inherited from group "atm-options"
##
family iso;
}
unit 200 {
##
## "atm-snap" was inherited from group "atm-options"
##
encapsulation atm-snap;
##
## "point-to-point" was inherited from group "atm-options"
##
point-to-point;
vci 0.200;
family inet {
address 10.0.0.200/30;
}
##
## "iso" was inherited from group "atm-options"
##
family iso;
}
}
}
[edit]
user@host# show | display inheritance | except ##
interfaces {
at-0/0/0 {
atm-options {
vpi 0 maximum-vcs 1024;
}
unit 100 {
encapsulation atm-snap;
point-to-point;
146
vci 0.100;
family inet {
address 10.0.0.100/30;
}
family iso;
}
unit 200 {
encapsulation atm-snap;
point-to-point;
vci 0.200;
family inet {
address 10.0.0.200/30;
}
family iso;
}
}
}
SEE ALSO
Interface Naming Convenons Used in Operaonal Commands | 282
Example: Use Conguraon Groups to Congure a Consistent IP Address
for the Management Interface
On devices with mulple Roung Engines, each Roung Engine is congured with a separate IP address
for the management interface. To access the primary Roung Engine, you must know which Roung
Engine is acve and use the appropriate IP address.
Another opon for consistent access to the primary Roung Engine is to congure an addional IP
address. You then use this address for the management interface regardless of which Roung Engine is
acve. This addional IP address is acve only on the management interface for the primary Roung
Engine. During switchover, the address moves to the new primary Roung Engine.
This example congures address 10.17.40.131 for both Roung Engines and includes a master-only
statement. With this conguraon, the
10.17.40.131
address is acve only on the primary Roung Engine.
147
The address remains consistent regardless of which Roung Engine is acve. Address 10.17.40.132 is
assigned to fxp0 on re0, and 10.17.40.133 is assigned to fxp0 on re1.
[edit groups re0 interfaces fxp0]
unit 0 {
family inet {
address 10.17.40.131/25 {
master-only;
}
address 10.17.40.132/25;
}
}
[edit groups re1 interfaces fxp0]
unit 0 {
family inet {
address 10.17.40.131/25 {
master-only;
}
address 10.17.40.133/25;
}
}
This feature is available on all routers that include dual Roung Engines. On a roung matrix composed
of the TX Matrix router, this feature is applicable to the switch-card chassis (SCC) only. Likewise, on a
roung matrix composed of a TX Matrix Plus router, this feature is applicable to the switch-fabric
chassis (SFC) only.
NOTE:
You must assign unique IP addresses for two interfaces that have duplicate addresses on
private and public interfaces. When graceful Roung Engine switchover (GRES) is enabled, the
CLI displays an appropriate commit error message if it nds idencal addresses. This error can
occur if you congure the same IP address for a management interface or internal interface
such as fxp0 and an external physical interface such as ge-0/0/1.
The em0 management Ethernet interface is used for the TX Matrix Plus router, T1600 routers
in a roung matrix, and PTX Series Packet Transport Routers. Junos OS automacally creates
the device's management Ethernet interface, em0.
148
Example: Use Conguraon Groups to Congure Peer Enes
This example creates a group some-isp that contains conguraon data relang to another ISP. It then
inserts apply-group statements at various points to allow those locaons in the conguraon hierarchy to
inherit this data.
[edit]
user@host# show
groups {
some-isp {
interfaces {
<xe-*> {
gigether-options {
flow-control;
}
}
}
protocols {
bgp {
group <*> {
neighbor <*> {
remove-private;
}
}
}
pim {
interface <*> {
version 1;
}
}
}
}
}
interfaces {
xe-0/0/0 {
apply-groups some-isp;
unit 0 {
family inet {
address 10.0.0.1/24;
}
}
149
}
}
protocols {
bgp {
group main {
neighbor 10.254.0.1 {
apply-groups some-isp;
}
}
}
pim {
interface xe-0/0/0.0 {
apply-groups some-isp;
}
}
}
[edit]
user@host# show | display inheritance
interfaces {
xe-0/0/0 {
##
## "gigether-options" was inherited from group "some-isp"
##
gigether-options {
##
## "flow-control" was inherited from group "some-isp"
##
flow-control;
}
unit 0 {
family inet {
address 10.0.0.1/24;
}
}
}
}
protocols {
bgp {
group main {
neighbor 10.254.0.1 {
##
## "remove-private" was inherited from group "some-isp"
##
150
remove-private;
}
}
}
pim {
interface xe-0/0/0.0 {
##
## "1" was inherited from group "some-isp"
##
version 1;
}
}
}
Example: Use Conguraon Groups to Establish Regional Conguraons
This example populates one group with conguraon data that is standard throughout the company,
while another group contains regional deviaons from this standard:
[edit]
user@host# show
groups {
standard {
interfaces {
<t3-*> {
t3-options {
compatibility-mode larscom subrate 10;
idle-cycle-flag ones;
}
}
}
}
northwest {
interfaces {
<t3-*> {
t3-options {
long-buildout;
compatibility-mode kentrox;
}
151
}
}
}
}
apply-groups standard;
interfaces {
t3-0/0/0 {
apply-groups northwest;
}
}
[edit]
user@host# show | display inheritance
interfaces {
t3-0/0/0 {
##
## "t3-options" was inherited from group "northwest"
##
t3-options {
##
## "long-buildout" was inherited from group "northwest"
##
long-buildout;
##
## "kentrox" was inherited from group "northwest"
##
compatibility-mode kentrox;
##
## "ones" was inherited from group "standard"
##
idle-cycle-flag ones;
}
}
}
Example: Congure Wildcard Conguraon Group Names
Wildcards are conguraon group names that use special characters to create a paern that you can
apply to mulple statements. Wildcards are useful for copying one set of conguraon opons to many
dierent conguraon groups. You must set up your wildcard name properly to ensure that the wildcard
conguraon opons get copied to the appropriate conguraon groups.
152
This example congures dierent values for the <*-major> and <*-minor> wildcard groups under the label-
switched-path statement. The asterisk (*) character represents a secon of the wildcard name that can
match any string of characters. For example, the conguraon opons under label-switched-path <*-major>
are passed on to label-switched-path metro-major and any other label-switched-path conguraon group
containing -major in its name.
[edit]
user@host# show
groups {
mpls-conf {
protocols {
mpls {
label-switched-path <*-major> {
retry-timer 5;
bandwidth 155m;
optimize-timer 60;
}
label-switched-path <*-minor> {
retry-timer 15;
bandwidth 64k;
optimize-timer 120;
}
}
}
}
}
apply-groups mpls-conf;
protocols {
mpls {
label-switched-path metro-major {
to 10.0.0.10;
}
label-switched-path remote-minor {
to 10.0.0.20;
}
}
}
[edit]
user@host# show | display inheritance
protocols {
mpls {
label-switched-path metro-major {
153
to 10.0.0.10;
##
## "5" was inherited from group "mpls-conf"
##
retry-timer 5;
## "155m" was inherited from group "mpls-conf"
##
bandwidth 155m;
##
## "60" was inherited from group "mpls-conf"
##
optimize-timer 60;
}
label-switched-path remote-minor {
to 10.0.0.20;
##
## "15" was inherited from group "mpls-conf"
##
retry-timer 15;
##
## "64k" was inherited from group "mpls-conf"
##
bandwidth 64k;
##
## "120" was inherited from group "mpls-conf"
##
optimize-timer 120;
}
}
}
Example: Reference the Preset Statement from the Defaults Group
The following example is a preset statement from the defaults group that is available for FTP in a
stateful rewall:
[edit]
groups {
junos-defaults {
154
applications {
application junos-ftp {# Use FTP default configuration
application-protocol ftp;
protocol tcp;
destination-port 21;
}
}
}
To reference a preset default statement from the defaults group, include the junos-
default-name
statement
at the applicable hierarchy level. For example, to reference the default statement for FTP in a stateful
rewall, include the junos-ftp statement at the [edit services stateful-firewall rule my-rule term my-term from
applications] hierarchy level:
[edit]
services {
stateful-firewall {
rule my-rule {
term my-term {
from {
applications junos-ftp; #Reference predefined statement, junos-ftp
}
}
}
}
}
Example: View Default Statements That Have Been Applied to the
Conguraon
To view the defaults that have been applied to the device conguraon, you issue the show | display
inheritance defaults command. This example displays the inherited defaults at the [edit system ports]
hierarchy level:
user@host# show system ports | display inheritance defaults
## ## 'console' was inherited from group 'junos-defaults'
155
## 'vt100' was inherited from group 'junos-defaults'
## console type vt100;
If you choose not to use exisng default statements, you can create your own conguraon groups
manually.
To view the complete conguraon informaon oming any comments marked with ##, use the no-
comments opon with the display inheritance command.
Set Up Roung Engine Conguraon Groups
In a device with two Roung Engines, both Roung Engines should share one conguraon. This setup
ensures that both Roung Engine conguraons are idencal. Within this conguraon, create two
Roung Engine groups, one for each Roung Engine. Within these groups, you specify the Roung
Engine–specic parameters.
For more informaon about the inial conguraon for redundant Roung Engine systems and the re0
group, see Junos OS High Availability User Guide.
To set up a Roung Engine conguraon group:
1. Create the conguraon group re0. The re0 group is a special group designator that RE0 uses, only in
a redundant roung plaorm.
[edit]
root# set groups re0
2. Navigate to the groups re0 level of the conguraon hierarchy.
[edit]
root# edit groups re0
3. Specify the device hostname.
[edit groups re0]
root# set system host-name
host-name
156
NOTE: The DNS server does not use the hostname that you specify in the device
conguraon to resolve to the correct IP address. The DNS server uses this hostname to
display the name of the Roung Engine in the CLI. For example, the hostname appears at
the command-line prompt when you are logged in to the CLI:
user-name
@
host-name
>
4. Congure the IP address and prex length for the device Ethernet interface.
For all devices
except
the TX Matrix Plus router, T1600 or T4000 routers in a roung matrix,
and PTX Series Packet Transport Routers:
[edit]
root@# set interfaces fxp0 unit 0 family inet address
address
/
prefix-length
For the TX Matrix Plus router, T1600 or T4000 routers in a roung matrix only, and PTX Series
Packet Transport Routers:
[edit]
root@# set interfaces em0 unit 0 family inet address
address
/
prefix-length
To use em0 as an out-of-band management Ethernet interface, you must congure its logical port,
em0.0, with a valid IP address.
5. Return to the top level of the hierarchy.
[edit groups re0]
root# top
6. Create the conguraon group re1.
[edit]
root# set groups re1
7.
Navigate to the groups re1 level of the conguraon hierarchy.
[edit]
root# edit groups re1
157
8. Specify the device hostname.
[edit groups re1]
root# set system host-name
host-name
9. Congure the IP address and prex length for the device Ethernet interface.
For all devices
except
the TX Matrix Plus router, T1600 or T4000 routers in a roung matrix,
and PTX Series Packet Transport Routers:
[edit]
root@# set interfaces fxp0 unit 0 family inet address
address
/
prefix-length
For the TX Matrix Plus router and T1600 or T4000 routers in a roung matrix only:
[edit]
root@# set interfaces em0 unit 0 family inet address
address
/
prefix-length
To use em0 as an out-of-band management Ethernet interface, you must congure its logical port,
em0.0, with a valid IP address.
10. Return to the top level of the hierarchy.
[edit groups re0]
root# top
11. Specify the group applicaon order.
[edit]
root# set apply-groups [ re0 re1 ]
How to Use Condions to Apply Conguraon Groups
You can use the when statement at the [edit groups
group-name
] hierarchy level to dene condions under
which to apply a conguraon group.
You can congure a group to apply based on the type of chassis, model, or Roung Engine,
virtual
chassis
member, cluster node, and start and oponal end me of day or date.
158
For example, you could use the when statement to create a generic conguraon group for each type of
node and then apply the conguraon based on certain node properes, such as chassis or model.
Example: Congure Condions for Applying Conguraon Groups
IN THIS SECTION
Requirements | 159
Overview | 159
Conguraon | 160
This example shows how to congure condions under which a specied conguraon group is to be
applied.
Requirements
No special conguraon beyond device inializaon is required before you congure this example.
Overview
You can congure your group conguraon data at the [edit groups
group-name
] hierarchy level. You can
then use the when statement to apply the group conguraon based on condions such as these: Type of
chassis, model, roung-engine, virtual chassis member, cluster node, and start and oponal end me of
day or date.
If you specify mulple condions in a single conguraon group, all condions must be met before the
conguraon group is applied.
You can specify the start me or the me duraon for the conguraon group to be applied. If only the
start me is specied, the conguraon group is applied at the specied me and it remains in eect
unl the me is changed. If the end me is specied, then on each day, the applied conguraon group
is started and stopped at the specied mes.
This example sets condions in a conguraon group, test1, such that this group is applied only when all
of the following condions are met: the router is a model MX240 router with chassis type LCC0, with a
Roung Engine operang as RE0, is member0 of the virtual chassis on node0, and the conguraon
group will only be in eect from 9:00 a.m. unl 5:00 p.m. each day.
159
Conguraon
IN THIS SECTION
Vericaon | 162
CLI Quick Conguraon
To quickly congure this example, copy the following commands, paste them into a text le, remove any
line breaks, change any details necessary to match your network conguraon, and then copy and paste
the commands into the CLI at the [edit] hierarchy level.
set groups test1 when model mx240
set groups test1 when chassis lcc0
set groups test1 when routing-engine re0
set groups test1 when member member0
set groups test1 when node node0
set groups test1 when time 9 to 5
Procedure
Step-by-Step Procedure
To congure condions for conguraon group test1:
1. Set the condion that idenes the model MX240 router.
[edit groups test1 when]
user@host# set model mx240
2. Set the condion that idenes the chassis type as LCC0.
[edit groups test1 when]
user@host# set chassis lcc0
160
3. Set the condion that idenes the Roung Engine operang as RE0.
[edit groups test1 when]
user@host# set routing-engine re0
4. Set the condion that idenes the virtual chassis member0.
[edit groups test1 when]
user@host# set member member0
5. Set the condion that idenes the cluster node0.
[edit groups test1 when]
user@host# set node node0
6. Set the condion that applies the group only between the hours of 9:00 a.m. and 5:00 p.m. daily.
[edit groups test1 when]
user@host# set time 9 to 5
NOTE: The syntax for specifying the me is: time
<start-time>
[to
<end-time>
] using the me
format yyyy-mm-dd.hh:mm, hh:mm, or hh.
7. Commit the conguraon.
user@host# commit
Results
In conguraon mode, conrm your conguraon by entering the show groups test1 command. If the
output does not display the intended conguraon, repeat the instrucons in this example to correct
the conguraon.
user@host# show groups test1
when {
161
time 9 to 5;
chassis lcc0;
model mx240;
routing-engine re0;
member member0;
node node0;
}
Vericaon
IN THIS SECTION
Check Group Inheritance with Condional Data | 162
Check Group Inheritance with Condional Data
Purpose
Verify that condional data from a conguraon group is inherited when applied.
Acon
Issue the show | display inheritance operaonal command with the when data to display the condional
inheritance. Using this example, you can issue one of these commands to determine that the condional
data was inherited:
user@host> show | display inheritance when model mx240
user@host> show | display inheritance when chassis lcc0
user@host> show | display inheritance when routing-engine re0
user@host> show | display inheritance when member member0
user@host> show | display inheritance when node node0
user@host> show | display inheritance when time 9 to 5
162
View the Conguraon
IN THIS SECTION
Display the Current Conguraon | 163
Example: Display the Current Conguraon | 164
Display Addional Informaon About the Conguraon | 166
Display set Commands from the Conguraon | 169
The show conguraon mode command displays the current conguraon for a device running Junos OS.
Display the Current Conguraon
To display the current conguraon for a Juniper Networks device, use the show command in
conguraon mode. This command displays the conguraon at the current hierarchy level or at the
specied level.
user@host# show
<statement-path>
The conguraon statements appear in a xed order, interfaces appear alphabecally by type, and then
in numerical order by slot number, PIC number, and port number. Note that when you congure the
device, you can enter statements in any order.
You also can use the CLI operaonal mode show configuration command to display the last commied
conguraon, which is the conguraon currently running on the router:
user@host> show configuration
163
When you show a conguraon, a mestamp at the top of the conguraon indicates when the
conguraon was last changed:
## Last commit: 2018-07-18 11:21:58 PDT by echen
version 8.3
If you have omied a required statement at a specic hierarchy level, when you issue the show command
in conguraon mode, a message indicates which statement is missing. If a mandatory statement is
missing, the CLI connues to display this message each me you issue a show command.
For example:
[edit]
user@host# show
protocols {
pim {
interface so-0/0/0 {
priority 4;
version 2;
# Warning: missing mandatory statement(s): 'mode'
}
}
}
Unsupported statements included in the CLI conguraon are displayed with the “unsupported” text in
the conguraon. For example, if a statement is congured on an unsupported plaorm, the CLI displays
a message that the statement is ignored in the conguraon because it is congured on an unsupported
plaorm. When you issue the show command with the | display xml opon, you can see the
unsupported="unsupported” aribute for conguraon that is unsupported.
The “unsupported” aribute included in text conguraon or XML conguraon is provided to scripts
when the unsupported="unsupported" aribute is included in the <get-configuration> RPC call.
Example: Display the Current Conguraon
The following example shows how you can display the current device conguraon.
164
Set and commit a conguraon:
[edit]
user@host# set protocols ospf area 0.0.0.0 interface xe-0/0/0 hello-interval 5
[edit]
user@host# commit
commit complete
[edit]
user@host# quit
exiting configuration mode
Display the current conguraon:
[edit]
user@host# show
protocols {
ospf {
area 0.0.0.0 {
interface xe-0/0/0 {
hello-interval 5;
}
}
}
}
Display the conguraon at a parcular hierarchy:
[edit]
user@host# show protocols ospf area 0.0.0.0
interface xe-0/0/0 {
hello-interval 5;
}
Move down a level and display the conguraon at that level:
[edit]
user@host# edit protocols ospf area 0.0.0.0
[edit protocols ospf area 0.0.0.0]
user@host# show
interface xe-0/0/0 {
165
hello-interval 5;
}
Display the last commied conguraon:
user@host> show configuration
## Last commit: 2018-08-10 11:21:58 PDT by user
version 8.3
protocols {
ospf {
area 0.0.0.0 {
interface xe-0/0/0 {
hello-interval 5;
}
}
}
}
Display Addional Informaon About the Conguraon
In conguraon mode only, to display addional informaon about the device conguraon, use the
display detail command aer the pipe ( | ) in conjuncon with a show command. The addional
informaon includes the help string that explains each conguraon statement and the permission bits
required to add and modify the conguraon statement.
user@host# show <
hierarchy-level
> | display detail
For example:
[edit]
user@host# show | display detail
##
## version: Software version information
## require: system
##
version 21.3-202107190949.0;
system {
##
166
## host-name: Host name for this router
## match: ^[[:alnum:]._-]+$
## require: system
##
}
host-name router-name;
##
## domain-name: Domain name for this router
## match: ^[[:alnum:]._-]+$
## require: system
##
domain-name isp.net;
##
## backup-router: Address of router to use while booting
##
backup-router 192.168.100.1;
root-authentication {
##
## encrypted-password: Encrypted password string
##
encrypted-password "$ABC123"; # SECRET-DATA
}
##
## name-server: DNS name servers
## require: system
##
name-server {
##
## name-server: DNS name server address
##
208.197.1.0;
}
login {
##
## class: User name (login)
## match: ^[[:alnum:]_-]+$
##
class super-user {
##
## permissions: Set of permitted operation categories
##
permissions all;
}
167
...
##
## services: System services
## require: system
##
services {
## services: Service name
##
ftp;
##
## services: Service name
##
telnet;
##
}
syslog {
##
## file-name: File to record logging data
##
file messages {
##
## Facility type
## Level name
##
any notice;
##
## Facility type
## Level name
##
authorization info;
}
}
}
chassis {
alarm {
sonet {
##
## lol: Loss of light
## alias: loss-of-light
##
lol red;
}
}
168
}
interfaces {
##
## Interface name
##
xe-2/1/1 {
atm-options {
##
## vpi: Virtual path index
## range: 0 .. 255
## maximum-vcs: Maximum number of virtual circuits on this VP
##
vpi 0 maximum-vcs 512;
}
##
## unit: Logical unit number
## range: 0 .. 16384
##
unit 0 {
##
## vci: ATM point-to-point virtual circuit identifier ([vpi.]vci)
}
##
vci 0.128;
}
}
...
Display set Commands from the Conguraon
IN THIS SECTION
Example: Display set Commands from the Conguraon | 170
Example: Display set Commands with the match Opon | 172
169
In conguraon mode, you can display the conguraon as a series of conguraon mode commands
required to re-create the conguraon. This is useful if you are not familiar with how to use
conguraon mode commands or if you want to cut, paste, and edit the displayed conguraon.
To display the conguraon as a series of conguraon mode commands, which are required to re-
create the conguraon from the top level of the hierarchy as set commands, issue the show conguraon
mode command with the display set opon:
user@host# show | display set <explicit>
When you issue the show configuration command with the | display set pipe opon to view the
conguraon as set commands, those porons of the conguraon that you do not have permissions to
view are substuted with the text ACCESS-DENIED.
You can use the <explicit> opon with the | display set command, to explicitly display all the
conguraon statements that the system internally creates, as a series of set commands, when you
congure certain statements from the top level of the hierarchy.
For example, assume you issue the set interfaces ge-0/0/0.0 family inet conguraon mode command.
You then show the resulng conguraon with the show interfaces ge-0/0/0 | display set command.
The output displays the same set command you entered. If you include the explicit argument, the output
also shows the conguraon statements needed to create the hierarchy where the family inet statement
is specied. Specically for this example, the output therefore includes the set interfaces ge-0/0/0 unit
0 statement in addion to the set interfaces ge-0/0/0.0 family inet statement.
Example: Display set Commands from the Conguraon
Display the set commands from the conguraon at the [edit interfaces] hierarchy level:
[edit interfaces xe-0/0/0]
user@host# show
unit 0 {
family inet {
address 192.107.1.230/24;
}
family iso;
family mpls;
}
inactive: unit 1 {
family inet {
address 10.0.0.1/8;
}
170
}
[edit interfaces ge-0/0/0]
user@host# show | display set
set interfaces ge-0/0/0 unit 0 family inet address 192.107.1.230/24
set interfaces xe-0/0/0 unit 1 family inet address 10.0.0.1/8
deactivate interfaces xe-0/0/0 unit 1
[edit interfaces ge-0/0/0]
user@host# show | display set | explicit
set interfaces ge-0/0/0 unit 0 family inet address 192.107.1.230/24
set interfaces xe-0/0/0 unit 0 family iso
set interfaces xe-0/0/0 unit 0 family mpls
set interfaces ge-0/0/0 unit 0 family inet
set interfaces ge-0/0/0 unit 0
set interfaces xe-0/0/0 unit 1 family inet address 10.0.0.1/8
deactivate interfaces xe-0/0/0 unit 1
To display the conguraon as a series of conguraon mode commands required to re-create the
conguraon from the current hierarchy level, issue the show conguraon mode command with the show
| display set relative opon. You can use the <explicit> opon to explicitly display, as a series of
commands, all the conguraons that the system internally creates when you congure certain
statements from the current hierarchy level.
[edit interfaces fe-0/0/0]
user@host# show
unit 0 {
family inet {
address 192.107.1.230/24;
}
family iso;
family mpls;
}
inactive: unit 1 {
family inet {
address 10.0.0.1/8;
}
}
[edit interfaces xe-0/0/0]
user@host# show | display set relative
set unit 0 family inet address 192.107.1.230/24
171
set unit 0 family iso
set unit 0 family mpls
set unit 1 family inet address 10.0.0.1/8
deactivate unit 1
user@host# show | display set relative | explicit
set unit 0 family inet address 192.168.1.230/24
set unit 0 family inet
set unit 0 family iso
set unit 0 family mpls
set unit 0
set unit 1 family inet address 10.0.0.1/8
set unit 1 family inet
deactivate unit 1
Example: Display set Commands with the match Opon
To display the conguraon as set commands and search for text matching a regular expression by
ltering output, specify the match opon aer the pipe ( | ):
user@host# show | display set | match
regular-expression
Display IP addresses associated with an interface:
xe-2/3/0 {
unit 0 {
family inet {
address 192.107.9.106/30;
}
}
}
so-5/1/0 {
unit 0 {
family inet {
address 192.107.9.15/32 {
destination 192.107.9.192;
}
}
}
}
172
lo0 {
unit 0 {
family inet {
address 127.0.0.1/32;
}
}
}
user@host# show interfaces | display set | match address
set interfaces xe-2/3/0 unit 0 family inet address 192.168.9.106/30
set interfaces so-5/1/0 unit 0 family inet address 192.168.9.15/32 destination 192.168.9.192
set interfaces lo0 unit 0 family inet address 127.0.0.1/32
Verify the Device Conguraon
To verify that the syntax of a Juniper Networks device conguraon is correct, use the conguraon
mode commit check command:
[edit]
user@host# commit check
configuration check succeeds
[edit]
user@host#
If the commit check command nds an error, a message indicates the locaon of the error.
RELATED DOCUMENTATION
Commit a Device Conguraon | 176
173
Commit the Conguraon
IN THIS SECTION
The Commit Model for Conguraons | 174
Commit a Device Conguraon | 176
Commit Operaon When Mulple Users Congure the Soware | 177
Commit Preparaon and Acvaon Overview | 178
Commit Device Conguraons in Two Steps: Preparaon and Acvaon | 180
Acvate a Device Conguraon with Conrmaon | 182
Schedule a Commit Operaon | 183
Monitor the Commit Process | 184
Add a Comment to Describe the Commied Conguraon | 186
Batch Commits Overview | 187
Example: Congure Batch Commit Server Properes | 188
Back Up the Commied Conguraon on the Alternate Boot Drive | 199
The commit conguraon mode command enables you to save the device conguraon changes to the
conguraon database and to acvate the conguraon on the device.
The Commit Model for Conguraons
The device conguraon is saved using a commit model—a candidate conguraon is modied as
desired and then commied to the system. When a conguraon is commied, the device checks the
conguraon for syntax errors, and if no errors are found, the conguraon is saved as juniper.conf.gz
and acvated. The formerly acve conguraon le is saved as the rst rollback conguraon le
(juniper.conf.1.gz), and any other rollback conguraon les are incremented by 1. For example,
juniper.conf.1.gz is incremented to juniper.conf.2.gz, making it the second rollback conguraon le.
The device can have a maximum of 49 rollback conguraons (numbered 1 through 49) saved on the
system.
174
On the device, the current conguraon le and the rst three rollback les (juniper.conf.gz.1,
juniper.conf.gz.2, juniper.conf.gz.3) are located in the /cong directory. (The remaining rollback les, 4
through 49, are located in /var/db/cong.)
If the recovery conguraon le rescue.conf.gz exists, this le is also located in the /cong directory.
The factory default les are located in the /etc/cong directory.
There are two mechanisms used to propagate the conguraons between Roung Engines within a
device:
Synchronizaon: Propagates a conguraon from one Roung Engine to a second Roung Engine
within the same device chassis.
To synchronize conguraons, use the commit synchronize CLI command. If one of the Roung Engines
is locked, the synchronizaon fails. If synchronizaon fails because of a locked conguraon le, you
can use the commit synchronize force command. This command overrides the lock and synchronizes the
conguraon les.
Distribuon: Propagates a conguraon across the roung plane on a mulchassis device.
Distribuon occurs automacally. There is no user command available to control the distribuon
process. If a conguraon is locked during a distribuon of a conguraon, the locked conguraon
does not receive the distributed conguraon le, so the synchronizaon fails. You need to clear the
lock before the conguraon and resynchronize the roung planes.
NOTE: When you use the commit synchronize force CLI command on a mulchassis plaorm, the
forced synchronizaon of the conguraon les does not aect the distribuon of the
conguraon le across the roung plane. If a conguraon le is locked on a device remote
from the device where the command was issued, the synchronizaon fails on the remote
device. You need to clear the lock and reissue the synchronization command.
SEE ALSO
Conguring Junos OS for the First Time on a Device with a Single Roung Engine
175
Commit a Device Conguraon
To save device conguraon changes to the conguraon database and to acvate the conguraon on
the device, use the commit conguraon mode command. You can issue the commit command from any
hierarchy level:
[edit]
user@host# commit
commit complete
[edit]
user@host#
When you enter the commit command, the conguraon is rst checked for syntax errors (commit check).
Then, if the syntax is correct, the conguraon is acvated and becomes the current, operaonal device
conguraon.
NOTE: We do not recommend performing a commit operaon on the backup Roung Engine
when graceful Roung Engine switchover is enabled on the router.
A conguraon commit can fail for any of the following reasons:
The conguraon includes incorrect syntax, which causes the commit check to fail.
The candidate conguraon that you are trying to commit is larger than 700 MB.
The conguraon is locked by a user who entered the configure exclusive command.
If the conguraon contains syntax errors, a message indicates the locaon of the error, and the
conguraon is not acvated. The error message has the following format:
[edit
edit-path
]
offending-statement
;’
error-message
For example:
[edit firewall filter login-allowed term allowed from]
‘icmp-type [ echo-request echo-reply ];’
keyword ‘echo-reply’ unrecognized
176
You must correct the error before recomming the conguraon. To return quickly to the hierarchy
level where the error is located, copy the path from the rst line of the error and paste it at the
conguraon mode prompt at the [edit] hierarchy level.
The uncommied, candidate conguraon le is /var/rundb/juniper.db. It is limited to 700 MB. If the
commit fails with a message configuration database size limit exceeded, view the le size from conguraon
mode by entering the command run file list /var/rundb detail. You can simplify the conguraon and
reduce the le size by creang conguraon groups with wildcards or dening less specic match
policies in your rewall lters.
NOTE: CLI commit-me warnings displayed for conguraon changes at the [edit interfaces]
hierarchy level are removed and are logged as system log messages.
This is also applicable to VRRP conguraon at the following hierarchy levels:
[edit interfaces
interface-name
unit
logical-unit-number
family (
inet
|
inet6
) address
address
]
[edit logical-systems
logical-system-name
interfaces
interface-name
unit
logical-unit-number
family
(inet | inet6) address
address
]
When you commit a conguraon, you commit the enre conguraon in its current form.
NOTE:
We do not recommend performing a commit operaon on the backup Roung Engine when
graceful Roung Engine switchover
is enabled on the device.
If you congure the same IP address for a management interface or internal interface such as
fxp0 and an external physical interface such as ge-0/0/1, when graceful Roung Engine
switchover (GRES) is enabled, the CLI displays an appropriate commit error message that
idencal addresses have been found on the private and public interfaces. In such cases, you
must assign unique IP addresses for the two interfaces that have duplicate addresses.
Commit Operaon When Mulple Users Congure the Soware
Up to 32 users can be in conguraon mode simultaneously making changes to the conguraon. All
changes made by all users are visible to everyone eding the conguraon—the changes become visible
as soon as the user presses the Enter key at the end of a command that changes the conguraon, such
as set, edit, or delete.
177
When any of the users eding the conguraon issues a commit command, the CLI checks and acvates
all changes by all users.
If you enter conguraon mode with the configure private command, each user has a private candidate
conguraon to edit somewhat independently of other users. When you commit the conguraon, the
CLI commits only your own changes. To synchronize your copy of the conguraon aer other users
have commied changes, you can run the update command in conguraon mode. A commit operaon
also updates all the private candidate conguraons. For example, suppose user X and user Y are both in
configure private mode, and user X commits a conguraon change. When user Y performs a subsequent
commit operaon and then views the new conguraon, the new conguraon seen by user Y includes
the changes made by user X.
If you enter conguraon mode with the configure exclusive command, you lock the candidate
conguraon for as long as you remain in conguraon mode. This allows you to make changes without
interference from other users. Other users can enter and exit conguraon mode, but they cannot
commit the conguraon. This is true even if the other users entered conguraon mode before you
enter the configure exclusive command. For example, suppose user X is already in the configure private or
configure mode. Then suppose user Y enters the configure exclusive mode. User X cannot commit any
changes to the conguraon, even if user X entered those changes before user Y logged in. If user Y
exits configure exclusive mode, user X can then commit the changes made in configure private or configure
mode.
Commit Preparaon and Acvaon Overview
You can complete the commit process in two steps. The two-step commit feature enables you to
congure several devices and simultaneously acvate the conguraons. Two-step commit provides a
denive me window for the commit to be eecve on the system. You can enter commit mode aer
the commit is prepared, but you will receive a message that the commit is pending acvaon.
In the rst step, the preparaon stage, the commit is validated and a new database with the necessary
les is generated. If the conguraon contains any syntax errors, an appropriate error message is
displayed, and the conguraon is not prepared. In the event of failure during the preparaon stage, the
error message commit check-out faileddisplays.
In the second step, the acvaon stage, the previously prepared conguraon is acvated. Next, if you
need to clear the prepared conguraon, you can do so by using clear system commit prepared command. A
log message is generated upon successful clearing of the pending commit.
NOTE: You cannot perform commit operaons in between preparaon and acvaon stages.
178
The two-step commit process is superior to the single-step process for me-crical commits. In the
single-step process, the preparaon me can vary depending on the exisng conguraon on the
device. In the two-step process, the complex preparaon work is more eciently handled.
Conguraon commands are provided that allow you to prepare the conguraon cache and acvate
the conguraon. You can prepare the devices with new conguraons and acvate them at the exact
mes you want.
The commit prepare command validates the conguraons, and the commit activate command acvates the
conguraons. The commands have the following conguraon opons:
and-quit
no-synchronize
peers-synchronize
synchronize
The commit prepare and commit activate commands are available for private, exclusive and shared commits
only. The commands are not applicable for dynamic and ephemeral modes. This feature is applicable for
mulchassis devices, but it is not applicable for batch commits.
To support this funconality using Network Conguraon Protocol (NETCONF), the following new
remote procedure calls (RPCs) are provided:
<commit-configuration>< prepare/></commit-configuration>
<commit-configuration><activate/></commit-configuration>
<clear-system-commit><prepared/></clear-system-commit>
NOTE:
In an MX Series Virtual Chassis setup the following applies: When commit prepare is issued on
one Roung Engine followed by switchover, the Roung Engine where the switchover
command is issued reboots. Therefore, the prepared cache is cleared in that Roung Engine.
In an MX Series Virtual Chassis setup, it is advisable to execute clear system commit prepared
command only on VC primary.
179
Commit Device Conguraons in Two Steps: Preparaon and Acvaon
You can complete the commit process in two steps. This enables you to congure several devices, and
the conguraons can be acvated simultaneously. In the rst step, known as the preparaon stage, the
commit is validated and a new database along with necessary les is generated. If the conguraon
contains any syntax errors, an appropriate error message is displayed, and the conguraon is not
prepared. In the second step, referred to as the acvaon stage, the previously prepared conguraon is
acvated and becomes the current, operaonal device conguraon.
To prepare the conguraon:
1. At the [edit] hierarchy level in conguraon mode, make the necessary changes to the conguraon.
For example, to congure the scripts of the system, issue the following command:
[edit]
user@host# set system scripts
language
For example:
[edit]
user@host#set system scripts language python
2. Issue the commit prepare command.
[edit]
user@host# commit prepare
The message commit prepare successful is displayed.
If the preparaon stage fails, the error message commit check-out failed is displayed.
[edit]
user@host# set interfaces ge-0/0/0 unit 0 family inet address 1.1.1.2/2
[edit]
user@host# set interfaces ge-0/0/1 unit 0 family inet address 1.1.1.2/24
[edit]
user@host# commit prepare
[edit interfaces ge-2/0/0 unit 0 family inet]
'address 1.1.1.2/24'
180
Cannot have the same local address on the same unit of an interface
error: configuration check-out failed
3. To verify the output of the show system commit command aer commit prepare is issued, use the following
command:
user@host> show system commit
commit prepared by user via cli is pending activation
To acvate the prepared conguraon:
1. Use the commit activate command
[edit]
user@host# commit activate
The message commit complete is displayed.
2. To verify the acvated system conguraon, use the following command:
user@host> show configuration system scripts
language python;
To verify the output of the show system commit and show system commit revision detail commands aer commit
activate is issued, issue the following commands.
user@host> show system commit
0 2018-07-12 22:54:46 PDT by user via cli commit activate
user@host> show system commit revision detail
Revision: re0-1499925285-2214
User : user
Client : cli
Time : 2018-07-12 22:54:46 PDT
Comment : commit activate
181
Acvate a Device Conguraon with Conrmaon
When you commit the current candidate conguraon, you can require an explicit conrmaon for the
commit to become permanent. This is useful if you want to verify that a conguraon change works
correctly and does not prevent access to the device. If the change prevents access or causes other
errors, the device automacally returns to the previous conguraon and restores access aer the
rollback conrmaon meout passes. This feature is called automac rollback.
To commit the current candidate conguraon but require an explicit conrmaon for the commit to
become permanent, use the commit confirmed conguraon mode command:
[edit]
user@host# commit confirmed
commit confirmed will be automatically rolled back in 10 minutes unless confirmed
commit complete
#commit confirmed will be rolled back in 10 minutes
[edit]
user@host#
Once you have veried that the change works correctly, you can keep the new conguraon acve by
entering a commit or commit check command within 10 minutes of the commit confirmed command. For
example:
[edit]
user@host# commit check
configuration check succeeds
If the commit is not conrmed within a certain me (10 minutes by default), the operang system
automacally rolls back to the previous conguraon and a broadcast message is sent to all logged-in
users.
To show when a rollback is scheduled aer a commit confirmed command, enter the show system commit
command. For example:
user@host>show system commit
0 2018-01-05 15:00:37 PST by root via cli commit confirmed, rollback in 3mins
Like the commit command, the commit confirmed command veries the conguraon syntax and reports any
errors. If there are no errors, the conguraon is acvated temporarily (10 minutes by default) and
begins running on the device.
182
Figure 4: Conrm a Conguraon
To change the amount of me before you must conrm the new conguraon, specify the number of
minutes when you issue the command:
[edit]
user@host# commit confirmed
minutes
commit complete
[edit]
user@host#
You can also use the commit confirmed command in the [edit private] conguraon mode.
Schedule a Commit Operaon
You can schedule when you want your candidate conguraon to become acve. To save device
conguraon changes and acvate the conguraon on the device at a future me or upon reboot, use
the commit at conguraon mode command, specifying reboot or a future me at the [edit] hierarchy level:
[edit]
user@host # commit at
string
string
is reboot or the future me to acvate the conguraon changes. You can specify me in two
formats:
A me value in the form
hh
:
mm
[:
ss
] (hours, minutes, and oponally seconds)—Commit the
conguraon at the specied me, which must be in the future but before 11:59:59 PM on the day
the commit at conguraon mode command is issued. Use 24-hour me for the
hh
value; for example,
183
04:30:00 is 4:30:00 AM, and 20:00 is 8:00 PM. The me is interpreted with respect to the clock and
me zone sengs on the router.
A date and me value in the form
yyyy-mm-dd hh
:
mm
[:
ss
] (year, month, date, hours, minutes, and,
oponally, seconds)—Commit the conguraon at the specied day and me, which must be aer
the commit at command is issued. Use 24-hour me for the
hh
value. For example, 2018-08-21 12:30:00 is
12:30 PM on August 21, 2018. The me is interpreted with respect to the clock and me zone
sengs on the router.
Enclose the
string
value in quotaon marks (" "). For example, commit at "18:00:00". For date and me,
include both values in the same set of quotaon marks. For example, commit at "2018-03-10 14:00:00".
A commit check is performed immediately when you issue the commit at conguraon mode command. If
the result of the check is successful, then the current user is logged out of conguraon mode, and the
conguraon data is le in a read-only state. No other commit can be performed unl the scheduled
commit is completed.
NOTE: If the device soware fails before the conguraon changes become acve, all
conguraon changes are lost.
You cannot enter the commit at conguraon command aer you issue the request system reboot
command.
You cannot enter the request system reboot command once you schedule a commit operaon for a
specic me in the future.
You cannot commit a conguraon when a scheduled commit is pending. For informaon about
how to cancel a scheduled conguraon by means of the clear command, see the CLI Explorer.
NOTE: We do not recommend performing a commit operaon on the backup Roung Engine
when graceful Roung Engine switchover is enabled on the device.
Monitor the Commit Process
To monitor the device conguraon commit process, use the display detail command aer the pipe with
the commit command:
user@host# commit | display detail
184
For example:
[edit]
user@host# commit | display detail
2018-09-22 15:39:39 PDT: exporting juniper.conf
2018-09-22 15:39:39 PDT: setup foreign files
2018-09-22 15:39:39 PDT: propagating foreign files
2018-09-22 15:39:39 PDT: complete foreign files
2018-09-22 15:39:40 PDT: copying configuration to juniper.data+
2018-09-22 15:39:40 PDT: dropping unchanged foreign files
2018-09-22 15:39:40 PDT: daemons checking new configuration
2018-09-22 15:39:41 PDT: commit wrapup...
2018-09-22 15:39:42 PDT: activating '/var/etc/ntp.conf'
2018-09-22 15:39:42 PDT: activating '/var/etc/kmd.conf'
2018-09-22 15:39:42 PDT: activating '/var/db/juniper.data'
2018-09-22 15:39:42 PDT: notifying daemons of new configuration
2018-09-22 15:39:42 PDT: signaling 'Firewall daemon', pid 24567, signal 1,
status 0
2018-09-22 15:39:42 PDT: signaling 'Interface daemon', pid 24568, signal 1,
status 0
2018-09-22 15:39:43 PDT: signaling 'Routing protocol daemon', pid 25679,
signal 1, status 0
2018-09-22 15:39:43 PDT: signaling 'MIB2 daemon', pid 24549, signal 1,
status 0
2018-09-22 15:39:43 PDT: signaling 'NTP daemon', pid 37863, signal 1, status 0
2018-09-22 15:39:43 PDT: signaling 'Sonet APS daemon', pid 24551, signal 1,
status 0
2018-09-22 15:39:43 PDT: signaling 'VRRP daemon', pid 24552, signal 1,
status 0
2018-09-22 15:39:43 PDT: signaling 'PFE daemon', pid 2316, signal 1, status 0
2018-09-22 15:39:43 PDT: signaling 'Traffic sampling control daemon', pid 24553
signal 1, status 0
2018-09-22 15:39:43 PDT: signaling 'IPsec Key Management daemon', pid
24556, signal 1, status 0
2018-09-22 15:39:43 PDT: signaling 'Forwarding UDP daemon', pid 2320,
signal 1, status 0
commit complete
185
Add a Comment to Describe the Commied Conguraon
You can include a comment that describes changes to the commied conguraon. To do so, include the
commit comment statement. The comment can be as long as 512 bytes and you must type it on a single line.
[edit]
user@host# commit comment
comment-string
comment-string
is the text of the comment.
NOTE: You cannot include a comment with the commit check command.
To add a comment to the commit command, include the comment statement aer the commit command:
[edit]
user@host# commit comment "add user joe"
commit complete
[edit]
user@host#
To add a comment to the commit confirmed command, include the comment statement aer the commit
confirmed command:
[edit]
user@host# commit confirmed comment "add customer to port 27"
commit confirmed will be automatically rolled back in 10 minutes unless confirmed
commit complete
[edit]
user@host#
To view these commit comments, issue the show system commit operaonal mode command.
NOTE: You can also use the commit confirmed command in the [edit private] conguraon mode.
Starng in Junos OS Release 24.2R1, Junos OS enforces you to issue a comment for each commit
request. This helps to track changes made by mulple users or administrators at the me of commit.
186
NOTE: The commit command does not execute without the comment argument.
To enforce the user to add a comment for each commit request, congure force-commit-log opon at the
[edit system commit] hierarchy level.
Batch Commits Overview
IN THIS SECTION
Aggregaon and Error Handling | 187
Batch commit aggregates or merges mulple conguraon edits from dierent CLI sessions or users and
adds them to a batch commit queue. A batch commit server running on the device takes one or more
jobs from the batch commit queue, applies the conguraon changes to the shared conguraon
database, and then commits the conguraon changes in a single commit operaon.
Batches are priorized by the commit server based on priority of the batch specied by the user or the
me when the batch job is added. When one batch commit is complete, the next set of conguraon
changes are aggregated and loaded into the batch queue for the next session of the batch commit
operaon. Batches are created unl there are no commit entries le in the queue directory.
When compared to the regular commit operaon where all commits are independently commied
sequenally, batch commits save me and system resources by comming mulple small conguraon
edits in a single commit operaon.
Batch commits are performed from the [edit batch] conguraon mode. The commit server properes
can be congured at the [edit system commit server] hierarchy level.
Aggregaon and Error Handling
When there is a load-me error in one of the aggregated jobs, the commit job that encounters the error
is discarded and the remaining jobs are aggregated and commied.
For example, if there are ve commit jobs (commit-1, commit-2, commit-3, commit-4, and commit-5) being
aggregated, and commit-3 encounters an error while loading, commit-3 is discarded and commit-1, commit-2,
commit-4, and commit-5 are aggregated and commied.
187
If there is an error during the commit operaon when two or more jobs are aggregated and commied,
the aggregaon is discarded and each of those jobs is commied individually like a regular commit
operaon.
For example, if there are ve commit jobs (commit-1, commit-2, commit-3, commit-4, and commit-5) that are
aggregated and if there is a commit error caused because of commit-3, the aggregaon is discarded,
commit-1, commit-2, commit-3, commit-4, and commit-5 are commied individually, and the CLI reports a commit
error for commit-3.
Example: Congure Batch Commit Server Properes
IN THIS SECTION
Requirements | 188
Overview | 188
Conguraon | 189
Vericaon | 192
This example shows how to congure batch commit server properes to manage batch commit
operaons.
Requirements
This example uses the following hardware and soware components:
MX Series 5G Universal Roung Plaorm
Overview
You can control how the batch commit queue is handled by the commit server by conguring the server
properes at the [edit system commit server] hierarchy level. This enables you to control how many commit
jobs are aggregated or merged into a single batch commit, the maximum number of jobs that can be
added to the queue, days to keep batch commit error logs, interval between two batch commits, and
tracing operaons for batch commit operaons.
188
Conguraon
IN THIS SECTION
CLI Quick Conguraon | 189
Conguring the Commit Server Properes | 189
Comming the Conguraon from Batch Conguraon Mode | 191
CLI Quick Conguraon
To quickly congure this secon of the example, copy the following commands, paste them into a text
le, remove any line breaks, change any details necessary to match your network conguraon, and
then copy and paste the commands into the CLI at the [edit] hierarchy level. You can congure the
commit server properes from either the regular [edit] mode or the [edit batch] mode.
Device R0
set system commit server maximum-aggregate-pool 4
set system commit server maximum-entries 500
set system commit server commit-interval 5
set system commit server days-to-keep-error-logs 30
set system commit server traceoptions file commitd_nov
set system commit server traceoptions flag all
Conguring the Commit Server Properes
Step-by-Step Procedure
1. (Oponal) Congure the number of commit transacons to aggregate or merge in a single commit
operaon.
The default value for maximum-aggregate-pool is 5.
NOTE: Seng maximum-aggregate-pool to 1 commits each of the jobs individually.
189
In this example, the number of commit transacons is set to 4 indicang that four dierent commit
jobs are aggregated into a single commit before the commit operaon is iniated.
[edit system commit server]
user@R0# set maximum-aggregate-pool 4
2. (Oponal) Congure the maximum number of jobs allowed in a batch.
This limits the number of commits jobs that are added to the queue.
[edit system commit server]
user@R0# set maximum-entries 500
NOTE: If you set maximum-entries to 1, the commit server cannot add more than one job to the
queue, and the CLI displays an appropriate message when you try to commit more than one
job.
3. (Oponal) Congure the me (in seconds) to wait before starng the next batch commit operaon.
[edit system commit server]
user@R0# set commit-interval 5
4. (Oponal) Congure the number of days to keep error logs.
The default value is 30 days.
[edit system commit server]
user@R0# set days-to-keep-error-logs 30
5. (Oponal) Congure tracing operaons to log batch commit events.
In this example, the lename for logging batch commit events is commitd_nov, and all traceopon ags
are set.
[edit system commit server]
user@R0# set traceoptions commitd_nov
user@R0# set traceoptions flag all
190
Results
From conguraon mode, conrm your conguraon by entering the show system commit server command.
If the output does not display the intended conguraon, repeat the instrucons in this example to
correct the conguraon.
user@R0# show system commit server
maximum-aggregate-pool 4;
maximum-entries 500;
commit-interval 5;
days-to-keep-error-logs 30;
traceoptions {
file commitd_nov;
flag all;
}
Comming the Conguraon from Batch Conguraon Mode
Step-by-Step Procedure
To commit the conguraon from the [edit batch] mode, do one of the following:
Log in to the device and enter commit.
[edit batch]
user@R0# commit
Added to commit queue request-id: 1000
To assign a higher priority to a batch commit job, issue the commit command with the priority opon.
[edit batch]
user@R0# commit priority
Added to commit queue request-id: 1001
191
To commit a conguraon without aggregang the conguraon changes with other commit jobs in
the queue, issue the commit command with the atomic opon.
[edit batch]
user@R0# commit atomic
Added to commit queue request-id: 1002
To commit a conguraon without aggregang the conguraon changes with other commit jobs in
the queue, and issuing a higher priority to the commit job, issue the commit command with the atomic
priority opon.
[edit batch]
user@R0# commit atomic priority
Added to commit queue request-id: 1003
Vericaon
IN THIS SECTION
Checking the Batch Commit Server Status | 192
Checking the Batch Commit Status | 193
Viewing the Patch Files in a Batch Commit Job | 194
Viewing the Trace Files for Batch Commit Operaons | 197
Conrm that the conguraon is working properly.
Checking the Batch Commit Server Status
Purpose
Check the status of the batch commit server.
192
Acon
user@R0> show system commit server
Commit server status : Not running
By default, the status of the commit server is Not running. The commit server starts running only when a
batch commit job is added to the queue.
When a batch commit job is added to the queue, the status of the commit server changes to Running.
user@R0> show system commit server
Commit server status : Running
Jobs in process:
1003 1004 1005
Meaning
The Jobs in process eld lists the commit IDs of jobs that are in process.
Checking the Batch Commit Status
Purpose
Check the commit server queue for the status of the batch commits.
Acon
user@R0> show system commit server queue
Pending commits:
Id: 1005
Last Modified: Tue Nov 1 23:56:43 2018
Completed commits:
Id: 1000
Last Modified: Tue Nov 1 22:46:43 2018
Status: Successfully committed 1000
Id: 1002
193
Last Modified: Tue Nov 1 22:50:35 2018
Status: Successfully committed 1002
Id: 1004
Last Modified: Tue Nov 1 22:51:48 2018
Status: Successfully committed 1004
Id: 1007
Last Modified: Wed Nov 2 01:08:04 2018
Status: Successfully committed 1007
Id: 1009
Last Modified: Wed Nov 2 01:16:45 2018
Status: Successfully committed 1009
Id: 1010
Last Modified: Wed Nov 2 01:19:25 2018
Status: Successfully committed 1010
Id: 1011
Last Modified: Wed Nov 2 01:28:16 2018
Status: Successfully committed 1011
Error commits:
Id: 1008
Last Modified: Wed Nov 2 01:08:18 2018
Status: Error while commiting 1008
Meaning
Pending commits displays commit jobs that are added to the commit queue but are not commied yet.
Completed commits displays the list of commit jobs that are successful. Error commits are commits that failed
because of an error.
Viewing the Patch Files in a Batch Commit Job
Purpose
View the mestamps, patch les, and the status of each of the commit jobs. Patch les show the
conguraon changes that occur in each commit operaon that is added to the batch commit queue.
194
Acon
1. Use the show system commit server queue patch command to view the patches for all commit operaons.
user@R0> show system commit server queue patch
Pending commits:
none
Completed commits:
Id: 1000
Last Modified: Tue Nov 1 22:46:43 2018
Status: Successfully committed 1000
Patch:
[edit groups]
re1 { ... }
+ GRP-DHCP-POOL-NOACCESS {
+ access {
+ address-assignment {
+ pool <*> {
+ family inet {
+ dhcp-attributes {
+ maximum-lease-time 300;
+ grace-period 300;
+ domain-name verizon.net;
+ name-server {
+ 4.4.4.1;
+ 4.4.4.2;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
Id: 1002
Last Modified: Tue Nov 1 22:50:35 2018
Status: Successfully committed 1002
Patch:
[edit]
195
+ snmp {
+ community abc;
+ }
Id: 1010
Last Modified: Wed Nov 2 01:19:25 2018
Status: Successfully committed 1010
Patch:
[edit system syslog]
file test { ... }
+ file j {
+ any any;
+ }
Error commits:
Id: 1008
Last Modified: Wed Nov 2 01:08:18 2018
Status: Error while commiting 1008
Patch:
[edit system]
+ radius-server {
+ 10.1.1.1 port 222;
+ }
The output shows the changes in conguraon for each commit job ID.
2. To view the patch for a specic commit job ID, issue the show system commit server queue patch id
<id-
number>
command.
user@R0> show system commit server queue patch id 1000
Completed commits:
Id: 1000
Last Modified: Tue Nov 1 22:46:43 2018
Status: Successfully committed 1000
Patch:
[edit system]
+ radius-server {
+ 192.168.69.162 secret teH.bTc/RVbPM;
+ 192.168.64.10 secret teH.bTc/RVbPM;
+ 192.168.60.52 secret teH.bTc/RVbPM;
196
+ 192.168.60.55 secret teH.bTc/RVbPM;
+ 192.168.4.240 secret teH.bTc/RVbPM;
+ }
Meaning
The output shows the patch created for a commit job. The + or - sign indicates the changes in the
conguraon for a specic commit job.
Viewing the Trace Files for Batch Commit Operaons
Purpose
View the trace les for batch commit operaons. You can use the trace les for troubleshoong
purposes.
Acon
Use the file show /var/log/
<filename>
command to view all entries in the log le.
user@R0> file show/var/log/commitd_nov
The output shows commit server event logs and other logs for batch commits.
Nov 1 22:46:43 Successfully committed 1000
Nov 1 22:46:43 pausing after commit for 0 seconds
...
Nov 1 22:46:43 Done working on queue
...
Nov 1 22:47:17 maximum-aggregate-pool = 5
Nov 1 22:47:17 maximum-entries= 0
Nov 1 22:47:17 asynchronous-prompt = no
Nov 1 22:47:17 commit-interval = 0
Nov 1 22:47:17 days-to-keep-error-logs = -1
...
Nov 1 22:47:17 Added to commit queue request-id: 1001
Nov 1 22:47:17 Commit server status=running
Nov 1 22:47:17 No need to pause
...
197
Nov 1 22:47:18 Error while commiting 1001
Nov 1 22:47:18 doing rollback
...
To view log entries only for successful batch commit operaons, issue the file show /var/log/
<filename>
command with the | match committed pipe opon.
The output shows batch commit job IDs for successful commit operaons.
user@R0> file show/var/log/commitd_nov | match committed
Nov 1 22:46:43 Successfully committed 1000
Nov 1 22:50:35 Successfully committed 1002
Nov 1 22:51:48 Successfully committed 1004
Nov 2 01:08:04 Successfully committed 1007
Nov 2 01:16:45 Successfully committed 1009
Nov 2 01:19:25 Successfully committed 1010
Nov 2 01:28:16 Successfully committed 1011
To view log entries only for failed batch commit operaons, issue the file show /var/log/
<filename>
command with the | match “Error while” pipe opon.
The output shows commit job IDs for failed commit operaons.
user@R0> file show/var/log/commitd_nov | match “Error while”
Nov 1 22:47:18 Error while commiting 1001
Nov 1 22:51:10 Error while commiting 1003
Nov 1 22:52:15 Error while commiting 1005
...
To view log entries only for commit server events, issue the file show /var/log/
<filename>
command
with the | match “commit server” pipe opon.
The output shows commit server event logs.
user@R0> file show/var/log/commitd_nov | match “commit server”
Nov 1 22:46:39 Commit server status=running
Nov 1 22:46:39 Commit server jobs=1000
Nov 1 22:46:43 Commit server status=not running
198
Nov 1 22:46:43 Commit server jobs=
Nov 1 22:47:17 Commit server status=running
Nov 1 22:47:18 Commit server jobs=1001
Nov 1 22:47:18 2 errors reported by commit server
Nov 1 22:47:18 Commit server status=not running
Nov 1 22:47:18 Commit server jobs=
Nov 1 22:50:31 Commit server status=running
Nov 1 22:50:31 Commit server jobs=1002
Nov 1 22:50:35 Commit server status=not running
Nov 1 22:50:35 Commit server jobs=
Nov 1 22:51:09 Commit server status=running
Nov 1 22:51:10 Commit server jobs=1003
Nov 1 22:51:10 2 errors reported by commit server
Nov 1 22:51:10 Commit server status=not running
...
Back Up the Commied Conguraon on the Alternate Boot Drive
Aer you commit the conguraon and are sased that it is running successfully, you should issue the
request system snapshot command to back up the new soware onto the /altconfig le system. If you do
not issue the request system snapshot command, the conguraon on the alternate boot drive is out of
sync with the conguraon on the primary boot drive.
The request system snapshot command backs up the root le system to /altroot, and /config to /altconfig.
The root and /config le systems are on the router’s ash drive, and the /altroot and /altconfig le
systems are on the router’s hard disk (if available).
Aer you issue the request system snapshot command, you cannot return to the previous version of the
soware because the running and backup copies of the soware are idencal.
RELATED DOCUMENTATION
Overview of the Congure Command | 65
199
4
CHAPTER
Managing Conguraons
Conguraon Files Overview | 201
Managing Conguraons | 203
Autoinstallaon of Conguraon Files Overview | 226
Loading Conguraon Files | 231
Back Up Conguraons to an Archive Site | 249
Factory Default Conguraon Overview | 252
Rescue Conguraon | 253
Encrypt and Decrypt Conguraon Files | 255
Example: Protecng the Junos OS Conguraon from Modicaon or Deleon |
259
Synchronizing Conguraons Across Roung Engines | 270
Conguraon Files Overview
IN THIS SECTION
Conguraon Files Overview | 201
Device Conguraon Storage Overview | 203
You use conguraon les to congure devices and to streamline device conguraon tasks. A
conguraon le stores the complete conguraon of a device. Keep in mind these disncons
between conguraon les:
The acve (running) conguraon is the operaonal le of the device. These les control device
behavior.
The candidate conguraon is the working copy that stores conguraon updates. These are the
les that you use to automac device conguraon.
Conguraon Files Overview
IN THIS SECTION
Conguraon File Terms | 202
A conguraon le stores the complete conguraon of a network device. The current conguraon of
a device is called the acve conguraon. You can alter this current conguraon, and you can also
return to a previous conguraon or to a rescue conguraon.
The 50 most recently commied conguraon les on a device are saved so that you can return to a
previous conguraon. The conguraon les are named as follows:
juniper.conf.gzThe current acve conguraon
juniper.conf.1.gz to juniper.conf.49.gz—Rollback conguraons
201
To make changes to the conguraon le, you must use conguraon mode in the CLI. When making
changes to a conguraon le, you are viewing and changing the candidate conguraon le. The
candidate conguraon enables you to make conguraon changes without causing operaonal
changes to the acve conguraon or causing potenal damage to your current network operaons.
Aer you commit the changes you made to the candidate conguraon, the system updates the acve
conguraon.
Conguraon File Terms
Table 8: Conguraon File Terms
Term Denion
acve conguraon Current commied conguraon of a device.
candidate conguraon Working copy of the conguraon that enables users to make conguraonal changes
without causing any operaonal changes unl this copy is commied.
conguraon group Group of conguraon statements that the rest of the conguraon can inherit.
commit a conguraon The act of checking a conguraon for proper syntax, acvang it, and marking as the
current conguraon le running on the device.
conguraon hierarchy A hierarchy of statements comprising the system conguraon. The two types of
statements are container and leaf: Container statements contain other statements.
Leaf statements do not contain other statements. All the container and leaf statements
together form the conguraon hierarchy.
default conguraon The inial values set for each conguraon parameter when a device is shipped.
rescue conguraon Well-known conguraon that recovers a device from a conguraon that denies
management access. Through the CLI, you set a current commied conguraon to be
the rescue conguraon.
roll back a conguraon The act of returning to a previously commied conguraon.
202
Device Conguraon Storage Overview
When you edit a Juniper Networks device conguraon, you work in a copy of the current conguraon
to create a candidate conguraon. The changes that you make to the candidate conguraon are
visible in the CLI immediately. Therefore, if mulple users are eding the conguraon at the same me,
all users can see all changes.
You commit your changes to cause a candidate conguraon to take eect. At this point, the candidate
le is checked for proper syntax, acvated, and marked as the current, operaonal soware
conguraon le. If mulple users are eding the conguraon simultaneously, all changes made by all
the users take eect when you commit the candidate conguraon.
In addion to saving the current conguraon, the CLI saves the current operaonal version and the
previous 49 versions of commied conguraons. The most recently commied conguraon is version
0, which is the current operaonal version. This current operaonal version is the default conguraon
that the system returns to if you roll back to a previous conguraon. The oldest saved conguraon is
version 49.
By default, the current conguraon and three previous versions of the commied conguraon are
saved on the device CompactFlash card. The currently operaonal device conguraon is stored in the
le juniper.conf.gz, and the last three commied conguraons are stored in the les juniper.conf.1.gz,
juniper.conf.2.gz, and conf.3.gz. These four les are stored on the device’s CompactFlash card in the
directory /cong.
The remaining 46 previous versions of commied conguraons, the les juniper.conf.4 through
juniper.conf.49, are stored in the directory /var/db/cong on the hard disk.
Managing Conguraons
IN THIS SECTION
The show | compare | display xml Command Output | 204
Returning to the Most Recently Commied Conguraon | 213
Returning to a Previously Commied Conguraon | 214
Using Conguraon Revision Ideners | 218
Saving a Conguraon to a File | 220
About Compressing the Current Conguraon File | 221
203
Free Up System Storage Space | 222
Clean Up Files with the CLI | 224
The show | compare | display xml Command Output
IN THIS SECTION
Add a Statement (create Operaon) | 205
Delete a Statement (delete Operaon) | 206
Change a Statement (delete and create Operaons) | 208
Change Metadata (inacve Aribute and Operaon) | 208
Add an Annotaon (comment Tag and create Operaon) | 210
Change an Annotaon (comment Tag, and delete and create Operaons) | 211
Add a Statement Inside a Container (create Operaon, and insert and key Aributes) | 211
Change the Order Inside a Container (merge Operaon, and insert and key Aributes) | 212
The compare | display xml lter compares the candidate conguraon with the current commied
conguraon and displays the dierences between the two conguraons in XML. To compare
conguraons, enter compare | display xml aer the pipe ( | ) symbol in either operaonal or conguraon
mode.
Example in operaonal mode:
user@host> show configuration | compare | display xml
Example in conguraon mode:
[edit]
user@host# show | compare | display xml
204
You can enter a specic conguraon hierarchy immediately preceding the compare lter, for example, show
configuration system syslog | compare | display xml. In conguraon mode, you can navigate to a hierarchy
where the command is applied.
The dierences from the compare lter funcon are output in XML. The configuration tag starts the
output. The context for changes is established with hierarchy name tags relave to the root of the
compare. For element changes, an operation aribute is output in the tag where a change occurs. This
aribute has the value create, delete, or merge. For metadata changes, the metadata name is specied. For
example, if a statement is marked inacve, the inactive="inactive" aribute and value are output. The nc
namespace is used when necessary to indicate that an aribute is in the NETCONF namespace rather
than the operang system namespace.
NOTE: Beginning with Junos OS Release 16.2R2, the show | compare | display xml command omits
the <configuration> tag in the XML output if the comparison returns no dierences or if the
comparison returns only dierences for non-nave conguraon data, for example, conguraon
data associated with an OpenCong data model.
The following secons explain the XML that is generated for specic types of conguraon changes.
The corresponding text changes are shown for comparison.
Add a Statement (create Operaon)
The following example shows the addion of IPv4 address 2.2.2.2 to unit 1.
The tags through name provide the context for the addion. The operation="create" aribute indicates that
a unit statement was created and is dened by the conguraon within the unit tag.
[edit interfaces ge-0/0/0]
user@host> show configuration | compare
[edit interfaces ge-0/0/0]
+ unit 1 {
+ family inet {
+ address 2.2.2.2/32;
+ }
+ }
[edit interfaces ge-0/0/0]
user@host# show | compare | display xml
<configuration>
<interfaces>
<interface>
205
<name>ge-0/0/0</name>
<unit nc:operation="create">
<name>1</name>
<family>
<inet>
<address>
<name>2.2.2.2/32</name>
</address>
</inet>
</family>
</unit>
</interface>
</interfaces>
</configuration>
Delete a Statement (delete Operaon)
The following example shows the deleon of a simple statement in the conguraon hierarchy. The tags
through system provide the context for the deleon. The operation="delete" aribute indicates that the
services statement was deleted. The conguraon following the services statement was deleted though is
not output.
[edit system]
user@host> show configuration | compare
[edit system]
- services {
- ftp;
- }
[edit system]
user@host# show | compare | display xml
<configuration>
<system>
<services operation="delete"/>
</system>
</configuration>
206
The following example shows the deleon of unit 1 from the ge-0/0/0 interface. The conguraon
following the unit statement was deleted though is not output.
[edit interfaces ge-0/0/0]
user@host> show configuration | compare
[edit interfaces ge-0/0/0]
- unit 1 {
- family inet {
- address 2.2.2.2/32;
- }
- }
[edit interfaces ge-0/0/0]
user@host# show | compare | display xml
<configuration>
<interfaces>
<interface>
<name>ge-0/0/0</name>
<unit nc:operation="delete">
<name>1</name>
</unit>
</interface>
</interfaces>
</configuration>
The following example shows the deleon of the apply-groups conguraon. The groups that are deleted
are not shown in the output.
[edit]
user@host# delete apply-groups
[edit]
user@host> show configuration | compare
[edit]
- apply-groups [ g1 g2 g3 ];
[edit]
user@host# show | compare | display xml
<configuration>
<apply-groups operation="delete"/>
</configuration>
207
Change a Statement (delete and create Operaons)
The following example shows a change in a statement in the hierarchy. The tags through system provide
the context for the change. The operation="delete" aribute indicates that the host-name statement was
deleted. The conguraon following the host-name statement was deleted, but this is not shown in the
output. The operation="create" aribute indicates that a host-name statement was created and is dened by
the conguraon within the host-name tag.
[edit system]
user@host> show configuration | compare
[edit system]
- host-name router1;
+ host-name router2;
[edit system]
user@host# show | compare | display xml
<configuration>
<system>
<host-name nc:operation="delete"/>
<host-name nc:operation="create">router2</host-name>
</system>
</configuration>
Change Metadata (inacve Aribute and Operaon)
The following example shows the inacvaon of a statement in the hierarchy. The tags through system
provide the context for the change. The inactive="inactive" aribute indicates that the syslog statement
was inacvated.
[edit system]
user@host> show configuration | compare
[edit system]
! inactive: syslog { ... }
[edit system]
user@host# show | compare | display xml
<configuration>
<system>
<syslog inactive="inactive"/>
208
</system>
</configuration>
The following example shows the addion of an inacve syslog statement. The operation="create" aribute
indicates that the syslog statement was created and is dened by the conguraon within the syslog tag.
The inactive="inactive" aribute indicates that the syslog statement was inacvated.
[edit system]
user@host> show configuration | compare
[edit system]
+ inactive: syslog {
+ file foo {
+ any any;
+ }
+ }
[edit system]
user@host# show | compare | display xml
<configuration>
<system>
<syslog nc:operation="create"
inactive="inactive">
<file>
<name>foo</name>
<contents>
<name>any</name>
<any/>
</contents>
</file>
</syslog>
</system>
</configuration>
209
Add an Annotaon (comment Tag and create Operaon)
The following example shows the addion of a comment to a statement. The tags through syslog provide
the context for the annotaon. The operation="create" aribute for the junos:comment tag indicates that a
comment was added to the [edit system syslog] hierarchy.
[edit system]
user@host> show configuration | compare
[edit system]
+ /* my-comments-simple */
syslog { ... }
[edit system]
user@host# show | compare | display xml
<configuration>
<system>
<junos:comment nc:operation="create">/* my-comments-simple
*/</junos:comment>
<syslog/>
</system>
</configuration>
The following example shows the addion of a comment to a statement. The tags through syslog provide
the context for the annotaon. The operation="create" aribute for the junos:comment tag indicates that a
comment was added to the [edit system syslog] hierarchy for the statement output within the syslog tag.
[edit system syslog]
user@host> show configuration | compare
+ /* my-comments-ele */
file f1 { ... }
[edit system syslog]
user@host# show | compare | display xml
<configuration>
<system>
<syslog>
<junos:comment nc:operation="create">/* my-comments-elem
*/</junos:comment>
<file>
<name>f1</name>
</file>
210
</syslog>
</system>
</configuration>
Change an Annotaon (comment Tag, and delete and create Operaons)
The following example shows the change of a comment for a statement. The tags through system provide
the context for the annotaon.
The operation="delete" aribute for the junos:comment tag indicates that a comment was deleted from
the [edit system] hierarchy at the syslog statement.
The operation="create" aribute for the junos:comment tag indicates that a comment was added to the
[edit system] hierarchy for the syslog statement.
[edit system]
user@host> show configuration | compare
- /* my-comments-1 */
+ /* my-comments-2 */
syslog { ... }
[edit system]
user@host# show | compare | display xml
<configuration>
<system>
<junos:comment nc:operation="delete"/>
<junos:comment nc:operation="create">/* my-comments-2
*/</junos:comment>
<syslog/>
</system>
</configuration>
Add a Statement Inside a Container (create Operaon, and insert and key Aributes)
The following example shows the addion of a file statement at the [edit system syslog] hierarchy. The
tags through syslog provide the context for the addion.
The operation="create" aribute for the file tag indicates that a file statement was added.
The yang:insert="after" aribute indicates that the le was added aer the posion indicated by the
yang:key="[name='file-1']" aribute.
211
The le-1 value represents the posion within the exisng file statements, where one is the rst le.
In this example, the new file statement was added aer the rst le.
[edit system syslog]
user@host> show configuration | compare
[edit system syslog]
file file-1 { ... }
+ file file-2 {
+ any any;
+ }
[edit system syslog]
user@host# show | compare | display xml
<configuration>
<system>
<syslog>
<file nc:operation="create"
yang:insert="after"
yang:key="[name='file-1']">
<name>file-2</name>
<contents>
<name>any</name>
<any/>
</contents>
</file>
</syslog>
</system>
</configuration>
Change the Order Inside a Container (merge Operaon, and insert and key Aributes)
The following example shows the change in order of file statements at the [edit system syslog] hierarchy.
The tags through syslog provide the context for the change.
The operation="merge" aribute for the file tag indicates that an exisng file statement was moved.
The yang:insert="after" aribute indicates that the le was moved aer the le in the posion
indicated by the yang:key="[name='file-1']" aribute.
The le-1 value represents a posion within the exisng file statements, where one is the rst le.
The value at the name tag, le-3, represents a posion within the exisng le statements.
212
In this example, the file statement in the third posion was moved aer the rst le.
[edit system syslog]
user@host> show configuration | compare
[edit system syslog]
file f1 { ... }
! file f3 { ... }
[edit system syslog]
user@host# show | compare | display xml
<configuration>
<system>
<syslog>
<file nc:operation="merge"
yang:insert="after"
yang:key="[name='file-1']">
<name>file-3</name>
</file>
</syslog>
</system>
</configuration>
Returning to the Most Recently Commied Conguraon
To return to the most recently commied conguraon and load it into conguraon mode without
acvang it, use the rollback conguraon mode command:
[edit]
user@host# rollback
load complete
To acvate the conguraon to which you rolled back, use the commit command:
[edit]
user@host# rollback
213
load complete
[edit]
user@host# commit
Returning to a Previously Commied Conguraon
IN THIS SECTION
Example of Returning to a Previous Conguraon | 214
Example of Displaying Previous Conguraons | 214
About Comparing Conguraon Versions | 216
This topic explains how you can return to an earlier conguraon than the most recently commied one.
Example of Returning to a Previous Conguraon
To return to a previous conguraon, you include the conguraon number, 0 through 49, in the rollback
command. The most recently saved conguraon is number 0 (which is the default conguraon to
which the system returns), and the oldest saved conguraon is number 49.
Example:
[edit]
user@host# rollback
number
load complete
Example of Displaying Previous Conguraons
To display previous conguraons, you use the rollback ? command. You include the rollback number,
date, me, the name of the user who commied changes, and the method of commit.
Example:
[edit]
user@host# rollback ?
Possible completions:
214
<[Enter]> Execute this command
<number> Numeric argument
0 2018-02-27 12:52:10 PST by abc via cli
1 2018-02-26 14:47:42 PST by def via cli
2 2018-02-14 21:55:45 PST by ghi via cli
3 2018-02-10 16:11:30 PST by jkl via cli
4 2018-02-10 16:02:35 PST by mno via cli
5 2018-03-16 15:10:41 PST by pqr via cli
6 2018-03-16 14:54:21 PST by stu via cli
7 2018-03-16 14:51:38 PST by vwx via cli
8 2018-03-16 14:43:29 PST by yzz via cli
9 2018-03-16 14:15:37 PST by abc via cli
10 2018-03-16 14:13:57 PST by def via cli
11 2018-03-16 12:57:19 PST by root via other
12 2018-03-16 10:45:23 PST by root via other
13 2018-03-16 10:08:13 PST by root via other
14 2018-03-16 01:20:56 PST by root via other
15 2018-03-16 00:40:37 PST by ghi via cli
16 2018-03-16 00:39:29 PST by jkl via cli
17 2018-03-16 00:32:36 PST by mno via cli
18 2018-03-16 00:31:17 PST by pqr via cli
19 2018-03-15 19:59:00 PST by stu via cli
20 2018-03-15 19:53:39 PST by vwx via cli
21 2018-03-15 18:07:19 PST by yzz via cli
22 2018-03-15 17:59:03 PST by abc via cli
23 2018-03-15 15:05:14 PST by def via cli
24 2018-03-15 15:04:51 PST by ghi via cli
25 2018-03-15 15:03:42 PST by jkl via cli
26 2018-03-15 15:01:52 PST by mno via cli
27 2018-03-15 14:58:34 PST by pqr via cli
28 2018-03-15 13:09:37 PST by root via other
29 2018-03-12 11:01:20 PST by stu via cli
30 2018-03-12 10:57:35 PST by vwx via cli
31 2018-03-11 10:25:07 PST by yzz via cli
32 2018-03-10 23:40:58 PST by abc via cli
33 2018-03-10 23:40:38 PST by def via cli
34 2018-03-10 23:14:27 PST by ghi via cli
35 2018-03-10 23:10:16 PST by jkl via cli
36 2018-03-10 23:01:51 PST by mno via cli
37 2018-03-10 22:49:57 PST by pqr via cli
38 2018-03-10 22:24:07 PST by stu via cli
39 2018-03-10 22:20:14 PST by vwx via cli
40 2018-03-10 22:16:56 PST by yzz via cli
215
41 2018-03-10 22:16:41 PST by abc via cli
42 2018-03-10 20:44:00 PST by def via cli
43 2018-03-10 20:43:29 PST by ghi via cli
44 2018-03-10 20:39:14 PST by jkl via cli
45 2018-03-10 20:31:30 PST by root via other
46 2018-03-10 18:57:01 PST by mno via cli
47 2018-03-10 18:56:18 PST by pqr via cli
48 2018-03-10 18:47:49 PST by stu via cli
49 2018-03-10 18:47:34 PST by vw via cli
| Pipe through a command
[edit]
About Comparing Conguraon Versions
In conguraon mode only, when you have made changes to the conguraon, you can compare the
candidate conguraon with a prior version. To compare versions, you use the compare command to
display the conguraons. The compare command compares the candidate conguraon with either the
current commied conguraon or a conguraon le. This command also displays the dierences
between the two conguraons.
To compare conguraons, you specify the compare command aer the pipe:
[edit]
user@host# show | compare (
filename
| rollback
n
)
filename
is the full path to a conguraon le. The le must be in the proper format: a hierarchy of
statements.
n
is the index into the list of previously commied conguraons. The most recently saved
conguraon is number 0, and the oldest saved conguraon is number 49. If you do not specify
arguments, the system compares candidate conguraon against the acve conguraon le (/
cong/juniper.conf).
The comparison output includes the following symbols in the prex for statements that are:
In the candidate conguraon only: a plus sign (+).
In the comparison le only: a minus sign (-).
Unchanged; a single blank space ( ).
216
The following example shows various changes, followed by a comparison of the candidate conguraon
with the acve conguraon. The example shows only the changes made at the [edit protocols bgp]
hierarchy level:
[edit]
user@host# edit protocols bgp
[edit protocols bgp]
user@host# show
group my-group {
type internal;
hold-time 60;
advertise-inactive;
allow 10.1.1.1/8;
}
group fred {
type external;
peer-as 33333;
allow 10.2.2.2/8;
}
group test-peers {
type external;
allow 10.3.3.3/8;
}
[edit protocols bgp]
user@host# set group my-group hold-time 90
[edit protocols bgp]
user@host# delete group my-group advertise-inactive
[edit protocols bgp]
user@host# set group fred advertise-inactive
[edit protocols bgp]
user@host# delete group test-peers
[edit protocols bgp]
user@host# show | compare
[edit protocols bgp group my-group]
-hold-time 60;
+hold-time 90;
-advertise-inactive;
[edit protocols bgp group fred]
+advertise-inactive;
[edit protocols bgp]
-group test-peers {
-type external;
217
-allow 10.3.3.3/8;
}
[edit protocols bgp]
user@host# show
group my-group {
type internal;
hold-time 90;
allow 10.1.1.1/8;
}
group fred {
type external;
advertise-inactive;
peer-as 3333;
allow 10.2.2.2/8;
}
Using Conguraon Revision Ideners
Every commit has a conguraon revision idener (CRI) associated with it. The CRI is a unique string
that, unlike the rollback index, does not change when new conguraons are commied.
Because the CRI for a given commied conguraon is xed, it has advantages over using a rollback
index. Network management systems (NMS) can cache the CRI for a given commit. At a later date, the
NMS can compare the cached value to the CRI of the current conguraon on the network device to
detect if other systems made out-of-band conguraon changes to the device, for example, during a
maintenance window.
Addionally, starng in Junos OS and Junos OS Evolved Release 20.4R1, you can use the CRI associated
with a commied conguraon to:
View the conguraon.
Compare two conguraons.
Revert to the conguraon.
Retrieve the current rollback index associated with that conguraon.
218
To view the CRI associated with each commit, use the show system commit include-configuration-revision
command. This will display the system commit history and the CRI for each commit.
user@host> show system commit include-configuration-revision
0 2020-08-02 00:42:58 IST by user via cli re0-1596309177-4
1 2020-08-02 00:42:53 IST by user via cli re0-1596309173-3
2 2020-08-02 00:42:50 IST by user via cli re0-1596309170-2
3 2020-08-02 00:42:40 IST by user via other re0-1596309160-1
Alternavely, you can view the CRI for a specic rollback number by issuing the show system rollback
number
configuration-revision command.
user@host> show system rollback 0 configuration-revision
The corresponding configuration revision is: re0-1596309177-4
Once you have the CRI string for a specic commit, you can view that conguraon with the show system
configuration revision
cri-string
command.
user@host> show system configuration revision re0-1596309177-4
You can compare 2 conguraons by using the compare opon with both CRIs.
user@host> show system configuration revision compare re0-1596309177-4 re0-1596309173-3
You can also use view the rollback number for a specic CRI by including the rollback-number
cri-string
opon.
user@host> show system configuration revision rollback-number re0-1596309160-1
The corresponding rollback number is: 3
Addionally, in conguraon mode, you can roll back to a conguraon by specifying the CRI instead of
the rollback index.
[edit]
user@host# rollback revision re0-1596309160-1
load complete
219
[edit]
user@host# commit
Saving a Conguraon to a File
Saving a device conguraon to a le allows you to edit it with any plain text editor of your choice. You
can save your current conguraon to an ASCII le, which saves the conguraon in its current form,
including any uncommied changes. If more than one user is modifying the conguraon, all changes
made by all users are saved.
To save soware conguraon changes to an ASCII le, use the save conguraon mode command:
[edit]
user@host# save
filename
[edit]
user@host#
The contents of the current level of the statement hierarchy (and below) are saved, along with the
statement hierarchy containing it. This allows a secon of the conguraon to be saved, while fully
specifying the statement hierarchy.
By default, the conguraon is saved to a le in your home directory, which is on the ash drive.
When you issue this command from anywhere in the hierarchy (except the top level), a replace tag is
automacally included at the beginning of the le. You can use the replace tag to control how a
conguraon is loaded from a le.
Example:
user@host> file show /var/home/user/myconf
replace:
protocols {
bgp {
disable;
group int {
type internal;
}
}
isis {
disable;
220
interface all {
level 1 disable;
}
interface fxp0.0 {
disable;
}
}
ospf {
traffic-engineering;
reference-bandwidth 4g;
...
}
}
About Compressing the Current Conguraon File
By default, the current operaonal conguraon le is compressed and is stored in the le
juniper.conf.gz in the /cong le system. The operaonal conguraon le is stored along with the last
three commied versions of the conguraon. If you have large networks, the current conguraon le
might exceed the available space in the /cong le system. Compressing the current conguraon le
enables the le to t in the le system, typically reducing the size of the le by 90 percent. You might
want to compress your current operaonal conguraon les when they reach 3 megabytes (MB) in
size.
When you compress the current conguraon le, the names of the conguraon les change. To
determine the size of the les in the /cong le system, you issue the file list /config detail command.
NOTE: We recommend that you compress the conguraon les (this is the default) to minimize
the amount of disk space that they require.
If you want to compress the current conguraon le, include the compress-configuration-files
statement at the [edit system] hierarchy level:
[edit system]
compress-configuration-files;
221
Commit the current conguraon le to include the compression-configuration-files statement. Commit
the conguraon again to compress the current conguraon le:
[edit system]
user@host# set compress-configuration-files
user@host# commit
commit complete
If you do not want to compress the current operaonal conguraon le, include the no-compress-
configuration-files statement at the [edit system] hierarchy level:
[edit system]
no-compression-configuration-files;
Commit the current conguraon le to include the no-compress-configuration-files statement. Commit
the conguraon again to uncompress the current conguraon le:
[edit system]
user@host# set no-compress-configuration-files
user@host# commit
commit complete
Free Up System Storage Space
IN THIS SECTION
Problem | 223
Soluon | 223
222
Problem
Descripon
The system le storage space on the device is full. Reboong the switch does not solve the problem.
The following error message appears during a typical operaon on the device aer the le storage space
is full:
user@host% cli
user@host> configure
/var: write failed, filesystem is full
Soluon
Clean up the le storage on the device by deleng system les.
1. Issue a request to clean up (delete) system les.
user@host> request system storage cleanup
The list of les to be deleted is displayed.
List of files to delete:
Size Date Name
11B Jul 26 20:55 /var/jail/tmp/alarmd.ts
124B Aug 4 18:05 /var/log/default-log-messages.0.gz
1301B Jul 26 20:42 /var/log/install.0.gz
387B Jun 3 14:37 /var/log/install.1.gz
4920B Aug 4 18:05 /var/log/messages.0.gz
20.0K Jul 26 21:00 /var/log/messages.1.gz
16.3K Jun 25 13:45 /var/log/messages.2.gz
804B Aug 4 18:05 /var/log/security.0.gz
16.8K Aug 3 11:15 /var/log/security.1.gz
487B Aug 4 18:04 /var/log/wtmp.0.gz
855B Jul 29 22:54 /var/log/wtmp.1.gz
920B Jun 30 16:32 /var/log/wtmp.2.gz
94B Jun 3 14:36 /var/log/wtmp.3.gz
353.2K Jun 3 14:37 /var/sw/pkg/jloader-qfx-11.2I20110303_1117_dc-builder.tgz
223
124.0K Jun 3 14:30 /var/tmp/gres-tp/env.dat
0B Apr 14 16:20 /var/tmp/gres-tp/lock
0B Apr 14 17:37 /var/tmp/if-rtsdb/env.lck
12.0K Jul 26 20:55 /var/tmp/if-rtsdb/env.mem
2688.0K Jul 26 20:55 /var/tmp/if-rtsdb/shm_usr1.mem
132.0K Jul 26 20:55 /var/tmp/if-rtsdb/shm_usr2.mem
2048.0K Jul 26 20:55 /var/tmp/if-rtsdb/trace.mem
155B Jul 26 20:55 /var/tmp/krt_gencfg_filter.txt
0B Jul 26 20:55 /var/tmp/rtsdb/if-rtsdb
1400.6K Aug 3 10:13 /var/tmp/sfid.core.0.gz
1398.9K Aug 3 17:01 /var/tmp/sfid.core.1.gz
Delete these files ? [yes,no] (no)
2. Select yes to delete the les.
3. Reboot the device.
BEST PRACTICE: We recommend that you regularly issue a request to clean up the system
le storage. Cleaning up the system le storage space opmizes device performance.
Clean Up Files with the CLI
You can use the CLI request system storage cleanup command to rotate log les and delete unnecessary les
on the device. If you are running low on storage space, the le cleanup procedure quickly idenes les
that you can delete.
The le cleanup procedure performs the following tasks:
Rotates log les—Archives all informaon in the current log les, deletes old archives, and creates
fresh log les.
Deletes log les in /var/log—Deletes any les that are not currently being wrien to.
Deletes temporary les in /var/tmp—Deletes any les that have not been accessed within two days.
Deletes all crash les in /var/crash—Deletes any core les that the device has wrien during an error.
Deletes all soware images (*.tgz les) in /var/sw/pkg—Deletes any soware images copied to this
directory during soware upgrades.
To rotate log les and delete unnecessary les with the CLI:
224
1. Enter operaonal mode in the CLI.
2. Rotate log les and idenfy the les that you can safely delete.
user@host> request system storage cleanup
The device rotates log les and displays the les that you can delete.
3. Enter yes at the prompt to delete the les.
NOTE: You can issue the request system storage cleanup dry-run command to review the list of les
that you can safely delete . The dry-run acon lets you review the list before you issue the request
system storage cleanup command to delete the les.
NOTE: On SRX Series Firewalls, the /var hierarchy is hosted in a separate paron (instead of the
root paron). If the operang system installaon fails as a result of insucient space:
Use the request system storage cleanup command to delete temporary les.
Delete any user-created les in both the root paron and under the /var hierarchy.
Change History Table
Feature support is determined by the plaorm and release you are using. Use Feature Explorer to
determine if a feature is supported on your plaorm.
Release
Descripon
16.2R2
Beginning with Junos OS Release 16.2R2, the show | compare | display xml command omits the
<configuration> tag in the XML output if the comparison returns no dierences or if the comparison
returns only dierences for non-nave conguraon data, for example, conguraon data associated
with an OpenCong data model.
225
Autoinstallaon of Conguraon Files Overview
IN THIS SECTION
Conguraon File Autoinstallaon—An Overview | 226
Conguring Autoinstallaon of Conguraon Files (CLI Procedure) | 229
Autoinstallaon is the automac conguraon of devices over the network without manual
intervenon, including manual conguraon. You (the network administrator) use autoinstallaon to
save me and to implement the same conguraon consistently across devices.
Conguraon File Autoinstallaon—An Overview
IN THIS SECTION
Typical Uses for Autoinstallaon | 227
Autoinstallaon Conguraon Files and IP Addresses | 227
Typical Autoinstallaon Process on a New Device | 227
Autoinstallaon is the automac conguraon of a device over the network from a preexisng
conguraon le that you create and store on a conguraon server—typically a Trivial File Transfer
Protocol (TFTP) server. You can use autoinstallaon to congure new devices automacally and to
deploy mulple devices from a central locaon in the network.
You enable autoinstallaon so that network devices implement autoinstallaon when they are powered
on. To congure autoinstallaon, you specify a conguraon server, an autoinstallaon interface, and a
protocol for IP address acquision.
226
NOTE: The QFX5200 switches work only with HTTP for autoinstallaon. They do not support
TFTP or FTP protocols. Autoinstallaon as a feature is not supported on all devices. Refer to your
hardware informaon for specic details.
Typical Uses for Autoinstallaon
Typical uses for autoinstallaon of the soware include:
Deploy and update mulple devices from a central locaon in the network.
Update a device automacally, when powered on.
Autoinstallaon Conguraon Files and IP Addresses
For the autoinstallaon process to work, you must store one or more host-specic or default
conguraon les on a conguraon server in the network. In addion, you must ensure that a service
such as Dynamic Host Conguraon Protocol (DHCP) is available to assign an IP address to thedevice.
You can set up the following conguraon les for autoinstallaon on the device:
network.conf—Default conguraon le for autoinstallaon, in which you specify IP addresses and
associated hostnames for devices on the network.
switch.conf—Default conguraon le for autoinstallaon on a switch. This le contains just enough
conguraon informaon for you to telnet to the device and congure it manually.
hostname
.conf—Host-specic conguraon le for autoinstallaon on a device. This le contains all
the conguraon informaon necessary for the device. In the lename, replace
hostname
with the
hostname assigned to the device.
If the server with the autoinstallaon conguraon le is not on the same LAN segment as the new
device, or if a specic device is required by the network, you must congure an intermediate device. You
must aach this intermediate device directly to the new device so that the new device can send TFTP,
Boot Protocol (BOOTP), and Domain Name System (DNS) requests through the intermediate device. In
this case, you specify the IP address of the intermediate device as the locaon at which to receive TFTP
autoinstallaon requests.
Typical Autoinstallaon Process on a New Device
When the device congured for autoinstallaon is powered on, it performs the following autoinstallaon
tasks:
227
1. The device sends out DHCP or BOOTP requests on each connected interface simultaneously to
obtain an IP address.
If a DHCP server responds to these requests, it provides the device with some or all of the following
informaon:
An IP address and subnet mask for the autoinstallaon interface.
The locaon of the (typically) TFTP server, HTTP server, or FTP server on which the conguraon
le is stored.
The name of the conguraon le to be requested from the TFTP server.
The IP address or hostname of the TFTP server.
If the DHCP server provides the server’s hostname, a DNS server must be available on the
network to resolve the name to an IP address.
The IP address of an intermediate device if the conguraon server is on a dierent LAN segment
from the device.
2. Aer the device acquires an IP address, the autoinstallaon process on the device aempts to
download a conguraon le in the following ways:
a. If the DHCP server species the host-specic conguraon le
hostname
.conf, the device uses
that lename in the TFTP server request. The autoinstallaon process on the new device makes
three unicast TFTP requests for
hostname
.conf. If these aempts fail, the device broadcasts three
requests to any available TFTP server for the le.
b. If the device does not locate a
hostname
.conf le, the autoinstallaon process sends three unicast
TFTP requests for a network.conf le that contains the device’s hostname-to-IP-address mapping
informaon. If these aempts fail, the device broadcasts three requests to any available TFTP
server for the le.
c. If the device fails to nd a network.conf le that contains a hostname entry for the device, the
autoinstallaon process sends out a DNS request and aempts to resolve the device's IP address
to a hostname.
d. If the device determines its hostname, it sends a TFTP request for the
hostname
.conf le.
e. If the device is unable to map its IP address to a hostname, it sends TFTP requests for the default
conguraon le device.conf. The TFTP request procedure is the same as for the network.conf
le.
3. Aer the device locates a conguraon le on a TFTP server, the autoinstallaon process downloads
the le, installs the le on the device, and commits the conguraon.
228
Conguring Autoinstallaon of Conguraon Files (CLI Procedure)
Autoinstallaon is the automac conguraon of a device over the network from a pre-exisng
conguraon le that you create and store on a conguraon server. A conguraon server is typically a
Trivial File Transfer Protocol (TFTP) server. You can use autoinstallaon to deploy mulple devices
automacally from a central locaon in the network.
Before you can congure autoinstallaon, you must enable autoinstallaon to run when you power on a
device already installed in your network. You enable it by specifying one or more interfaces, protocols,
and conguraon servers to be used for autoinstallaon.
To enable autoinstallaon to run, complete the following steps:
1. Ensure that a service such as Dynamic Host Conguraon Protocol (DHCP) is available to assign an
IP address to the device.
2. Congure a DHCP server on your network to meet your network requirements. You can congure a
switch to operate as a DHCP server.
3. Create one of the following conguraon les, and store it on a TFTP server (or HTTP server or FTP
server) in the network:
A host-specic le with the name
hostname
.conf for each device undergoing autoinstallaon.
Replace
hostname
with the name of a device. The
hostname
.conf le typically contains all the
conguraon informaon necessary for the device with this hostname.
A default conguraon le named device.conf with the minimum conguraon necessary to
enable you to telnet into the new device for further conguraon.
4. Physically aach the device to the network using a Gigabit Ethernet port.
5. If you congured the DHCP server to provide only the TFTP server hostname, add an IP address-to-
hostname mapping entry for the TFTP server. Map the TFTP server hostname to the DNS database
le on the Domain Name System (DNS) server in the network.
6. If the device is not on the same network segment as the DHCP server (or other device providing IP
address resoluon), congure an exisng device as an intermediate device to receive TFTP and DNS
requests and forward them to the TFTP server and the DNS server. You must congure the LAN or
serial interface on the intermediate device with the IP addresses of the hosts providing TFTP and
DNS services. Connect this interface to the device.
7. If you are using
hostname
.conf les for autoinstallaon, you must also complete the following tasks:
Congure the DHCP server to provide a
hostname
.conf lename to each device. Each device uses
its
hostname
.conf lename to request a conguraon le from the TFTP server. Copy the
necessary
hostname
.conf conguraon les to the TFTP server.
229
Create a default conguraon le named network.conf, and copy it to the TFTP server. This le
contains IP-address-to-hostname mapping entries. If the DHCP server does not send a
hostname
.conf lename to a new device, the device uses network.conf to resolve its hostname
based on its IP address.
Alternavely, you can add the IP-address-to-hostname mapping entry for the device to a DNS
database le.
The device uses the hostname to request a
hostname
.conf le from the TFTP server.
Before you explicitly enable and congure autoinstallaon on the device, perform these tasks as needed
for your network conguraon:
To congure autoinstallaon:
1. Specify the URL address of one or more servers from which to obtain conguraon les.
[edit system]
user@host# set autoinstallation configuration-servers tftp://tftpconfig.example.com
NOTE: You can also use an FTP address such as p://
user
:
password
@spcong.example.com.
2. Congure one or more Ethernet interfaces to perform autoinstallaon and one or two procurement
protocols for each interface. The switch uses the protocols to send a request for an IP address for the
interface:
[edit system]
user@host# set autoinstallation interfaces ge-0/0/0 bootp
To verify autoinstallaon, from the CLI enter the show system autoinstallation status command.
Example:
user@host> show system autoinstallation status
Autoinstallation status:
Master state: Active
Last committed file: None
Configuration server of last committed file: 10.25.100.1
Interface:
Name: ge-0/0/0
230
State: Configuration Acquisition
Acquired:
Address: 192.168.124.75
Hostname: host-ge-000
Hostname source: DNS
Configuration filename: device-ge-000.conf
Configuration filename server: 10.25.100.3
Address acquisition:
Protocol: DHCP Client
Acquired address: None
Protocol: RARP Client
Acquired address: None
Interface:
Name: ge-0/0/1
State: None
Address acquisition:
Protocol: DHCP Client
Acquired address: None
Protocol: RARP Client
Acquired address: None
Loading Conguraon Files
IN THIS SECTION
Examples for Loading a Conguraon from a File or the Terminal | 232
How Character Encoding Works on Juniper Networks Devices | 235
About Specifying Statements and Ideners | 237
About Loading a Conguraon from a File | 241
Upload a Conguraon File | 245
Load JSON Conguraon Data With Unordered List Entries | 246
Loading conguraon les on the device are helpful for loading parts of conguraon les that might be
common across many devices within a network.
231
Examples for Loading a Conguraon from a File or the Terminal
You can create a le containing conguraon data for a Juniper Networks device, copy the le to the
local device, and then load the le into the CLI. Aer you have loaded the le, you can commit it to
acvate the conguraon on the device, or you can edit the conguraon interacvely using the CLI
and commit the conguraon at a later me.
You can also create a conguraon while typing at the terminal and then load the conguraon. Loading
a conguraon from the terminal is useful when you are cung exisng porons of the conguraon
and pasng them elsewhere in the conguraon.
To load an exisng conguraon le that is located on the device, you use the load conguraon mode
command:
[edit]
user@host# load (factory-default | merge | override | patch | replace | set | update)
filename
<relative> <json>
To load a conguraon from the terminal, you use the following version of the load conguraon mode
command. Press Ctrl-d to end the input.
[edit]
user@host# load (factory-default | merge | override | patch | replace | set | update) terminal
<relative> <json>
To replace an enre conguraon, you specify the override opon at any level of the hierarchy. A load
override operaon completely replaces the current candidate conguraon with the le you are loading.
Thus, if you saved a complete conguraon, you use this opon.
An override operaon discards the current candidate conguraon and loads the conguraon in
lename
or the conguraon that you type at the terminal. When you use the override opon and
commit the conguraon, all system processes reparse the conguraon.
To replace porons of a conguraon, you specify the replace opon. The load replace operaon looks for
replace: tags that you added to the loaded le. The operaon then replaces those parts of the candidate
conguraon with whatever is specied aer the tag. This is useful when you want more control over
exactly what is being changed. For this operaon to work, you must include replace: tags in the le or
conguraon that you type at the terminal. The soware searches for the replace: tags, deletes the
exisng statements of the same name, if any, and replaces them with the incoming conguraon. If no
statement of the same name exists, the replace operaon adds to the conguraon the statements
marked with the replace: tag.
232
If, in an override or merge operaon, you specify a le or type text that contains replace: tags, the replace:
tags are ignored. In this scenario, the override or merge operaon takes precedence and is performed.
If you are performing a replace operaon, and if the le that you specify lacks replace: tags, the replace
operaon runs as a merge operaon. The replace operaon also runs as a merge operaon if the text you
type lacks replace: tags. This informaon might be useful if you are running automated scripts and
cannot know in advance whether the scripts need to perform a replace operaon or a merge operaon.
The scripts can use the replace operaon to cover either case.
The load merge operaon merges the conguraon from the saved le or terminal with the exisng
candidate conguraon. This informaon is useful if you are adding new conguraon secons. For
example, suppose that you are adding a BGP conguraon to the [edit protocols] hierarchy level, where
there was no BGP conguraon before. You can use the load merge operaon to combine the incoming
conguraon with the exisng candidate conguraon. If the exisng conguraon and the incoming
conguraon contain conicng statements, the statements in the incoming conguraon override
those in the exisng conguraon.
To replace only those parts of the conguraon that have changed, you specify the update opon at any
level of the hierarchy. The load update operaon compares the candidate conguraon and the new
conguraon data. This operaon changes only those parts of the candidate conguraon that are
dierent from the new conguraon. You would use this operaon, for example, if there is an exisng
BGP conguraon and the le you are loading changes it in some way.
The merge, override, and update opons support loading conguraon data in JavaScript Object Notaon
(JSON) format. When loading conguraon data that uses JSON format, you must specify the json
opon in the command. To load JSON conguraon data that contains unordered list entries, that is, list
entries where the list key is not necessarily the rst element in the list entry, see "Load JSON
Conguraon Data With Unordered List Entries" on page 246.
To change part of the conguraon with a patch le, you specify the patch opon. The load patch
operaon loads a le or terminal input that contains conguraon changes. First, on a device that
already has the conguraon changes, you type the show | compare command to output the dierences
between two conguraons. Then you can load the dierences on another device. The advantage of the
load patch command is that it saves you from having to copy snippets from dierent hierarchy levels into
a text le before loading them into the target device. This might be a useful me saver if you are
conguring several devices with the same opons. For example, suppose that you congure a roung
policy on router1 and you want to replicate the policy conguraon on router2, router3, and router4.
You can use the load patch operaon.
In this example, you rst run the show | compare command.
233
Example:
user@router1# show | compare rollback 3
[edit protocols ospf]
+ export default-static;
- export static-default
[edit policy-options]
+ policy-statement default-static {
+ from protocol static;
+ then accept;
+ }
Connuing this example, you copy the output of the show | compare command to the clipboard, making
sure to include the hierarchy levels. On router2, router3, and router4, you type load patch terminal and
paste the output. You then press Enter and press Ctrl-d to end the operaon. If the patch input species
dierent values for an exisng statement, the patch input overrides the exisng statement.
To use the merge, replace, set, or update opon without specifying the full hierarchy level, you specify the
relative opon. This opon loads the incoming conguraon relave to your current edit point in the
conguraon hierarchy.
Example:
[edit system]
user@host# show static-host-mapping
bob sysid 987.654.321ab
[edit system]
user@host# load replace terminal relative
[Type ^D at a new line to end input]
replace: static-host-mapping {
bob sysid 0123.456.789bc;
}
load complete
[edit system]
user@host# show static-host-mapping
bob sysid 0123.456.789bc;
To load a conguraon that contains set conguraon mode commands, specify the set opon. This
opon executes the conguraon instrucons line by line as they are stored in a le or from a terminal.
The instrucons can contain any conguraon mode command, such as set, edit, exit, and top.
234
To copy a conguraon le from another network system to the local router, you can use the SSH and
Telnet ulies, as described in the CLI Explorer.
NOTE: If you are working in a Common Criteria environment, system log messages are created
whenever a secret aribute is changed (for example, password changes or changes to the
RADIUS shared secret). These changes are logged during the following conguraon load
operaons:
load merge
load replace
load override
load update
How Character Encoding Works on Juniper Networks Devices
Junos OS conguraon data and operaonal command output might contain non-ASCII characters,
which are outside of the 7-bit ASCII character set. When displaying operaonal or conguraon data in
certain formats or within a certain type of session, the soware escapes and encodes these characters.
The soware escapes or encodes the characters using the equivalent UTF-8 decimal character
reference.
The CLI aempts to display any non-ASCII characters in conguraon data that is produced in text, set,
or JSON format. The CLI also aempts to display these characters in command output that is produced
in text format. In the excepon cases, the CLI displays the UTF-8 decimal character reference instead.
(Excepon cases include conguraon data in XML format and command output in XML or JSON
format,) In NETCONF and Junos XML protocol sessions, you see a similar result if you request
conguraon data or command output that contains non-ASCII characters. In this case, the server
returns the equivalent UTF-8 decimal character reference for those characters for all formats.
For example, suppose the following user account, which contains the Lan small leer n with a lde (ñ),
is congured on the device.
[edit]
user@host# set system login user mariap class super-user uid 2007 full-name "Maria Peña"
235
When you display the resulng conguraon in text format, the CLI prints the corresponding character.
[edit]
user@host# show system login user mariap
full-name "Maria Peña";
uid 2007;
class super-user;
When you display the resulng conguraon in XML format in the CLI, the ñ character maps to its
equivalent UTF-8 decimal character reference &#195;&#177;. The same result occurs if you display the
conguraon in any format in a NETCONF or Junos XML protocol session.
[edit]
user@host# show system login user mariap | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/17.2R1/junos">
<configuration junos:changed-seconds="1494033077" junos:changed-localtime="2017-05-05
18:11:17 PDT">
<system>
<login>
<user>
<name>mariap</name>
<full-name>Maria Pe&#195;&#177;a</full-name>
<uid>2007</uid>
<class>super-user</class>
</user>
</login>
</system>
</configuration>
<cli>
<banner>[edit]</banner>
</cli>
</rpc-reply>
When you load conguraon data onto a device, you can load non-ASCII characters using their
equivalent UTF-8 decimal character references.
236
About Specifying Statements and Ideners
IN THIS SECTION
Specifying Statements | 237
Performing CLI Type Checking | 239
This topic provides details about CLI container statements and leaf statements so that you know how to
must specify them when creang ASCII conguraon les. This topic also describes how the CLI
performs type checking to verify that the data you entered is in the correct format.
Specifying Statements
Statements are shown one of two ways, either with braces ({ }) or without:
Statement name and idener, with one or more lower-level statements enclosed in braces:
statement-name1
identifier-name
{
statement-name2
;
additional-statements
;
}
Statement name, idener, and a single idener:
statement-name
identifier-name1
identifier-name2
;
The
statement-name
is the name of the statement. The
idener-name
is a name or other string that
uniquely idenes an instance of a statement. You use an idener when a statement can be specied
more than once in a conguraon.
When specifying a statement, you must specify a statement name, an idener name, or both,
depending on the statement hierarchy.
You specify ideners in one of the following ways:
idener-name
The
idener-name
is a keyword used to uniquely idenfy a statement when a
statement can be specied more than once in a statement.
237
idener-name value
The
idener-name
is a keyword, and the
value
is a required opon variable.
idener-name
[
value1 value2 value3
...]The
idener-name
is a keyword that accepts mulple
values. The brackets are required when you specify a set of values; however, they are oponal when
you specify only one value.
The following examples illustrate how statements and ideners are specied in the conguraon:
protocol { # Top-level statement (
statement-name
).
ospf { # Statement under "protocol" (
statement-name
).
area 0.0.0.0 { # OSPF area "0.0.0.0" (
statement-name identifier-name
),
interface so-0/0/0 { # which contains an interface named "so-0/0/0."
hello-interval 25; # Identifier and value (
identifier-name value
).
priority 2; # Identifier and value (
identifier-name value
).
disable; # Flag identifier (
identifier-name
).
}
interface so-0/0/1; # Another instance of "interface," named so-0/0/1,
} # this instance contains no data, so no braces
} # are displayed.
}
policy-options { # Top-level statement (
statement-name
).
term term1 { # Statement under "policy-options"
# (
statement-name value
).
from { # Statement under "term" (
statement-name
).
route-filter 10.0.0.0/8 orlonger reject; # One identifier ("route-
filter") with
route-filter 127.0.0.0/8 orlonger reject; # multiple values.
route-filter 128.0.0.0/16 orlonger reject;
route-filter 149.20.64.0/24 orlonger reject;
route-filter 172.16.0.0/12 orlonger reject;
route-filter 191.255.0.0/16 orlonger reject;
}
then { # Statement under "term" (
statement-name
).
next term; # Identifier (
identifier-name
).
}
}
}
When you create an ASCII conguraon le, you specify statements and ideners. Each statement has
a preferred style, and the CLI uses that style when displaying the conguraon in response to a
conguraon mode show command. You can specify statements and ideners in one of the following
ways:
238
Statement followed by ideners:
statement-name identifier-name
[...]
identifier-name
value
[...];
Statement followed by ideners enclosed in braces:
statement-name
{
identifier-name
;
[...]
identifier-name
value
;
[...]
}
For some repeang ideners, you can use one set of braces for all the statements:
statement-name
{
identifier-name value1
;
identifier-name value2
;
}
Performing CLI Type Checking
When you specify ideners and values, the CLI performs type checking to verify that the data you
entered is in the correct format. For example, for a statement in which you must specify an IP address,
the CLI requires that you enter an address in a valid format. Otherwise, an error message indicates what
you need to type. lists the data types the CLI checks. The following are CLI conguraon input types:
Table 9: CLI
Conguraon Input Types
Data Type Format Examples
Physical interface
name (used in the
[edit interfaces]
hierarchy)
type-fpc
/
pic
/
port
Correct: et-0/0/1
Incorrect: et-0
239
Table 9: CLI Conguraon Input Types
(Connued)
Data Type Format Examples
Full interface name
type-fpc
/
pic
/
port
<:
channel
>.
logical
Correct: et-0/0/1.0
Incorrect: et-0/0/1
Full or abbreviated
interface name
(used in places
other than the [edit
interfaces]
hierarchy)
type-
<
fpc
</
pic
/
port
>><<:
channel
>.
logical>
Correct: et, et-1, et-1/2/3:4.5
IP address
0x
hex-bytesoctet
<.
octet
<.
octet
.
<
octet
>>>
Correct: 1.2.3.4, 0x01020304, 128.8.1, 128.8
Sample translaons:
1.2.3 becomes 1.2.3.0
0x01020304 becomes 1.2.3.4
0x010203 becomes 0.1.2.3
IP address
(desnaon prex)
and prex length
0x
hex-bytes
<
/length
>
octet
<
octet
<
octet
.<
octet
>>><
/length
>
Correct: 10/8, 128.8/16, 1.2.3.4/32, 1.2.3.4
Sample translaons:
1.2.3 becomes 1.2.3.0/32
0x01020304 becomes 1.2.3.4/32
0x010203 becomes 0.1.2.3/32
default becomes 0.0.0.0/0
Internaonal
Organizaon for
Standardizaon
(ISO) address
hex-nibble
<
hex-nibble
...> Correct: 47.1234.2345.3456.00, 47123423453456.00,
47.12.34.23.45.34.56.00
Sample translaons:
47123456 becomes 47.1234.56
47.12.34.56 becomes 47.1234.56
4712.3456 becomes 47.1234.56
240
Table 9: CLI Conguraon Input Types
(Connued)
Data Type Format Examples
OSPF area
idener (ID)
0x
hex-bytesoctet
<.
octet
<.
octet
.<
octet 
>>>
decimal-number
Correct: 54, 0.0.0.54, 0x01020304, 1.2.3.4
Sample translaons:
54 becomes 0.0.0.54
257 becomes 0.0.1.1
128.8 becomes 128.8.0.0
0x010203 becomes 0.1.2.3
About Loading a
Conguraon from a File
The following examples demonstrate the process of loading a conguraon from a le.
Figure 5: Overriding the Current Conguraon
241
Figure 6: Using the replace Opon
Figure 7: Using the merge Opon
242
Figure 8: Using a Patch File
243
Figure 9: Using the set Opon
244
Upload a Conguraon File
You can create a conguraon le on your local system, copy the le to the device, and then load the le
into the CLI. Aer you have loaded the conguraon le, you can commit it to acvate the conguraon
on the device. You can also edit the conguraon interacvely using the CLI and commit it at a later
me.
To upload a conguraon le from your local system:
1. Create the conguraon le using a text editor such as Notepad, making sure that the syntax of the
conguraon le is correct.
2. In the conguraon text le, include one or more of the following opons to perform the required
acon when the le is loaded.
Table 10: Opons for the load Command
Opons Descripon
merge Combines the current acve conguraon with either the conguraon in the
lename that you specify or the conguraon that you type in the terminal
window. A merge operaon is useful when you are adding a new secon to an
exisng conguraon. If the acve conguraon and the incoming conguraon
contain conicng statements, the statements in the incoming conguraon
override those in the acve conguraon.
override Discards the current candidate conguraon. Loads either the conguraon in
the lename that you specify or the conguraon that you type at the terminal.
When you use the override opon and commit the conguraon, all system
processes reparse the conguraon. You can use the override opon at any level
of the hierarchy.
replace Searches for the replace tags, deletes the exisng statements of the same name,
if any, and replaces the exisng statements with the incoming conguraon. If no
statement of the same name exists, the replace operaon adds the statements
marked with the replace tag to the acve conguraon.
NOTE: For this operaon to work, you must include replace tags in the text le or
in the conguraon that you enter at the terminal.
3. Press Ctrl+a to select all the text in the conguraon le.
4. Press Ctrl+c to copy the contents of the conguraon text le to the Clipboard.
5. Log in to the device using your username and password.
245
6. Enter conguraon mode: user@host> configure
[edit]
user@host#
7. Load the conguraon le: [edit] user@host# load merge terminal
8. At the cursor, paste the contents of the Clipboard using the mouse and the Paste icon: [edit]
user@host# load merge terminal [Type ^D at a new line to end input] >Cursor is here. Paste the
contents of the clipboard here<
9. Press Enter.
10. Press Ctrl+d to set the end-of-le marker.
To view results of the conguraon steps before comming the conguraon, type the show command
at the user prompt.
To commit these changes to the acve conguraon, type the commit command at the user prompt. You
can also edit the conguraon interacvely using the CLI and commit it at a later me.
Load JSON Conguraon Data With Unordered List Entries
The Junos schema denes certain conguraon objects as lists. In JSON conguraon data, a list
instance is encoded as a name/array pair, and the array elements are JSON objects. Generally, the order
of members in a JSON-encoded list entry is arbitrary because JSON objects are fundamentally
unordered collecons of members. However, the Junos schema requires that list keys precede any other
siblings within a list entry and appear in the order specied by the schema.
For example, the user object at the [edit system login] hierarchy level is a list where name is the list key that
uniquely idenes each user.
list user {
key name;
description "Username";
uses login-user-object;
}
In the following sample conguraon data, the list key (name) is the rst element for each user. By default,
when you load JSON conguraon data, Junos devices require that the list keys precede any other
siblings within a list entry and appear in the order specied by the schema.
{
"configuration" : {
246
"system" : {
"login" : {
"user" : [
{
"name" : "operator",
"class" : "operator",
"uid" : 3001
},
{
"name" : "security-admin",
"class" : "super-user",
"uid" : 3002
}
]
}
}
}
}
Junos devices provide two opons to load JSON conguraon data that contains unordered list entries,
that is, list entries where the list key is not necessarily the rst element.
Use the request system convert-json-configuration operaonal mode command to produce JSON
conguraon data with ordered list entries before loading the data on the device.
Congure the reorder-list-keys statement at the [edit system configuration input format json] hierarchy
level. Aer you congure the statement, you can load JSON conguraon data with unordered list
entries, and the device reorders the list keys as required by the Junos schema during the load
operaon.
NOTE: When you congure the reorder-list-keys statement, the load operaon can take
signicantly longer to parse the conguraon, depending on the size of the conguraon and the
number of lists. Thus, for large conguraons or conguraons with many lists, we recommend
using the request system convert-json-configuration command instead of the reorder-list-keys
statement.
247
For example, suppose the user-data.json le contains the following JSON conguraon. If you tried to
load the conguraon, the device would emit a load error for admin2 because the list key name is not the
rst element in that list entry.
user@host> file show /var/tmp/user-data.json
{
"configuration" : {
"system" : {
"login" : {
"user" : [
{
"name" : "admin1",
"class" : "super-user",
"uid" : 3003
},
{
"class" : "super-user",
"name" : "admin2",
"uid" : 3004
}
]
}
}
}
}
If you use the request system convert-json-configuration command with the previous le as input, the
command generates the specied output le with JSON conguraon data that the Junos device can
parse during the load operaon.
user@host> request system convert-json-configuration /var/tmp/user-data.json output-filename
user-data-ordered.json
user@host> file show user-data-ordered.json
{
"configuration":{
"system":{
"login":{
"user":[
{
"name":"admin1",
248
"class":"super-user",
"uid":3003
},
{
"name":"admin2",
"class":"super-user",
"uid":3004
}
]
}
}
}
}
Alternavely, you can congure the reorder-list-keys conguraon statement.
user@host# set system configuration input format json reorder-list-keys
user@host# commit
Aer you congure the statement, you can load the original JSON conguraon le with unordered list
entries, and the device handles the list entries when it parses the conguraon.
user@host# load merge json /var/tmp/user-data.json
load complete
Back Up Conguraons to an Archive Site
IN THIS SECTION
Congure the Transfer of the Acve Conguraon | 250
You can congure a device to transfer its conguraon to an archive le periodically.
249
Congure the Transfer of the Acve Conguraon
If you want to back up your device’s current conguraon to an archive site, you can congure the
device to transfer its acve conguraon by FTP, HTTP, secure copy (SCP), or SFTP periodically or aer
each commit.
To congure the device to transfer its acve conguraon to an archive site, include statements at the
[edit system archival configuration] hierarchy level:
[edit system archival configuration]
archive-sites {
file:/
path
;
file:///
path
;
ftp://
username
@
host
<:
port
>//
url-path
;
http://
username
@
host
<:
port
>/
url-path
;
scp://
username
@
host
<:
port
>/
url-path
;
sftp://
username
@
host
<:
port
>/
url-path
;
}
routing-instance
routing-instance
;
transfer-interval
interval
;
transfer-on-commit;
When you congure the device to transfer its conguraon les, you specify an archive site to which
the les are transferred. If you specify more than one archive site, the device aempts to transfer les to
the rst archive site in the list, moving to the next site only if the transfer fails.
When you use the archive-sites statement, you can specify a desnaon as an FTP URL, HTTP URL,
SCP-style remote le specicaon, or SFTP URL. The URL type le: is also supported. When you specify
the archive site, do not add a forward slash (/) to the end of the URL.
NOTE:
The URL type le: is supported only for local les.
When using the FTP opon, specify a double forward slash (//) aer the host:port. For
example: p://username@host<:port>//url-path
le:/path/ is the minimal representaon of a local le with no authority eld and an absolute path that
begins with a slash "/" as dened in RFC 8089.
le:///path is an example for a tradional le URI for a local le with an empty authority as dened in
RFC 8089.
250
NOTE: When specifying a URL in a statement using an IPv6 host address, you must enclose the
enre URL in quotaon marks ("") and enclose the IPv6 host address in brackets ([ ]). For
example, "p://
username
<:
password
>@[
ipv6-host-address
]<:
port
>//
url-path
"
To congure the device to periodically transfer its acve conguraon to an archive site, include the
transfer-interval statement at the [edit system archival configuration] hierarchy level:
[edit system archival configuration]
transfer-interval
interval
;
The
interval
is a period of me ranging from 15 through 2880 minutes.
To congure the device to transfer the conguraon to an archive site each me you commit the
conguraon, include the transfer-on-commit statement at the [edit system archival configuration] hierarchy
level:
[edit system archival configuration]
transfer-on-commit;
If the network device reaches the archive server through a specic roung instance, congure the
routing-instance statement at the [edit system archival configuration] hierarchy level, and specify the
roung instance.
[edit system archival configuration]
routing-instance
routing-instance
;
The desnaon lename is saved in the following format, where
n
corresponds to the number of the
compressed conguraon rollback le that has been archived:
<
router-name
>_
YYYYMMDD_HHMMSS
_juniper.conf.
n
.gz
NOTE: The me included in the desnaon lename is in Coordinated Universal Time (UTC).
251
Factory Default Conguraon Overview
IN THIS SECTION
Restore the Default Factory Conguraon | 252
The default factory conguraon contains the basic device conguraon sengs. This rst
conguraon of the device is loaded automacally the rst me you install the device and power it on.
Restore the Default Factory Conguraon
If for any reason the current acve conguraon fails, you can restore the default factory conguraon.
The default factory conguraon contains the basic conguraon sengs and is somemes referred to
as the rescue conguraon. This is the rst conguraon of the device and is loaded the rst me you
install the device and power it on.
The load factory default command is a standard conguraon command. This conguraon command
replaces the current acve conguraon with the default factory conguraon.
To restore the switch to the default factory conguraon:
1. Make sure you are in conguraon mode.
2. Enter the following commands at the CLI:
[edit]
user@switch# load factory-default
[edit]
user@switch# delete system commit factory-settings
[edit]
user@switch# commit
NOTE: This process clears prior commied conguraon parameters, except for those that
preserve a Virtual Chassis conguraon. A Virtual Chassis is a group of devices congured to
252
work together as if they were a single device. You can use the load factory-default command to
restore the factory default conguraon on a Virtual Chassis without removing anything
needed to keep the Virtual Chassis working.
3. Make sure you congure the root (superuser) password. Set the root authencaon password and
commit. If you congure the plain-text-password opon, you are prompted to enter and conrm the
password.
[edit]
user@switch# set system root-authentication plain-text-password
New password:
type password here
Retype new password:
retype password here
user@switch# commit
SEE ALSO
No Link Title
Rescue Conguraon
IN THIS SECTION
Creang and Returning to a Rescue Conguraon | 253
A rescue conguraon is the known working conguraon. If the acve conguraon is corrupted, the
device automacally loads the rescue conguraon le as the acve conguraon.
Creang and Returning to a Rescue Conguraon
A
rescue conguraon
allows you to dene a known working conguraon or a conguraon with a
known state for recovery, if necessary. This alleviates the necessity of having to remember the rollback
number with the
rollback
command. The rescue conguraon rolls back the device to a known
253
conguraon, or can serve as a last resort if your device conguraon and the backup conguraon les
become damaged beyond repair.
To save the most recently commied conguraon as the rescue conguraon so that you can return to
it at any me, issue the request system configuration rescue save command:
user@host> request system configuration rescue save
To return to the rescue conguraon, use the rollback rescue conguraon mode command. To commit
the rescue conguraon, thereby acvang it, use the commit command.
[edit]
user@host# rollback rescue
load complete
NOTE: If the rescue conguraon does not exist, or if the rescue conguraon is not a complete,
viable conguraon, then the rollback command fails, an error message appears, and the current
conguraon remains acve.
To delete an exisng rescue conguraon, issue the request system configuration rescue delete command:
user@host> request system configuration rescue delete
user@host>
NOTE: We recommend seng the rescue conguraon. This enables the device to automacally
load the rescue conguraon le as the acve conguraon if for any reason the current acve
conguraon fails. A minor alarm Rescue configuration is not set is raised if you do not set the
rescue conguraon using the request system configuration rescue save command.
254
Encrypt and Decrypt Conguraon Files
IN THIS SECTION
Encrypt Conguraon Files | 255
Decrypt Conguraon Files | 257
Modify the Encrypon Key | 258
You store conguraon data and sensive network informaon in conguraon les. Encrypng
conguraon les enables you to secure the informaon they store. Decrypng means disabling the
encrypon of conguraon les on a device and making the les readable to all.
NOTE: Encrypon features are not available on all Juniper Networks devices. If these features
are not available on one or more of your devices, the Junos OS CLI encrypon-related commands
described in this topic may be hidden or may not funcon. See your hardware documentaon for
details.
Encrypt Conguraon Files
To encrypt conguraon les on a Juniper Networks device, you need an encrypon key. You congure
an encrypon key in EEPROM and determine which encrypon process is appropriate for your network.
To congure an encrypon key, select the most appropriate request system set-encryption-key command in
operaonal mode, as described in the following table.
255
Table 11: The request system set-encrypon-key CLI Commands
CLI Command Descripon
request system set-encryption-key
Sets the encrypon key and enables default
conguraon le encrypon:
AES encrypon for the Canada and U.S. version of
the operang system
DES encrypon for the internaonal version of the
operang system
request system set-encryption-key algorithm des
Sets the encrypon key and species conguraon le
encrypon by DES.
request system set-encryption-key unique
Sets the encrypon key and enables default
conguraon le encrypon with a unique encrypon
key that includes the chassis serial number of the
device.
When you encrypt conguraon les with the unique
key, you can decrypt the les on the current device
only. You cannot copy encrypt conguraon les to
another device and decrypt them.
request system set-encryption-key des unique
Sets the encrypon key and species conguraon le
encrypon by DES with a unique encrypon key.
To encrypt conguraon les on a device:
1. Enter operaonal mode in the CLI.
2. Congure an encrypon key in EEPROM and determine the encrypon process; for example, enter
the request system set-encryption-key command.
user@host> request system set-encryption-key
Enter EEPROM stored encryption key:
256
3. At the prompt, enter the encrypon key. The encrypon key must have at least six characters.
Enter EEPROM stored encryption key:juniper1
Verifying EEPROM stored encryption key:
4. At the second prompt, reenter the encrypon key.
5. Enter conguraon mode in the CLI.
6. Enable conguraon le encrypon to take place.
[edit]
user@host# edit system
user@host# set encrypt-configuration-files
7. Begin the encrypon process by comming the conguraon.
[edit]
user@host# commit
commit complete
Decrypt Conguraon Files
Decrypng conguraon les means disabling the le encrypon on a device, which makes the les
readable to all.
To disable the encrypon of conguraon les on a device:
1. Enter operaonal mode in the CLI.
2. Verify your permission to decrypt conguraon les on this device by entering the encrypon key for
the device.
Example:
user@host> request system set-encryption-key
Enter EEPROM stored encryption key:
Verifying EEPROM stored encryption key:
3. At the second prompt, reenter the encrypon key.
4. Enter conguraon mode in the CLI.
257
5. Enable conguraon le decrypon.
[edit]
user@host# edit system
user@host# set no-encrypt-configuration-files
6. Begin the decrypon process by comming the conguraon.
[edit]
user@host# commit
commit complete
Modify the Encrypon Key
When you modify the encrypon key, the conguraon les are decrypted and then reencrypted with
the new encrypon key.
To modify the encrypon key:
1. Enter operaonal mode in the CLI.
2. Congure a new encrypon key in EEPROM, and determine the encrypon process; for example,
enter the request system set-encryption-key command.
user@host> request system set-encryption-key
Enter EEPROM stored encryption key:
3. At the prompt, enter the new encrypon key. The encrypon key must have at least six characters.
Enter EEPROM stored encryption key:juniperone
Verifying EEPROM stored encryption key:
4. At the second prompt, reenter the new encrypon key.
258
Example: Protecng the Junos OS Conguraon
from Modicaon or Deleon
IN THIS SECTION
Requirements | 259
Overview | 260
Protecng a Parent-Level Hierarchy | 260
Protecng a Child Hierarchy | 261
Protecng a Conguraon Statement Within a Hierarchy | 262
Protecng a List of Ideners for a Conguraon Statement | 263
Protecng an Individual Member from a Homogenous List | 264
Unprotecng a Conguraon | 265
Vericaon | 266
This example shows how to use the protect and unprotect commands in the conguraon mode to protect
and unprotect the CLI conguraon.
Requirements
This example uses the following hardware and soware components:
An M Series, MX Series, PTX Series, or T Series device
Junos OS 11.2 or later running on all devices
259
Overview
IN THIS SECTION
Topology | 260
The Junos OS enables you to protect the device conguraon from being modied or deleted by other
users. This can be accomplished by using the protect command in the conguraon mode of the CLI.
Likewise, you can also unprotect a protected conguraon by using the unprotect command.
These commands can be used at any level of the conguraon hierarchy—a top-level parent hierarchy or
a conguraon statement or an idener within the lowest level of the hierarchy.
If a conguraon hierarchy is protected, users cannot perform the following acvies:
Deleng or modifying a hierarchy or a statement or idener within the protected hierarchy
Inserng a new conguraon statement or an idener within the protected hierarchy
Renaming a statement or idener within the protected hierarchy
Copying a conguraon into a protected hierarchy
Acvang or deacvang statements within a protected hierarchy
Annotang a protected hierarchy
Topology
Protecng a Parent-Level Hierarchy
IN THIS SECTION
Procedure | 261
260
Procedure
Step-by-Step Procedure
To protect a conguraon at the top level of the hierarchy:
Idenfy the hierarchy that you want to protect and issue the protect command for the hierarchy at the
[edit] hierarchy level.
For example, if you want to protect the enre [edit access] hierarchy level, use the following command:
[edit]
user@host# protect access
Results
Protects all elements under the parent hierarchy.
NOTE: If you issue the protect command for a hierarchy that is not used in the conguraon, the
Junos OS CLI displays the following error message:
[edit]
user@host# protect access
warning: statement not found
Protecng a Child Hierarchy
IN THIS SECTION
Procedure | 262
261
Procedure
Step-by-Step Procedure
To protect a child hierarchy contained within a parent hierarchy:
Navigate to the parent container hierarchy. Use the protect command for the hierarchy at the parent
level.
For example, if you want to protect the [edit system syslog console] hierarchy level, use the following
command at the [edit system syslog] hierarchy level.
[edit system syslog]
user@host# protect console
Results
Protects all elements under the child hierarchy.
Protecng a Conguraon Statement Within a Hierarchy
IN THIS SECTION
Procedure | 262
Procedure
Step-by-Step Procedure
To protect a conguraon statement within a hierarchy level:
Navigate to the hierarchy level containing the statement that you want to protect and issue the protect
command for the hierarchy.
262
For example, if you want to protect the host-name statement under the [edit system] hierarchy level, use
the following command:
[edit system]
user@host# protect host-name
Results
Protecng a List of Ideners for a Conguraon Statement
IN THIS SECTION
Procedure | 263
Procedure
Step-by-Step Procedure
Some conguraon statements can take mulple values. For example, the address statement at the [edit
system login deny-sources] hierarchy level can take a list of hostnames, IPv4 addresses, or IPv6 addresses.
Suppose you have the following conguraon:
[edit system login]
deny-sources {
address [ 172.17.28.19 172.17.28.20 172.17.28.21 172.17.28.22];
}
To protect all the addresses for the address statement, use the following command at the [edit] level:
[edit]
user@host# protect system login deny-sources address
263
Results
All the addresses ([172.17.28.19 172.17.28.20 172.17.28.21 172.17.28.22]) for the address statement
are protected.
Protecng an Individual Member from a Homogenous List
IN THIS SECTION
Procedure | 264
Procedure
Step-by-Step Procedure
Suppose you have the following conguraon:
[edit groups ]
test1 {
system {
name-server {
10.1.2.1;
10.1.2.2;
10.1.2.3;
10.1.2.4;
}
}
}
To protect one or more individual addresses for the name-server statement, issue the following command
at the [edit] level:
[edit]
user@host# protect groups test1 system name-server 10.1.2.1
user@host# protect groups test1 system name-server 10.1.2.4
264
Results
Addresses 10.1.2.1 and 10.1.2.4 are protected.
Unprotecng a Conguraon
IN THIS SECTION
Procedure | 265
Procedure
Step-by-Step Procedure
Suppose you have the following conguraon at the [edit system] hierarchy level:
protect: system {
host-name bigping;
domain-search 10.1.2.1;
login {
deny-sources {
protect: address [ 172.17.28.19 172.17.28.173 172.17.28.0 174.0.0.0 ];
}
}
}
To unprotect the enre [edit system] hierarchy level, issue the following command at the [edit] level:
[edit]
user@host# unprotect system
Results
The enre system hierarchy level is unprotected.
265
Vericaon
IN THIS SECTION
Verify That a Hierarchy Is Protected Using the show Command | 266
Verify That a Hierarchy Is Protected by Aempng to Modify a Conguraon | 267
Verify Usage of the protect Command | 267
View the Conguraon in XML | 268
Verify That a Hierarchy Is Protected Using the show Command
Purpose
To check that a conguraon hierarchy is protected.
Acon
In the conguraon mode, issue the show command at the [edit] hierarchy level to see all the
conguraon hierarchies and conguraon statements that are protected.
NOTE: All protected hierarchies or statements are prexed with a protect: string.
...
protect: system {
host-name bigping;
domain-search 10.1.2.1;
login {
deny-sources {
protect: address [ 172.17.28.19 172.17.28.173 172.17.28.0 174.0.0.0 ];
}
}
}
...
266
Verify That a Hierarchy Is Protected by Aempng to Modify a Conguraon
Purpose
To verify that a conguraon is protected by trying to modify the conguraon using the activate, copy,
insert, rename, and delete commands.
Acon
To verify that a conguraon is protected:
1. Try using the activate, copy, insert, rename, and delete commands for a top-level hierarchy or a child-level
hierarchy or a statement within the hierarchy.
For a protected hierarchy or statement, the Junos OS displays an appropriate warning that the
command has not executed. For example:
protect: system {
host-name a;
inactive: domain-search [ a b ];
}
2. To verify that the hierarchy is protected, try issuing the activate command for the domain-search
statement:
[edit system]
user@host# activate system domain-search
The Junos OS CLI displays an appropriate message:
warning: [system] is protected, 'system domain-search' cannot be activated
Verify Usage of the protect Command
Purpose
To view the protect commands used for protecng a conguraon.
267
Acon
1. Navigate to the required hierarchy.
2. Issue the show | display set relative command.
user@host> show | display set relative
set system host-name bigping
set system domain-search 10.1.2.1
set system login deny-sources address 172.17.28.19
set system login deny-sources address 172.17.28.173
set system login deny-sources address 172.17.28.0
set system login deny-sources address 174.0.0.0
protect system login deny-sources address
protect system
View the Conguraon in XML
Purpose
To check if the protected hierarchies or statements are also displayed in the XML. Protected hierarchies,
statements, or ideners are displayed with the | display xml aribute in the XML.
Acon
To view the conguraon in XML:
1. Navigate to the hierarchy you want to view.
2. Use the show command with the pipe symbol and opon | display xml:
[edit system]
user@host# show | display xml
[edit]
user@host# show system | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/11.2I0/junos">
<configuration junos:changed-seconds="1291279234" junos:changed-localtime="2017-12-02
00:40:34 PST">
<system protect="protect">
<host-name>bigping</host-name>
268
<domain-search>10.1.2.1</domain-search>
<login>
<message>
\jnpr
\tUNAUTHORIZED USE OF THIS ROUTER
\tIS STRICTLY PROHIBITED!
</message>
<class>
<name>a</name>
<allow-commands>commit-synchronize</allow-commands>
<deny-commands>commit</deny-commands>
</class>
<deny-sources>
<address protect="protect">172.17.28.19</address>
<address protect="protect">172.17.28.173</address>
<address protect="protect">172.17.28.0</address>
<address protect="protect">174.0.0.0</address>
</deny-sources>
</login>
<syslog>
<archive>
</archive>
</syslog>
</system>
</configuration>
<cli>
<banner>[edit]</banner>
</cli>
</rpc-reply>
NOTE: Loading an XML conguraon with the unprotect="unprotect" tag unprotects an already
protected hierarchy. For example, suppose you load the following XML hierarchy:
<protocols unprotect="unprotect">
<ospf>
269
<area>
<name>0.0.0.0</name>
<interface>
<name>all</name>
</interface>
</area>
</ospf>
</protocols>
The [edit protocols] hierarchy becomes unprotected if it is already protected.
Synchronizing Conguraons Across Roung
Engines
IN THIS SECTION
Roung Engine Synchronizaon Overview | 270
Congure Mulple Roung Engines to Synchronize Commied Conguraons Automacally | 274
On devices with redundant Roung Engines, you can perform a commit synchronize, which acvates and
synchronizes the conguraon on both Roung Engines.
Roung Engine Synchronizaon Overview
If your device has two Roung Engines, you can manually direct one Roung Engine to synchronize its
conguraon with the other by issuing the commit synchronize command. The Roung Engine on which
you execute this command (the requesng Roung Engine) rst commits the conguraon. The
requesng Roung Engine then copies and loads its candidate conguraon to the responding Roung
Engine. Each Roung Engine performs a syntax check on the candidate conguraon le before
comming it. The commit synchronizaon process takes place one Roung Engine at a me.
270
If no errors are found, the conguraon is acvated and becomes the current operaonal conguraon
on both Roung Engines.
NOTE: If the commit fails on either Roung Engine, the commit process is rolled back on the
other Roung Engine as well. This safeguard ensures that both Roung Engines have the same
conguraon.
NOTE: If your conguraon includes a large amount of text or many apply-groups, commit mes
can be longer than desired.
For example, you may want both Roung Engines to have the same conguraon. In this scenario, if you
are logged in to re1 (requesng Roung Engine), you issue the commit synchronize command on re1.
Roung Engine re1 copies and loads its candidate conguraon to re0 (responding Roung Engine). Both
Roung Engines then perform a syntax check on the candidate conguraon le being commied. If no
errors are found, the re1 candidate conguraon is acvated and becomes the current operaonal
conguraon on both Roung Engines.
NOTE: When you issue the commit synchronize command, you must use the groups re0 and re1. For
informaon about how to use the apply-groups statement, see "Applying a Conguraon Group"
on page 131.
You can synchronize a Roung Engine's current operaonal conguraon le with the other Roung
Engine's conguraon le. To do this, you log in to the Roung Engine from which you want to
synchronize and issue the commit synchronize command.
Example:
[edit]
user@host# commit synchronize
re0:
configuration check succeeds
re1:
commit complete
re0:
commit complete
271
NOTE: The backup Roung Engine may be only parally commied due to invalid conguraon
during system reboot. In this case, the commit synchronize command with the force opon from the
primary Roung Engine does not work.
The commit synchronize command does not work if the responding Roung Engine has uncommied
conguraon changes. However, you can force commit synchronizaon on the Roung Engines by using
the force opon. When you issue the commit synchronize command with the force opon from one Roung
Engine, the conguraon sessions on the other Roung Engine are terminated. When those sessions are
terminated on the other Roung Engine, its conguraon is synchronized with the conguraon on the
Roung Engine from which you issued the command.
NOTE: We recommend that you use the force opon only if you are unable to resolve the issues
that caused the commit synchronize command to fail.
To force a commit synchronize on the Roung Engines, you log in to the Roung Engine from which you
want to synchronize. Then, you issue the command with the force opon.
Example:
[edit]
user@host# commit synchronize force
re0:
re1:
commit complete
re0:
commit complete
[edit]
user@host#
NOTE: If you have nonstop roung enabled on your device, you enter the commit synchronize
command from the primary Roung Engine aer you make any changes to the conguraon. If
you enter this command on the backup Roung Engine, the soware displays a warning and
commits the conguraon.
272
Include the fast-synchronize statement at the [edit system] hierarchy level to have the synchronizaon
occur simultaneously between the primary and the backup Roung Engines:
[edit system]
commit fast-synchronize;
NOTE:
When the fast-synchronize statement is congured, the commits on the primary Roung Engine
and the backup Roung Engine run in parallel. In this process, the conguraon is validated
only on the Roung Engine where you execute the commit command. Therefore, we
recommend that you not include too many conguraon details in groups like re0 and re1,
because the conguraon specied in group re0 is applied only if the current Roung Engine
is in slot 0. Likewise, the conguraon specied in group re1 is applied only if the current
Roung Engine is in slot 1.
If fast-synchronize is enabled and both Roung Engines (primary and backup) run dierent
soware versions, the backup Roung Engine conguraon may not be valid. This is true
even if the primary Roung Engine validates the conguraon. Therefore, ensure that the
same operang systemoperang system soware version is running on both the Roung
Engines.
You can use the commit synchronize scripts command to synchronize a Roung Engine's conguraon and
all commit, event, lib, op, and SNMP scripts with the other Roung Engine. If you congure the load-
scripts-from-flash statement for the requesng Roung Engine, the device synchronizes the scripts. The
device synchronizes the scripts from ash memory on the requesng Roung Engine to ash memory
on the responding Roung Engine. Otherwise, the device synchronizes the scripts from the hard disk on
the requesng Roung Engine to the hard disk on the responding Roung Engine. The device
synchronizes all scripts regardless of whether they are enabled in the conguraon or have been
updated since the last synchronizaon.
To synchronize a Roung Engine's conguraon le and all scripts with the other Roung Engine, log in
to the Roung Engine from which you want to synchronize, and issue the commit synchronize scripts
command.
Example:
[edit]
user@host# commit synchronize scripts
re0:
configuration check succeeds
273
re1:
commit complete
re0:
commit complete
NOTE: If the commit check operaon fails for the requesng Roung Engine, the process stops,
and the scripts are not copied to the responding Roung Engine. If the commit check or commit
operaon fails for the responding Roung Engine, the scripts are sll synchronized. The scripts
are sll synchronized because the synchronizaon occurs before the commit check operaon on
the responding Roung Engine.
Include the synchronize statement at the [edit system scripts] hierarchy level to synchronize scripts every
me you issue a commit synchronize command.
[edit system scripts]
synchronize;
Congure Mulple Roung Engines to Synchronize Commied
Conguraons Automacally
If your device has mulple Roung Engines, you can manually direct one Roung Engine to synchronize
its conguraon with the others by issuing the commit synchronize command.
To make the Roung Engines synchronize automacally whenever a conguraon is commied, include
the commit synchronize statement at the [edit system] hierarchy level:
[edit system]
commit synchronize;
The Roung Engine on which you execute the commit command (requesng Roung Engine) copies and
loads its candidate conguraon to the other (responding) Roung Engines. All Roung Engines then
perform a syntax check on the candidate conguraon le being commied. If no errors are found, the
conguraon is acvated and becomes the current operaonal conguraon on all Roung Engines.
For the commit synchronizaon process, the primary Roung Engine commits the conguraon and
sends a copy of the conguraon to the backup Roung Engine. Then the backup Roung Engine loads
and commits the conguraon. So, the commit synchronizaon between the primary and backup
274
Roung Engines takes place one Roung Engine at a me. If the conguraon has a large text size or
many apply-groups, commit mes can be longer than desired.
You can use the commit fast-synchronize statement to have the synchronizaon between the primary and
backup Roung Engines occur simultaneously instead of sequenally. This can reduce the me needed
for synchronizaon because the commits on the primary and backup Roung Engines occur in parallel.
Include the fast-synchronize statement at the [edit system] hierarchy level to have synchronize occur
simultaneously between the primary and the backup Roung Engines:
[edit system]
commit fast-synchronize
NOTE:
If commit fails on either Roung Engine, the commit process is rolled back on the other
Roung Engine as well. This ensures that both Roung Engines have the same conguraon.
When the fast-synchronize statement is congured, the commits on the primary Roung Engine
and the backup Roung Engine run in parallel. In this process, the conguraon is validated
only on the Roung Engine where you execute the commit command. Therefore, we
recommend liming the number of conguraon details in groups like re0 and re1, because
the conguraon specied in group re0 is applied only if the current Roung Engine is in slot
0. Likewise, the conguraon specied in group re1 is applied only if the current Roung
Engine is in slot 1.
If fast-synchronize is enabled and if the primary Roung Engine and backup Roung Engines
run dierent soware versions, you cannot be sure that the backup Roung Engine
conguraon is valid. This is true even if the primary Roung Engine validates the
conguraon, Therefore, ensure that the operang system soware version running on both
the Roung Engines is the same.
Change History Table
Feature support is determined by the plaorm and release you are using. Use Feature Explorer to
determine if a feature is supported on your plaorm.
Release
Descripon
19.4R1-S1
Starng in Junos OS Evolved Release 19.4R1-S1, commit synchronize is enabled by default on
PTX10008. If you issue commit at the [edit system] hierarchy level from the primary roung engine,
you see that the backup roung engine is automacally synchronized.
275
19.4R1
Starng in Junos OS Evolved Release 19.4R1, commit synchronize is enabled by default on PTX10008.
If you issue commit at the [edit system] hierarchy level from the primary roung engine, you see that
the backup roung engine is automacally synchronized.
276
5
CHAPTER
Using Operaonal Commands to
Monitor Devices
CLI Operaonal Mode Overview | 278
Using Operaonal Commands to Monitor a Device | 285
Filtering Operaonal Command Output | 301
CLI Operaonal Mode Overview
IN THIS SECTION
CLI Operaonal Mode Command Overview | 278
Display Opons of the show Command—An Overview | 281
Interface Naming Convenons Used in Operaonal Commands | 282
About Group Interface Names Using Wildcard Characters | 284
In operaonal mode, you can use Junos OS CLI commands to monitor and troubleshoot a device. The
monitor, ping, show, test, and traceroute commands enable you to display informaon and test network
connecvity for the device.
CLI Operaonal Mode Command Overview
IN THIS SECTION
CLI Operaonal Mode Command Categories | 278
Commonly Used Operaonal Mode Commands | 279
You (the network administrator) can control all network operaons using the Junos OS CLI operaonal
mode commands described in this topic.
CLI Operaonal Mode Command Categories
CLI operaonal mode commands fall into the following broad categories:
Operaonal mode commands for monitoring and troubleshoong—The following commands perform
funcons related to informaon and stascs about the soware and to test network connecvity.
clear—Clear stascs and protocol database informaon.
278
file—Perform le operaons.
mtraceTrace a mulcast path from source to receiver.
monitor—Perform real-me debugging of various soware components, including the roung
protocols and interfaces.
ping—Determine the reachability of a remote network host.
show—Display the current conguraon and informaon about interfaces, roung protocols,
roung tables, roung policy lters, system alarms, and the chassis.
testTest the conguraon and applicaon of policy lters and autonomous system (AS) path
regular expressions.
tracerouteTrace the route to a remote network host.
Commands for restarng soware processes—The commands in the restart hierarchy restart the
various system processes, including the roung protocol, interface, and SNMP.
A command—request—Perform system-level operaons, including stopping and reboong the router
or switch and loading operang system images.
A command—start—Exit the CLI and start a UNIX shell.
A command—configure—Enter conguraon mode, which provides a series of commands that
congure the system, including the roung protocols, interfaces, network management, and user
access.
For more informaon about the CLI operaonal mode commands, see the CLI Explorer. Alternavely,
you can enter ? at the operaonal mode command prompt to view a list of available commands.
Commonly Used Operaonal Mode Commands
The following table lists some operaonal commands you may nd useful for monitoring router or
switch operaon.
Table 12: Commonly Used
Operaonal Mode Commands
Items to Check Descripon Command
Soware version Versions of soware running on the router or switch
show version
Log les Contents of the log les
monitor
279
Table 12: Commonly Used Operaonal Mode Commands
(Connued)
Items to Check Descripon Command
Log les and their contents and recent user logins
show log
Remote systems Host reachability and network connecvity
ping
The route to a network system
traceroute
Conguraon Current system conguraon
show configuration
File manipulaon List of les and directories on the router or switch
file list
Contents of a le
file show
Interface informaon Detailed informaon about interfaces
show interfaces
Chassis Chassis alarm status
show chassis alarms
Informaon currently on cra display
show chassis craft-interface
Router or switch environment informaon
show chassis environment
Hardware inventory
show chassis hardware
Roung table
informaon
Informaon about entries in the roung tables
show route
Forwarding table
informaon
Informaon about data in the kernel’s forwarding table
show route forwarding-table
280
Display Opons of the show Command—An Overview
The show command can include brief, detail, extensive, or terse opons. You can use these and other
opons to control the amount and type of informaon to view.
1. At any point in the CLI, you can enter the ? character to view all the currently available opons. For
example:
user@host> show interfaces fe-1/1/1 ?
Possible completions:
<[Enter]> Execute this command
brief Display brief output
descriptions Display interface description strings
detail Display detailed output
extensive Display extensive output
media Display media information
snmp-index SNMP index of interface
statistics Display statistics and detailed output
terse Display terse output
| Pipe through a command
2. At any point in the CLI, you can use the show command with one of the following opons to display
the detail you need to view.
281
Figure 10: Command Output Opons
Interface Naming Convenons Used in Operaonal Commands
IN THIS SECTION
Physical Part of an Interface Name | 282
Logical Part of an Interface Name | 283
Channel Idener Part of an Interface Name | 283
This topic explains the interface naming convenons used in operaonal commands.
Physical Part of an Interface Name
The physical interface naming convenons for Juniper Networks device plaorms is as follows:
282
On SRX Series Firewalls, the unique name of each network interface has the following format to
idenfy the physical device that corresponds to a single physical network connector:
type-slot
/
pim-or-ioc
/
port
On other plaorms, when you display informaon about an interface, you specify the following
ideners: interface type, the slot in which the Flexible PIC Concentrator (FPC) is installed, the slot
on the FPC in which the PIC is located, and the congured port number.
In the physical part of the interface name, a hyphen (-) separates the media type from the FPC
number, and a slash (/) separates the FPC, PIC, and port numbers:
type-fpc
/
pic
/
port
NOTE: Excepons to the
type-fpc
/
pic
/
port
physical descripon include the aggregated Ethernet
and aggregated SONET/SDH interfaces, which use the syntax ae
number
and as
number
, respecvely.
Logical Part of an Interface Name
The logical unit part of the interface name corresponds to the logical unit number, which can be a
number from 0 through 16,384. You use logical unit numbers to uniquely idenfy physical storage
systems or virtual storage systems within a network. In the virtual part of the name, a period (.)
separates the port and logical unit numbers:
SRX Series Firewalls:
type-slot/pim-or-ioc/port:channel.unit
Other plaorms:
type-fpc
/
pic
/
port.logical
Channel Idener Part of an Interface Name
The channel idener part of an interface name is required only on channelized interfaces. For
channelized interfaces, channel 0 idenes the rst channelized interface. For channelized intelligent
queuing (IQ) interfaces, channel 1 idenes the rst channelized interface.
283
NOTE: Depending on the type of channelized interface, you can specify up to three levels of
channelizaon.
A colon (:) separates the physical and virtual parts of the interface name:
SRX Series Firewalls:
type-slot
/
pim-or-ioc
/
port:channel
type-slot
/
pim-or-ioc
/
port:channel:channel
type-slot
/
pim-or-ioc
/
port:channel:channel:channel
Other plaorms:
type-fpc
/
pic
/
port:channel
type-fpc/
/
pic
/
port:channel:channel
type-fpc
/
pic
/
port:channel:channel:channel
About Group Interface Names Using Wildcard Characters
You can use wildcard characters in operaonal commands to specify groups of interface names without
having to type each name individually. The following table lists the available wildcard characters. You
must enclose all wildcard characters except the asterisk (*) in quotaon marks (“ ”).
Table 13: Wildcard Characters for Specifying Interface Names
Wildcard Character Descripon
* (asterisk)
Match any string of characters in that posion in the interface name. For example,
so* matches all SONET/SDH interfaces.
"[
character
<
character
...>]"
Match one or more individual characters in that posion in the interface name.
For example, so-“[03]”* matches all SONET/SDH interfaces in slots 0 and 3.
284
Table 13: Wildcard Characters for Specifying Interface Names
(Connued)
Wildcard Character Descripon
"[!
character
<
character
...>]" Match all characters except those included in the brackets. For example, so-“[!
03]”* matches all SONET/SDH interfaces except those in slots 0 and 3.
"[
character1
-
character2
]" Match a range of characters. For example, so-“[0-3]” * matches all SONET/SDH
interfaces in slots 0, 1, 2, and 3.
"[!
character1
-
character2
]"
Match all characters that are not in the specied range of characters. For example,
so-”[!0-3]”* matches all SONET/SDH interfaces in slots 4, 5, 6, and 7.
Using Operaonal Commands to Monitor a Device
IN THIS SECTION
CLI Command Compleon Example | 286
Operaonal Mode Commands: Overview of Controlling the Scope | 287
Viewing Files and Directories on a Device | 289
Display Operang System Informaon | 295
Managing Programs and Processes Using Operaonal Mode Commands | 295
CLI Comment Character # for Operaonal Mode Commands | 300
Operaonal mode CLI commands enable you to monitor and control the operaon of a Juniper
Networks device. The operaonal mode commands exist in a hierarchical structure.
285
CLI Command Compleon Example
The command compleon feature can help make it easier both to enter commands or to learn what
possible compleon opons are available at any given me.
This example shows the result of issuing the show interfaces command. In this case, the spacebar is used
to autocomplete the command.
user@host> sh<Space>ow i<Space>
'i' is ambiguous.
Possible completions:
igmp Show information about IGMP
interface Show interface information
isis Show information about IS-IS
user@host> show in<Space>terfaces
Physical interface: at-0/1/0, Enabled, Physical link is Up
Interface index: 11, SNMP ifIndex: 65
Link-level type: ATM-PVC, MTU: 4482, Clocking: Internal, SONET mode
Speed: OC12, Loopback: None, Payload scrambler: Enabled
Device flags: Present Running
Link flags: 0x01
...
user@host>
This example shows how to display a list of all log les whose names start with the string “messages,
and then display the contents of one of the les. Here, the Tab key is used to perform the
autocompleon.
user@myhost> show log mes?
Possible completions:
<filename>Log file to display
messagesSize: 1417052, Last changed: Mar 3 00:33
messages.0.gzSize: 145575, Last changed: Mar 3 00:00
messages.1.gzSize: 134253, Last changed: Mar 2 23:00
messages.10.gzSize: 137022, Last changed: Mar 2 14:00
messages.2.grSize: 137112, Last changed: Mar 2 22:00
messages.3.gzSize: 121633, Last changed: Mar 2 21:00
messages.4.gzSize: 135715, Last changed: Mar 2 20:00
messages.5.gzSize: 137504, Last changed: Mar 2 19:00
messages.6.gzSize: 134591, Last changed: Mar 2 18:00
286
messages.7.gzSize: 132670, Last changed: Mar 2 17:00
messages.8.gzSize: 136596, Last changed: Mar 2 16:00
messages.9.gzSize: 136210, Last changed: Mar 2 15:00
user@myhost> show log mes
<Tab>
sages.4
<Tab>
.gz
<Enter>
Jan 15 21:00:00 myhost newsyslog[1381]: logfile turned over
...
Operaonal Mode Commands: Overview of Controlling the Scope
IN THIS SECTION
Roung Matrix Command Opons | 288
The Junos OS CLI operaonal commands include opons that you can use to idenfy specic
components on a device. For example:
You use the show interfaces command to display informaon about all interfaces on the router.
1. Type the show interfaces command to display informaon about all interfaces on the router.
user@host> show interfaces
Physical interface: so-0/0/0, Enabled, Physical link is Up
Interface index: 128, SNMP ifIndex: 23
Link-level type: PPP, MTU: 4474, Clocking: Internal, SONET mode, Speed: OC3,
Loopback: None, FCS: 16, Payload scrambler: Enabled
Device flags : Present Running
Interface flags: Point-To-Point SNMP-Traps Internal: 0x4000
Link flags : Keepalives
Keepalive settings: Interval 10 seconds, Up-count 1, Down-count 3
Keepalive: Input: 13861 (00:00:05 ago), Output: 13891 (00:00:01 ago)
LCP state: Opened
NCP state: inet: Opened, inet6: Not-configured, iso: Opened, mpls: Not-configured
CHAP state: Closed
PAP state: Closed
CoS queues : 4 supported, 4 maximum usable queues
Last flapped : 2008-06-02 17:16:14 PDT (1d 14:21 ago)
287
Input rate : 40 bps (0 pps)
Output rate : 48 bps (0 pps)
---(more)---
NOTE: This example output shows only one interface, for the sake of brevity, but in reality,
the interfaces informaon for all four would be shown aer the —(more)— prompts.
2. To display informaon about a specic interface, type that interface as a command opon:
user@host> show interfaces fe-0/1/3
Physical interface: fe-0/1/3, Enabled, Physical link is Up
Interface index: 135, SNMP ifIndex: 30
Link-level type: Ethernet, MTU: 1514, Speed: 100mbps, MAC-REWRITE Error: None,
Loopback: Disabled, Source filtering: Disabled, Flow control: Enabled
Device flags : Present Running
Interface flags: SNMP-Traps Internal: 0x4000
Link flags : None
CoS queues : 4 supported, 4 maximum usable queues
Current address: 00:05:85:8f:c8:22, Hardware address: 00:05:85:8f:c8:22
Last flapped : 2008-06-02 17:16:15 PDT (1d 14:28 ago)
Input rate : 0 bps (0 pps)
Output rate : 0 bps (0 pps)
Active alarms : None
Active defects : None
user@host>
Roung Matrix Command Opons
The show version command oers several opons for viewing informaon about the roung matrix.
user@host> show version ?
Possible completions:
<[Enter]> Execute this command
all-lcc Show software version on all LCC chassis
brief Display brief output
detail Display detailed output
288
lcc Show software version on specific LCC (0..3)
scc Show software version on the SCC
| Pipe through a command
Viewing Files and Directories on a Device
IN THIS SECTION
Directories on the Device | 289
List Files and Directories | 290
Filenames and URLs | 293
The operang system stores informaon in les on the device, including conguraon les, log les, and
device soware les. This topic shows some examples of operaonal commands that you can use to
view les and directories on a device.
Directories on the Device
The following table lists some standard directories on a Juniper Networks device.
Table 14: Directories on the Device
DIrectory Descripon
/config
This directory is located on the device’s internal ash drive. It contains the acve conguraon
(juniper.conf) and rollback les 1, 2, and 3.
/var/db/config
This directory is located on the device’s hard drive and contains rollback les 4 through 49.
/var/tmp
This directory is located on the device’s hard drive. It holds core les from the various processes
on the Roung Engines. Core les are generated when a parcular process crashes. Juniper
Networks engineers use these core les to diagnose the cause of the failure.
289
Table 14: Directories on the Device
(Connued)
DIrectory Descripon
/var/log
This directory is located on the device’s hard drive. It contains les generated by both the
device’s logging funcon and the traceoptions command.
/var/home
This directory is located on the device’s hard drive. It contains a subdirectory for each congured
user on the device. These individual user directories are the default le locaon for many
soware commands.
/altroot
This directory is located on the device’s hard drive and contains a copy of the root le structure
from the internal ash drive. This directory is used in certain disaster recovery modes where the
internal ash drive is not operaonal.
/altconfig This directory is located on the device’s hard drive and contains a copy of the /config le
structure from the internal ash drive. This directory is also used in certain disaster recovery
modes when the internal ash drive is not operaonal.
List Files and Directories
You can view the devices directory structure as well as individual les by issuing the file command in
operaonal mode.
1. To get help about the file command, enter file ?:
user@host> file ?
Possible
completions:
<[Enter]> Execute this command
archive Archives files from the system
change-owner Change owner of file
change-permission Change permission of file
checksum Calculate file checksum
compress Compress file
copy Copy files (local or remote)
delete Delete files from the system
delete-directory Delete a directory
link Create link between files
290
list List file information
make-directory Create a new
make-directory Create a new
user@host> file
Help shows that the file command includes several opons for manipulang les.
2. Use the list opon to see the directory structure of the device. For example, to show the les
located in your home directory on the device:
user@host> file list
.ssh/
common
The default directory for the file list command is the home directory of the user logged in to the
device. In fact, the user’s home directory is the default directory for most of the commands requiring
a lename.
3. To view the contents of other le directories, specify the directory locaon. For example:
user@host> file list /config
juniper.conf
juniper.conf.1.gz
juniper.conf.2.gz
juniper.conf.3.gz
4. You can also use the device’s context-sensive help system to locate a directory. For example:
user@host> file list /?
Possible completions:
<[Enter]> Execute this command
<path> Path to list
/COPYRIGHT Size: 6355, Last changed: Feb 13 2017
/altconfig/ Last changed: Aug 07 2017
/altroot/ Last changed: Aug 07 2017
/bin/ Last changed: Apr 09 22:31:35
/boot/ Last changed: Apr 09 23:28:39
/config/ Last changed: Apr 16 22:35:35
/data/ Last changed: Aug 07 2017
/dev/ Last changed: Apr 09 22:36:21
/etc/ Last changed: Apr 11 03:14:22
291
/kernel Size: 27823246, Last changed: Aug 07 2017
/mfs/ Last changed: Apr 09 22:36:49
/mnt/ Last changed: Jan 11 2017
/modules/ Last changed: Apr 09 22:33:54
/opt/ Last changed: Apr 09 22:31:00
/packages/ Last changed: Apr 09 22:34:38
/proc/ Last changed: May 07 20:25:46
/rdm.taf Size: 498, Last changed: Apr 09 22:37:31
/root/ Last changed: Apr 10 02:19:45
/sbin/ Last changed: Apr 09 22:33:55
/staging/ Last changed: Apr 09 23:28:41
/tmp/ Last changed: Apr 11 03:14:49
/usr/ Last changed: Apr 09 22:31:34
/var/ Last changed: Apr 09 22:37:30
user@host> file list /var/?
<[Enter]> Execute this command
<path> Path to list
/var/account/ Last changed: Jul 09 2017
/var/at/ Last changed: Jul 09 2017
/var/backups/ Last changed: Jul 09 2017
/var/bin/ Last changed: Jul 09 2017
/var/crash/ Last changed: Apr 09 22:31:08
/var/cron/ Last changed: Jul 09 2017
/var/db/ Last changed: May 07 20:28:40
/var/empty/ Last changed: Jul 09 2017
/var/etc/ Last changed: Apr 16 22:35:36
/var/heimdal/ Last changed: Jul 10 2017
/var/home/ Last changed: Apr 09 22:59:18
/var/jail/ Last changed: Oct 31 2017
/var/log/ Last changed: Apr 17 02:00:10
/var/mail/ Last changed: Jul 09 2017
/var/msgs/ Last changed: Jul 09 2017
/var/named/ Last changed: Jul 10 2017
/var/packages/ Last changed: Jan 18 02:38:59
/var/pdb/ Last changed: Oct 31 2017
/var/preserve/ Last changed: Jul 09 2017
/var/run/ Last changed: Apr 17 02:00:01
/var/rundb/ Last changed: Apr 17 00:46:00
/var/rwho/ Last changed: Jul 09 2017
/var/sdb/ Last changed: Apr 09 22:37:31
/var/spool/ Last changed: Jul 09 2017
/var/sw/ Last changed: Jul 09 2017
/var/tmp/ Last changed: Apr 09 23:28:41
292
/var/transfer/ Last changed: Jul 09 2017
/var/yp/ Last changed: Jul 09 2017
user@host> file list /var/
5. You can also display the contents of a le. For example:
user@host>file show /var/log/inventory
Jul 9 23:17:46 CHASSISD release 8.4I0 built by builder on 2017-06-12 07:58:27 UTC
Jul 9 23:18:05 CHASSISD release 8.4I0 built by builder on 2017-06-12 07:58:27 UTC
Jul 9 23:18:06 Routing Engine 0 - part number 740-003239, serial number 9000016755
Jul 9 23:18:15 Routing Engine 1 - part number 740-003239, serial number 9001018324
Jul 9 23:19:03 SSB 0 - part number 710-001951, serial number AZ8025
Jul 9 23:19:03 SSRAM bank 0 - part number 710-001385, serial number 243071
Jul 9 23:19:03 SSRAM bank 1 - part number 710-001385, serial number 410608
...
Filenames and URLs
You can include a lename in CLI commands and conguraon statements such as these:
file copy
file archive,
load,
save
set system login user
username
authentication
load-key-file
request system software add
On a roung matrix, you can include chassis informaon as part of the lename (for example, lcc0, lcc0-
re0, or lcc0-re1).
You can specify a lename or URL in one of the following ways:
filename
—File in the user’s current directory on the local ash drive. You can use wildcards to specify
mulple source les or a single desnaon le. Neither HTTP nor FTP supports wildcards.
293
NOTE: Only the file (compare | copy | delete | list | rename | show) commands support
wildcards. When you issue the file show command with a wildcard, the command must
resolve to one lename.
path
/
filename
—File on the local ash disk.
/var/
filename
or /var/
path
/
filename
—File on the local hard disk.
You can also specify a le on a local Roung Engine for a specic T640 router on a roung matrix:
user@host> file delete lcc0-re0:/var/tmp/junk
a:
filename
or a:
path
/
filename
—File on the local drive. The default path is / (the root-level directory). The
removable media can be in MS-DOS or UNIX (UFS) format.
hostname:
/
path
/
filename, hostname:filename, hostname:path
/
filename,
or scp://
hostname
/
path
/
filename
—File on
an scp/ssh client. This form is not available in the worldwide version of the operang system. The
default path is the user’s home directory on the remote system. You can also specify
hostname
as
username
@
hostname
.
ftp://
hostname
/
path
/
filename
—File on an FTP server. You can also specify
hostname
as
username
@
hostname
or
username
:
password
@
hostname
. The default path is the user’s home directory.
To specify an absolute path, the path must start with %2F; for example, ftp://
hostname
/%2F
path
/
filename
.
To have the system prompt you for the password, specify prompt in place of the password. If a
password is required, and you do not specify the password or prompt, an error message is displayed:
user@host> file copy ftp://[email protected]//filename
file copy ftp.hostname.net: Not logged in.
user@host> file copy ftp://username:[email protected]//filename
Password for [email protected]:
http://
hostname
/
path
/
filename
—File on an HTTP server. You can also specify
hostname
as
username
@
hostname
or
username
:
password
@
hostname
. If a password is required and you omit it, you are prompted for it.
re0:/
path
/
filename
or re1:/
path
/
filename
—File on a local Roung Engine.
294
You can also specify a le on a local Roung Engine for a specic T640 router on a roung matrix:
user@host> show log lcc0-re1:chassisd
Display Operang System Informaon
You can display Junos OS version informaon and other status to determine if the version of the
soware that you are running supports specic features or hardware.
To display this informaon:
1. Make sure you are in operaonal mode.
2. To display brief informaon and status for the kernel and Packet Forwarding Engine, enter the show
version brief command. This command shows version informaon for soware packages installed on
the router.
If the Junos Crypto Soware Suite is listed, the router has Canada and USA encrypted soware. If
the Junos Crypto Soware Suite is not listed, the router is running worldwide nonencrypted
soware.
3. To display detailed version informaon, enter the show version detail command. This command
displays the hostname and version informaon for soware packages installed on your router. It also
includes the version informaon for each soware process.
Managing Programs and Processes Using Operaonal Mode Commands
IN THIS SECTION
Show Soware Processes | 296
Restart the Soware Process | 297
Stop the Soware | 298
Reboot the Soware | 299
This topic shows some examples of Junos OS operaonal commands that you can use to manage
programs and processes on a Juniper Networks device.
295
Show Soware Processes
To verify system operaon or to begin diagnosing an error condion, you may need to display
informaon about soware processes running on the device.
To show soware processes:
1. Make sure you are in operaonal mode.
2. Enter the show system processes extensive command. This command shows the CPU ulizaon on the
device and lists the processes in order of CPU ulizaon.
The following table lists and describes the output elds included in this example. The elds are listed in
alphabecal order.
Table 15: The show system process extensive Command Output Fields
Field Descripon
COMMAND
Command that is running.
last pid
Last process idener assigned to the process.
load averages
Three load averages, followed by the current me.
Mem
Informaon about physical and virtual memory allocaon.
NICE
UNIX “nice” value. The nice value allows a process to change its nal scheduling priority.
PID
Process idener.
PRI
Current kernel scheduling priority of the process. A lower number indicates a higher priority.
processes Number of exisng processes and the number of processes in each state (sleeping, running,
starting, zombies, and stopped).
RES
Current amount of resident memory, in KB.
296
Table 15: The show system process extensive Command Output Fields
(Connued)
Field Descripon
SIZE Total size of the process (text, data, and stack), in KB.
STATE Current state of the process (sleep, wait, run, idle, zombi, or stop).
Swap
Informaon about physical and virtual memory allocaon.
USERNAME
Owner of the process.
WCPU
Weighted CPU usage.
Restart the Soware Process
To correct an error condion, you might need to restart a soware process running on the device. You
can use the restart command to force a restart of a soware process.
CAUTION: Do not restart a soware process unless specically asked to do so by your
Juniper Networks customer support representave. Restarng a soware process
during normal operaon of a device can interrupt packet forwarding and cause data
loss.
To restart a soware process:
1. Make sure you are in operaonal mode.
2. Enter the following command:
user@host> restart
process-name
< (immediately | gracefully | soft) >
process-name
is the name of the process that you want to restart. For example, routing or class-of-
service. You can use the command compleon feature of the system to see a list of soware
processes that you can restart using this command.
The opon gracefully restarts the soware process aer performing clean-up tasks.
The opon immediately restarts the soware process without performing any clean-up tasks.
297
The opon soft rereads and reacvates the conguraon without completely restarng the
soware processes. For example, BGP peers stay up and the roung table stays constant.
NOTE: The gracefully, immediately, and soft opons for the restart command are oponal and not
required for execung the command.
The following example shows how to restart the roung process:
user@host> restart routing
Routing protocol daemon started, pid 751
When a process restarts, the process idener (PID) is updated.
Figure 11: Restarng a Process
Stop the Soware
CAUTION: To avoid possible damage to the le system and to prevent data loss, you
must always shut down the soware gracefully before powering o the device.
You must stop the soware on a device through a direct console connecon, not through the network.
As the soware shuts down, the network will go down, and if you were connected that way, you will not
see the results output.
To stop the soware:
298
1. Make sure you are in operaonal mode.
2. Enter the request system halt command. This command stops all system processes and halts the
operang system. For example:
user@host> request system halt
Halt the system? [yes,no] (no) yes
shutdown: [pid 3110]
Shutdown NOW!
*** FINAL System shutdown message from root@host ***
System going down IMMEDIATELY
user@host> Dec 17 17:28:40 init: syslogd (PID 2514) exited with status=0 Normal Exit
Waiting (max 60 seconds) for system process `bufdaemon' to stop...stopped
Waiting (max 60 seconds) for system process `syncer' to stop...stopped
syncing disks... 4
done
Uptime: 3h31m41s
ata0: resetting devices.. done
The operating system has halted.
Please press any key to reboot.
Reboot the Soware
Aer a soware upgrade or to recover (occasionally) from an error condion, you must reboot the
soware. As with the shutdown command, you must reboot through a direct console connecon otherwise
you will not see the command output when the network goes down during the reboot process.
To reboot the soware:
1. Make sure you are in operaonal mode.
2. Enter the request system reboot command. This command displays the nal stages of the system
shutdown and executes the reboot. Reboot requests are recorded to the system log les, which you
can view with the show log messages command. For example:
user@host>request system rebootReboot the system? [yes,no] (no)yes
shutdown: [pid 845]
Shutdown NOW!
*** FINAL System shutdown message from root@host ***
System going down IMMEDIATELY
299
user@host> Dec 17 17:34:20 init: syslogd (PID 409) exited with status=0 Normal Exit
Waiting (max 60 seconds) for system process `bufdaemon' to stop...stopped
Waiting (max 60 seconds) for system process `syncer' to stop...stopped
syncing disks... 10 6
done
Uptime: 2m45s
ata0: resetting devices.. done
Rebooting...
CLI Comment Character # for Operaonal Mode Commands
The comment character enables you to copy operaonal mode commands that include comments from
a le and paste them into the CLI. A pound or hash symbol (#) at the beginning of the command line
indicates a comment line. This command is useful for describing frequently used operaonal mode
commands, such as a user’s work instrucons on how to monitor the network. To add a comment to a
command le, you must place # as the rst character of the line. When you start a command with #, the
operang system disregards the rest of the line.
NOTE: The device conguraon does not save the comments you enter in the CLI, whether
individually or by pasng in the contents of a conguraon le. Comments entered at the CLI are
ignored.
To add comments in operaonal mode, you start with a # and end with a new line (carriage return):
user@host> #
comment-string
comment-string
is the text of the comment. The comment text can be any length, but each comment line
must begin with a #.
300
Filtering Operaonal Command Output
IN THIS SECTION
About Using the Pipe ( | ) Symbol to Filter Command Output | 301
Example: Use Regular Expressions with the Pipe ( | ) Symbol to Filter Command Output | 303
Example: Pipe ( | ) Filter Funcons in the Command-Line Interface | 304
Filter Operaonal Mode Command Output in a QFabric System | 318
Use Suppress-Zero Filter with the Pipe ( | ) Symbol to Filter Zero Values in Command Output | 319
The pipe | symbol lets you (the network administrator) lter the command output in both operaonal
and conguraon modes.
About Using the Pipe ( | ) Symbol to Filter Command Output
You can lter command output by adding the pipe ( | ) symbol when you enter the command.
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 lters that you can use with the pipe symbol ( | ):
user@host> show interfaces | ?
user@host> show interfaces | ?
Possible completions:
append Append output text to file
301
count Count occurrences
display Show additional kinds of information
except Show only text that does not match a pattern
find Search for first occurrence of pattern
hold Hold text without exiting the --More-- prompt
last Display end of output only
match Show only text that matches a pattern
no-more Don't paginate output
refresh Refresh a continuous display of the command
request Make system-level requests
resolve Resolve IP addresses
save Save output text to file
tee Write to standard output and file
trim Trim specified number of columns from start of line
For the show configuration command only, you can combine the pipe symbol and queson mark to display
an addional compare lter:
user@host> show configuration | ?
Possible completions:
compare Compare configuration changes with prior version
...
You can enter any of the pipe lters in combinaon. For example:
user@host>
command
| match
regular-expression
| save
filename
NOTE: This topic describes
only
the lters that you can use for
operaonal mode command
output.
302
Example: Use Regular Expressions with the Pipe ( | ) Symbol to Filter
Command Output
You use the except, find, and match lters with the pipe symbol to employ regular expressions to lter
output. Juniper Networks uses the regular expressions as dened in POSIX 1003.2. If a regular
expression contains spaces, operators, or wildcard characters, enclose the expression in quotaon
marks.
Table 16: Common Regular Expression Operators in Operaonal Mode Commands
Operator Funcon
|
Indicates that a match can be one of the two terms on either side of the pipe.
^
Used at the beginning of an expression to denote where a match should begin.
$
Used at the end of an expression to denote that a term must be matched exactly up to the point of
the $ character.
[ ]
Species a range of leers or digits to match. To separate the start and end of a range, use a hyphen
( - ).
( )
Species a group of terms to match.
For example, if a command produces the following output:
user@host> show chassis hardware
Hardware inventory:
Item Version Part number Serial number Description
Chassis F0632 MX80
Midplane REV 09 711-031594 ZW0568 MX80
PEM 0 Rev 04 740-028288 VK09886 AC Power Entry Module
Routing Engine BUILTIN BUILTIN Routing Engine
TFEB 0 BUILTIN BUILTIN Forwarding Engine Processor
QXM 0 REV 06 711-028408 ZW4288 MPC QXM
FPC 0 BUILTIN BUILTIN MPC BUILTIN
MIC 0 BUILTIN BUILTIN 4x 10GE XFP
PIC 0 BUILTIN BUILTIN 4x 10GE XFP
Xcvr 0 REV 02 740-014289 C825XU010 XFP-10G-SR
303
Xcvr 1 REV 03 740-014289 CB25BQ0WD XFP-10G-SR
Xcvr 2 REV 01 740-011571 C739XJ039 XFP-10G-SR
FPC 1 BUILTIN BUILTIN MPC BUILTIN
MIC 1 *** Hardware Not Supported ***
Fan Tray Fan Tray
A pipe lter of | match "FPC-1" displays the following output:
FPC 1 BUILTIN BUILTIN MPC BUILTIN
A pipe lter of | except "FPC 1" displays the following output:
Hardware inventory:
Item Version Part number Serial number Description
Chassis F0632 MX80
PEM 0 Rev 04 740-028288 VK09886 AC Power Entry Module
Routing Engine BUILTIN BUILTIN Routing Engine
TFEB 0 BUILTIN BUILTIN Forwarding Engine Processor
FPC 0 BUILTIN BUILTIN MPC BUILTIN
Fan Tray Fan Tray
Example: Pipe ( | ) Filter Funcons in the Command-Line Interface
IN THIS SECTION
Examples of Conguraons and Their Dierences in Text | 305
Examples of Conguraons and Their Dierences in XML | 307
Example of Counng the Number of Lines of Output | 308
Example of Output Displayed in XML Tag Format | 308
Example of Displaying Stac Conguraon Data | 308
Example of Displaying Ephemeral Conguraon Data | 309
Example of Displaying Output in JSON Format | 309
Example of Displaying the Conguraon with YANG Translaon Scripts Applied | 310
Example of Displaying the RPC Tags for a Command | 311
304
Example of Ignoring Output That Does Not Match a Regular Expression | 312
Example of Displaying Output from the First Match of a Regular Expression | 312
Example of Retaining Output Aer the Last Screen | 313
Example of Displaying Output Beginning with the Last Entries | 313
Example of Displaying Output That Matches a Regular Expression | 314
Example of Prevenng Output from Being Paginated | 314
Example of Sending Command Output to Other Users | 314
Example of Resolving IP Addresses | 315
Example of Saving Output to a File | 315
Example of Appending Output to a File | 316
Example of Displaying Output on Screen and Wring to a File | 316
Example of Trimming Output by Specifying the Starng Column | 317
Example of Refreshing the Output of a Command | 317
This topic describes and provides examples of the pipe ( | ) lter funcons that the Junos OS CLI
supports.
Examples of Conguraons and Their Dierences in Text
The compare lter compares the candidate conguraon with either the current commied conguraon
or a conguraon le. It also displays the dierences between the two conguraons with text
characters.
To compare conguraon les, you enter compare aer the pipe ( | ) symbol, as follows:
show | compare [rollback
n
|
filename
]
The rollback
n
variable is the index into the list of previously commied conguraons. The most
recently saved conguraon is 0. If you do not specify arguments, the candidate conguraon is
compared against the acve conguraon le (/cong/juniper.conf), which is the same as comparing to
rollback index 0.
The full path (or URL) to a conguraon le is
lename
.
The comparison output uses the following convenons:
305
Statements that are in the candidate conguraon only are prexed with a plus sign (+).
Statements that are in the comparison le only are prexed with a minus sign (–).
Statements that are unchanged are prexed with a single blank space ( ).
Example:
user@host> show configuration system | compare rollback 9
[edit system]
+ host-name device;
+ backup-router 192.168.71.254;
- ports {
- console log-out-on-disconnect;
- }
[edit system name-server]
+ 172.17.28.11;
172.17.28.101 { ... }
[edit system name-server]
172.17.28.101 { ... }
+ 172.17.28.100;
+ 172.17.28.10;
[edit system]
- scripts {
- commit {
- allow-transients;
- }
- }
+ services {
+ ftp;
+ rlogin;
+ rsh;
+ telnet;
+ }
We have enhanced output from the show | compare command to more accurately reect conguraon
changes. This enhancement includes more intelligent handling of order changes in lists. For example,
consider group names that are reordered as follows:
groups {
groups {
group_xmp; group_xmp;
306
group_cmp; group_grp:
group_grp; group_cmp;
}
}
In early releases, output from the show | compare command looked like the following:
[edit groups]
- group_xmp;
- group_cmp;
- group_grp;
+ group_xmp;
+ group_grp;
+ group_cmp;
Now, output from the show | compare command looks like the following:
[edit groups]
group_xmp {...}
! group_grp {...}
Examples of Conguraons and Their Dierences in XML
The compare | display xml lter compares the candidate conguraon with the current commied
conguraon and displays the dierences between the two conguraons in XML. To compare
conguraons, you enter compare | display xml aer the pipe ( | ) symbol in either operaonal or
conguraon mode.
Example in operaonal mode:
user@host> show configuration | compare | display xml
Example in conguraon mode:
[edit]
user@host# show | compare | display xml
You can enter a specic conguraon hierarchy before using the | compare command. In conguraon
mode, you can navigate to a hierarchy where the command is applied.
307
Example of Counng the Number of Lines of Output
To count the number of lines in command output, enter count aer the pipe symbol ( | ). For example:
user@host> show configuration | count
Count: 269 lines
Example of Output Displayed in XML Tag Format
To display command output in XML tag format, you enter display xml aer the pipe symbol ( | ).
The following example displays the show cli directory command output as XML tags:
user@host> show cli directory | display xml
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/7.5I0/junos">
<cli>
<working-directory>/var/home/user</working-directory>
</cli>
<cli>
<banner></banner>
</cli>
</rpc-reply>
If the conguraon data or command output contains characters that are outside of the 7-bit ASCII
character set, the CLI displays the equivalent UTF-8 decimal character reference for those characters in
the XML output.
Example of Displaying Stac Conguraon Data
You can view the inherited conguraon data and informaon about the source group from which the
conguraon has been inherited with respect to the stac conguraon database. To view this data, you
issue the show configuration | display inheritance command.
user@host> show configuration | display inheritance
## Last commit: 2018-03-29 15:54:17 PDT
version 16.2R2;
system {
...
}
308
Example of Displaying Ephemeral Conguraon Data
Juniper Extension Toolkit (JET) applicaons, Network Conguraon Protocol (NETCONF), and Junos
XML protocol client applicaons can congure the ephemeral conguraon database. The ephemeral
database is an alternate conguraon database that provides a fast programmac interface for
performing conguraon updates.
To view the complete post-inheritance conguraon merged with the conguraon data in all instances
of the ephemeral database, use the show ephemeral-configuration merge command.
user@host> show ephemeral-configuration merge
## Last changed: 2019-02-01 09:47:20 PST
version 18.2R1;
system {
...
}
Example of Displaying Output in JSON Format
You can display the conguraon or command output in JavaScript Object Notaon (JSON) format by
entering display json aer the pipe symbol ( | ).
The following example displays the show cli directory command output in JSON format:
user@host> show cli directory | display json
{
"cli" : [
{
"working-directory" : [
{
"data" : "/var/home/username"
}
]
}
]
}
If the operaonal command output contains characters that are outside of the 7-bit ASCII character set,
the CLI displays the equivalent UTF-8 decimal character reference for those characters in the JSON
output.
309
Example of Displaying the Conguraon with YANG Translaon Scripts Applied
You can load YANG modules onto devices running Junos OS to augment the conguraon hierarchy
with data models that Junos OS does not support navely. Junos OS does support translaon of these
models.. The acve conguraons and candidate conguraons contain the conguraon data for non-
nave YANG data models in the syntax dened by that model. These conguraons do not explicitly
display the corresponding translated Junos OS syntax, which is commied as a transient change.
The | display translation-scripts lter displays the complete post-inheritance conguraon, with the
translated conguraon data from all enabled translaon scripts explicitly included in the output. To
display the conguraon with all enabled YANG translaon scripts applied, append the | display
translation-scripts lter to the show configuration command in operaonal mode or the show command in
conguraon mode. For example:
user@host> show configuration | display translation-scripts
To view just the non-nave conguraon data aer translaon, you use the | display translation-
scripts translated-config lter in either operaonal mode or conguraon mode.
user@host> show configuration | display translation-scripts translated-config
In conguraon mode, you can display just the conguraon dierences in the hierarchies
corresponding to non-nave YANG data models before or aer translaon scripts are applied. To display
those dierences, you append the configured-delta or translated-delta keyword, respecvely, to the show |
display translation-scripts command. In both cases, the XML output displays the deleted conguraon
data, followed by the new conguraon data.
user@host# show | display-translation-scripts (configured-delta | translated-delta)
The following example displays a sample conguraon with and without translaon scripts applied. The
show command displays the conguraon, which includes the non-nave conguraon data in the syntax
that the YANG data model denes. The | display translation-scripts lter displays the non-nave
conguraon data in both the syntax dened by the YANG data model and the translated Junos OS
syntax. Both commands display the enre conguraon, which has been truncated for brevity in this
example. However, the show command returns the pre-inhertance conguraon, whereas the show |
display translation-scripts command returns the post-inheritance conguraon.
user@host# show
...
myint:intconfig {
310
interfaces {
interface ge-0/0/0 {
config {
description test;
}
}
}
}
...
user@host# show | display translation-scripts
...
interfaces {
ge-0/0/0 {
description test;
gigether-options {
no-flow-control;
}
}
}
...
myint:intconfig {
interfaces {
interface ge-0/0/0 {
config {
description test;
}
}
}
}
...
Example of Displaying the RPC Tags for a Command
To display the remote procedure call (RPC) XML tags for an
operaonal mode command
, you enter
display xml rpc aer the pipe symbol ( | ).
311
The following example displays the RPC tags for the show route command:
user@host> show route | display xml rpc
<rpc-reply xmlns:junos="http://xml.juniper.net/junos/10.1I0/junos">
<rpc>
<get-route-information>
</get-route-information>
</rpc>
<cli>
<banner></banner>
</cli>
</rpc-reply>
Example of Ignoring Output That Does Not Match a Regular Expression
To ignore text that matches a regular expression, specify the except command aer the pipe symbol ( | ).
If the regular expression contains any spaces, operators, or wildcard characters, enclose it in quotaon
marks.
The following example displays all users who are logged in to the router, except for the user root:
user@host> show system users | except root
8:28PM up 1 day, 13:59, 2 users, load averages: 0.01, 0.01, 0.00
USER TTY FROM LOGIN@ IDLE WHAT
user p0 device1.example.com 7:25PM - cli
Example of Displaying Output from the First Match of a Regular Expression
To display output starng with the rst occurrence of text matching a regular expression, you enter find
aer the pipe symbol ( | ). If the regular expression contains any spaces, operators, or wildcard
characters, enclose it in quotaon marks.
The following example displays the routes in the roung table starng at IP address 208.197.169.0:
user@host> show route | find 208.197.169.0
208.197.169.0/24 *[Static/5] 1d 13:22:11
> to 192.168.4.254 via so-3/0/0.0
224.0.0.5/32 *[OSPF/10] 1d 13:22:12, metric 1
iso.0: 1 destinations, 1 routes (1 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
312
47.0005.80ff.f800.0000.0108.0001.1921.6800.4015.00/160
*[Direct/0] 1d 13:22:12
> via lo0.0
The following example displays the rst CCC entry in the forwarding table:
user@host> show route forwarding-table | find ccc
Routing table: ccc
MPLS:
Interface.Label Type RtRef Nexthop Type Index NhRef Netif
default perm 0 rjct 3 1
0 user 0 recv 5 2
1 user 0 recv 5 2
32769 user 0 ucst 45 1 fe-0/0/0.534
fe-0/0/0. (CCC) user 0 indr 44 2
10.0.16.2 Push 32768, Push
Example of Retaining Output Aer the Last Screen
You can retain output and scroll or search through it by holding rather than returning immediately to the
CLI prompt aer viewing the last screen of output. To retain output, you enter hold aer the pipe symbol
( | ). The following example prevents returning to the CLI prompt aer you have viewed the last screen
of output from the show log log-file-1 command:
user@host> show log log-file-1 | hold
Example of Displaying Output Beginning with the Last Entries
You can view log les in which the end of the le contains the most recent entries. To display text
starng from the end of the output, you enter last <
lines
> aer the pipe symbol ( | ).
The following example displays the last entries in log-le-1 le:
user@host> show log log-file-1 | last
NOTE: When the number of lines requested is less than the number of lines that the screen
length seng permits you to display, the system returns a subset. The system returns as many
313
lines as permied by the screen length seng. That is, if your screen length is set to 20 lines and
you have requested only the last 10 lines, the system returns the last 19 lines instead of the last
10 lines.
Example of Displaying Output That Matches a Regular Expression
To display output that matches a regular expression, you enter match
regular-expression
aer the pipe
symbol ( | ). If the regular expression contains any spaces, operators, or wildcard characters, enclose it in
quotaon marks.
The following example matches all the Asynchronous Transfer Mode (ATM) interfaces in the
conguraon:
user@host> show configuration | match at-
at-2/1/0 {
at-2/1/1 {
at-2/2/0 {
at-5/2/0 {
at-5/3/0 {
Example of Prevenng Output from Being Paginated
By default, if output is longer than the length of the terminal screen, you receive a ---(more)--- message
to display the remaining output. To display the remaining output, you press Space.
To prevent the output from being paginated, you enter no-more aer the pipe symbol ( | ).
The following example displays output from the show configuration command all at once:
user@host> show configuration | no-more
This feature is useful if you want to copy the enre output and paste it into an email message.
Example of Sending Command Output to Other Users
To display command output on the terminal of a specic user logged in to your router, or on the
terminals of all users logged in to your router, you enter request message (all | user
account
@
terminal
) aer
the pipe symbol ( | ).
314
If you are troubleshoong your router and talking with a customer service representave on the phone,
you can share the command output. You use the request message command to send your representave
the command output you are currently viewing on your terminal.
The following example sends the output from the show interfaces command that you enter on your
terminal to the terminal of the user root@ttyp1:
user@host> show interfaces | request message user root@ttyp1
The user root@ttyp1 sees the following output appear on the terminal screen:
Message from user@host on /dev/ttyp0 at 10:32 PST...
Physical interface: dsc, Enabled, Physical link is Up
Interface index: 5, SNMP ifIndex: 5
Type: Software-Pseudo, MTU: Unlimited...
Example of Resolving IP Addresses
In operaonal mode only, if the output of a command displays an unresolved IP address, you can enter |
resolve aer the command to display the name associated with the IP address. The resolve lter enables
the system to perform a reverse DNS lookup of the IP address. If DNS is not enabled, the lookup fails
and no substuon is performed.
To perform a reverse DNS lookup of an unresolved IP address, you enter resolve <full-names> aer the
pipe symbol ( | ). If you do not specify the full-names opon, the name is truncated to t whatever eld
width limitaons apply to the IP address.
The following example performs a DNS lookup on any unresolved IP addresses in the output from the
show ospf neighbors command:
user@host> show ospf neighbors | resolve
Example of Saving Output to a File
When command output is lengthy, when you need to store or analyze the output, or when you need to
send the output in an e-mail message or by FTP, you can save the output to a le. By default, the le is
placed in your home directory on the router.
To save command output to a le, you enter save
filename
aer the pipe symbol ( | ).
315
The following example saves the output from the request support information command to a le named
my-support-info.txt:
user@host> request support information | save my-support-info.txt
Wrote 1143 lines of output to ‘my-support-info.txt’
Example of Appending Output to a File
When command output is displayed, you can either save the output to a le, which overwrites the
exisng contents of that le, or you can append the output text to a specic le.
To append the command output to the le, you enter append
filename
aer the pipe symbol ( | ).
The following example appends the output from the request support information command to a le named
my-support-info.txt:
user@host> request support information | append my-support-info.txt
Wrote 2247 lines of output to 'my-support-info.txt'
Example of Displaying Output on Screen and Wring to a File
When command output is displayed, you can also write the output to a le. To both display the output
and write it to a le, you enter tee
filename
aer the pipe symbol (|).
The following example displays the output from the show interfaces ge-* terse command (displaying
informaon about the status of the Gigabit Ethernet interfaces on the device) and diverts the output to
a le called ge-interfaces.txt:
user@host> show interfaces ge-* terse | tee ge-interfaces.txt
Interface Admin Link Proto Local Remote
ge-0/1/0 up down
ge-0/1/1 up up
ge-0/1/2 up down
ge-0/1/3 up up
316
Unlike the UNIX tee command, only an error message is displayed if the le cannot be opened (instead
of displaying the output and then the error message).
user@host> show interfaces ge-* terse | tee /home/user/test.txt
error: tee failed: file /home/user/test.txt could not be opened
user@host>
Example of Trimming Output by Specifying the Starng Column
Output appears on the terminal screen in terms of rows and columns. The rst alphanumeric character
starng at the le of the screen is in column 1, the second character is in column 2, and so on. To display
output starng from a specic column (thus trimming the lemost poron of the output), you enter trim
columns aer the pipe symbol ( | ). The trim lter is useful for trimming the date and me from the
beginning of system log messages.
The following example displays output from the show system storage command, ltering out the rst 10
columns:
user@host> show system storage | trim 11
NOTE: The trim command does not accept negave values.
Example of Refreshing the Output of a Command
You can run an operaonal mode command with the | refresh pipe opon to refresh the output
displayed on the screen periodically. The default refresh occurs every second. However, you can also
explicitly specify a refresh interval from 1 through 604,800 seconds. For example, to refresh the output
of the show interfaces command every 5 seconds, you run the following command:
user@host> show interfaces | refresh 5
317
Filter Operaonal Mode Command Output in a QFabric System
When you issue an operaonal mode command in a QFabric system, the output generated can be fairly
extensive because of the number of components contained within the system. To make the output more
accessible, you can lter the output by appending the | filter opon to the end of most commands.
1. To lter operaonal mode command output and limit it to a Node group, include the | filter node-
group
node-group-name
opon at the end of your operaonal mode command. For example:
root@qfabric> show interfaces terse | filter node-group NW-NG-0
Interface Admin Link Proto Local Remote
NW-NG-0:dsc up up
NW-NG-0:em0 up up
NW-NG-0:em1 up up
NW-NG-0:gre up up
NW-NG-0:ipip up up
NW-NG-0:lo0 up up
NW-NG-0:lo0.16384 up up inet 127.0.0.1 --> 0/0
NW-NG-0:lo0.16385 up up inet
NW-NG-0:lsi up up
NW-NG-0:mtun up up
NW-NG-0:pimd up up
NW-NG-0:pime up up
NW-NG-0:tap up up
Node01:ge-0/0/10 up up
Node01:ge-0/0/40 up up
Node01:ge-0/0/41 up up
vlan up up
2. To lter operaonal mode command output and limit it to a set of Node groups, include the | filter
node-group opon at the end of your operaonal mode command and specify the list of Node group
names in brackets. For example:
root@qfabric> show ethernet-switching interfaces | filter node-group [NW-NG-0 RSNG-1]
Interface State VLAN members Tag Tagging Blocking
NW-NG-0:ae0.0 up v200 200 tagged unblocked
v50 50 tagged unblocked
v51 51 tagged unblocked
v52 52 tagged unblocked
v53 53 tagged unblocked
318
RSNG-1:ae0.0 up v200 200 untagged unblocked
RSNG-1:ae47.0 up v50 50 tagged unblocked
v51 51 tagged unblocked
v52 52 tagged unblocked
v53 53 tagged unblocked
Use Suppress-Zero Filter with the Pipe ( | ) Symbol to Filter Zero Values in
Command Output
Junos OS supports suppress-zero lter to exclude lines with ‘0' values for any of the elds in given line.
This feature is available for all the operaonal show commands. For show commands CLI output, lines
with ‘0’ values output can be masked. The output lines with non-zero values are displayed. You can use
this to mask zero counters’ values. If a line has non-zero values along with ‘0’ values in a line, it is not
masked. If ‘0’ appears in descripon or string eld, it is not masked and is emied in the CLI output.
NOTE: This feature is applicable for CLI operaonal commands only. The suppress-zeros lter is
not applicable for commands that don't use rendering. For example, show configuration, traceroute,
ping and other monitor commands.
Here are a few examples for the show commands with suppress-zeroes lter:
For example, if a command produces the following output:
user@host> show interfaces vtep
Physical interface: vtep, Enabled, Physical link is Up
Interface index: 133, SNMP ifIndex: 517
Type: Software-Pseudo, Link-level type: VxLAN-Tunnel-Endpoint, MTU: Unlimited, Speed:
Unlimited
Device flags : Present Running
Interface flags: SNMP-Traps
Link type : Full-Duplex
Link flags : None
Last flapped : Never
Input packets : 0
Output packets: 0
319
A pipe lter of | suppress-zeros displays the following output:
user@host> show interfaces vtep | suppress-zeros
Physical interface: vtep, Enabled, Physical link is Up
Interface index: 133, SNMP ifIndex: 517
Type: Software-Pseudo, Link-level type: VxLAN-Tunnel-Endpoint, MTU: Unlimited, Speed:
Unlimited
Device flags : Present Running
Interface flags: SNMP-Traps
Link type : Full-Duplex
Link flags : None
Last flapped : Never
In this example, the Input packets and Output packets elds are masked as these elds contain ‘0’
integer values.
If a command produces the following output:
user@host> show interfaces fxp0
Physical interface: fxp0, Enabled, Physical link is Up
Interface index: 8, SNMP ifIndex: 1
Description: 0
Type: Ethernet, Link-level type: Ethernet, MTU: 1514, Speed: 1000mbps
Device flags : Present Running
Interface Specific flags: Internal: 0x100000
Interface flags: SNMP-Traps
Link type : Full-Duplex
Link flags : 0x4
Current address: 54:04:0a:dd:85:8d, Hardware address: 54:04:0a:dd:85:8d
Last flapped : 2023-11-15 19:02:00 IST (21:40:35 ago)
Input packets : 1530766
Output packets: 13469
Logical interface fxp0.0 (Index 5) (SNMP ifIndex 13)
Flags: Up SNMP-Traps 0x4000000 Encapsulation: ENET2
Input packets : 1528251
Output packets: 13481
Protocol inet, MTU: 1500
Max nh cache: 75000, New hold nh limit: 75000, Curr nh cnt: 186, Curr new hold cnt: 0, NH
drop cnt: 0
Flags: Sendbcast-pkt-to-re, Is-Primary
320
Addresses, Flags: Is-Preferred Is-Primary
Destination: 10.221.128/18, Local: 10.221.133.141, Broadcast: 10.221.191.255
A pipe lter of | suppress-zeros displays the following output:
user@host> show interfaces fxp0 | suppress-zeros
Physical interface: fxp0, Enabled, Physical link is Up
Interface index: 8, SNMP ifIndex: 1
Description: 0
Type: Ethernet, Link-level type: Ethernet, MTU: 1514, Speed: 1000mbps
Device flags : Present Running
Interface Specific flags: Internal: 0x100000
Interface flags: SNMP-Traps
Link type : Full-Duplex
Link flags : 0x4
Current address: 54:04:0a:dd:85:8d, Hardware address: 54:04:0a:dd:85:8d
Last flapped : 2023-11-15 19:02:00 IST (21:40:35 ago)
Input packets : 1530766
Output packets: 13469
Logical interface fxp0.0 (Index 5) (SNMP ifIndex 13)
Flags: Up SNMP-Traps 0x4000000 Encapsulation: ENET2
Input packets : 1528251
Output packets: 13481
Protocol inet, MTU: 1500
Max nh cache: 75000, New hold nh limit: 75000, Curr nh cnt: 186, Curr new hold cnt: 0, NH
drop cnt: 0
Flags: Sendbcast-pkt-to-re, Is-Primary
Addresses, Flags: Is-Preferred Is-Primary
Destination: 10.221.128/18, Local: 10.221.133.141, Broadcast: 10.221.191.255
In this example, the Description eld is not masked in the output as it is a string type and is a non-
integer. The Max nh cache: 75000, New hold nh limit: 75000, Curr nh cnt: 186, Curr new hold cnt: 0, NH drop
cnt: 0 line is not masked as it contains non-zero integer counter values in it.
Change History Table
321
Feature support is determined by the plaorm and release you are using. Use Feature Explorer to
determine if a feature is supported on your plaorm.
Release Descripon
18.2R1 In Junos OS Release 18.1 and earlier, to view the complete post-inheritance conguraon merged with
the conguraon data in all instances of the ephemeral conguraon database, use the show ephemeral-
configuration | display merge command. Starng in Junos OS Release 18.2R1, the display merge opon
is deprecated.
17.3R1 Starng in Junos OS Release 17.3R1, OpenCong supports the operaonal state emied by daemons
directly in JSON format in addion to XML format. To congure JSON compact format, use the
command set system export-format state-data json compact. This command converts XML format to
compact JSON format. Else, it emits the JSON in non-compact format.
16.2R2
Starng in Junos OS Release 16.2R2, the show | compare | display xml command omits the
<configuration> tag in the XML output if the comparison returns no dierences or if the comparison
returns only dierences for non-nave conguraon data, for example, conguraon data associated
with an OpenCong data model.
16.2R2
Starng in Junos OS Release 16.2R2, the show | compare | display xml command omits the
<configuration> tag in the XML output if the comparison returns no dierences or if the comparison
returns only dierences for non-nave conguraon data, for example, conguraon data associated
with an OpenCong data model.
16.1 Starng in Junos OS Release 16.1, devices running Junos OS emit JSON-formaed conguraon data
using a new default implementaon for serializaon.
16.1 Starng in Junos OS Release 16.1, you can load YANG modules onto devices running Junos OS to
augment the conguraon hierarchy with data models that are not navely supported by Junos OS but
can be supported by translaon. The acve and candidate conguraons contain the conguraon data
for non-nave YANG data models in the syntax dened by that model, but they do not explicitly display
the corresponding translated Junos OS syntax, which is commied as a transient change.
14.2 Starng in Junos OS Release 14.2, you can display the conguraon or command output in JavaScript
Object Notaon (JSON) format by entering display json aer the pipe symbol ( | ).
8.3
Starng with Junos OS Release 8.3, output from the show | compare command has been enhanced to
more accurately reect conguraon changes. This includes more intelligent handling of order changes
in lists.
322
6
CHAPTER
Conguraon Statements and
Operaonal Commands
Junos CLI Reference Overview | 324
Junos CLI Reference Overview
We've consolidated all Junos CLI commands and conguraon statements in one place. Learn about the
syntax and opons that make up the statements and commands and understand the contexts in which
you’ll use these CLI elements in your network conguraons and operaons.
Junos CLI Reference
Click the links to access Junos OS and Junos OS Evolved conguraon statement and command
summary topics.
Conguraon Statements
Operaonal Commands
324