labunix's blog

labunixのラボUnix

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

■RTX1000のバックアップ、初期化、復元
 RTX1000は「grep」が使えないモデル。
 シリアル接続に使うのはクロスケーブル(リバースケーブル)。
 私の環境ではCiscoルータのシリアルケーブルが使用中なので、USB変換ケーブルを使用。
 IP設定(初期IPなし)をして、Web管理コンソールに接続が出来るまで。

# env LANG=C screen /dev/ttyUSB0

> show status boot
RTX1000 Rev.8.01.29 (Fri Apr 15 11:50:44 2011)
Power-on boot

> show config list
No. Date       Time     Size    Sects   Comment
--- ---------- -------- ------- ------- --------------------------------------
 0  2013/11/11 23:58:10      89 070/070 
--- ---------- -------- ------- ------- --------------------------------------

■RTX1000自身がtftpサーバになるので、debian側ではtftp clientを用意する。

$ dpkg -l tftp | tail -1 | sed s/"   *"/","/g
ii,tftp,0.17-18,amd64,Trivial file transfer protocol client
$ sudo /sbin/ifconfig eth2 172.31.31.254/24 up
$ sudo route add -net 172.31.31.0/24 gw 172.31.31.200 eth2

■RTX1000側のtftpサーバの有効化とIP設定
 LANケーブルはLAN1のポート1に接続

> administrator
Password: 
# tftp host any
# ip lan1 address 172.31.31.200/24
# save
Saving ... CONFIG0 Done .
# show config 
# RTX1000 Rev.8.01.29 (Fri Apr 15 11:50:44 2011)
# MAC Address : XX:XX:XX:XX:XX:XX, XX:XX:XX:XX:XX:XX, XX:XX:XX:XX:XX:XX, 
# Memory 16Mbytes, 3LAN, 1BRI
# main:  RTX1000 ver=b0 serial=XXXXXXXXX MAC-Address=00:XX:XX:XX:XX:XX MAC-Addr
ess=00:XX:XX:XX:XX:XX MAC-Address=00:XX:XX:XX:XX:XX
timezone +09:00
console character ascii
ip lan1 address 172.31.31.200/24
tftp host any
# exit
> show status lan1
LAN1
Description:                    
Ethernet Address:               XX:XX:XX:XX:XX:XX
Operation mode setting:         Type (Link status)
               PORT1:           Auto Negotiation (100BASE-TX Full Duplex)
               PORT2:           Auto Negotiation (Link Down)
               PORT3:           Auto Negotiation (Link Down)
               PORT4:           Auto Negotiation (Link Down)
Maximum Transmission Unit(MTU): 1500 octets
Promiscuous mode:               OFF
Transmitted:                    53 packets (16130 octets)
Received:                       55 packets (2645 octets)

■ルータなので、GWやルーティングはRTX1000側にも設定出来る
 バックアップ、リストア時のパスワードは平文保存となる為、ここでは設定しない。

> administrator 
Password: 
# ip route default gateway 172.31.31.254
# no ip route default gateway 

■configのバックアップ(手動/パスなし)

$ tftp 172.31.31.200
tftp> status
Connected to 172.31.31.200.
Mode: netascii Verbose: off Tracing: off
Rexmt-interval: 5 seconds, Max-timeout: 25 seconds
tftp> get config
Received 1668 bytes in 0.0 seconds
tftp> quit

■configのバックアップ(自動/パスなし)
 日付のファイル名を追加した

$ (sleep 1; echo "get config config.`env LANG=C date '+%Y%m%d'`";
   sleep 1; echo "quit";) | tftp 172.31.31.200;echo
tftp> Received 1668 bytes in 0.0 seconds
tftp> 
$

■debian側に転送されたconfigの確認

$ ls config*
config	config.20140517
$ grep -v "^\$\|^#" config 
timezone +09:00
console character ascii
ip lan1 address 172.31.31.200/24
pp disable all
tunnel disable all
tftp host any

■時間の設定をしていないが、バックアップ時刻が含まれる。

$ diff -a config config.20140517 
6c6
< #	Reporting Date: Jan 1 09:40:19 1980
---
> #	Reporting Date: Jan 1 09:42:42 1980

■初期化

# cold start 
Password: 
Restarting ...
# show config 
# show config
# RTX1000 Rev.8.01.29 (Fri Apr 15 11:50:44 2011)
# MAC Address : XX:XX:XX:XX:XX:XX, XX:XX:XX:XX:XX:XX, XX:XX:XX:XX:XX:XX,
# Memory 16Mbytes, 3LAN, 1BRI
# main:  RTX1000 ver=b0 serial=XXXXXXXXX MAC-Address=00:XX:XX:XX:XX:XX MAC-Addr
ess=00:XX:XX:XX:XX:XX MAC-Address=00:XX:XX:XX:XX:XX

■復元
 tftpの設定は必要なので、debian側に保存している最小構成をシリアルコンソールに流し込む方が早い。

$ grep -v "^#\|^\$" config.20140517 
timezone +09:00
console character ascii
ip lan1 address 172.31.31.200/24
pp disable all
tunnel disable all
tftp host any

> administrator 
Password: 
# timezone +09:00
# console character ascii
# ip lan1 address 172.31.31.200/24
# pp disable all
# tunnel disable all
# tftp host any

■I常時、tftpサーバが稼働しているのはトラブルの元なので、
 IP制限をするか、停止しておく。
 パスワードの暗号化の解除、tftpの設定、configの保存という流れになるので停止がお勧め。

# no tftp host any
# tftp host 172.31.31.254
# no tftp host
# save
Saving ... CONFIG0 Done .

■最小のバックアップ目的のconfigでは無いリストア用のconfigからは、
 以下のようにtftpが有効にならないようにしておく方がベター。

$ sed -i s/"^tftp"/"# &"/g config.20140517$ grep tftp config.20140517 
# tftp host any