Cisco IOS XR Commit Replace and Rollback Configuration - 夜莺博客

Cisco IOS XR Commit Replace and Rollback Configuration

IOS XR configuration does not change the moment you type a command - every change lives in a candidate configuration until you commit it. That commit-based model is what makes commit replace and configuration rollback such powerful safety tools on ASR 9000, NCS and 8000 series routers. commit replace is the IOS XR equivalent of wiping the router clean (like write erase on classic IOS), while rollback lets you return to any previously committed configuration. This article explains both mechanisms with real command sequences and the operational habits that keep you out of trouble.

Understanding the IOS XR Commit Model

In IOS XR every configuration session produces a commit with a unique ID, and each commit can carry an optional label. You can list all commits and roll back to any of them, which is fundamentally safer than classic IOS because the device keeps a complete history of configuration changes:

RP/0/0/CPU0:router# show configuration commit list
RP/0/0/CPU0:router(config)# commit label TEST

Wiping the Running Configuration with Commit Replace

To erase the entire running configuration, enter configuration mode and issue commit replace. IOS XR warns that the operation is service affecting and asks for confirmation:

RP/0/0/CPU0:PE1# configure terminal
RP/0/0/CPU0:PE1(config)# commit replace
This commit will replace or remove the entire running configuration. This
operation can be service affecting.
Do you wish to proceed? [no]: yes

After the commit, show running-config returns an empty configuration. Note that commit replace removes the whole configuration, so it is normally used to decommission a router or to start from a clean slate during re-provisioning.

Rolling Back to a Good Configuration

If a change breaks the router, roll back to a previous commit ID or label - this is the recovery path you will use far more often:

RP/0/0/CPU0:PE1# rollback configuration to 1000000015
Loading Rollback Changes.
Loaded Rollback Changes in 1 sec
Committing..
Configuration successfully rolled back to '1000000015'.

Because the rollback itself becomes a new commit, IOS XR never loses the ability to undo an undo.

Safer Change Windows with commit confirmed

For risky maintenance, IOS XR supports a confirmed commit that is automatically rolled back if you do not confirm it within a timer:

RP/0/0/CPU0:router(config)# commit confirmed 5
RP/0/0/CPU0:router(config)# commit

If connectivity to the router is lost during the change window, the router reverts to the previous configuration when the timer expires - a classic protection against locking yourself out.

Operational Best Practices

  • Always label important commits (commit label pre-maintenance) so rollback targets are easy to identify.
  • Test rollback configuration in a lab before you need it in production.
  • Use commit confirmed for any change that could cut your management session.
  • Never run commit replace casually: it removes every interface, protocol and management statement.

Related articles: Cisco IOS XR BGP configuration (iBGP/eBGP), Arista EOS configuration sessions, commit and rollback, and Junos commit confirmed and safe rollback.

原文链接:https://community.cisco.com/t5/networking-knowledge-base/quot-commit-replace-quot-command-in-cisco-ios-xr/ta-p/3153954