思科設備啟動流程:POST → ROMMON → 引導 IOS (Flash/TFTP) → 載入 Startup-config (NVRAM) → Running-config (RAM)。
配置寄存器 控制啟動行為,關鍵位:
0x0=ROMMON、0x1=Boot First Flash、0x2-0xF=依據 boot system 命令。1 = 跳過載入 Startup-config (密碼在這裡)。0x2102:正常啟動,載入 NVRAM 配置。0x2142:Bit 6=1 (忽略 NVRAM) + Boot Field=2 (默認引導) → 進入無配置的 IOS,可直接 enable 進特權模式。reload。Ctrl+Break / Special Command → Break,SecureCRT: Alt+B / Ctrl+Break,Tera Term: Alt+B)。提示符變為 rommon 1>。rommon 1> confreg 0x2142
rommon 2> reset
Would you like to enter the initial configuration dialog? [yes/no]: 輸入 no。Router> enable (無密碼直接進入 Router#)。Router# copy startup-config running-config
! 或
Router# configure replace nvram:startup-config force
Router# configure terminal
Router(config)# enable secret NEW_STRONG_PASSWORD ! 加密特權密碼,最高優先級
Router(config)# enable password FALLBACK_PASSWORD ! 非加密備用,建議同 secret
Router(config)# line console 0
Router(config-line)# password CONSOLE_PWD
Router(config-line)# login
Router(config-line)# line vty 0 4
Router(config-line)# password VTY_PWD
Router(config-line)# login
Router(config-line)# transport input ssh ! 僅允許 SSH
Router(config)# config-register 0x2102
Router(config)# end
Router# copy running-config startup-config
! 或 write memory
reload 重啟,用新密碼登錄。| 平台 | Break 發送方式 | 配置寄存器默認 | 備註 |
|---|---|---|---|
| ISR 4000/ASR 1000 (IOS-XE) | 同標準 Break | 0x2102 | 支持 confreg 0x2142 |
| Catalyst 交換機 (IOS) | Mode 鍵長按 (見下文) | 0x2102/0x102 | 見「交換機密碼恢復」 |
| Nexus (NX-OS) | Ctrl+] 進 loader> 提示符 | N/A | 用 bootmode reset 進維護模式 |
| ASA 防火牆 | 電源重啟 + Break | 0x1 | 進入 ROMMON 用 config-register 0x41 忽略配置 |
switch: 提示符。switch: flash_init 初始化文件系統。switch: rename flash:config.text flash:config.text.old (備份舊配置)。switch: boot 載入 IOS,無配置啟動。rename flash:config.text.old flash:config.text 恢復配置文件名。copy flash:config.text system:running-config 載入舊配置到運行內存。config-register 0x2102、write memory。0x2142 (十六進制)。copy startup-config running-config 直接改密 → 重啟後密碼未生效 (仍讀舊 NVRAM)。config-register 0x2102 → 下次重啟再次跳過配置,陷入循環。no service password-recovery → 物理安全鎖死,僅能刷機/退貨。密碼恢復本質是「通過配置寄存器 Bit 6 跳過 NVRAM 配置載入,進入無密碼特權模式,合併舊配置至運行內存,修改密碼後恢復寄存器並保存」。熟練掌握標準流程、平台差異與失敗排查,是網絡工程師應急處理的核心硬技能。