Sổ tay kỹ thuật

Junos CLI cheatsheet

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

Tra nhanh lệnh Junos hay dùng - show, pipe, configure, commit check/confirmed, compare, rollback, load và display set.

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

Junos cũng dùng candidate config: sửa xong phải commit. Hệ thống giữ tối đa 50 bản rollback (rollback 0 là active hiện tại). Lệnh IOS XR tương đương: IOS XR CLI cheatsheet.

Pipe và hiển thị

Mục đích Lệnh
Tắt phân trang (cả phiên / 1 lệnh) set cli screen-length 0 / show ... | no-more
Lọc dòng / loại trừ show interfaces terse | match ge- / | except down
Đếm dòng show route protocol bgp | count
Xem N dòng cuối show log messages | last 50
Config dạng lệnh set show configuration | display set
Tìm trong config dạng set show configuration | display set | match 203.0.113.1
Output XML / JSON show bgp summary | display xml / | display json
Tên RPC tương ứng (cho PyEZ, NETCONF) show interfaces terse | display xml rpc
Xem config sau khi áp dụng group show configuration | display inheritance
Lưu output ra file show route | save /var/tmp/route.txt

Show vận hành

Mục đích Lệnh
Phiên bản / uptime show version / show system uptime
Phần cứng, serial show chassis hardware
Alarm show chassis alarms / show system alarms
Interface tóm tắt / chi tiết show interfaces terse / show interfaces ge-0/0/1 extensive
Quang (DOM) show interfaces diagnostics optics ge-0/0/1
BGP show bgp summary / show bgp neighbor 203.0.113.1
Route show route 203.0.113.0/24 / show route summary
Route nhận/quảng bá với neighbor show route receive-protocol bgp 203.0.113.1 / show route advertising-protocol bgp 203.0.113.1
LLDP show lldp neighbors
Log show log messages | last 50
CPU / RE show chassis routing-engine
Lịch sử commit show system commit

Cấu hình

Mục đích Lệnh
Vào config (dùng chung) / độc quyền / riêng configure / configure exclusive / configure private
Di chuyển trong cây edit protocols bgp group EBGP / up / top
Thêm / xoá set ... / delete ...
Vô hiệu hoá tạm (giữ config) deactivate interfaces ge-0/0/1 / activate ...
Đổi tên / chép khối rename interfaces ge-0/0/1 to ge-0/0/2 / copy interfaces ge-0/0/1 to ge-0/0/2
Ghi chú lên config annotate group EBGP "CHG-1234 transit A"
Chạy lệnh vận hành trong config mode run show bgp summary
Ai đang sửa config status
Thoát config mode exit configuration-mode

Compare, commit, rollback

Mục đích Lệnh
Diff candidate với active show | compare
Diff candidate với rollback N show | compare rollback 1
Diff 2 bản rollback (operational mode) show system rollback 1 compare 0
Kiểm tra cú pháp và ràng buộc, không áp dụng commit check
Commit kèm ghi chú commit comment "CHG-1234"
Commit tự rollback sau N phút commit confirmed 5
Xác nhận commit confirmed commit (hoặc commit check)
Commit rồi thoát commit and-quit
Commit hẹn giờ / huỷ hẹn giờ commit at "2026-11-06 23:00:00" / clear system commit (operational)
Commit đồng bộ 2 RE commit synchronize
Bỏ mọi thay đổi chưa commit rollback 0
Quay về bản trước rollback 1 → show | compare → commit
Lưu / nạp rescue config request system configuration rescue save / rollback rescue

Làm từ xa trên thiết bị sản xuất: commit check → commit confirmed 5 → kiểm tra vẫn SSH được và dịch vụ ổn → commit. Mất kết nối thì 5 phút sau Junos tự quay lại.

Load config

Mục đích Lệnh
Dán lệnh set từ terminal load set terminal (kết thúc bằng Ctrl+D)
Dán khối config dạng cây, gộp vào load merge terminal relative (đang edit ở đâu thì gộp tại đó)
Gộp từ file load merge /var/tmp/change.conf
Thay các khối có tag replace: load replace /var/tmp/change.conf
Thay toàn bộ config load override /var/tmp/full.conf
Áp các lệnh từ diff đã lưu load patch /var/tmp/change.patch

load override thay toàn bộ candidate. Sau đó luôn show | compare trước khi commit để chắc không mất cấu hình quản trị (system, interfaces mgmt, firewall lo0).

File và hệ thống

Mục đích Lệnh
Liệt kê file file list /var/tmp/
Xem file file show /var/tmp/change.conf
Lưu config ra file save /var/tmp/backup-20261106.conf (config mode)
Vào shell start shell
Khởi động lại request system reboot

Tự động hoá bằng Python: Junos PyEZ cơ bản.