Sổ tay kỹ thuật

IOS XR CLI cheatsheet

cheatsheet#iosxr#cli#config· cập nhật 2026-11-06

Tra nhanh lệnh IOS XR hay dùng - show, commit, commit confirmed, rollback, config replace, backup và install.

Sửa trang này
Mục lục

IOS XR dùng mô hình two-stage commit: sửa trong target config, chỉ có hiệu lực khi commit. Mỗi commit có commit ID, rollback được theo ID hoặc theo số lần gần nhất. Lệnh Junos tương đương: Junos CLI cheatsheet.

Phiên làm việc và lọc output

Mục đích Lệnh
Tắt phân trang terminal length 0
Lọc dòng / bắt đầu từ / loại trừ show run | include desc / show run | begin router bgp / show log | exclude LINK
Config dạng 1 dòng / lệnh (dễ grep, dễ copy) show running-config | formal
Config của 1 khối show running-config router bgp / show running-config interface Gi0/0/0/1
Ghi output ra file show tech-support routing bgp | file harddisk:/bgp-tech.txt
Chạy lệnh exec trong chế độ config do show bgp summary

Show vận hành

Mục đích Lệnh
Phiên bản, uptime show version
Card, trạng thái node show platform
Phần cứng, serial show inventory
Interface tóm tắt show interfaces brief / show ipv4 interface brief
Lỗi, counter interface show interfaces Gi0/0/0/1 | include "rate|error|drops"
Quang (DOM) show controllers optics 0/0/0/1
BGP show bgp ipv4 unicast summary / show bgp vrf all summary
Route show route ipv4 203.0.113.0/24 / show route summary
LLDP show lldp neighbors
Log show logging last 50
CPU / memory show processes cpu sorted / show memory summary
Alarm show alarms brief system active

Cấu hình và commit

Mục đích Lệnh
Vào config (dùng chung target) / độc quyền configure / configure exclusive
Xem thay đổi chưa commit show configuration (trong config mode)
Diff chưa commit dạng +/- show commit changes diff
Commit kèm ghi chú / label commit comment CHG-1234 / commit label CHG-1234
Commit, tự rollback nếu không xác nhận sau N giây commit confirmed 300
Xác nhận commit confirmed commit
Commit phần hợp lệ, bỏ phần lỗi commit best-effort
Thay toàn bộ running bằng target config commit replace
Xem lý do commit lỗi show configuration failed
Bỏ thay đổi chưa commit, ở lại config mode clear
Bỏ thay đổi và thoát abort
Session config đang mở / xoá session treo show configuration sessions / clear configuration sessions <session-id>

commit replace thay toàn bộ running-config bằng nội dung target. Chỉ dùng sau khi load đúng file config đầy đủ, và nên đi kèm commit confirmed khi làm từ xa.

Lịch sử và rollback

Mục đích Lệnh
Danh sách commit show configuration commit list / show configuration commit list detail
Nội dung 1 commit show configuration commit changes 1000000123
Nội dung commit gần nhất show configuration commit changes last 1
Xem trước rollback sẽ đổi gì show configuration rollback changes last 1
Rollback N commit gần nhất rollback configuration last 1
Rollback về trạng thái sau commit ID rollback configuration to 1000000123

Backup, load, config replace

Mục đích Lệnh
Lưu running ra file copy running-config harddisk:/backup-20261106.cfg
Xem file dir harddisk: / more harddisk:/backup-20261106.cfg
Load file vào target (merge) configure → load harddisk:/change.cfg → show commit changes diff → commit
Thay toàn bộ config từ file configure → load harddisk:/full.cfg → commit replace
Đổi cấu hình từ interface này sang interface khác replace interface Gi0/0/0/1 with Gi0/0/0/2 (config mode)
Thay chuỗi trong toàn bộ config replace pattern 'old-desc' with 'new-desc' (config mode)

Install (eXR 64-bit, IOS XR 6.x/7.x)

Mục đích Lệnh
Package đang chạy show install active summary
Package đã commit / chưa active show install committed summary / show install inactive summary
Thêm package / ISO từ đĩa install add source harddisk:/ <file.iso> <file.rpm>
Kiểm tra tiến trình show install request / show install log
Kích hoạt theo operation ID install activate id <op-id>
Ghi nhận để giữ sau reload install commit
Dọn package không dùng install remove inactive all

Platform chạy IOS XR 7 dạng XR7/LNT (Cisco 8000, NCS 540 một số model) dùng bộ lệnh install package add, install apply, install commit thay cho chu trình add/activate ở trên. Kiểm tra release notes của platform trước khi nâng cấp.

Admin, shell và debug nhanh

Mục đích Lệnh
Vào chế độ admin (eXR, nếu platform có) admin
Vào shell Linux của XR run
Ping/traceroute từ VRF ping vrf MGMT 192.0.2.1 source MgmtEth0/RP0/CPU0/0 / traceroute 203.0.113.1
Theo dõi log realtime terminal monitor (tắt: terminal monitor disable)
Telemetry đang chạy show telemetry model-driven subscription

Tự động hoá các thao tác trên bằng Ansible: Đẩy cấu hình IOS XR bằng Ansible.