Managing Configuration Comments on IOS XR
Introduction
Recently, I had to configure an ASR9K from scratch, starting from a set of configuration lines taken from another device. During the configuration process, I realized that, unlike IOS XE, IOS XR allows comments to be included directly alongside configuration commands. In IOS XE, it is well known that comments cannot be saved within the running configuration. When comments are inserted using the ! character, they are not stored in NVRAM or in the active copy of the configuration file. As a result, comments do not appear when displaying the active configuration using the show running-config command. The situation is different with IOS XR. On this platform, it is possible to include comments directly within the configuration. These comments are stored together with the rest of the configuration, making them visible in the output of commands such as show running-config.
How to Insert a Comment in IOS XR
Therefore, the special character used to insert a comment within the configuration, and thus before executing the usual commit operation to save it, is the ! character. The comment is then associated with the configuration command that follows. A simple example is shown below, based on the following topology.

A simple OSPF adjacency in Area 0 has been configured between the two PEs. PE-TEST-1 advertises the network 1.1.1.1/32 (which corresponds to the IP address assigned to the local Loopback 0 interface) to PE-TEST-2. Below is the configuration of PE-TEST-1.
RP/0/RP0/CPU0:PE-TEST-1#show running-config router ospf 1
Sun Jan 4 07:33:57.059 UTC
router ospf 1
area 0
interface Loopback0
passive enable
!
interface GigabitEthernet0/0/0/1
bfd minimum-interval 50
bfd fast-detect
bfd multiplier 3
network point-to-point
!
!
!
Below is the configuration of PE-TEST-2.
RP/0/RP0/CPU0:PE-TEST-2#show running-config router ospf 1
Sun Jan 4 07:34:17.149 UTC
router ospf 1
area 0
interface GigabitEthernet0/0/0/0
bfd minimum-interval 50
bfd fast-detect
bfd multiplier 3
network point-to-point
!
!
!
The node PE-TEST-2 correctly receives the advertisement for the network 1.1.1.1/32, as can be verified from PE-TEST-2. The network is advertised by PE-TEST-1 with an OSPF cost of 1.
RP/0/RP0/CPU0:PE-TEST-2#show ip ospf 1 database router adv-router 10.0.0.1
Sun Jan 4 07:35:01.712 UTC
OSPF Router with ID (10.0.0.2) (Process ID 1)
Router Link States (Area 0)
Routing Bit Set on this LSA
LS age: 29
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 10.0.0.1
Advertising Router: 10.0.0.1
LS Seq Number: 80000011
Checksum: 0xab03
Length: 60
Number of Links: 3
Link connected to: a Stub Network
(Link ID) Network/subnet number: 1.1.1.1
(Link Data) Network Mask: 255.255.255.255
Number of TOS metrics: 0
TOS 0 Metrics: 1
[OUTPUT OMITTED]
Now, the OSPF cost of the Loopback 0 interface on PE-TEST-1 is modified, and a comment is added to explain the reason for this choice. The following configuration is then applied.
RP/0/RP0/CPU0:PE-TEST-1(config-ospf)#area 0
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar)#int loopback 0
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#! BACKUP PATH - COST 450
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#cost 450
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#commi
Sun Jan 4 07:36:13.761 UTC
When displaying the OSPF configuration, the comment is now shown. It is important to emphasize that the comment is associated with the configuration command that follows. In other words, the configuration command passive enable is entirely independent of the comment that was just added.
RP/0/RP0/CPU0:PE-TEST-1#show running-config router ospf 1
Sun Jan 4 07:37:16.152 UTC
router ospf 1
area 0
interface Loopback0
! BACKUP PATH - COST 450
cost 450
passive enable
!
interface GigabitEthernet0/0/0/1
bfd minimum-interval 50
bfd fast-detect
bfd multiplier 3
cost 13
network point-to-point
!
!
!
The OSPF cost for the network 1.1.1.1/32 was subsequently updated on PE-TEST-2 as well.
RP/0/RP0/CPU0:PE-TEST-2#show ip ospf 1 database router adv-router 10.0.0.1
Sun Jan 4 07:37:16.152 UTC
OSPF Router with ID (10.0.0.2) (Process ID 1)
Router Link States (Area 0)
Routing Bit Set on this LSA
LS age: 26
Options: (No TOS-capability, DC)
LS Type: Router Links
Link State ID: 10.0.0.1
Advertising Router: 10.0.0.1
LS Seq Number: 80000012
Checksum: 0x5a90
Length: 60
Number of Links: 3
Link connected to: a Stub Network
(Link ID) Network/subnet number: 1.1.1.1
(Link Data) Network Mask: 255.255.255.255
Number of TOS metrics: 0
TOS 0 Metrics: 450
[OUTPUT OMITTED]
How to Modify a Comment in IOS XR
Once a comment has been associated with a command, it can be updated. Two approaches are available for doing so:
- Enter the updated comment and then reapply the same command with the same configuration parameters.
- Enter the updated comment and then apply the same command with different configuration parameters.
For example, consider the first scenario where we want to update the comment associated with the OSPF cost command on the Loopback 0 interface of PE-TEST-1, while keeping the same cost value. The sequence of commands to achieve this is shown below.
RP/0/RP0/CPU0:PE-TEST-1(config-ospf)#area 0
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar)#int loopback 0
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#! NEW COMMENT - BACKUP PATH - 450
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#cost 450
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#commi
Sun Jan 4 07:40:11.132 UTC
By verifying the configuration using the standard command, it can be confirmed that the comment has been successfully updated. Additionally, packet capture analysis confirmed that PE-TEST-1 did not send any OSPF LSU messages to PE-TEST-2.
RP/0/RP0/CPU0:PE-TEST-1#show running-config | i COMMENT
Sun Jan 4 07:41:01.261 UTC
! NEW COMMENT - BACKUP PATH - 450
In the second scenario, we examine what happens when, after updating the comment, the OSPF cost of the interface is modified from 450 to 150.
RP/0/RP0/CPU0:PE-TEST-1(config-ospf)#area 0
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar)#int loopback 0
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#! NEW VALUE - BACKUP PATH - 150
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#cost 150
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#commi
Sun Jan 4 07:42:43.721 UTC
By checking the configuration again using the standard command, it can be confirmed that the comment has been successfully updated.
RP/0/RP0/CPU0:PE-TEST-1#show running-config | i NEW
Sun Jan 4 07:43:23.411 UTC
! NEW VALUE - BACKUP PATH - 150
How to Remove a Comment in IOS XR
After modifying the command, if it needs to be removed from PE-TEST-1, the specific clear comment command must be used. Once executed, the configuration command associated with that comment should be re-entered. An example is provided below, assuming the objective is to remove the comment ! NEW VALUE - BACKUP PATH - 150.
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#clear comment
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#cost 150
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#commit
Sun Jan 4 07:45:13.816 UTC
The comment was therefore removed as expected. Additionally, packet capture analysis confirmed that PE-TEST-1 did not send any OSPF LSU messages to PE-TEST-2.
RP/0/RP0/CPU0:PE-TEST-1#show running-config router ospf 1 area 0 interface loopback 0
Sun Jan 4 07:48:42.113 UTC
router ospf 1
area 0
interface Loopback0
cost 150
passive enable
!
!
!
How to Insert a Comment within a Commit in IOS XR
So far, we have seen how it is possible to add, modify and remove comments from the configuration. In IOS XR, however, it is also possible to include comments within a commit (up to a maximum of 60 characters). This functionality, which is reminiscent of version control systems (VCS), can be useful when trying to understand which changes are included in a particular commit. Let us now consider reconfiguring the interface cost while including a descriptive comment with the commit. The commands below illustrate how to perform this operation.
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#cost 450
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#commit comment ?
LINE Comment for this commit (Max 60 characters)
RP/0/RP0/CPU0:PE-TEST-1(config-ospf-ar-if)#commit comment Updated Link Cost
Sun Jan 4 07:51:21.533 UTC
The list of all commits (up to a maximum of 36) can be displayed using the show configuration commit list command.
RP/0/RP0/CPU0:PE-TEST-1#show configuration commit list
Sun Jan 4 07:52:16.546 UTC
SNo. Label/ID User Line Client Time Stamp
~~~~ ~~~~~~~~ ~~~~ ~~~~ ~~~~~~ ~~~~~~~~~~
1 1000000036 admin con0_RP0_CPU0 CLI Sun Jan 4 07:51:21 2026
2 1000000035 admin con0_RP0_CPU0 CLI Sun Jan 4 07:45:13 2026
[OUTPUT OMITTED]
To view the comment, the show configuration commit list detail command that shows the details of each commit must be used.
RP/0/RP0/CPU0:PE-TEST-1#show configuration commit list detail
Sun Jan 4 07:53:45.823 UTC
1) CommitId: 1000000036 Label: NONE
UserId: admin Line: con0_RP0_CPU0
Client: CLI Time: Sun Jan 4 07:51:21 2026
Comment: Updated Link Cost
2) CommitId: 1000000035 Label: NONE
UserId: admin Line: con0_RP0_CPU0
Client: CLI Time: Sun Jan 4 07:45:13 2026
Comment: NONE
[OUTPUT OMITTED]
In the most recent commit, the Comment field displays the value that was previously entered.
I hope this post has been helpful. If you have any additional information to share, feel free to reach out via social media. See you in the next one! 🙂