Cisco IOS XR CLI Basics: Command Modes and Show Commands - 夜莺博客

Cisco IOS XR CLI Basics: Command Modes and Show Commands

Cisco IOS XR runs on ASR 9000, CRS and NCS routers with a distributed architecture, and its CLI differs from classic IOS in important ways: configuration is commit-based, the router runs secure domain routers (SDRs), and the prompt identifies the exact node (RP/0/RSP0/CPU0). This guide covers the IOS XR command modes, how to navigate and commit configuration, and the show commands used for day-to-day operations and troubleshooting.

If you already know IOS or IOS XE, the fastest route to competence on IOS XR is to accept three facts up front. First, nothing you type takes effect until you commit. Second, the configuration is persistent the moment it is committed, so there is no separate "save" step. Third, every command is executed against a specific node in a distributed chassis, and the prompt tells you which one. Get comfortable with those three and the rest of IOS XR reads like IOS with a different coat of paint.

The IOS XR Prompt Explained

The prompt RP/0/RSP0/CPU0:router# packs the whole hardware topology into a single line. RP is the route processor role, the next three fields identify the rack, slot and CPU (here rack 0, RSP0, CPU0), and the text after the colon is the hostname. On a multi-chassis system or an NCS with line-card CPUs, the same prompt shape identifies exactly which node you are talking to and therefore which processes and interfaces you can see from that context.

This matters operationally: a show command issued on one RP may not display state held on another, which is why IOS XR offers the RP/0/RSP0/CPU0:router# prefix before every command in its documentation. The practical rule is that any show output which looks incomplete should be re-run from a different node before you conclude something is missing.

IOS XR Command Modes

Mode Prompt Purpose
EXEC RP/0/RSP0/CPU0:router# show and clear commands for an SDR
Administration EXEC RP/0/RSP0/CPU0:router(admin)# system-wide resources, SDRs
Administration configuration RP/0/RSP0/CPU0:router(admin-config)# fabric, SDR and system-level configuration
Global configuration RP/0/RSP0/CPU0:router(config)# configure an SDR
Interface configuration RP/0/RSP0/CPU0:router(config-if)# interface-specific settings
Routing protocol submodes RP/0/RSP0/CPU0:router(config-ospf)# OSPF, BGP, IS-IS, route-policy and MPLS stanzas

Moving between modes follows a simple grammar. admin from EXEC takes you into the administration plane; configure from either EXEC or administration EXEC takes you into the corresponding configuration plane; exit steps back one level and end returns all the way to EXEC. The distinction that confuses IOS engineers most is that administration mode is where SDRs, fabric and system-level resources live - ordinary interface and routing configuration belongs in the SDR plane, reached by configure from EXEC.

Navigating and Committing Configuration

RP/0/RSP0/CPU0:router# configure
RP/0/RSP0/CPU0:router(config)# hostname R1
RP/0/RSP0/CPU0:router(config)# commit
RP/0/RSP0/CPU0:router(config)# end

Unlike classic IOS, changes in IOS XR take effect only after commit. Uncommitted changes can be discarded with abort, and previous commits can be rolled back by commit ID - see our IOS XR commit and rollback guide for details.

Two commands make this model safe to work with in production. show configuration from configuration mode displays the changes sitting in the target buffer, so you can review the full diff before committing. And because the running configuration is persistent as soon as it is committed, there is no IOS-style copy running-config startup-config on IOS XR at all - a habit that is hard to break but harmless if you keep typing it, because the router simply reports an unrecognised command.

Commit Options: Confirmed, Comments and Labels

RP/0/RSP0/CPU0:router(config)# commit confirmed 5
RP/0/RSP0/CPU0:router(config)# commit comment "OSPF area 10 added per CHG-10231"
RP/0/RSP0/CPU0:router(config)# commit label ospf-area10
RP/0/RSP0/CPU0:router(config)# show configuration commit list

commit confirmed <minutes> is the single most valuable command in IOS XR. The configuration takes effect immediately but is automatically rolled back unless you type commit again within the timer - a five-minute safety net that has saved countless engineers from locking themselves out of a remote router. commit comment embeds a change ticket or reason in the commit history, and commit label attaches a human-readable name to a commit so it can be referenced by name instead of by the auto-generated commit ID. Together they turn the commit history into an audit trail that a change-management process can actually use.

If you were working with a BGP or MPLS change that could not be fully verified in five minutes, set commit confirmed with a longer window and a fallback plan rather than committing outright, and remember that any subsequent commit confirms the change.

Common Show Commands

RP/0/RSP0/CPU0:router# show version
RP/0/RSP0/CPU0:router# show platform
RP/0/RSP0/CPU0:router# show interfaces
RP/0/RSP0/CPU0:router# show running-config
RP/0/RSP0/CPU0:router# show logging
RP/0/RSP0/CPU0:router# show memory
RP/0/RSP0/CPU0:router# show inventory
RP/0/RSP0/CPU0:router# show route
RP/0/RSP0/CPU0:router# show interfaces GigabitEthernet0/0/0/0 brief

show version reports the IOS XR release; show platform lists linecards and their state; show interfaces shows interface counters and drops; show logging displays syslog messages with severity levels. On a distributed chassis show platform is the first thing to check when a line card misbehaves, because it reports per-slot state and the latest reload reason. show inventory gives you the serial numbers you will need for an RMA or a support case.

Note the interface naming convention: IOS XR uses a four-part identifier, rack/slot/module/port, so a physical port on a line card is GigabitEthernet0/0/0/0 rather than the IOS GigabitEthernet0/0. Getting this wrong is the most common reason a valid-looking interface command is rejected.

Configuring Basic Features

RP/0/RSP0/CPU0:router(config)# domain name cisco.com
RP/0/RSP0/CPU0:router(config)# domain name-server 8.8.8.8
RP/0/RSP0/CPU0:router(config)# logging 10.1.1.1
RP/0/RSP0/CPU0:router(config)# logging console emergencies
RP/0/RSP0/CPU0:router(config)# commit

Logging can be sent to console, terminal, buffer or a syslog server, each with its own severity threshold (emergencies through debugging).

Configuring an Interface: A Worked Example

RP/0/RSP0/CPU0:router# configure
RP/0/RSP0/CPU0:router(config)# interface GigabitEthernet0/0/0/0
RP/0/RSP0/CPU0:router(config-if)# description UPLINK-TO-CORE
RP/0/RSP0/CPU0:router(config-if)# ipv4 address 192.0.2.1 255.255.255.252
RP/0/RSP0/CPU0:router(config-if)# no shutdown
RP/0/RSP0/CPU0:router(config-if)# commit
RP/0/RSP0/CPU0:router(config-if)# end

Three details differ from IOS here. The address family is explicit: ipv4 address rather than ip address, because IOS XR supports dual-stack natively and the configuration hierarchy reflects that. The mask can be entered in dotted-decimal or prefix notation. And no shutdown is committed together with the address, so an interface cannot be left half-configured by an interrupted session.

Once committed, verify with show interfaces GigabitEthernet0/0/0/0 brief, which prints the line protocol state, and show ipv4 interface GigabitEthernet0/0/0/0 for the address and VRF binding. If you expected a route and none appeared, check the address family again first - an IPv4 address typed as ip address on IOS XR is a syntax error, not a silent misconfiguration.

Troubleshooting Basics

RP/0/RSP0/CPU0:router# ping 10.1.1.2
RP/0/RSP0/CPU0:router# traceroute 10.1.1.2
RP/0/RSP0/CPU0:router# show tech-support
RP/0/RSP0/CPU0:router# show processes blocked
RP/0/RSP0/CPU0:router# show processes cpu
RP/0/RSP0/CPU0:router# show logging | include %ROUTING

show tech-support collects a large amount of system information for TAC analysis; show processes blocked/cpu identifies stuck or CPU-hungry processes in the distributed architecture.

The pipe filters carry over from IOS, including include, exclude and begin, and they are the difference between a five-line answer and a two-hundred-line scroll. On a busy ASR 9000, show logging | include %LINK or show route | include 10.10.10.0 answer most first-line questions instantly. For counter-level faults such as CRC errors or input drops, the interface-specific guides linked below go deeper than the generic commands here.

SDRs, Administration Mode and When to Use Them

IOS XR can partition a physical chassis into secure domain routers (SDRs), and each SDR behaves like an independent router with its own configuration, interfaces, routing processes and users. Administration mode is the only place you can see and manage the whole system: creating and deleting SDRs, moving resources between them, and viewing fabric-level state.

RP/0/RSP0/CPU0:router# admin
RP/0/RSP0/CPU0:router(admin)# show platform
RP/0/RSP0/CPU0:router(admin)# configure
RP/0/RSP0/CPU0:router(admin-config)# sdr default-sdr
RP/0/RSP0/CPU0:router(admin-config)# commit
RP/0/RSP0/CPU0:router(admin-config)# end
RP/0/RSP0/CPU0:router# exit

The trap for anyone new to the platform is that a command which works in one plane is often rejected in the other. Diagnostics such as show controllers and some platform-level counter commands live in administration mode, while everything an operator normally touches - interfaces, routing protocols, route policies - lives in the SDR plane. When a show command returns "not found" on an otherwise healthy ASR 9000, check whether you are in the right plane before assuming the feature is missing, and remember that you need to exit administration mode to get back to the SDR.

Most single-tenant networks never touch SDR configuration, but they still benefit from knowing that administration mode exists, because it is where fabric, fan-tray, power and SDR-level logs surface. A line card that keeps resetting often shows nothing in the SDR log while administration mode records the reload reason in full.

IOS XR, IOS and NX-OS Side by Side

Task Cisco IOS / XE Cisco IOS XR Cisco NX-OS
Enter configuration configure terminal configure configure terminal
Apply config immediate commit immediate
Discard changes reload / manual undo abort no commands
Save to startup write memory not required (persistent) copy run start
Interface name GigabitEthernet0/0 GigabitEthernet0/0/0/0 Ethernet1/2
IPv4 address ip address ipv4 address ip address
Rollback archive / configure replace commit history, by ID or label checkpoint / rollback

The table's most useful row is the last one. IOS XR's commit history is a first-class feature rather than an add-on: every commit is numbered, timestamped and optionally labelled, and the configuration can be moved backwards to any of them. NX-OS offers a comparable checkpoint and rollback mechanism, which serves the same purpose in a different syntax.

Related articles: Cisco IOS XR configuration management and Cisco Nexus NX-OS VLAN and trunk configuration. For hardware-level faults, see ASR 9000 fabric troubleshooting show commands and IOS XR interface CRC error troubleshooting.

原文链接:https://www.cisco.com/en/US/docs/ios_xr_sw/Beta_R3.4/gs34book.pdf