Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Modify the Configuration of a Device

The CLI enables you to modify an existing Junos OS configuration. This section explains the specifics of adding a statement, deleting a statement, copying a statement, and inserting a new identifier, including examples.

Display Users Currently Editing the Configuration

To display the users currently editing the configuration, use the status configuration mode command:

The system displays who is editing the configuration (rchen), where the user is logged in (terminal p0), the date and time the user logged in (2018-03-01 13:17:25 PST), and what level of the hierarchy the user is editing ([edit interfaces]).

If you issue the status configuration mode command and a user has scheduled a candidate configuration to become active for a future time, the system displays who scheduled the commit (root), where the user is logged in (terminal d0), the date and time the user logged in (2018-10-31 14:55:15 PST), and that a commit is pending (commit at).

If you issue the status configuration mode command and a user is editing the configuration in configure exclusive mode, the system displays who is editing the configuration (root), where the user is logged in (terminal d0), the date and time the user logged in (2018-11-01 13:05:11 PST), and that a user is editing the configuration in configure exclusive mode (exclusive [edit]).

How to Modify the Juniper Networks Device Configuration

To configure a Juniper Networks device or to modify an existing configuration, you add statements to the configuration using the edit and set commands. For each statement hierarchy, you create the hierarchy starting with a statement at the top level. You then continue creating the hierarchy with statements that move progressively lower in the hierarchy.

To modify the hierarchy, you use two configuration mode commands. Select the relevant command based on what you want to accomplish:

  • edit—Moves to a specified hierarchy level. If that hierarchy level does not exist, the edit command creates it. The edit command has the following syntax:

  • set—Creates a configuration statement and sets identifier values. After you issue a set command, you remain at the same level in the hierarchy. The set command has the following syntax:

    The hierarchy to the configuration 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 configuration statement itself is statement. Theidentifier string identifies an instance of a statement.

Statements can be either container statements or leaf statements. A container statement can include additional 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 differentiate between them.

Note:

You cannot use the edit command to change the value of identifiers. You must use the set command.

How to Add Configuration Statements and Identifiers

You configure all properties of a Juniper Networks device by including statements in the configuration. A statement consists of a keyword, which is fixed text. You can also include an identifier in a statement. An identifier is an identifying name that you define, such as the name of an interface or a username, and that enables you and the CLI to discriminate among a collection of statements.

For example, the following list shows the statements available at the top level in configuration mode:

An angle bracket ( > ) before the statement name indicates that it is a container statement and that you can define other statements at levels below it. If there is no angle bracket ( > ) before the statement name, the statement is a leaf statement; you cannot define 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:

In some statements, you can include an identifier. For some identifiers, such as interface names, you must specify the identifier 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 first PIC location, and in the first port on the Physical Interface Card (PIC).

For other identifiers, such as interface descriptive text and policy and firewall term names, you can specify any name, including special characters, spaces, and tabs.

You must enclose identifiers in quotation marks (double quotes). You must also use quotation marks to enclose identifiers and any strings that include a space, a tab character, or any of the following characters:

If you do not type an option for a statement that requires one, a message indicates the type of information required. In this example, you must type an area number to complete the command:

How to Delete a Statement from a Device Configuration

You delete a statement or identifier from a device configuration using the delete configuration mode command. Deleting a statement or an identifier effectively "unconfigures" the functionality associated with that statement or identifier, returning that functionality to its default condition.

When you delete a statement, the statement and all its subordinate statements and identifiers are removed from the configuration.

For statements that can have more than one identifier, when you delete one identifier, only that identifier is deleted. The other identifiers in the statement remain.

To delete the entire hierarchy starting at the current hierarchy level, use the delete command without specifying a statement or an identifier. When you omit the statement or identifier, you are prompted to confirm the deletion:

Note:

You cannot delete multiple statements or identifiers within a hierarchy using a single delete command. You must delete each statement or identifier individually, using multiple delete commands. For example, consider the following configuration at the [edit system] hierarchy level:

To delete the domain-name, host-name, and backup-router from the configuration, you must delete each statement individually.

You cannot issue a single delete command. For example, the following command would not work:

You can delete related configuration items simultaneously, such as channelized interfaces or static routes, by using a single command and regular expressions. Deleting a statement or an identifier effectively “unconfigures” the functionality associated with that statement or identifier, returning that functionality to its default condition.

You can delete only certain parts of the configuration where you normally put multiple items, such as interfaces. However, you cannot delete "groups" of different items, as shown in this example:

When you delete a statement, the statement and all its subordinate statements and identifiers are removed from the configuration.

To delete related configuration items, issue the wildcard configuration mode command with the delete option and specify the statement path, the items to be summarized with a regular expression, and the regular expression, as follow:

Note:

When you use the wildcard command to delete related configuration items, the regular expression must be the final statement.

If the Junos OS matches more than eight related items, the CLI displays only the first eight items.

How to Delete Interfaces from the Configuration

You can delete multiple T1 interfaces in the range from t1-0/0/0:0 through t1-0/0/0:23 by using this syntax:

How to Delete Routes from the Configuration

You can delete static routes in the range from 172.0.0.0 to 172.255.0.0 by using this syntax:

Example: Delete a Statement from the Device Configuration

The following example shows how to delete the ospf statement, effectively unconfiguring OSPF on the router:

Delete all statements from the current level down:

Unconfigure a specific property. In this example, remove the interface speed setting:

Copy a Statement in the Configuration

When you have many similar statements in a device configuration, you can add one statement and then make copies of that statement. Copying a statement duplicates that statement and the entire hierarchy of statements configured under that statement. Copying statements is useful when you are configuring many physical or logical interfaces of the same type.

To make a copy of an existing statement in the configuration:

  1. Use the configuration mode copy command:
  2. Immediately after you have copied a portion of the configuration, check the validity of the new configuration.
  3. If the configuration is invalid, modify either the copied portion or the original portion to produce a valid configuration.

Example: Copy a Statement in the Configuration

This example shows how you can create one virtual connection (VC) on an interface by copying an existing VC.

Requirements

No special configuration beyond device initialization is required before configuring this example.

Before you begin this example, configure the following initial configuration:

To quickly configure the initial configuration for this example, copy the following commands, paste them into a text file, remove any line breaks and change any details necessary to match your network configuration, copy and paste this command into the CLI at the [edit] hierarchy level, and then enter commit in configuration mode.

Overview

In this example illustrating how to copy statements, you add a virtual connection that is very similar to a virtual connection already configured.

Configuration

CLI Quick Configuration

Start at the [edit interfaces at-1/0/0] hierarchy level.

Configure by Copying

Step-by-Step Procedure

To configure by copying a configuration:

  1. Go to the [edit interfaces at-1/0/0] hierarchy level and copy unit 61.

  2. Take a look at the new configuration and see what you need to change to make the configuration valid.

  3. Change the configuration to make it valid.

    In this example you want to reconfigure the virtual circuit identifier (VCI) and virtual path identifier (VPI).

    You also want to replace the IP address of the new interface with its own IP address.

Results

Example: Replace a Configuration

If you need to make changes to the configuration of a device, you can always remove the original configuration settings using the delete command and add your new configuration settings using the set command. However, there are other ways of modifying a configuration that are more efficient and easier to use.

This example shows how to use the following configuration mode commands to update an existing configuration:

  • rename—Rename an existing configuration setting, such as an interface name. This command can be useful when you are adding new interfaces to a device.

  • copy—Copy a configuration setting and the entire hierarchy of statements configured under that setting. Copying configuration statements is useful when you are configuring many physical or logical interfaces of the same type.

  • replace—Make global changes to text patterns in the configuration. For example, if you consistently misspell a word common to the description statement for all of the interfaces on your device, you can fix this mistake with a single command.

Requirements

No special configuration beyond device initialization is required before configuring this example.

Overview

During the first example in this topic, you make the following configuration changes:

  • Create a new interface with a description that contains a typing error.

  • Copy the configuration 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 description for the interfaces that you created.

In the second, shorter example, you try some of the same commands under slightly different circumstances.

Configuration

Use the Copy, Rename, and Replace Commands to Modify a Loopback Interface Configuration

Step-by-Step Procedure
CAUTION:

If your existing configuration uses any of the loopback interface unit numbers used in this example, you must substitute different unused loopback interface unit numbers. Otherwise, following these steps could damage the existing operational status of your device.

To create and modify a configuration of a loopback interface using the copy, rename, and replace commands:

  1. Create a new loopback interface unit number and include a description.

    The mistakes in the spelling of loopback in the description are intentional.

  2. Display the configuration for the loopback interface you have just added.

  3. Duplicate the loopback interface you have just created, errors included, from unit 100 to unit 101.

  4. Display the configurations for loopback interfaces lo0 unit 100 and lo0 unit 101.

    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.

  6. Display the configuration for loopback interface lo0 unit 100.

    You should not see any results from this command. The loopback interface lo0 unit 100 is now gone. The rename command replaces the configuration statement indicated with the new configuration.

  7. Fix the misspelling of the word loopback in the descriptions for loopback interfaces lo0 unit 101 and lo0 unit 102.

  8. Display the configuration for loopback interfaces lo0 unit 101 and lo0 102 to verify that the word loopback is now spelled correctly.

    The replace command replaces all instances of the pattern specified in the command, unless limited in some way. The next example in this topic shows one way to limit the effect of the replace command.

  9. In configuration mode, use the rollback command to returnthe device configuration to the state it was in before you executed the previous steps.

Results

In configuration mode, use the show interfaces lo0 unit 101 and show interfaces lo0 unit 102 commands to ensure that the device configuration is in the state it was in before you executed the steps in this example.

You should not see any results from this command.

You should not see any results from this command.

Compare the Copy Command at the Top-Level Configuration 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 configuration mode hierarchy.

The following example requires you to navigate to various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode .

  1. Create an Ethernet interface.

  2. Copy the interface you just created to another interface.

    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:

    Notice that the keyword interfaces is not repeated after the preposition to and before the value to be copied. This happens in some top-level statements with the copy command.

    Tip:

    Similarly, in the rename command, you do not repeat the keyword part of the statement before the new identifier in some top-level statements.

  3. Show your configuration so far.

  4. Replace the address for et-2/1/0 with another IP address.

    Notice that if you want to change only a specific occurrence of a pattern instead of all occurrences, youmust navigate to that specific hierarchy level before using the replace command.

  5. Show the interfaces again.

  6. In configuration mode, use the rollback command to return the device configuration to the state it was in before you executed the previous steps.

Results

In configuration mode, use the show interfaces et-2/0/0 and show interfaces et-2/1/0 commands to ensure that the device configuration is in the state it was in before you executed the steps in this example.

You should not see any results from this command.

You should not see any results from this command.

Insert a New Identifier in a Device Configuration

When configuring a Juniper Networks device, you can enter most statements and identifiers in any order. Regardless of the order in which you enter the configuration statements, the CLI always displays the configuration in a strict order. However, in a few cases the order of the statements matters because the configuration statements create a sequence that is analyzed in order.

For example, in a routing policy or firewall filter, you define terms that are analyzed sequentially. Also, when you create a named path in dynamic MPLS, you define an ordered list of the transit routers in the path, starting with the first transit router and ending with the last one.

To modify a portion of the configuration in which the statement order matters, use the insert configuration mode command:

If you do not use the insert command but instead configure the identifier, the identifier is placed at the end of the list of similar identifiers.

Example: Insert a New Identifier in a Device Configuration

This example shows the use of the insert command.

Whereas a term added using the set command is placed at the end of the existing 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 matters because the configuration 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 T1 before the term T2, both T1 and T2 must already exist and be populated. Junos OS removes empty terms automatically.

Requirements

Before you can insert a term, you must configure an initial policy. To quickly configure the initial policy for this example, copy the following commands, paste them into a text file, remove any line breaks and change any details necessary to match your network configuration, copy and paste the commands into the CLI at the [edit policy-options] hierarchy level, and then enter commit from configuration mode.

Now check to verify that you have the hierarchy configured correctly:

Overview

To modify a portion of the configuration in which the statement order matters, you must use the insert configuration mode command. If you use the set command instead, the added statement or identifier will be in the wrong place sequentially. The only other way to get the terms of the command in the correct order is to dismantle the configuration and start over.

Configuration

CLI Quick Configuration

To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks and change any details necessary to match your network configuration, copy and paste the commands into the CLI at the [edit policy-options] hierarchy level, and then enter commitin configuration mode.

Configure to Insert Terms

Step-by-Step Procedure
  1. Determine the order in which your configuration terms need to go. Consider both the original terms and the new terms you plan to add.

    In the original configuration, the policy is named statics, and there are four terms. Each of the first three terms matches on a different match criteria, and the resulting matches are rejected. The last term accepts all the rest of the traffic.

    In this example, you need to add two terms that eliminate additional types of traffic. Both these terms need to go before the last term in the original configuration.

  2. Rename original term4 to term6.

    This step preserves the original last term, now renamed term6, as the last term.

  3. Create a new term4.

    A new term is added that matches traffic from local system addresses and rejects it.

  4. Create new term5.

    A new term is added that matches traffic from aggregate routes and rejects it.

  5. Insert term4 after term3.

  6. Insert term5 after term4.

Results

Deactivate and Reactivate Statements and Identifiers in a Device Configuration

In a Junos OS configuration, you can deactivate statements and identifiers so they do not take effect when you issue the commit command. Any deactivated statements and identifiers are marked with the inactive tag. They remain in the configuration but are not activated when you issue a commit command.

To deactivate a statement or identifier, use the deactivate configuration mode command:

To reactivate a statement or identifier, use the activate configuration mode command:

In both commands, the statement and the identifier you specify must be at the current hierarchy level. When you deactivate a statement, that specific statement is ignored and is not applied at all when you issue a commit command.

To disable a statement, use the disable configuration mode command.

In some portions of the configuration hierarchy, you can include a disable statement to disable functionality. One example is disabling an interface by including the disable statement at the [edit interface interface-name] hierarchy level. When you disable a function, it is reactivated when you issue a commit command but is treated as though it is down or administratively disabled.

Example: Deactivate and Reactivate Statements and Identifiers in a Device Configuration

This example shows a common use case in which you use the deactivate and activate configuration mode commands. It involves dual Routing Engines, primary and backup, that have graceful Routing Engine switchover (GRES) configured. The software on both Routing Engines needs to be upgraded. This can easily be accomplished by deactivating GRES, updating the Routing Engines, and then reactivating GRES.

Note:

You can also perform a similar upgrade using the same setup, except that nonstop active routing (NSR) is configured instead of GRES. You would need to deactivate NSR and then upgrade the Routing Engines before reactivating NSR.

Requirements

This example requires the use of a device with dual Routing Engines that can be upgraded.

Before you begin this example, make sure that you have GRES configured.

Overview

In this example, there are two Routing Engines. GRES is configured, and the Routing Engines need to be upgraded. To accomplish the upgrade, you need to deactivate the GRES feature, upgrade each of the Routing Engines, and then activate GRES again.

Configuration

Configure the Deactivation and Reactivation of GRES

Step-by-Step Procedure

To deactivate and reactivate GRES for Routing Engine upgrade:

  1. Show that GRES is enabled for the router.

  2. Deactivate GRES.

  3. Show that GRES is deactivated.

  4. Upgrade the Routing Engines one by one.

    For instructions on upgrading Junos OS on dual Routing Engines, see Installing the Software Package on a Device with Redundant Routing Engines.

  5. Reactivate GRES.

Results

Verify that GRES feature is activated again.

How to Make Global Changes in the Device Configuration

You can make global changes to variables and identifiers in the device configuration by using the replace configuration mode command. This command replaces a pattern in a configuration with another pattern. For example, you can use this command to find and replace all occurrences of an interface name when a PIC is moved to another slot in the router.

The pattern pattern1 option is a text string or regular expression that defines the identifiers and values you want to replace in the configuration.

The pattern2 option is a text string or regular expression that replaces the identifiers and values located within pattern1.

The CLI uses standard UNIX-style regular expression syntax (as defined in POSIX 1003.2). If the regular expression contains spaces, operators, or wildcard characters, enclose the expression in quotation marks. Greedy qualifiers (match as much as possible) are supported. Lazy qualifiers (match as little as possible) are not supported.

The upto n option specifies the number of objects replaced. The value of n controls the total number of objects that are replaced in the configuration (not the total number of times the pattern occurs). Objects at the same hierarchy level (siblings) are replaced first. Multiple occurrences of a pattern within a given object are considered a single replacement. For example, if a configuration 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 option, all identifiers and values in the configuration that match pattern1 are replaced.

The replace command is available in configuration mode at any hierarchy level. All matches are case-sensitive.

Common Regular Expressions to Use with the replace Command

Table 1: Common Regular Expressions to Use with the replace Command

Operator

Function

|

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.

$

Used at the end of an expression, denotes that a term must be matched exactly up to the point of the $ character.

[ ]

Specifies a range of letters or digits to match. To separate the start and end of a range, use a hyphen ( - ).

( )

Specifies 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 nth group.

&

Back reference that matches the entire match.

The following table lists some replacement examples.

Table 2: Replacement Examples

Command

Result

replace pattern myrouter with router1

Match: myrouter

Result: router1

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 Configuration—the \n Back Reference

This example shows how you can use a back reference to replace a pattern.

Requirements

No special configuration beyond device initiation is required before configuring this example.

Before you begin, configure the following:

To quickly configure this initial configuration, copy the following commands and paste them in a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level:

Overview

One of the most useful features of regular expressions is the back reference. Backreferences provide a convenient way to identify a repeated character or substring within a string. Once you find the pattern, you can repeat it without writing it again. You refer to the previously captured pattern with just \# (where # is a numeral that indicates the number of times you want the pattern matched).

You can use backreferences to recall, or find, 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 time it would take to look for and replace the pattern manually.

Configuration

Configuring a Replacement Using a Back Reference in the Command

Step-by-Step Procedure

To replace a pattern in a Junos OS configuration using a back reference:

  • Use the replace command.

    In this case, we want to replace :1bf5with 1bf5.

    Notice the back reference (\1), which indicates the pattern should be searched for and replaced only once.

Results

Here is the resulting configuration:

In this example, the pattern 2000::c0a8::1bf5 is replaced with 2000::c0a8:1bf5 once.

Example: Global Replace in a Device Configuration—Replacing an Interface Name

This example shows how to replace an interface name globally in a configuration by using the replace command.

Using the replace command can be a faster and better way to change a configuration. 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 configuration. Or you might want to quickly extend the configuration with other similar configurations, for example, similar interfaces.

By using a combination of the copy and replace commands, you can add to a configuration and then replace certain aspects of the newly copied configurations. The replace command works with regular expressions. Regular expressions are quick, flexible, and ubiquitous. You can fashion just about any pattern you might need to search for, and most programming languages support regular expressions.

Requirements

No special configuration beyond device initialization is required before configuring this example.

Before you begin, configure the following hierarchy on the router. To quickly configure this hierarchy, see CLI Quick Configuration .

Overview

This example shows how to replace an interface name globally in a configuration by using the replace command. It is a simple example.

The previous configuration is the starting point for this configuration update. In the course of this example, you change the name of the initial interface throughout the configuration with one command.

Configuration

CLI Quick Configuration

To quickly configure the initial configuration for this example, copy the following commands, paste them into a text file, remove any line breaks and change any details necessary to match your network configuration, copy and paste these commands into the CLI at the [edit] hierarchy level, and then enter commit from configuration mode.:

Configuring an Interface Name Change

Step-by-Step Procedure

To change an interface name:

  1. Make sure that you are at the top of the configuration mode hierarchy.

  2. Replace so-0/0/0 with so-1/1/0 using the replace command, which uses the pattern keyword.

Results

After making the required changes, verify the configuration by using the show interfaces and show protocols configuration mode commands.

After you have confirmed that the configuration is correct, enter the commit command.

Example: Global Replace in a Device Configuration—the upto Option

Consider the hierarchy shown in Figure 1. The text string 010101 appears in three places: the description sections 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 option to perform replacements in a device configuration:

Figure 1: Replacement by Object Replacement by Object

An upto 2 option 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 first (since these are siblings in the hierarchy level). Because of the upto 2 restriction, the replace command replaces patterns in the first and second instance in the hierarchy (siblings), but not the third instance (child of the first instance).

Add Comments in a Device Configuration

You can include comments in a device configuration to describe any statement in the configuration. You can add comments interactively in the CLI and by editing the ASCII configuration file.

When configuring 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 configuration 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 configuration, use the annotate configuration mode command:

statement is the configuration statement to which you are attaching the comment; it must be at the current hierarchy level. If a comment for the specified 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 quotation 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 existing comment, specify an empty comment string:

If you add comments with the annotate command, you can view the comments within the configuration by entering the show configuration mode command or the show configuration operational mode command.

Note:

Junos OS supports annotation up to the last level in the configuration hierarchy, including oneliners. However, annotation of parts (the child statements or identifiers within the oneliner) of the oneliner is not supported. For example, in the following sample configuration hierarchy, annotation is supported up to the level 1 parent hierarchy, but not supported for the metric child statement:

Add Comments in a File

When you edit the ASCII configuration file 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 file, 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 configuration into the CLI.

The following excerpt from a configuration example illustrates how to place and how not to place comments in a configuration file:

When you include comments in the configuration file 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 multiple lines.

  • Start the comment with a # and end it with a new line (carriage return).

Example: Include Comments in a Device Configuration by Using the CLI

Adding comments to a device configuration makes the configuration file readable and more readily understood by users. You can include comments as you configure by using the annotate statement. In this example, comments are added by using the CLI for an already existing configuration:

Requirements

No special configuration beyond device initialization is required before configuring this example.

Before you add a comment, you must configure the following hierarchy on the router.

To quickly configure the initial configuration for this example, copy the following command, paste it into a text file, remove any line breaks and change any details necessary to match your network configuration, copy and paste this command into the CLI at the [edit] hierarchy level, and then enter commit from configuration mode.

Now verify that you have this hierarchy configured.

Overview

When you add comments by using the CLI, you do so in configuration 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 configure 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 configuration hierarchy and use the show command.

Configuration

CLI Quick Configuration

To quickly configure the comments for this example, copy the following commands, paste them into a text file, remove any line breaks and change any details necessary to match your network configuration, copy and paste the commands into the CLI, starting at the [edit] hierarchy level, and then enter commit from configuration mode.

Notice that the commands are moving you down the hierarchy as you annotate different sections of the hierarchy.

Including Comments in the CLI Configuration Mode

Step-by-Step Procedure

This procedure assumes that you have already configured the initial configuration.

To add comments to a configuration:

  1. Move to the first hierarchy level to which you need to add a comment.

  2. Add a comment to the area configuration statement by using the annotate statement.

  3. Move down a level to the interface configuration statement.

  4. Add a comment to interface so-0/0/0.0 by using the annotate statement.

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.

After you have confirmed that the configuration is correct, enter the commit command.