例:IP オプション パケットをカウントするフィルターの設定
次に、ステートレス ファイアウォール フィルターを使用して、個々の IP オプション パケットをカウントする例を示します。
要件
この例では、MX シリーズ ルーター上の 10 ギガビット イーサネット モジュラー ポート コンセントレータ(MPC)、60 ギガビット イーサネット MPC、60 ギガビット キューイング イーサネット MPC、または 60 ギガビット イーサネット拡張キューイング MPC 上のインターフェイスを使用します。このインターフェイスを使用すると、特定の値に一致するパケットに対して、
count
、 、および 非終了アクションを使用できるIPv4ファイアウォールフィルター(標準またはサービスフィルター)を適用できます。また、終了アクションも使用する必要はありません。logsyslog
ip-option
discard
この例を設定する前に、デバイス初期化以外の特別な設定を行う必要はありません。
概要
この例では、ステートレス ファイアウォール フィルターを使用して、IP オプション パケットをカウントしますが、トラフィックはブロックしません。また、このフィルターは、ルーズまたはストリクトなソースルーティングがあるパケットをログに記録します。
IP オプション ヘッダー フィールドは、IPv4 ヘッダーのみのオプション フィールドです。および 一致条件は、標準のステートレスファイアウォールフィルターとサービスフィルターでのみサポートされています。ip-options
ip-options-except
MおよびT Seriesルーターでは、ファイアウォールフィルターはオプションタイプとインターフェイス単位で ip-options
パケットをカウントできません。限定的な回避策は、 コマンドを使用して、パケット転送エンジン(PFE)単位で統計情報を表示する ことです。show pfe statistics ip options
ip-options
サンプル出力については、show pfe statistics ipを参照してください。
設定
次の例では、設定階層のいくつかのレベルに移動する必要があります。CLI のナビゲーションについては、を参照してください 。設定モードでのCLIエディターの使用
この例を設定するには、以下のタスクを実行します。
CLIクイック構成
この例をすばやく設定するには、次の設定コマンドをテキスト ファイルにコピーし、改行を削除してから、 階層レベルの CLI にコマンドを貼り付けます。[edit]
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