萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 網路安全 >  >> 路由器知識 >> 路由器設定 >> Cisco 思科路由器

Cisco 路由器配置備份與還原實務:Running/Startup/NVRAM/TFTP/SCP 完整操作指南

配置檔備份是網管生存底線。Cisco 提供 copy 指令在 RAM (Running-config)、NVRAM (Startup-config)、TFTP/SCP/FTP 伺服器、Flash 之間互傳。本文詳細說明三大備份場景、自動化排程、加密傳輸與災難恢復演練流程。

三大核心備份指令

指令方向用途
copy running-config startup-configRAM → NVRAM**存檔**,下次開機生效 (等同 write memory)
copy running-config tftpRAM → TFTP Server**異地備份**,防裝置損壞/遺失配置
copy tftp running-configTFTP → RAM**還原配置** (合併模式,不覆蓋未提及項目)

實操範例:備份至 TFTP

Router# copy running-config tftp
Address or name of remote host []? 192.168.100.50
Destination filename [router-confg]? R1_20240515.cfg
!!
624 bytes copied in 0.05 secs
Router#

實操範例:從 TFTP 還原

Router# copy tftp running-config
Address or name of remote host []? 192.168.100.50
Source filename []? R1_20240515.cfg
Destination filename [running-config]?
Accessing tftp://192.168.100.50/R1_20240515.cfg...
Loading R1_20240515.cfg from 192.168.100.50 (via GigabitEthernet0/0): !
[OK - 624 bytes]
624 bytes copied in 0.09 secs
Router#

進階:SCP 安全傳輸 (IOS 12.2+ 支援)

! 1. 啟用 SSH/SCP Server
ip ssh version 2
ip scp server enable
aaa new-model
aaa authentication login default local
username scpuser privilege 15 secret ScpPass2024

! 2. 從路由器推送至 SCP Server (Linux)
Router# copy running-config scp://scpuser:ScpPass2024@192.168.100.50/backups/R1_$(date +%F).cfg

! 3. 從 SCP Server 拉回
Router# copy scp://scpuser:ScpPass2024@192.168.100.50/backups/R1_20240515.cfg running-config

自動化備份排程 (Kron / EEM)

! 每日 02:00 備份 running-config 至 TFTP
kron policy-list DAILY_BACKUP
 cli copy running-config tftp://192.168.100.50/\$h_$t.cfg
!
kron occurrence DAILY at 02:00 recurring
 policy-list DAILY_BACKUP

災難恢復演練流程 (季度必演)

  1. 準備乾淨同型號備機,同版本 IOS。
  2. Console 連線,copy tftp running-config 載入備份配置。
  3. copy running-config startup-config 存檔。
  4. reload 重啟驗證啟動正常、介面 Up、鄰居建立、業務通暢。
  5. 記錄 RTO (恢復時間目標) 與 RPO (恢復點目標)。

常見錯誤與對策

  • TFTP 連線失敗:ACL/防火牆阻擋 UDP 69、路由器無路由到 TFTP Server、介面未 Up。→ 加 ip tftp source-interface Loopback0、檢查 ACL。
  • 合併配置導致衝突:copy tftp running-config 為合併非覆蓋,殘留舊配置。→ 先 erase startup-config → reload → 再還原,或使用 configure replace (IOS 12.3+)。
  • 檔名含中文/空格失敗:僅用英數、底線、連字符、日期格式。
copyright © 萬盛學電腦網 all rights reserved