例:TCP および ICMP フラッドから保護するステートレス ファイアウォール フィルターの構成
この例では、TCP および ICMP サービス拒否攻撃から保護するステートレス ファイアウォール フィルターを作成する方法を示します。
要件
ステートレス ファイアウォール フィルターを構成する前に、デバイス初期化以外の特別な構成を行う必要はありません。
概要
この例では、TCP および ICMP パケットをポリシングするために呼び出され るステートレス ファイアウォール フィルターを作成します。protect-RE
ここで説明するポリサーを使用します。
tcp-connection-policer
- このポリサーは、TCP トラフィックを 1,000,000 ビット/秒(bps)に制限し、最大バースト サイズは 15,000 バイトです。いずれかの制限を超えるトラフィックは破棄されます。icmp-policer
- このポリサーは、ICMP トラフィックを 1,000,000 bps に制限し、最大バースト サイズは 15,000 バイトです。いずれかの制限を超えるトラフィックは破棄されます。
制限を指定する場合、帯域幅の制限は 32,000 bps から 32,000,000,000 bps まで、バーストサイズの制限は 1,500 バイトから 100,000,000 バイトまでです。制限を指定するときは、次の省略形を使用します。k (1,000)、m (1,000,000)、および g (1,000,000,000)。
各ポリサーは、フィルター項目のアクションに組み込まれます。この例には、次の用語が含まれています。
tcp-connection-term
- 送信元アドレスが 192.168.0.0/24 または 10.0.0.0/24 の特定の TCP パケットをポリシングします。これらのアドレスは、 プレフィックス リストで定義されます。trusted-addresses
フィルタリングされたパケットに含まれる パケット 一致条件は 、ビットフィールド一致条件 のエイリアスで、確立されたTCPセッションを示しますが、TCP接続の最初のパケットは示しません。
tcp-established
tcp-established
tcp-flags “(ack | rst)”
icmp-term
- ICMP パケットをポリシングします。すべてのICMPパケットがカウンターで カウントされます。icmp-counter
コマンドを使用して、ファイアウォールフィルター 内で用語を移動できます。insert
『Junos OS CLIユーザーガイド』の「挿入」を参照してください。inserthttps://www.juniper.net/documentation/en_US/junos/information-products/pathway-pages/junos-cli/junos-cli.html
ステートレス ファイアウォールは、インターフェイスの入力側または出力側、あるいはその両方に適用できます。デバイスを通過するパケットをフィルタリングするには、ルーティングエンジン以外のインターフェイスにファイアウォールフィルターを適用します。ルーティングエンジンから発信されるパケット、またはルーティングエンジンへ向かうパケットをフィルタリングするには、ファイアウォールフィルターをループバック(lo0)インターフェイスに適用します。
図 1は、サンプルのネットワークを示しています。
このファイアウォールフィルターは、ルーティングエンジンのトラフィックをTCPパケットに制限するため、レイヤー4に他のトランスポートプロトコルを使用するルーティングプロトコルは、このフィルターがアクティブな場合、セッションを正常に確立できません。デモンストレーションのために、この例ではデバイスR1とデバイスR2の間にOSPFを設定します。
CLIクイック構成は、図 1でのすべてのデバイスの設定を示しています。
セクション#configuration1102__policy-firewall-tcp-icmp-stは、デバイスR2の手順を説明します。
設定
手順
CLIクイック構成
ステートレス ファイアウォール フィルターをすばやく構成するには、次のコマンドをテキスト ファイルにコピーし、改行を削除してから、コマンドを CLI に貼り付けます。
デバイスR1
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.1/30 set interfaces lo0 unit 0 family inet address 192.168.0.1/32 primary set interfaces lo0 unit 0 family inet address 172.16.0.1/32 set protocols bgp group ext type external set protocols bgp group ext export send-direct set protocols bgp group ext peer-as 200 set protocols bgp group ext neighbor 10.0.0.2 set protocols ospf area 0.0.0.0 interface fe-1/2/0.0 set protocols ospf area 0.0.0.0 interface lo0.0 passive set policy-options policy-statement send-direct term 1 from protocol direct set policy-options policy-statement send-direct term 1 then accept set routing-options router-id 192.168.0.1 set routing-options autonomous-system 100
デバイスR2
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.2/30 set interfaces lo0 unit 0 family inet filter input protect-RE set interfaces lo0 unit 0 family inet address 192.168.0.2/32 primary set interfaces lo0 unit 0 family inet address 172.16.0.2/32 set protocols bgp group ext type external set protocols bgp group ext export send-direct set protocols bgp group ext neighbor 10.0.0.1 peer-as 100 set protocols ospf area 0.0.0.0 interface lo0.0 passive set protocols ospf area 0.0.0.0 interface fe-1/2/0.0 set policy-options prefix-list trusted-addresses 10.0.0.0/24 set policy-options prefix-list trusted-addresses 192.168.0.0/24 set policy-options policy-statement send-direct term 1 from protocol direct set policy-options policy-statement send-direct term 1 then accept set routing-options router-id 192.168.0.2 set routing-options autonomous-system 200 set firewall family inet filter protect-RE term tcp-connection-term from source-prefix-list trusted-addresses set firewall family inet filter protect-RE term tcp-connection-term from protocol tcp set firewall family inet filter protect-RE term tcp-connection-term from tcp-established set firewall family inet filter protect-RE term tcp-connection-term then policer tcp-connection-policer set firewall family inet filter protect-RE term tcp-connection-term then accept set firewall family inet filter protect-RE term icmp-term from source-prefix-list trusted-addresses set firewall family inet filter protect-RE term icmp-term from protocol icmp set firewall family inet filter protect-RE term icmp-term then policer icmp-policer set firewall family inet filter protect-RE term icmp-term then count icmp-counter set firewall family inet filter protect-RE term icmp-term then accept set firewall policer tcp-connection-policer filter-specific set firewall policer tcp-connection-policer if-exceeding bandwidth-limit 1m set firewall policer tcp-connection-policer if-exceeding burst-size-limit 15k set firewall policer tcp-connection-policer then discard set firewall policer icmp-policer filter-specific set firewall policer icmp-policer if-exceeding bandwidth-limit 1m set firewall policer icmp-policer if-exceeding burst-size-limit 15k set firewall policer icmp-policer then discard
ステップバイステップでの手順
次の例では、設定階層のいくつかのレベルに移動する必要があります。CLI のナビゲーションについては、を参照してください 。設定モードでのCLIエディターの使用
ステートレス ファイアウォール フィルターを構成して破棄するには:
デバイスインターフェイスを設定します。
[edit interfaces fe-1/2/0 unit 0 family inet ] user@R2# set address 10.0.0.2/30 [edit interfaces lo0 unit 0 family inet] user@R2# set address 192.168.0.2/32 primary user@R2# set address 172.16.0.2/32
BGP ピアリング セッションを構成します。
[edit protocols bgp group ext] user@R2# set type external user@R2# set export send-direct user@R2# set neighbor 10.0.0.1 peer-as 100
自律システム(AS)番号とルーターIDを設定します。
[edit routing-options] user@R2# set autonomous-system 200 user@R2# set router-id 192.168.0.2
OSPFを設定します。
[edit protocols ospf area 0.0.0.0] user@R2# set interface lo0.0 passive user@R2# set interface fe-1/2/0.0
信頼できるアドレスのリストを定義します。
[edit policy-options prefix-list trusted-addresses] user@R2# set 10.0.0.0/24 user@R2# set 192.168.0.0/24
直接ルートをアドバタイズするポリシーを設定します。
[edit policy-options policy-statement send-direct term 1] user@R2# set from protocol direct user@R2# set then accept
TCP ポリサーを構成します。
[edit firewall policer tcp-connection-policer] user@R2# set filter-specific user@R2# set if-exceeding bandwidth-limit 1m user@R2# set if-exceeding burst-size-limit 15k user@R2# set then discard
ICMP ポリサーを作成します。
[edit firewall policer icmp-policer] user@R2# set filter-specific user@R2# set if-exceeding bandwidth-limit 1m user@R2# set if-exceeding burst-size-limit 15k user@R2# set then discard
TCP フィルター規則を構成します。
[edit firewall family inet filter protect-RE term tcp-connection-term] user@R2# set from source-prefix-list trusted-addresses user@R2# set from protocol tcp user@R2# set from tcp-established user@R2# set then policer tcp-connection-policer user@R2# set then accept
ICMP フィルター規則を構成します。
[edit firewall family inet filter protect-RE term icmp-term] user@R2# set from source-prefix-list trusted-addresses user@R2# set from protocol icmp user@R2# set then policer icmp-policer user@R2# set then count icmp-counter user@R2# set then accept
ループバックインターフェイスにフィルターを適用します。
[edit interfaces lo0 unit 0] user@R2# set family inet filter input protect-RE
結果
コンフィギュレーション モードから 、 、 、 、および コマンドを入力して、コンフィギュレーションを確認します。show interfaces
show protocols
show policy-options
show routing-options
show firewall
出力結果に意図した設定内容が表示されない場合は、この例の手順を繰り返して設定を修正します。
user@R2# show interfaces fe-1/2/0 { unit 0 { family inet { address 10.0.0.2/30; } } } lo0 { unit 0 { family inet { filter { input protect-RE; } address 192.168.0.2/32 { primary; } address 172.16.0.2/32; } } }
user@R2# show protocols bgp { group ext { type external; export send-direct; neighbor 10.0.0.1 { peer-as 100; } } } ospf { area 0.0.0.0 { interface lo0.0 { passive; } interface fe-1/2/0.0; } }
user@R2# show policy-options prefix-list trusted-addresses { 10.0.0.0/24; 192.168.0.0/24; } policy-statement send-direct { term 1 { from protocol direct; then accept; } }
user@R2# show routing-options router-id 192.168.0.2; autonomous-system 200;
user@R2# show firewall family inet { filter protect-RE { term tcp-connection-term { from { source-prefix-list { trusted-addresses; } protocol tcp; tcp-established; } then { policer tcp-connection-policer; accept; } } term icmp-term { from { source-prefix-list { trusted-addresses; } protocol icmp; } then { policer icmp-policer; count icmp-counter; accept; } } } } policer tcp-connection-policer { filter-specific; if-exceeding { bandwidth-limit 1m; burst-size-limit 15k; } then discard; } policer icmp-policer { filter-specific; if-exceeding { bandwidth-limit 1m; burst-size-limit 15k; } then discard; } }
デバイスの設定が完了したら、設定モードから commit
を入力します。
検証
設定が正常に機能していることを確認します。
TCP ポリサーを確認するには、パケット生成ツールを使用できます。このタスクは、ここでは示されていません。
- 有効なステートレス ファイアウォール フィルターの表示
- Telnet を使用した TCP ファイアウォール フィルターで TCP が確立した状態の確認
- Telnet を使用した TCP ファイアウォール フィルターの信頼できるプレフィックス条件の確認
- OSPF を使用した TCP ファイアウォール フィルターの検証
- ICMPファイアウォールフィルターの検証
有効なステートレス ファイアウォール フィルターの表示
目的
ファイアウォールフィルターの設定を確認します。
アクション
動作モードからshow firewall
コマンドを入力します。
user@R2> show firewall Filter: protect-RE Counters: Name Bytes Packets icmp-counter 0 0 Policers: Name Bytes Packets icmp-policer 0 tcp-connection-policer 0
意味
出力には、デバイス R2 で有効なフィルタ、カウンタ、およびポリサーが表示されます。
Telnet を使用した TCP ファイアウォール フィルターで TCP が確立した状態の確認
目的
Telnet トラフィックが想定どおりに動作することを確認します。
アクション
デバイスが、条件を満たす ホストとの TCP セッションのみを確立できることを確認します。from tcp-established
デバイスR2から、デバイスR1とのBGPセッションが確立されていることを確認します。
user@R2> show bgp summary | match down Groups: 1 Peers: 1 Down peers: 0
デバイスR2からデバイスR1にtelnetでアクセス。
user@R2> telnet 192.168.0.1 Trying 192.168.0.1... Connected to R1.example.net. Escape character is '^]'. R1 (ttyp4) login:
デバイスR1からデバイスR2にtelnetで接続します。
user@R1> telnet 192.168.0.2 Trying 192.168.0.2... telnet: connect to address 192.168.0.2: Operation timed out telnet: Unable to connect to remote host
デバイスR2で、一致条件を無効に します。
from tcp-established
[edit firewall family inet filter protect-RE term tcp-connection-term] user@R2# deactivate from tcp-established user@R2# commit
デバイスR1からデバイスR2へのtelnet接続を再試行します。
user@R1> telnet 192.168.0.1 Trying 192.168.0.2... Connected to R2.example.net. Escape character is '^]'. R2 (ttyp4) login:
意味
次の情報を確認します。
予想通り、BGPセッションが確立されます。一致条件は、BGP セッションの確立をブロックすることは想定されていません。
from tcp-established
デバイスR2から、デバイスR1にtelnetで接続できます。デバイスR1にはファイアウォールフィルターが設定されていないため、これは予期される動作です。
デバイス R1 からデバイス R2 に telnet で接続することはできません。Telnet はトランスポート プロトコルとして TCP を使用するため、この結果は驚くべきものかもしれません。Telnet接続できない原因は、 一致条件です。
from tcp-established
この一致条件は、デバイスR2で受け入れられるTCPトラフィックのタイプを制限します。この一致条件が無効になると、Telnet セッションは成功します。
Telnet を使用した TCP ファイアウォール フィルターの信頼できるプレフィックス条件の確認
目的
Telnet トラフィックが想定どおりに動作することを確認します。
アクション
デバイスが、信頼できる送信元アドレスの 1 つと一致する IP アドレスのホストとの Telnet セッションのみを確立できることを確認します。例えば、信頼できるアドレスプレフィックスの1つを持つ別のホストから、 コマンドを使用してデバイスにログインします。telnet
また、信頼できない送信元アドレスとの Telnet セッションがブロックされていることを確認してください。
デバイスR1から、信頼できない送信元アドレスからデバイスR2にtelnet。
user@R1> telnet 172.16.0.2 source 172.16.0.1 Trying 172.16.0.2... ^C
デバイスR2から、信頼できるプレフィックスのリストに172.16/16を追加します。
[edit policy-options prefix-list trusted-addresses] user@R2# set 172.16.0.0/16 user@R2# commit
デバイスR1からデバイスR2へのtelnet接続を再試行します。
user@R1> telnet 172.16.0.2 source 172.16.0.1 Trying 172.16.0.2... Connected to R2.example.net. Escape character is '^]'. R2 (ttyp4) login:
意味
次の情報を確認します。
デバイス R1 から、信頼できない送信元アドレスでデバイス R2 に telnet で接続することはできません。信頼できるプレフィックスのリストに 172.16/16 プレフィックスが追加されると、送信元アドレス 172.16.0.1 からの telnet 要求が受け入れられます。
OSPF セッションの確立はブロックされます。OSPFは、そのトランスポートプロトコルとしてTCPを使用しません。一致条件が無効 になった後、OSPF セッションの確立はブロックされません。
from protocol tcp
OSPF を使用した TCP ファイアウォール フィルターの検証
目的
OSPFトラフィックが期待通りに動作することを確認します。
アクション
デバイスが OSPF 接続を確立できないことを確認します。
デバイスR1から、OSPFセッションを確認します。
user@R1> show ospf neighbor Address Interface State ID Pri Dead 10.0.0.2 fe-1/2/0.0 Init 192.168.0.2 128 34
デバイスR2から、OSPFセッションを確認します。
user@R2> show ospf neighbor
デバイスR2から、一致条件を削除します 。
from protocol tcp
[edit firewall family inet filter protect-RE term tcp-connection-term] user@R2# deactivate from protocol user@R2# commit
デバイスR1から、OSPFセッションを再確認します。
user@R1> show ospf neighbor Address Interface State ID Pri Dead 10.0.0.2 fe-1/2/0.0 Full 192.168.0.2 128 36
デバイスR2から、OSPFセッションを再確認します。
user@R2> show ospf neighbor Address Interface State ID Pri Dead 10.0.0.1 fe-1/2/0.0 Full 192.168.0.1 128 39
意味
次の情報を確認します。
OSPF セッションの確立はブロックされます。OSPFは、そのトランスポートプロトコルとしてTCPを使用しません。一致条件が無効 になると、OSPFセッションの確立に成功します。
from protocol tcp
ICMPファイアウォールフィルターの検証
目的
ICMP パケットがポリシングおよびカウントされていることを確認します。また、信頼できない送信元アドレスからの要求の場合は、ping 要求が破棄されるようにします。
アクション
前の検証手順で行った設定変更を元に戻します。
TCP ファイアウォール設定を再度アクティブにし、172.16/16 の信頼できる送信元アドレスを削除します。
[edit firewall family inet filter protect-RE term tcp-connection-term] user@R2# activate from protocol user@R2# activate from tcp-established [edit policy-options prefix-list trusted-addresses] user@R2# delete 172.16.0.0/16 user@R2# commit
デバイスR1から、デバイスR2のループバックインターフェイスにpingを実行します。
user@R1> ping 192.168.0.2 rapid count 600 size 2000 PING 192.168.0.2 (192.168.0.2): 2000 data bytes !!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!!!.!!!!!!!!.!!!!!!!!.!!!!!!!! --- 192.168.0.2 ping statistics --- 600 packets transmitted, 536 packets received, 10% packet loss pinground-trip min/avg/max/stddev = 2.976/3.405/42.380/2.293 ms
デバイスR2から、ファイアウォールの統計情報を確認します。
user@R2> show firewall Filter: protect-RE Counters: Name Bytes Packets icmp-counter 1180804 1135 Policers: Name Bytes Packets icmp-policer 66 tcp-connection-policer 0
デバイスR1の信頼できない送信元アドレスから、デバイスR2のループバックインターフェイスにpingリクエストを送信します。
user@R1> ping 172.16.0.2 source 172.16.0.1 PING 172.16.0.2 (172.16.0.2): 56 data bytes ^C --- 172.16.0.2 ping statistics --- 14 packets transmitted, 0 packets received, 100% packet loss
意味
次の情報を確認します。
ping の出力は、10% のパケット損失が発生していることを示しています。
ICMPパケットカウンターが増加しており、ICMPポリサーも増加しています。
デバイスR2は、 コマンドにICMP応答を送信しません。
ping 172.16.0.2 source 172.16.0.1