例:破棄インターフェイスへのパケットの転送
この例では、破棄ルーティングを使用して、サービス拒否(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
この例の主な焦点である別の戦略は、ルーティングポリシーと破棄インターフェイスを使用することです。このアプローチでは、破棄インターフェイスには、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クイックコンフィグレーション
この例を簡単に設定するには、以下のコマンドをコピーしてテキストファイルに貼り付け、改行を削除して、ネットワーク構成に合わせて必要な詳細を変更し、コマンドを [edit] 階層レベルの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 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 interfaces、 show protocols 、 show policy-options、 show routing-options、 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アドレスにpingする
目的
宛先アドレスにパケットを送信します。
アクション
デバイス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がデバイスR1に192.0.2.101ルートをアドバタイズすると、デバイスR2は100:5555コミュニティタグを追加します。