labunix's blog

labunixのラボUnix

SRX100HのJ-Web待受IPをコンソールから変更する。

■SRX100HのJ-Web待受IPをコンソールから変更する。
 物理も仮想も大きくは変わらない。

 SRX100の初期設定、初期化、バックアップ、リストア
 http://labunix.hateblo.jp/entry/20141222/1419228797

 ダウンロードしたJUNOSのマニュアルを整理してみた。
 http://labunix.hateblo.jp/entry/20150803/1438533985

 vmplayerでvSRXを試す。
 http://labunix.hateblo.jp/entry/20150412/1428767862

■注意点
 コマンドで先に変更してしまうと初期設定のウイザードがあることすら知らないかも知れない。
 SSGの時も後からでもウイザードを起動出来たけれど、SRXでも出来る。
 J-webで[Configure]->[Tasks]->[Run Setup Wizard]の順にたどると初期設定ウイザードが起動する。

 ロールバックとか余計なことをしているが、要点としては以下の3つの作業を行う。

 rootパスワードを設定
 DHCPサーバの無効化、デフォルトの待受IP[192.168.1.1]の削除
 待受IPの設定

■SRXでも「request system power-off」が使えるのに、
 よく分からない事で時間を使っていたりしていますが。。。

 vSRXの電源OFFを行うタイミングについて確認してみる。
 http://labunix.hateblo.jp/entry/20150830/1440878778
 
■今回はResetボタンを15秒間長押しでリセット。
 [commit]と同じくらいの時間待つが、初期化メッセージは表示されなかった。

■alarmランプの橙点灯対応として以下コマンドを流し込み。

cli
show system alarms
request system configuration rescue save
show system alarms

■オペレーションモードでコマンドを流し込んだ結果は以下。
 [Rescue configuration is not set]がalarm橙点灯の原因で、
 それを解消したので消灯したことが分かる。

root> show system alarms 
1 alarms currently active
Alarm time               Class  Description
2015-09-19 13:36:21 UTC  Minor  Rescue configuration is not set

root> request system configuration rescue save 

root> show system alarms 
No alarms currently active

■rootパスワードの設定にもコミットが必要なので注意。

root> configure
root# set system root-authentication plain-text-password 
New password:
Retype new password:
root# show | compare 
[edit system]
+   root-authentication {
+       encrypted-password "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; ## SECRET-DATA
+   }

[edit]
root# commit 
commit complete

■なお、rootパスワードを設定しないと[commit]に失敗する。

root# commit                                                             
[edit]
  'system'
    Missing mandatory statement: 'root-authentication'
error: commit failed: (missing statements)

■SSG同様に、DHCPを無効にしてIPを変更すればOKです。

 2台目のSSG5をシリアル接続で遊ぶ
 http://labunix.hateblo.jp/entry/20140430/1398826255

■初期IPは「192.168.1.1」と分かっているのでサブネットで検索する。
 オペレーションモードの場合は[show]ではなく、[show configuration]。
 SSGでは[bgroup0]に属していた[fe-0/0/7][vlan.0]に属する。

root> show configuration | display set | match 192.168.1
set system services dhcp router 192.168.1.1
set system services dhcp pool 192.168.1.0/24 address-range low 192.168.1.2
set system services dhcp pool 192.168.1.0/24 address-range high 192.168.1.254
set interfaces vlan unit 0 family inet address 192.168.1.1/24

root> show configuration | display set | match vlan.0 
set system services web-management http interface vlan.0
set system services web-management https interface vlan.0
set security zones security-zone trust interfaces vlan.0
set vlans vlan-trust l3-interface vlan.0

■ということで自身がアクセスしたいIPに書き換えた以下のコマンドを
 オペレーションモードから流し込む想定で記述。

configure
delete system services dhcp router 192.168.1.1
delete interfaces vlan unit 0 family inet address 192.168.1.1/24
set interfaces vlan unit 0 family inet address 172.17.17.254/24
show | compare
commit and-quit

■流し込んだ結果は以下。

root> configure 
delete system servicEntering configuration mode

es dhcp router 192.168.1.1
delete interfaces vlan unit 0 family inet address 192.168.1.1/24
set interfaces vlan unit 0 family inet address 172.17.17.254/24
show | compare
commit and-quit
[edit]
root# delete system services dhcp router 192.168.1.1 

[edit]
root# delete interfaces vlan unit 0 family inet address 192.168.1.1/24 

[edit]
root# set interfaces vlan unit 0 family inet address 172.17.17.254/24 

[edit]
root# show | compare 
[edit system services dhcp]
-    router {
-        192.168.1.1;
-    }
[edit interfaces vlan unit 0 family inet]
+       address 172.17.17.254/24;
-       address 192.168.1.1/24;

[edit]
root# commit and-quit 

■デフォルトでは05までの
 5世代まで前の設定に[rollback]出来る。

root> show configuration | display set | match rollback 
set system max-configuration-rollbacks 50から5までは6つなのだけど、
 [0]は今のコンフィグなので、遡れる世代は5つ。

root> configure    
Entering configuration mode

[edit]
root# rollback ?
Possible completions:
  <[Enter]>            Execute this command
  0                    2015-09-19 13:56:26 UTC by root via cli 
  1                    2015-09-19 13:55:36 UTC by root via cli 
  2                    2015-09-19 13:52:53 UTC by root via cli 
  3                    2015-09-19 13:50:40 UTC by root via cli 
  4                    2015-09-19 13:43:54 UTC by root via cli 
  5                    2015-09-19 13:36:13 UTC by root via button 
  rescue               2015-09-19 13:38:05 UTC by root via cli 
  |                    Pipe through a command
[edit]

root# show | compare 

[edit]
root# rollback 1 
load complete

[edit]
root# show | compare 
[edit system services dhcp]
+    router {
+        192.168.1.1;
+    }
[edit interfaces vlan unit 0 family inet]
+       address 192.168.1.1/24;
-       address 172.17.17.254/24;

■最大は49世代。[0]は今の設定を保存するので、
 実質的に設定の世代管理をしない。

root# set system max-configuration-rollbacks ?
Possible completions:
  <max-configuration-rollbacks>  Number of rollback configuration files (0..49)

■ロールバックして再度IPを変更して設定してみる。
 まずはロールバック。

root# rollback 2        
load complete

[edit]
root# show | compare    
[edit system services dhcp]
+    router {
+        192.168.1.1;
+    }
[edit interfaces vlan unit 0 family inet]
+       address 192.168.1.1/24;
-       address 172.17.17.254/24;

[edit]
root# commit 
commit complete

■IPを[254]から[201]に変更して流し込み。

configure
delete system services dhcp router 192.168.1.1
delete interfaces vlan unit 0 family inet address 192.168.1.1/24
set interfaces vlan unit 0 family inet address 172.17.17.201/24
show | compare
commit and-quit

■今の設定を確認する。

root> show configuration | display set | match 172.17.17. 
set interfaces vlan unit 0 family inet address 172.17.17.201/24

■J-Webとsshにログインしてみる。
 Fortigateで[dmz]->[internal]でNATしているので、FROMはFortigateのIP。

$ ssh root@172.31.31.201
root@172.31.31.201's password: 
--- JUNOS 12.1X44-D25.5 built 2013-10-24 20:29:21 UTC

root> show system users                 
 2:30PM  up 1:32, 1 user, load averages: 0.12, 0.10, 0.08
USER     TTY      FROM                              LOGIN@  IDLE WHAT
root     p0       172.17.17.202                    2:29PM      - cli           

■普通に以下のように同一のサブネットでログインしているのと同じなので、
 特に気にならない。

$ ssh root@172.17.17.201
root@172.17.17.201's password:

■デフォルトでは[VLAN 3]のタグVLANに属しているようだ。

root> show interfaces vlan terse 
Interface               Admin Link Proto    Local                 Remote
vlan                    up    up  
vlan.0                  up    up   inet     172.17.17.201/24

root> show vlans 
Name           Tag     Interfaces
default        1      
                       None
vlan-trust     3      
                       fe-0/0/1.0, fe-0/0/2.0, fe-0/0/3.0, fe-0/0/4.0,
                       fe-0/0/5.0, fe-0/0/6.0, fe-0/0/7.0*