LoginSignup
1
0

More than 5 years have passed since last update.

StaticNATはアドレス変換後のACL設定がないとできなかったけどいらないはずなのになんでみたいな話

Last updated at Posted at 2018-06-13

はまったので

要件

  1. LinuxServerはグローバルIPを持たない
  2. グローバルIPの1.1.1.1にポート22022でアクセスするとLinuxServerにsshできるようにする
  3. グローバルIP1.1.1.1のポート22022は全開放する
[SRX]--------------------[LinuxServer]
1.1.1.1:22022            10.1.0.1:22

こうなった

1.22022ポートを指定するためのapplication設定を作成

set applications application SSH_22022 protocol tcp
set applications application SSH_22022 source-port 1-65535
set applications application SSH_22022 destination-port 22022

2.StaticNATを設定

set security nat static rule-set NAT rule ssh_22022 match destination-address 1.1.1.1/32
set security nat static rule-set NAT rule ssh_22022 match destination-port 22022
set security nat static rule-set NAT rule ssh_22022 match then static-nat prefix 10.1.0.1/32
set security nat static rule-set NAT rule ssh_22022 match then static-nat prefix mapped-port 22

3.source/destをanyにして1で作ったapplicationを許可

0.0.0.0:22022でLISTENなイメージ

set security policies from-zone Internet to-zone Internal policy Inernet-to-Internal match source-address any
set security policies from-zone Internet to-zone Internal policy Inernet-to-Internal match destination-address any
set security policies from-zone Internet to-zone Internal policy Inernet-to-Internal match application SSH_22022
set security policies from-zone Internet to-zone Internal policy Inernet-to-Internal then permit

これだと接続できない

マッピングするポートでもACL判定してるらしいので、
22番を通す設定を追加。
applicationはあらかじめSRXにプリセットのjunos-sshをつかう。

set security policies from-zone Internet to-zone Internal policy Inernet-to-Internal match application SSH_22022 junos-ssh

これでOK!
なんか22も許可されてんじゃないかと心配になるけど、
22022からはSSHできて、22ははねてくれるので大丈夫。

追記

コメントいただきました!ありがとうございます。
そうなんだろうな~って感じなんですが周囲を相当巻き込んで検証して
実際これじゃないと動かなかったという備忘録ですのでケースの1例ってことでよろしくです。

処理の順序がStatic NAT→Policyの順になるため、この例ではPolicyで22022を開ける必要はありません。
SSH_22022のアプリケーション作成も不要になります。
set security policies from-zone Internet to-zone Internal policy Inernet-to-Internal match junos-ssh

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0