labunix's blog

labunixのラボUnix

Cisco IOS(WS-C2970G-24T-E)のバックアップ

■Cisco IOS(WS-C2970G-24T-E)のバックアップ
 遊びで壊す前に。。。

 WS-C2970G-24T-Eを触ってみた
 http://labunix.hateblo.jp/entry/20140326/1395842497

■debian側の設定
 anonymousを無効にしてCiscoユーザと同じアカウントを作成。

$ sudo apt-get install -y vsftpd
$ sudo grep "^#anonymous\|^local\|^write" /etc/vsftpd.conf 
#anonymous_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
$ sudo /etc/init.d/vsftpd restart

■C2970側の暗号化パスワード用のコンフィグ「private-config.text」の削除と再作成
 これをしないと以下のエラーになる。
「%Error opening nvram:/startup-config (Permission denied)」

S1#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
S1(config)#service password-encryption 
S1(config)#end

S1#write memory 
Building configuration...
[OK]

S1#show flash: | include private
  353  -rwx           5  Mar 30 2014 14:11:08 +00:00  private-config.text

■それではバックアップ
 バージョン確認、起動中の設定の保存
 「private-config.text」の削除
 バックアップ対象と起動用の設定を確認して、FTPでアップロード。

S1#show version | include flash:
System image file is "flash:/c2970-lanbase-mz.122-25.SEC2/c2970-lanbase-mz.122-25.SEC2.bin"

S1$ copy running-config startup-config
Destination filename [startup-config]? 
Building configuration...
[OK]

S1#del flash:/private-config.text
Delete filename [private-config.text]? 
Delete flash:/private-config.text? [confirm]

S1#show flash: 

Directory of flash:/

    2  drwx         192   Mar 1 1993 00:04:49 +00:00  c2970-lanbase-mz.122-25.SEC2
  349  -rwx         106   Mar 1 1993 00:04:49 +00:00  info
  350  -rwx        1391   Mar 1 1993 00:08:27 +00:00  config.text.old
  351  -rwx        3050   Mar 1 1993 00:40:54 +00:00  config.text.2
  354  -rwx        1633  Mar 30 2014 13:59:55 +00:00  config.text

15998976 bytes total (9896960 bytes free)

S1#show boot 
BOOT path-list      : 
Config file         : flash:/config.text
Private Config file : flash:/private-config.text
Enable Break        : no
Manual Boot         : no
HELPER path-list    : 
Auto upgrade        : yes

S1#archive upload-sw ftp://unixusername:unixpassword@172.16.16.200/c2970-save.tar 

■パスワード暗号化を有効に戻す。

S1#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
S1(config)#service password-encryption 
S1(config)#end
S1#write memory 
Building configuration...
[OK]
S1#show flash: | include private
  352  -rwx           5  Mar 30 2014 14:18:22 +00:00  private-config.text

■debian側で確認
 html系はWeb管理コンソールとそのヘルプファイル
 メインは「c2970-lanbase-mz.122-25.SEC2.bin」

# tar tvf c2970-save.tar 2> /dev/null | awk '($NF>="/"){print $NF}' | grep ^/ | grep -v "/html/" | column
/c2970-lanbase-mz.122-25.SEC2					/config.text.old
/c2970-lanbase-mz.122-25.SEC2/c2970-lanbase-mz.122-25.SEC2.bin	/config.text.2
/c2970-lanbase-mz.122-25.SEC2/html				/config.text
/c2970-lanbase-mz.122-25.SEC2/info				/update
/info								/update/info