掌握華為路由器的命令行界面(CLI)是網絡工程師的基本功。本文整理了從用戶模式到全局配置、接口配置以及路由協議的常用命令,幫助您快速完成設備部署與故障排查。
| 命令 | 功能說明 | 提示符示例 |
|---|---|---|
enable / en | 從用戶模式進入特權模式 | > → # |
configure terminal / conf t | 進入全局配置模式 | # → (config)# |
interface / int <類型> <編號> | 進入指定接口配置模式(如 int g0/0/1、int s0) | (config)# → (config-if)# |
exit | 返回上一級模式 | - |
quit | 直接退回用戶模式 | - |
乙太網/千兆接口示例:
interface GigabitEthernet0/0/1
ip address 192.168.1.1 255.255.255.0
description 連接核心交換機
no shutdown
串行接口(WAN 專線)示例—— 綁定 HDLC/PPP 封裝:
interface Serial0
link-protocol ppp # 或 hdlc
ip address 202.100.1.1 255.255.255.252
ppp authentication-mode chap # 若用 PPP 需配置認證
no shutdown
IP Unnumbered(借用接口 IP)技巧:
interface Serial0
ip address unnumbered interface GigabitEthernet0/0/1
# 默認路由(出口指向 Serial0)
ip route-static 0.0.0.0 0.0.0.0 Serial0
# 指定下一跳 IP 的靜態路由
ip route-static 10.10.20.0 255.255.255.0 202.100.1.2 preference 60
# 黑洞路由(防止路由環路)
ip route-static 172.16.0.0 255.255.0.0 null 0
save(或 write)display current-configurationdisplay interface brief / display ip interface briefreboot(需確認)reset saved-configuration 後 rebootset authentication password simple <新密碼> privilege 15| 命令 | 用途 |
|---|---|
ping -c 5 -s 1500 8.8.8.8 | 連通性測試(指定次數、包大小) |
tracert 8.8.8.8 | 路由追蹤 |
display logging | 查看日誌緩衝區 |
debugging all | 開啟所有調試(慎用,高負載時可能導致 CPU 飆升) |
terminal monitor | 將調試輸出導向當前 VTY 終端 |
display cpu-usage | 查看 CPU 佔用率 |
? 顯示可用命令;command ? 顯示參數說明。save backup.cfg 將當前配置另存為文件,便於回滾。display current-configuration | include <關鍵字> 驗證。溫馨提示: 不同華為路由器系列(AR、NE、CX 等)命令細節可能略有差異,請以設備當前版本文檔為準。生產環境變更前請務必在測試環境驗證。