Sổ tay kỹ thuật

BGP – lệnh show/clear/debug trên IOS XR và Junos

cheatsheet#bgp#iosxr#junos· cập nhật 2026-11-06

Tra nhanh lệnh BGP tương đương giữa IOS XR và Junos khi kiểm tra session, route nhận/gửi, policy và VPN.

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

Quy ước: neighbor 198.51.100.2, prefix 203.0.113.0/24, VRF CUST-A. Trên IOS XR có thể bỏ ipv4 unicast (mặc định là IPv4 unicast). Lệnh CLI chung xem IOS XR CLI và Junos CLI.

Session

Mục đích IOS XR Junos
Tóm tắt mọi neighbor show bgp ipv4 unicast summary show bgp summary
Tóm tắt mọi AFI/SAFI show bgp all all summary show bgp summary
Chi tiết một neighbor (state, timer, lý do reset) show bgp neighbor 198.51.100.2 show bgp neighbor 198.51.100.2
Chỉ dòng trạng thái và lỗi gần nhất show bgp neighbor 198.51.100.2 | include "BGP state|Last reset" show bgp neighbor 198.51.100.2 | match "State|Last error"
Neighbor chưa Established (cột state hiện Idle/Active/Connect thay vì số prefix) show bgp ipv4 unicast summary | include "Idle|Active|Connect" show bgp summary | match "Idle|Active|Connect"
Cấu hình đang áp cho neighbor show running-config router bgp 64500 neighbor 198.51.100.2 show configuration protocols bgp group ISP-A
Log thay đổi session show logging | include BGP show log messages | match bgp_

Route nhận và gửi

Mục đích IOS XR Junos
Route nhận và được chấp nhận show bgp ipv4 unicast neighbor 198.51.100.2 routes (sau inbound policy) show route receive-protocol bgp 198.51.100.2 (attribute trước import policy)
Route nhận trước policy, kể cả bị loại show bgp ipv4 unicast neighbor 198.51.100.2 received routes (cần soft-reconfiguration inbound always) —
Route bị import policy loại hoặc next-hop không resolve so received routes với routes show route receive-protocol bgp 198.51.100.2 hidden
Route gửi đi show bgp ipv4 unicast neighbor 198.51.100.2 advertised-routes show route advertising-protocol bgp 198.51.100.2
Đếm route gửi đi show bgp ipv4 unicast neighbor 198.51.100.2 advertised-count show route advertising-protocol bgp 198.51.100.2 | count
Chi tiết mọi path của một prefix show bgp ipv4 unicast 203.0.113.0/24 show route 203.0.113.0/24 detail
Vì sao path này thắng/thua show bgp ipv4 unicast 203.0.113.0/24 bestpath-compare show route 203.0.113.0/24 detail | match "Inactive reason"
Route BGP đã vào RIB show route ipv4 bgp show route protocol bgp table inet.0
Thống kê số route theo protocol show route ipv4 summary show route summary

Policy

Mục đích IOS XR Junos
Xem policy show rpl route-policy ISP-A-IN show configuration policy-options policy-statement ISP-A-IN
Xem prefix-set / prefix-list show rpl prefix-set OUR-PREFIXES show configuration policy-options prefix-list OUR-PREFIXES
Policy đang gắn ở đâu show rpl route-policy ISP-A-IN attachment-points show configuration protocols bgp | display set | match ISP-A-IN
Thử policy với một prefix (không có lệnh tương đương, dùng received routes + routes để so) test policy ISP-A-IN 203.0.113.0/24

Clear

Mục đích IOS XR Junos
Áp lại policy inbound (không reset TCP) clear bgp ipv4 unicast 198.51.100.2 soft in clear bgp neighbor 198.51.100.2 soft-inbound
Gửi lại toàn bộ update outbound clear bgp ipv4 unicast 198.51.100.2 soft out clear bgp neighbor 198.51.100.2 soft
Hard reset session clear bgp ipv4 unicast 198.51.100.2 clear bgp neighbor 198.51.100.2

Hard reset làm rơi toàn bộ route từ neighbor đó. Trên peering có full table, luôn thử soft trước. Junos tự áp lại import policy sau commit nên thường không cần clear.

VPN / VRF

Mục đích IOS XR Junos
Session PE-CE trong VRF show bgp vrf CUST-A summary show bgp summary instance CUST-A
Bảng định tuyến VRF show route vrf CUST-A show route table CUST-A.inet.0
VPNv4 route theo RD show bgp vpnv4 unicast rd 64500:100 show route table bgp.l3vpn.0 | match 64500:100
Một prefix VPN (label, RT) show bgp vpnv4 unicast rd 64500:100 203.0.113.0/24 show route table bgp.l3vpn.0 203.0.113.0/24 detail
Session VPNv4 với RR show bgp vpnv4 unicast summary show bgp summary (dòng bgp.l3vpn.0)

Debug / trace

Chỉ bật trong thời gian ngắn, lọc theo neighbor nếu có thể.

! IOS XR
debug bgp update
show logging | include BGP
undebug all
# Junos: traceoptions ghi ra /var/log/bgp-trace
set protocols bgp traceoptions file bgp-trace size 10m files 3
set protocols bgp traceoptions flag update detail
commit
show log bgp-trace | last 50
delete protocols bgp traceoptions
commit