例:IP オプション パケットをカウントするためのフィルタの設定
この例では、ステートレス ファイアウォール フィルタを使用して個々の IP オプション パケットをカウントする方法を示しています。
要件
この例では、MX シリーズ ルーターの 10 ギガビット イーサネット MPC(モジュラー ポート コンセントレータ)、60 ギガビット イーサネット MPC、60 ギガビット キューイング イーサネット MPC、または 60 ギガビット イーサネット拡張キューイング MPC 上のインターフェイスを使用します。このインターフェイスを使用すると、終端処理も使用することなく、特定 ip-option
の値に一致するパケットに対して 、log
およびsyslog
終端処理以外のアクションを使用count
できる IPv4 ファイアウォール フィルタ(標準またはサービス フィルタ)をdiscard
適用できます。
この例を設定する前に、デバイス初期化以外の特別な設定は必要ありません。
概要
この例では、ステートレス ファイアウォール フィルタを使用して IP オプション パケットをカウントしますが、トラフィックはブロックしません。また、フィルタは、ルーズまたはストリクトソースルーティングを持つパケットをログに記録します。
IP オプション ヘッダー フィールドは、IPv4 ヘッダーのみのオプション フィールドです。条件 ip-options
と ip-options-except
一致条件は、標準のステートレス ファイアウォール フィルターとサービス フィルターでのみサポートされています。
M および T シリーズ ルーターでは、ファイアウォール フィルターはオプション タイプごと、インターフェイスごとにパケットをカウント ip-options
できません。このコマンドを使用 show pfe statistics ip options
してパケット転送エンジン(PFE)ごとに統計情報を確認 ip-options
するのは、限定的な方法です。サンプル出力については 、show pfe statistics ip を参照してください。
設定
次の例では、設定階層のさまざまなレベルに移動する必要があります。CLI のナビゲーションの詳細については、 を参照してください 設定モードでのCLIエディターの使用。
この例を設定するには、次のタスクを実行します。
CLI クイック設定
この例を迅速に設定するには、次の設定コマンドをテキスト ファイルにコピーし、改行を削除してから、コマンドを階層レベルで [edit]
CLI に貼り付けます。
set firewall family inet filter ip_options_filter term match_strict_source from ip-options strict-source-route set firewall family inet filter ip_options_filter term match_strict_source then count strict_source_route set firewall family inet filter ip_options_filter term match_strict_source then log set firewall family inet filter ip_options_filter term match_strict_source then accept set firewall family inet filter ip_options_filter term match_loose_source from ip-options loose-source-route set firewall family inet filter ip_options_filter term match_loose_source then count loose_source_route set firewall family inet filter ip_options_filter term match_loose_source then log set firewall family inet filter ip_options_filter term match_loose_source then accept set firewall family inet filter ip_options_filter term match_record from ip-options record-route set firewall family inet filter ip_options_filter term match_record then count record_route set firewall family inet filter ip_options_filter term match_record then accept set firewall family inet filter ip_options_filter term match_timestamp from ip-options timestamp set firewall family inet filter ip_options_filter term match_timestamp then count timestamp set firewall family inet filter ip_options_filter term match_timestamp then accept set firewall family inet filter ip_options_filter term match_router_alert from ip-options router-alert set firewall family inet filter ip_options_filter term match_router_alert then count router_alert set firewall family inet filter ip_options_filter term match_router_alert then accept set firewall family inet filter ip_options_filter term match_all then accept set interfaces ge-0/0/1 unit 0 family inet address 10.1.2.3/30 set interfaces ge-0/0/1 unit 0 family inet filter input ip_options_filter
ステートレス ファイアウォール フィルタの設定
手順
ステートレス ファイアウォール フィルタを設定するには、次の手順にしたがってください ip_option_filter
。
ステートレス ファイアウォール フィルターを作成します
ip_option_filter
。[edit] user@host# edit firewall family inet filter ip_options_filter
IP オプション ヘッダー フィールドを使用してパケットのカウント、ログ記録、受信を行う最初の条件を
strict_source_route
設定します。[edit firewall family inet filter ip_option_filter] user@host# set term match_strict_source from ip-options strict_source_route user@host# set term match_strict_source then count strict_source_route user@host# set term match_strict_source then log user@host# set term match_strict_source then accept
次の項を設定して、IP オプション ヘッダー フィールドを使用してパケットの
loose-source-route
カウント、ログ記録、受け入れを行います。[edit firewall family inet filter ip_option_filter] user@host# set term match_loose_source from ip-options loose-source-route user@host# set term match_loose_source then count loose_source_route user@host# set term match_loose_source then log user@host# set term match_loose_source then accept
IP オプション ヘッダー フィールドを使用してパケットをカウントして受け入れる次の条件を
record-route
設定します。[edit firewall family inet filter ip_option_filter] user@host# set term match_record from ip-options record-route user@host# set term match_record then count record_route user@host# set term match_record then accept
IP オプション ヘッダー フィールドを使用してパケットをカウントして受け入れる次の条件を
timestamp
設定します。[edit firewall family inet filter ip_option_filter] user@host# set term match_timestamp from ip-options timestamp user@host# set term match_timestamp then count timestamp user@host# set term match_timestamp then accept
IP オプション ヘッダー フィールドを使用してパケットをカウントして受け入れる次の条件を
router-alert
設定します。[edit firewall family inet filter ip_option_filter] user@host# set term match_router_alert from ip-options router-alert user@host# set term match_router_alert then count router_alert user@host# set term match_router_alert then accept
カウンターを増やすことなく、パケットを受け入れる最後の条件を作成します。
[edit firewall family inet filter ip_option_filter] user@host# set term match_all then accept
論理インターフェイスにステートレス ファイアウォール フィルタを適用する
手順
論理インターフェイスにステートレス ファイアウォール フィルタを適用するには、次の手順にしたがってください。
ステートレス ファイアウォール フィルタを適用する論理インターフェイスを設定します。
[edit] user@host# edit interfaces ge-0/0/1 unit 0 family inet
論理インターフェイスのインターフェイス アドレスを設定します。
[edit interfaces ge-0/0/1 unit 0 family inet] user@host# set address 10.1.2.3/30
ステートレス ファイアウォール フィルタを論理インターフェイスに適用します。
[edit interfaces ge-0/0/1 unit 0 family inet] user@host# set filter input ip_options_filter
受験者の構成を確認してコミットする
手順
受験者の設定を確認してコミットするには、次の手順に応えます。
設定モード コマンドを入力して、ステートレス ファイアウォール フィルタの設定を
show firewall
確認します。コマンド出力に意図した設定が表示されない場合は、この例の手順を繰り返して設定を修正します。[edit] user@host# show firewall family inet { filter ip_options_filter { term match_strict_source { from { ip-options strict-source-route; } then { count strict_source_route; log; accept; } } term match_loose_source { from { ip-options loose-source-route; } then { count loose_source_route; log; accept; } } term match_record { from { ip-options record-route; } then { count record_route; accept; } } term match_timestamp { from { ip-options timestamp; } then { count timestamp; accept; } } term match_router_alert { from { ip-options router-alert; } then { count router_alert; accept; } } term match_all { then accept; } } }
設定モード コマンドを入力して、インターフェイスの設定を
show interfaces
確認します。コマンド出力に意図した設定が表示されない場合は、この例の手順を繰り返して設定を修正します。[edit] user@host# show interfaces ge-0/0/1 { unit 0 { family inet { filter { input ip_option_filter; } address 10.1.2.3/30; } } }
デバイスの設定が完了したら、受験者の設定をコミットします。
[edit] user@host# commit
検証
設定が正しく機能していることを確認するには、動作モード コマンドを show firewall filter ip_option_filter
入力します。また、次の形式のコマンドを使用して、ログカウンターと個別のカウンタを個別に表示することもできます。
show firewall counter strict_source_route
show firewall counter loose_source_route
show firewall counter record_route
show firewall counter timestamp
show firewall counter router_alert
show firewall log