例:パケットを破棄インターフェイスに転送する
この例では、ルーティングを破棄してサービス拒否(DoS)攻撃を緩和し、重要なネットワークリソースを外部攻撃から保護し、顧客に保護サービスを提供して、各顧客が独自の保護を開始し、DoSの試みをログに記録して追跡する方法を示しています。
要件
この例を設定する前に、デバイス初期化以外の特別な設定は必要ありません。
概要
ルーティングを破棄する際、ルーターは、数百万ものリクエストを短期間で同じアドレスに送信することを禁止するルールで構成されます。短時間で受信するリクエストが多すぎると、ルーターはリクエストを転送せずに破棄します。リクエストは、パケットを転送しないルーターに送信されます。問題のあるルートは、破棄ルートまたはブラックホール ルートと呼ばれることもあります。廃棄すべきルートのタイプは、ピアやその他の顧客からの顧客への攻撃、顧客からピアやその他の顧客への攻撃、攻撃指示を提供するホストである攻撃コントローラ、およびボゴンまたは無効な IP アドレスとして知られる未割り当てのアドレス スペースとして識別されます。
攻撃試行が特定された後、通信事業者は攻撃を緩和するための設定を行うことができます。Junos OSでルーティングの破棄を設定する方法の1つは、ルートを破棄するために使用されるネクストホップごとに破棄スタティックルートを作成することです。破棄静的ルートは、 オプションを discard
使用します。
次がその例です。
user@host# show routing-options
static {
route 192.0.2.101/32 discard;
route 192.0.2.103/32 discard;
route 192.0.2.105/32 discard;
}
user@host> show route protocol static terse inet.0: 3 destinations, 3 routes (3 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both A V Destination P Prf Metric 1 Metric 2 Next hop AS path * ? 192.0.2.101/32 S 5 Discard * ? 192.0.2.103/32 S 5 Discard * ? 192.0.2.105/32 S 5 Discard
この例の主な焦点であるもう 1 つの戦略は、ルーティング ポリシーと破棄インターフェイスを使用することです。このアプローチでは、破棄インターフェイスには、null ルート ルートに割り当てるネクスト ホップが含まれています。破棄インターフェイスは1つの論理ユニット(ユニット0)しか持つことができませんが、ユニット0に複数のIPアドレスを設定できます。
次がその例です。
user@host# show interfaces dsc
unit 0 {
family inet {
address 192.0.2.102/32 {
destination 192.0.2.101;
}
address 192.0.2.104/32 {
destination 192.0.2.103;
}
address 192.0.2.106/32 {
destination 192.0.2.105;
}
}
}
user@host> show interfaces terse dsc b Interface Admin Link Proto Local Remote dsc up up dsc.0 up up inet 192.0.2.102 --> 192.0.2.101 192.0.2.104 --> 192.0.2.103 192.0.2.106 --> 192.0.2.105
破棄静的ルートを使用する代わりに破棄インターフェイスを使用する利点は、破棄インターフェイスを使用することで、トラフィックのカウント、ロギング、サンプリングのために、インターフェイスにフィルターを設定および割り当てることです。これは、この例で示されています。
実際にパケットを破棄するには、BGPセッションにアタッチされたルーティングポリシーが必要です。廃棄対象ルートを検索するには、ルートフィルター、アクセスリスト、またはBGPコミュニティ値を使用できます。
例えば、ルートフィルターを使用する方法を次に示します。
ルート フィルター
protocols { bgp { import blackhole-by-route; } } policy-options { policy-statement blackhole-by-route { term specific-routes { from { route-filter 10.10.10.1/32 exact; route-filter 10.20.20.2/32 exact; route-filter 10.30.30.3/32 exact; route-filter 10.40.40.4/32 exact; } then { next-hop 192.0.2.101 } } } }
図 1 は、サンプル ネットワークを示しています。

この例には、外部 BGP(EBGP)セッションが確立された 3 つのルーターが含まれています。
デバイス R1 は攻撃対象デバイスを表します。デバイスR3は、攻撃を受けているデバイスに最も近いルーターを表します。デバイスR2は、パケットを廃棄インターフェイスに転送することで、攻撃を緩和します。
この例では、破棄インターフェイスに適用されるアウトバウンドフィルターを示しています。
単一の NULL ルート フィルターを使用する際の問題は、可視性です。すべての破棄パケットは、同じカウンターをインクリメントします。破棄されるパケットのカテゴリーを確認するには、宛先クラス使用率(DCU)を使用し、ユーザー定義クラスを各 null ルート コミュニティに関連付けます。次に、ファイアウォールフィルターのDCUクラスを参照します。関連する例については、 および を例:宛先クラスに基づくレート制限フィルターの設定参照してください例:送信元プレフィックスと宛先プレフィックスを転送クラスにグループ化。
ルート フィルターやアクセス リストの使用と比較して、コミュニティ値の使用は管理上最も難しく、最も拡張性の高いアプローチです。したがって、これはこの例で示すアプローチです。
デフォルトでは、ネクストホップは外部BGP(EBGP)ピアアドレスと等しい必要があります。NULL ルート サービスのネクスト ホップを変更するには、EBGP セッションにマルチホップ機能を設定する必要があります。
CLI クイックコンフィギュレーション は、 内のすべてのデバイス 図 1の設定を示しています。
セクション #configuration756__policy-discard-st では、デバイス R2 の手順について説明します。
設定
手順
CLI クイックコンフィギュレーション
この例を迅速に設定するには、以下のコマンドをコピーしてテキスト ファイルに貼り付け、改行を削除し、ネットワーク設定に合わせて必要な詳細を変更し、コマンドを 階層レベルの CLI [edit]
にコピー アンド ペーストします。
デバイス 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 set protocols bgp group ext type external set protocols bgp group ext peer-as 200 set protocols bgp group ext neighbor 10.0.0.2 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 fe-1/2/1 unit 0 family inet address 10.1.0.1/30 set interfaces dsc unit 0 family inet filter output log-discard set interfaces dsc unit 0 family inet address 192.0.2.102/32 destination 192.0.2.101 set interfaces lo0 unit 0 family inet address 192.168.0.2/32 set protocols bgp import blackhole-policy set protocols bgp group ext type external set protocols bgp group ext multihop set protocols bgp group ext export dsc-export set protocols bgp group ext neighbor 10.0.0.1 peer-as 100 set protocols bgp group ext neighbor 10.1.0.2 peer-as 300 set policy-options policy-statement blackhole-policy term blackhole-communities from community blackhole-all-routers set policy-options policy-statement blackhole-policy term blackhole-communities then next-hop 192.0.2.101 set policy-options policy-statement dsc-export from route-filter 192.0.2.101/32 exact set policy-options policy-statement dsc-export from route-filter 192.0.2.102/32 exact set policy-options policy-statement dsc-export then community set blackhole-all-routers set policy-options policy-statement dsc-export then accept set policy-options community blackhole-all-routers members 100:5555 set routing-options static route 192.0.2.102/32 next-hop 192.0.2.101 set routing-options autonomous-system 200 set firewall filter log-discard term one then count counter set firewall filter log-discard term one then log
デバイスR3
set interfaces fe-1/2/1 unit 0 family inet address 10.1.0.2/30 set interfaces lo0 unit 0 family inet address 192.168.0.3/32 set interfaces lo0 unit 0 family inet address 192.0.2.102/32 set protocols bgp group ext type external set protocols bgp group ext peer-as 200 set protocols bgp group ext neighbor 10.1.0.1 set routing-options autonomous-system 300
手順
次の例では、設定階層内のさまざまなレベルに移動する必要があります。その方法の詳細については、 Junos OS CLIユーザーガイドを参照してください設定モードでのCLIエディターの使用。
デバイスR2を設定するには:
ルーター インターフェイスを作成します。
[edit interfaces] user@R2# set fe-1/2/0 unit 0 family inet address 10.0.0.2/30 user@R2# set fe-1/2/1 unit 0 family inet address 10.1.0.1/30 user@R2# set lo0 unit 0 family inet address 192.168.0.2/32
すべてのパケットとカウントに一致するファイアウォールフィルターを設定し、パケットをログに記録します。
[edit firewall filter log-discard term one] user@R2# set then count counter user@R2# set then log
破棄インターフェイスを作成し、出力ファイアウォールフィルターを適用します。
入力ファイアウォール フィルターは、このコンテキストでは影響しません。
[edit interfaces dsc unit 0 family inet] user@R2# set filter output log-discard user@R2# set address 192.0.2.102/32 destination 192.0.2.101
破棄インターフェイスで指定された宛先アドレスにネクストホップを送信する静的ルートを設定します。
[edit routing-options static] user@R2# set route 192.0.2.102/32 next-hop 192.0.2.101
BGPピアリングを設定します。
[edit protocols bgp ] user@R2# set group ext type external user@R2# set group ext multihop user@R2# set group ext neighbor 10.0.0.1 peer-as 100 user@R2# set group ext neighbor 10.1.0.2 peer-as 300
ルーティングポリシーを設定します。
[edit policy-options policy-statement blackhole-policy term blackhole-communities] user@R2# set from community blackhole-all-routers user@R2# set then next-hop 192.0.2.101 [edit policy-options policy-statement dsc-export] user@R2# set from route-filter 192.0.2.101/32 exact user@R2# set from route-filter 192.0.2.102/32 exact user@R2# set then community set blackhole-all-routers user@R2# set then accept [edit policy-options community blackhole-all-routers] user@R2# set members 100:5555
ルーティング ポリシーを適用します。
[edit protocols bgp ] user@R2# set import blackhole-policy user@R2# set group ext export dsc-export
自律システム(AS)番号を設定します。
[edit routing-options] user@R2# set autonomous-system 200
結果
設定モードから、 、 、 show protocols
、 show policy-options
show routing-options
、および のコマンドをshow interfaces
発行して、設定をshow firewall
確認します。出力結果に意図した設定が表示されない場合は、この例の手順を繰り返して設定を修正します。
[edit] user@R2# show interfaces fe-1/2/0 { unit 0 { family inet { address 10.0.0.2/30; } } } fe-1/2/1 { unit 0 { family inet { address 10.1.0.1/30; } } } dsc { unit 0 { family inet { filter { output log-discard; } address 192.0.2.102/32 { destination 192.0.2.101; } } } } lo0 { unit 0 { family inet { address 192.168.0.2/32; } } }
user@R2# show protocols bgp { import blackhole-policy; group ext { type external; multihop; export dsc-export; neighbor 10.0.0.1 { peer-as 100; } neighbor 10.1.0.2 { peer-as 300; } } }
user@R2# show policy-options policy-statement blackhole-policy { term blackhole-communities { from community blackhole-all-routers; then { next-hop 192.0.2.101; } } } policy-statement dsc-export { from { route-filter 192.0.2.101/32 exact; route-filter 192.0.2.102/32 exact; } then { community set blackhole-all-routers; accept; } } community blackhole-all-routers members 100:5555;
user@R2# show routing-options static { route 192.0.2.102/32 next-hop 192.0.2.101; } autonomous-system 200;
user@R2# show firewall filter log-discard { term one { then { count counter; log; } } }
デバイスの設定が完了したら、設定モードから を入力します commit
。
検証
設定が正しく機能していることを確認します。
ファイアウォール カウンターのクリア
目的
既知のゼロ(0)状態から開始していることを確認するには、カウンターをクリアします。
対処
デバイスR2から、 コマンドを
clear firewall
実行します。user@R2> clear firewall filter log-discard
デバイスR2から、 コマンドを
show firewall
実行します。user@R2> show firewall filter log-discard Filter: /log-discard Counters: Name Bytes Packets counter 0 0
192.0.2.101アドレスの pinging
目的
宛先アドレスにパケットを送信します。
対処
デバイスR1から、 コマンドを ping
実行します。
user@R1> ping 192.0.2.101 PING 192.0.2.101 (192.0.2.101): 56 data bytes ^C --- 192.0.2.101 ping statistics --- 4 packets transmitted, 0 packets received, 100% packet loss
意味
予想通り、ping リクエストは失敗し、応答は送信されません。パケットは破棄されています。
出力フィルターの確認
目的
デバイスR2のファイアウォールフィルターが正しく機能していることを確認します。
対処
デバイスR2から コマンドを show firewall filter log-discard
入力します。
user@R2> show firewall filter log-discard Filter: log-discard Counters: Name Bytes Packets counter 336 4
意味
予想通り、カウンターは増加しています。
pingパケットには、20バイトのIPオーバーヘッドと8バイトのICMPヘッダーが含まれています。
コミュニティ属性の確認
目的
ルートがコミュニティ属性でタグ付けされていることを確認します。
対処
デバイスR1から、デバイスR2、192.0.2.101のネイバーアドレスを使用して、 コマンドを入力 show route extensive
します。
user@R1> show route 192.0.2.101 extensive inet.0: 4 destinations, 4 routes (4 active, 0 holddown, 0 hidden) 192.0.2.101/32 (1 entry, 1 announced) TSI: KRT in-kernel 192.0.2.101/32 -> {10.0.0.2} *BGP Preference: 170/-101 Next hop type: Router, Next hop index: 684 Address: 0x94141d8 Next-hop reference count: 2 Source: 10.0.0.2 Next hop: 10.0.0.2 via fe-1/2/0.0, selected Session Id: 0x8000a State: <Active Ext> Local AS: 100 Peer AS: 200 Age: 53:03 Validation State: unverified Task: BGP_200.10.0.0.2+63097 Announcement bits (1): 2-KRT AS path: 200 I Communities: 100:5555 Accepted Localpref: 100 Router ID: 192.168.0.2
意味
予想通り、デバイスR2が192.0.2.101ルートをデバイスR1にアドバタイズすると、デバイスR2は100:5555コミュニティタグを追加します。