TechLibrary

Navigation Back up to About Overview

Example: Including Comments in a Junos OS Configuration by Using the CLI

Adding comments to a Junos OS configuration makes the configuration file readable and more readily understood by users. Using the Junos OS CLI, 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.

set protocols ospf area 0.0.0.0 interface so-0/0/0.0 hello-interval 5

Now, check that you have this hierarchy configured.

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 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.

edit protocols ospfannotate area 0.0.0.0 "Backbone area configuration added June 15, 1998" edit area 0.0.0.0annotate interface so-0/0/0.0 "Interface from router sj1 to router sj2"

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.
    [edit]user@host# edit protocols ospf
  2. Add a comment to the area configuration statement by using the annotate statement.
    [edit protocols ospf]user@host# annotate area 0.0.0.0 "Backbone area configuration added June 15, 1998"
  3. Move down a level to the interface configuration 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, 1998 */area 0.0.0.0 {/* Interface from router sj1 to router sj2 */interface so-0/0/0.0 {hello-interval 5;}}}

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

Published: 2014-10-22