読者です 読者をやめる 読者になる 読者になる

labunix's blog

labunixのラボUnix

Cisco 892のバックアップ、初期化、復元


■Cisco 892のバックアップ、初期化、復元
 今回は9つの100M、1つの1G、それに1つのISDNポートを持ったルータ
 バージョンは新しいので、そのまま。
 IOSイメージはtftpではなく「ftp転送」が必要。

Press RETURN to get started.

Router>enable 
Router#show version | section interface
9 FastEthernet interfaces
1 Gigabit Ethernet interface
1 ISDN Basic Rate interface
Router#show version | include IOS|bin
Cisco IOS Software, C890 Software (C890-UNIVERSALK9-M), Version 15.3(3)M1, RELEASE SOFTWARE (fc1)
System image file is "flash:c890-universalk9-mz.153-3.M1.bin

■対象の確認

Router#dir
Directory of flash:/

    1  -rw-    50448544   Mar 1 1984 00:01:00 +00:00  c890-universalk9-mz.153-3.M1.bin

253100032 bytes total (202649600 bytes free)

■debian側

$ sudo /sbin/ifconfig eth2 172.31.31.254/24 up
$ sudo route add -net 172.31.31.0/24 gw 172.31.31.253 eth2
$ ls /srv/tftp/
$ netstat -an | grep :69
udp        0      0 0.0.0.0:69              0.0.0.0:*

■VLAN 1にIPを設定

Router>enable 
Router#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#interface vlan 1
Router(config-if)#no shutdown
Router(config-if)#ip address 172.31.31.253 255.255.255.0
Router(config-if)#exit
Router(config)#ip default-gateway 172.31.31.254
Router(config)#end
Router#write memory 
Building configuration...
[OK]
Router#copy running-config startup-config
Destination filename [startup-config]? 
Building configuration...
[OK]
Router#show interfaces fastEthernet 0 | include up     
FastEthernet0 is up, line protocol is up 
  Full-duplex, 100Mb/s
Router#show running-config interface vlan 1
Building configuration...

Current configuration : 63 bytes
!
interface Vlan1
 ip address 172.31.31.253 255.255.255.0
end

Router#show vlan-switch brief | exclude 100[2345]

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0, Fa1, Fa2, Fa3, Fa4, Fa5
                                                Fa6, Fa7


■tftpサーバにバックアップ
 空き容量があるのに、空き領域エラー。
 毎回33MB程度の同じところで止まるので、tftpの問題か。

Router#copy running-config flash:small.config
Destination filename [small.config]? 
1453 bytes copied in 1.156 secs (1257 bytes/sec)

Router#copy flash:small.config tftp://172.31.31.254/small.config
Address or name of remote host [172.31.31.254]? 
Destination filename [small.config]? 
.!!
1453 bytes copied in 4.060 secs (358 bytes/sec)

Router#copy flash:c890-universalk9-mz.153-3.M1.bin tftp://172.31.31.254
Address or name of remote host [172.31.31.254]? 
Destination filename [c890-universalk9-mz.153-3.M1.bin]? 
...
%Error writing tftp://172.31.31.254/c890-universalk9-mz.153-3.M1.bin (No space left on device)..
...

■ftp転送に変更

$ sudo /etc/init.d/vsftpd start
Starting FTP server: vsftpd.

Router#configure terminal 
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#ip ftp username labunix
Router(config)#ip ftp password XXXXXXXX
Router(config)#end
Router#copy flash:c890-universalk9-mz.153-3.M1.bin ftp://172.31.31.254
Address or name of remote host [172.31.31.254]? 
Destination filename [c890-universalk9-mz.153-3.M1.bin]? 
Writing c890-universalk9-mz.153-3.M1.bin !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
...
50448544 bytes copied in 36.540 secs (1380639 bytes/sec)

■データサイズとmd5sumハッシュチェック

Router#verify /md5 flash:c890-universalk9-mz.153-3.M1.bin
...
 of flash:c890-universalk9-mz.153-3.M1.bin Done!
verify /md5 (flash:c890-universalk9-mz.153-3.M1.bin) = 3374d857d034be34e582f8963d172750
Router#dir flash:c890-universalk9-mz.153-3.M1.bin | include bin
Directory of flash:/c890-universalk9-mz.153-3.M1.bin
    1  -rw-    50448544   Mar 1 1984 00:01:00 +00:00  c890-universalk9-mz.153-3.M1.bin

$ env LANG=C ls -l /srv/tftp/ | awk '{print $NF}'
32808
small.config

$ env LANG=C ls -l c890-universalk9-mz.153-3.M1.bin | awk '{print $(NF-4),$NF}'
50448544 c890-universalk9-mz.153-3.M1.bin
$ md5sum ~/c890-universalk9-mz.153-3.M1.bin 
3374d857d034be34e582f8963d172750  c890-universalk9-mz.153-3.M1.bin

■startup-configとrunning-configのサイズが異なる。
 ftpの設定の後、保存していないから。

Router#dir nvram:
Directory of nvram:/

  253  -rw-        1453                    <no date>  startup-config
  254  ----           5                    <no date>  private-config
  255  -rw-        1453                    <no date>  underlying-config
    1  -rw-        2945                    <no date>  cwmp_inventory
    4  ----         160                    <no date>  persistent-data
    5  -rw-          17                    <no date>  ecfm_ieee_mib

262136 bytes total (255506 bytes free)
Router#dir system:
Directory of system:/

  115  drwx           0                    <no date>  cme
    2  -r--           0                    <no date>  default-running-config
  768  dr-x           0                    <no date>  fpm
    3  drwx           0                    <no date>  its
  105  dr-x           0                    <no date>  memory
    1  -rw-        1534                    <no date>  running-config
  104  dr-x           0                    <no date>  vfiles

No space information available
Router#write memory 
Building configuration...
[OK]
Router#verify /md5 system:/running-config
.MD5 of system:/running-config Done!
verify /md5 (system:/running-config) = 9639f60f748b0713defd33e2dad108c9

Router#verify /md5 nvram:startup-config
.MD5 of nvram:startup-config Done!
verify /md5 (nvram:startup-config) = 9639f60f748b0713defd33e2dad108c9

Router#copy running-config flash:small.config
Destination filename [small.config]? 
%Warning:There is a file already existing with this name 
Do you want to over write? [confirm]
1534 bytes copied in 1.032 secs (1486 bytes/sec)

Router#copy flash:small.config tftp://172.31.31.254
Address or name of remote host [172.31.31.254]? 
Destination filename [small.config]? 
!!
1534 bytes copied in 0.012 secs (127833 bytes/sec)

■初期化

Router#erase startup-config 
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]
[OK]
Erase of nvram: complete
Router#reload
Proceed with reload? [confirm]

...

% Please answer 'yes' or 'no'.
Would you like to enter the initial configuration dialog? [yes/no]: no


■「flash:small.config」からの復元

Router>enable 
Router#show running-config | section Vlan1
interface Vlan1
 no ip address
Router#copy flash:small.config running-config
Destination filename [running-config]? 
 Multidrop Termination is already ENABLED
1534 bytes copied in 0.124 secs (12371 bytes/sec)
Router#show running-config | section Vlan1 
interface Vlan1
 ip address 172.31.31.253 255.255.255.0
Router#
Router#
Router#ping 172.31.31.254
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.31.31.254, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 1/1/1 ms