labunix's blog

labunixのラボUnix

SRX100の初期設定、初期化、バックアップ、リストア

■SRX100の初期設定、初期化、バックアップ、リストア
 以下を参考に。

 SRX100サービスゲートウェイクイックスタートガイド
 http://www.juniper.net/techpubs/hardware/junos-srx/srx100/translated/japanese/530-034743-JA_Juniper.pdf

 JUNOS - CLI/GUI接続、起動方法、ログイン、停止方法、初期化方法、オレンジのALARM
 http://www.infraeye.com/study/junos2.html

■JUNOS OSとはいえ、基本的にただのFreeBSD。
 そして結構起動が遅い。

FreeBSD/MIPS U-Boot bootstrap loader, Revision 2.5
...
JAIL MFS partition created
...

■とりあえず初期化

 前面パネルのRESET CONFIGボタンを15秒間押し続ける。

■ログイン、ログアウト
 root、パス無し。

$ sudo screen /dev/ttyS0
Amnesiac (ttyu0)
login: root
root@% exit
logout

[Ctrl][a][k]
Really kill this window [y/n]y

■「Rescue configuration is not setALARMの対処
 ※初期状態ではALARMランプが橙点灯している。

root@% cli
root> show system alarms 
2 alarms currently active
Alarm time               Class  Description
2014-12-22 04:03:52 UTC  Minor  Rescue configuration is not set
2014-12-22 03:58:52 UTC  Minor  Autorecovery information needs to be saved
root> request system configuration rescue save 
root> show system configuration rescue 
1 alarms currently active
Alarm time               Class  Description
2014-12-22 03:58:52 UTC  Minor  Autorecovery information needs to be saved

root> show system configuration rescue
## Last changed: 2014-12-22 03:57:06 UTC
version 12.1X44-D25.5;
system {
    autoinstallation {
        delete-upon-commit;
        traceoptions {
            level verbose;
            flag {
                all;
            }
        }
        interfaces {
            fe-0/0/0 {
                bootp;
            }
        }
    }
    name-server {
        208.67.222.222;
        208.67.220.220;
    }
    services {
        ssh;

root> 

■余談ながら、初期設定のDNSはOpenDNS。

$ whois 208.67.222.222 | grep -i "OrgName\|date"
RegDate:        2006-06-06
Updated:        2012-03-02
OrgName:        OpenDNS, LLC
RegDate:        2008-02-26
Updated:        2014-01-06

$ whois 208.67.220.220 | grep -i "OrgName\|date"
RegDate:        2006-06-06
Updated:        2012-03-02
OrgName:        OpenDNS, LLC
RegDate:        2008-02-26
Updated:        2014-01-06

■もう一つの「Autorecovery information needs to be saved」ALARMの対処
 ※まだALARMは橙点灯、「show system alarms」の結果が空になるとALARMが消灯した。

root> show system alarms 
1 alarms currently active
Alarm time               Class  Description
2014-12-22 03:58:52 UTC  Minor  Autorecovery information needs to be saved
root> show system autorecovery state 
Configuration:
  File             Recovery Information    Integrity Check    Action / Status
  rescue.conf.gz   Saved                   Passed             None
BSD Labels:
  Slice            Recovery Information    Integrity Check    Action / Status
  s1               Not Saved               Not checked        Requires save
  s2               Not Saved               Not checked        Requires save
  s3               Not Saved               Not checked        Requires save
  s4               Not Saved               Not checked        Requires save

root> request system autorecovery state save 
Saving config recovery information
Saving license recovery information
Saving BSD label recovery information

root> show system alarms                        
No alarms currently active

root> show system autorecovery state 
Configuration:
  File             Recovery Information    Integrity Check    Action / Status
  rescue.conf.gz   Saved                   Passed             None
BSD Labels:
  Slice            Recovery Information    Integrity Check    Action / Status
  s1               Saved                   Passed             None
  s2               Saved                   Passed             None
  s3               Saved                   Passed             None
  s4               Saved                   Passed             None

■FreeBSDベースなので、めちゃくちゃ普通にshutdownが走る。。。
 電源が切れたら電源ケーブルを抜く。
 再度電源を入れるには、全面パネルの電源ボタンを押す。

root> request system power-off 
Power Off the system ? [yes,no] (no) yes 

Shutdown NOW!
...
Turning the system power off.

■ただのFreeBSDというのは、デフォルトシェルを見れば分かる。

root@% date
Mon Dec 22 04:21:54 UTC 2014
root@% uname -iprs
JUNOS 12.1X44-D25.5 mips JUNIPER_OCTEON
root@% echo $SHELL
/bin/csh
root@% ls /bin/*sh
/bin/csh        /bin/sh         /bin/tcsh

■ScreenOS風のコマンド
 get系ではなくshow系にコマンド体系が変わっている。

root@% cli
root> show version 
Model: srx100h
JUNOS Software Release [12.1X44-D25.5]
root> show chassis hardware 
Hardware inventory:
Item             Version  Part number  Serial number     Description
Chassis                                XXXXXXXXXXXX      SRX100H
Routing Engine   REV 08   XXX-XXXXXX   XXXXXXXXXXXX      RE-SRX100H
FPC 0                                                    FPC
  PIC 0                                                  8x FE Base PIC
Power Supply 0  

■初期状態では、0/0はUnTrust、0/10/7はTrust。
 Trustは「vlan unit 0」に属している。
 IPとログインパスワードを設定すれば、Web管理画面で操作出来る。

root> configure
root# delete interfaces vlan unit 0 family inet address 192.168.1.1/24
root# set interfaces vlan unit 0 family inet address 172.31.31.253/24 
root# set system root-authentication plain-text-password    
New password:
Retype new password:
root# commit
commit complete

[edit]
root# exit
root> show interfaces vlan terse    
Interface               Admin Link Proto    Local                 Remote
vlan                    up    up  
vlan.0                  up    up   inet     172.31.31.253/24

root> show configuration | display set
...
set interfaces fe-0/0/0 unit 0
set interfaces fe-0/0/1 unit 0 family ethernet-switching vlan members vlan-trust
set interfaces fe-0/0/2 unit 0 family ethernet-switching vlan members vlan-trust
set interfaces fe-0/0/3 unit 0 family ethernet-switching vlan members vlan-trust
set interfaces fe-0/0/4 unit 0 family ethernet-switching vlan members vlan-trust
set interfaces fe-0/0/5 unit 0 family ethernet-switching vlan members vlan-trust
set interfaces fe-0/0/6 unit 0 family ethernet-switching vlan members vlan-trust
set interfaces fe-0/0/7 unit 0 family ethernet-switching vlan members vlan-trust
set interfaces vlan unit 0 family inet address 172.31.31.253/24
set vlans vlan-trust vlan-id 3
set vlans vlan-trust l3-interface vlan.0

■ssh経由のバックアップ
 ユーザをちゃんと作った方が良い。
 ポートは22固定の様子。
 IPも普段は待ち受けてないので、Web経由にしよう。。。

root> file copy /config/juniper.conf.gz 172.31.31.254:/home/labunix
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.31.31.254' (ECDSA) to the list of known hosts.
root@172.31.31.254's password: 
juniper.conf.gz                               100% 1090     1.1KB/s   00:00    
■Linuxからなので以下とか。
 というかSRX100でもFreeBSDコマンドで出来る方法だったりする。。。

$ script junos.log
$ ssh root@172.31.31.253
root@% cli
root> show configuration | no-more 

■リストア
 scriptコマンドで取得したファイルをviで余分な箇所を削除、
 リストアしてみる。
 稼働中のコンフィグと同じなので、差分は無いし、正常にコミットできる。

root@% cli
root> configure 
Entering configuration mode

[edit]
root# load override junos.log 
load complete

[edit]
root# show | compare 

[edit]
root# commit 
commit complete

[edit]