Technical Documentation

Adding Comments in a JUNOS Configuration

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

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:

user@host# annotate statement "comment-string"

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:

user@host# annotate statement ""

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.

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

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.

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. For more information about the description statement, see the JUNOS Network Interfaces Configuration Guide.

Note: The JUNOS Software supports annotation up to the last level in the configuration hierarchy. However, annotation of the configuration options or statements within the last level in the hierarchy 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:

[edit protocols]isis {interface ge-0/0/0.0 {level 1 metric 10;}}}

Published: 2010-04-27