例:ユニキャスト RPF の設定(ルーター上)
この例では、カスタマーエッジインターフェイスでユニキャストRPFを設定して着信トラフィックをフィルタリングすることにより、イングレスインターフェイスをサービス拒否(DoS)および分散型サービス拒否(DDoS)攻撃から防御する方法を示します。
必要条件
デバイスの初期化以上の特別な設定は必要ありません。
概要
この例では、デバイス A は OSPF を使用して、デバイス D に接続するリンクのプレフィックスをアドバタイズしています。デバイス B にはユニキャスト RPF が設定されています。OSPF は、機器 B と機器 C の間のリンク、および機器 A と機器 C の間のリンクでは有効ですが、機器 A と機器 B の間のリンクでは有効ではありません。そのため、機器Bは機器Cを経由して機器Dへのルートを学習します。
DHCP または BOOTP を使用する環境でイングレス フィルタリングを使用する場合は、送信元アドレスが 0.0.0.0、宛先アドレスが 255.255.255.255 のパケットが、必要に応じてルーターのリレー エージェントに到達できるようにする必要があります。
この例には、失敗フィルターも含まれています。パケットがユニキャスト RPF チェックに不合格になると、失敗フィルターが評価され、パケットを受け入れるかどうかが判断されます。この例のフェイルフィルターは、デバイスBのインターフェイスがDHCP(動的ホスト構成プロトコル)パケットを受け入れることを可能にします。フィルターは、送信元アドレスが 0.0.0.0、宛先アドレスが 255.255.255.255 のすべてのパケットを受け入れます。
構成
CLIクイック構成
この例をすばやく設定するには、次のコマンドをコピーしてテキストファイルに貼り付け、改行を削除して、ネットワーク構成に合わせて必要な詳細を変更し、 [edit]
階層レベルのCLIにコマンドをコピーして貼り付けます。
1 デバイスA 1
set interfaces fe-1/2/0 unit 1 family inet address 10.0.0.1/30 set interfaces fe-0/0/2 unit 5 family inet address 10.0.0.5/30 set interfaces fe-0/0/1 unit 17 family inet address 10.0.0.17/30 set interfaces fe-0/1/1 unit 25 family inet address 10.0.0.25/30 set interfaces fe-1/1/1 unit 29 family inet address 10.0.0.29/30 set protocols ospf export send-direct set protocols ospf area 0.0.0.0 interface fe-0/1/1.25 set protocols ospf area 0.0.0.0 interface fe-1/1/1.29 set policy-options policy-statement send-direct from protocol direct set policy-options policy-statement send-direct from route-filter 10.0.0.16/30 exact set policy-options policy-statement send-direct then accept
1 デバイスB 1
set interfaces fe-1/2/0 unit 2 family inet rpf-check fail-filter rpf-special-case-dhcp set interfaces fe-1/2/0 unit 2 family inet address 10.0.0.2/30 set interfaces fe-1/1/1 unit 6 family inet rpf-check fail-filter rpf-special-case-dhcp set interfaces fe-1/1/1 unit 6 family inet address 10.0.0.6/30 set interfaces fe-0/1/1 unit 9 family inet rpf-check fail-filter rpf-special-case-dhcp set interfaces fe-0/1/1 unit 9 family inet address 10.0.0.9/30 set interfaces fe-0/1/0 unit 13 family inet rpf-check fail-filter rpf-special-case-dhcp set interfaces fe-0/1/0 unit 13 family inet address 10.0.0.13/30 set protocols ospf area 0.0.0.0 interface fe-0/1/1.9 set protocols ospf area 0.0.0.0 interface fe-0/1/0.13 set routing-options forwarding-table unicast-reverse-path active-paths set firewall filter rpf-special-case-dhcp term allow-dhcp from source-address 0.0.0.0/32 set firewall filter rpf-special-case-dhcp term allow-dhcp from destination-address 255.255.255.255/32 set firewall filter rpf-special-case-dhcp term allow-dhcp then count rpf-dhcp-traffic set firewall filter rpf-special-case-dhcp term allow-dhcp then accept set firewall filter rpf-special-case-dhcp term default then log set firewall filter rpf-special-case-dhcp term default then reject
1 デバイスC 1
set interfaces fe-1/2/0 unit 10 family inet address 10.0.0.10/30 set interfaces fe-0/0/2 unit 14 family inet address 10.0.0.14/30 set interfaces fe-1/0/2 unit 21 family inet address 10.0.0.21/30 set interfaces fe-1/2/2 unit 26 family inet address 10.0.0.26/30 set interfaces fe-1/2/1 unit 30 family inet address 10.0.0.30/30 set protocols ospf area 0.0.0.0 interface fe-1/2/0.10 set protocols ospf area 0.0.0.0 interface fe-0/0/2.14 set protocols ospf area 0.0.0.0 interface fe-1/2/2.26 set protocols ospf area 0.0.0.0 interface fe-1/2/1.30
デバイスD 1
set interfaces fe-1/2/0 unit 18 family inet address 10.0.0.18/30
デバイスE 1
set interfaces fe-1/2/0 unit 22 family inet address 10.0.0.22/30
デバイス A の設定
手順
次の例では、設定階層のいくつかのレベルに移動する必要があります。CLIのナビゲーションについては、「 1 コンフィグレーション・モードでのCLIエディタの使用」を参照してください。
デバイス A を設定するには:
インターフェイスを設定します。
[edit interfaces] user@A# set fe-1/2/0 unit 1 family inet address 10.0.0.1/30 user@A# set fe-0/0/2 unit 5 family inet address 10.0.0.5/30 user@A# set fe-0/0/1 unit 17 family inet address 10.0.0.17/30 user@A# set fe-0/1/1 unit 25 family inet address 10.0.0.25/30 user@A# set fe-1/1/1 unit 29 family inet address 10.0.0.29/30
OSPFを設定します。
[edit protocols ospf] user@A# set export send-direct user@A# set area 0.0.0.0 interface fe-0/1/1.25 user@A# set area 0.0.0.0 interface fe-1/1/1.29
ルーティングポリシーを設定します。
[edit policy-options policy-statement send-direct] user@A# set from protocol direct user@A# set from route-filter 10.0.0.16/30 exact user@A# set then accept
デバイス A の設定が完了したら、設定をコミットします。
[edit] user@A# commit
デバイス B の設定
手順
次の例では、設定階層のいくつかのレベルに移動する必要があります。CLIのナビゲーションについては、「 1 コンフィグレーション・モードでのCLIエディタの使用」を参照してください。
デバイス B を設定するには:
インターフェイスを設定します。
[edit interfaces] user@B# set fe-1/2/0 unit 2 family inet address 10.0.0.2/30 user@B# set fe-1/1/1 unit 6 family inet address 10.0.0.6/30 user@B# set fe-0/1/1 unit 9 family inet address 10.0.0.9/30 user@B# set fe-0/1/0 unit 13 family inet address 10.0.0.13/30
OSPFを設定します。
[edit protocols ospf area 0.0.0.0] user@B# set interface fe-0/1/1.9 user@B# set interface fe-0/1/0.13
ユニキャスト RPF を設定し、オプションの失敗フィルターを適用します。
[edit interfaces] user@B# set fe-1/2/0 unit 2 family inet rpf-check fail-filter rpf-special-case-dhcp user@B# set fe-1/1/1 unit 6 family inet rpf-check fail-filter rpf-special-case-dhcp user@B# set fe-0/1/1 unit 9 family inet rpf-check fail-filter rpf-special-case-dhcp user@B# set fe-0/1/0 unit 13 family inet rpf-check fail-filter rpf-special-case-dhcp
(オプション)パケットがRPFチェックに失敗した場合に評価される失敗フィルターを設定します。
[edit firewall filter rpf-special-case-dhcp] user@B# set term allow-dhcp from source-address 0.0.0.0/32 user@B# set term allow-dhcp from destination-address 255.255.255.255/32 user@B# set term allow-dhcp then count rpf-dhcp-traffic user@B# set term allow-dhcp then accept user@B# set term default then log user@B# set term default then reject
(オプション)RPF チェックで考慮されるアクティブ パスのみを設定します。
これはデフォルトの動作です。
[edit routing-options forwarding-table] user@B# set unicast-reverse-path active-paths
デバイス B の設定が完了したら、設定をコミットします。
[edit] user@B# commit
業績
show firewall
、show interfaces
、show protocols
、show routing-options
、および show policy-options
コマンドを発行して、設定を確認します。出力結果に意図した設定内容が表示されない場合は、この例の手順を繰り返して設定を修正します。
1 デバイスA 1
user@A# show interfaces fe-1/2/0 { unit 1 { family inet { address 10.0.0.1/30; } } } fe-0/0/2 { unit 5 { family inet { address 10.0.0.5/30; } } } fe-0/0/1 { unit 17 { family inet { address 10.0.0.17/30; } } } fe-0/1/1 { unit 25 { family inet { address 10.0.0.25/30; } } } fe-1/1/1 { unit 29 { family inet { address 10.0.0.29/30; } } }
user@A# show protocols ospf { export send-direct; area 0.0.0.0 { interface fe-0/1/1.25; interface fe-1/1/1.29; } }
user@A# show policy-options policy-statement send-direct { from { protocol direct; route-filter 10.0.0.16/30 exact; } then accept; }
1 デバイスB 1
user@B# show firewall filter rpf-special-case-dhcp { term allow-dhcp { from { source-address { 0.0.0.0/32; } destination-address { 255.255.255.255/32; } } then { count rpf-dhcp-traffic; accept; } } term default { then { log; reject; } } } user@B# show interfaces fe-1/2/0 { unit 2 { family inet { rpf-check fail-filter rpf-special-case-dhcp; address 10.0.0.2/30; } } } fe-1/1/1 { unit 6 { family inet { rpf-check fail-filter rpf-special-case-dhcp; address 10.0.0.6/30; } } } fe-0/1/1 { unit 9 { family inet { rpf-check fail-filter rpf-special-case-dhcp; address 10.0.0.9/30; } } } fe-0/1/0 { unit 13 { family inet { rpf-check fail-filter rpf-special-case-dhcp; address 10.0.0.13/30; } } }
user@B# show protocols ospf { area 0.0.0.0 { interface fe-0/1/1.9; interface fe-0/1/0.13; } }
user@B# show routing-options forwarding-table { unicast-reverse-path active-paths; }
CLIクイック設定に示すように、デバイスC、デバイスD、およびデバイスEで設定を入力します。
検証
設定が正常に機能していることを確認します。
ユニキャスト RPF が有効になっていることを確認する
目的
デバイス B のインターフェイスでユニキャスト RPF が有効になっていることを確認します。
アクション
user@B> show interfaces fe-0/1/0.13 extensive Logical interface fe-0/1/0.13 (Index 73) (SNMP ifIndex 553) (Generation 208) Flags: SNMP-Traps 0x4000 Encapsulation: ENET2 Traffic statistics: Input bytes : 999390 Output bytes : 1230122 Input packets: 12563 Output packets: 12613 Local statistics: Input bytes : 998994 Output bytes : 1230122 Input packets: 12563 Output packets: 12613 Transit statistics: Input bytes : 396 0 bps Output bytes : 0 0 bps Input packets: 0 0 pps Output packets: 0 0 pps Protocol inet, MTU: 1500, Generation: 289, Route table: 22 Flags: Sendbcast-pkt-to-re, uRPF RPF Failures: Packets: 0, Bytes: 0 Addresses, Flags: Is-Preferred Is-Primary Destination: 10.0.0.12/30, Local: 10.0.0.13, Broadcast: 10.0.0.15, Generation: 241
意味
uRPF フラグは、このインターフェイスでユニキャスト RPF が有効になっていることを確認します。
送信元アドレスがブロックされていることを確認する
目的
ping
コマンドを使用して、デバイス B が予期しない送信元アドレスからのトラフィックをブロックしていることを確認します。
アクション
デバイスAから、送信元アドレスとして10.0.0.17を使用して、デバイスBのインターフェイスにpingを実行します。
user@A> ping 10.0.0.6 source 10.0.0.17 PING 10.0.0.6 (10.0.0.6): 56 data bytes ^C --- 10.0.0.6 ping statistics --- 3 packets transmitted, 0 packets received, 100% packet loss
意味
予想どおり、ping 操作は失敗します。
送信元アドレスのブロックが解除されていることを確認する
目的
ping
コマンドを使用して、RPF チェックが非アクティブ化されたときにデバイス B がトラフィックをブロックしないようにします。
アクション
インターフェイスの 1 つで RPF チェックを無効にします。
ping 操作を再実行します。
user@B> deactivate interfaces fe-1/1/1.6 family inet rpf-check user@A> ping 10.0.0.6 source 10.0.0.17 PING 10.0.0.2 (10.0.0.2): 56 data bytes 64 bytes from 10.0.0.2: icmp_seq=0 ttl=63 time=1.316 ms 64 bytes from 10.0.0.2: icmp_seq=1 ttl=63 time=1.263 ms ^C --- 10.0.0.2 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max/stddev = 1.263/1.289/1.316/0.027 ms
意味
予想どおり、ping 操作は成功します。