例:プレフィックスリストに基づいてポートへのTCPアクセスを制限するフィルターの設定
この例では、許可された BGP ピアを含むプレフィックス ソースのリストを指定することによって、ルーティング エンジン宛ての特定の TCP および ICMP(インターネット制御メッセージ プロトコル)トラフィックを制限する標準的なステートレス ファイアウォール フィルターを設定する方法を示します。
要件
この例を設定する前に、デバイス初期化以外の特別な設定を行う必要はありません。
概要
この例では、ステートレス ファイアウォール フィルターを作成します。このフィルターは、指定したプレフィックスを持つ BGP ピアを除くすべてのリクエスターからポート 179 への TCP 接続試行をすべてブロックします。
トポロジー
許可された BGP ピアを含むソース プレフィックスのリストを指定するソース プレフィックス リスト plist_bgp179が作成されます。
ステートレス ファイアウォール フィルターは filter_bgp179 送信元プレフィックス リストから plist_bgp179 宛先ポート番号 179 までのすべてのパケットを照合します。
設定
CLIクイック構成
この例をすばやく設定するには、次のコマンドをコピーしてテキストファイルに貼り付け、改行を削除して、ネットワーク構成に合わせて必要な詳細を変更し、[edit]階層レベルのCLIにコマンドをコピー&ペーストしてください。
set policy-options prefix-list plist_bgp179 apply-path "protocols bgp group <*> neighbor <*>" set firewall family inet filter filter_bgp179 term 1 from source-address 0.0.0.0/0 set firewall family inet filter filter_bgp179 term 1 from source-prefix-list plist_bgp179 except set firewall family inet filter filter_bgp179 term 1 from destination-port bgp set firewall family inet filter filter_bgp179 term 1 then reject set firewall family inet filter filter_bgp179 term 2 then accept set interfaces lo0 unit 0 family inet filter input filter_bgp179 set interfaces lo0 unit 0 family inet address 127.0.0.1/32
フィルターを設定する
ステップバイステップでの手順
次の例では、設定階層内のさまざまなレベルに移動する必要があります。CLIのナビゲーションについては、Junos OS CLIユーザーガイドの 設定モードでCLIエディターを使用する を参照してください。
フィルターを構成するには:
プレフィックスリスト bgp179 を展開して、 protocols bgp group <*> neighbor <*> で定義された BGP ピアグループが指すすべてのプレフィックスを含めます。
[edit policy-options prefix-list plist_bgp179] user@host# set apply-path " protocols bgp group <*> neighbor <*>"
指定されたBGPピアを除くすべてのリクエスターからポート179へのTCP接続試行を拒否するフィルター条件を定義します。
[edit firewall family inet filter filter_bgp179] user@host# set term term1 from source-address 0.0.0.0/0 user@host# set term term1 from source-prefix-list bgp179 except user@host# set term term1 from destination-port bgp user@host# set term term1 then reject
すべてのパケットを受け入れるように、もう一方のフィルター条件を定義します。
[edit firewall family inet filter filter_bgp179] user@host# set term term2 then accept
ファイアウォールフィルターをループバックインターフェイスに適用します。
[edit interfaces lo0 unit 0 family inet] user@host# set filter input filter_bgp179 user@host# set address 127.0.0.1/32
結果
コンフィギュレーションモードから、show firewallshow interfaces、、およびの各コマshow policy-optionsンドを入力し、コンフィギュレーションを確認します。出力結果に意図した設定内容が表示されない場合は、この例の手順を繰り返して設定を修正します。
user@host# show firewall
family inet {
filter filter_bgp179 {
term 1 {
from {
source-address {
0.0.0.0/0;
}
source-prefix-list {
plist_bgp179 except;
}
destination-port bgp;
}
then {
reject;
}
}
term 2 {
then {
accept;
}
}
}
}
user@host# show interfaces
lo0 {
unit 0 {
family inet {
filter {
input filter_bgp179;
}
address 127.0.0.1/32;
}
}
}
user@host# show policy-options
prefix-list plist_bgp179 {
apply-path "protocols bgp group <*> neighbor <*>";
}
デバイスの設定が完了したら、設定モードから commit を入力します。
検証
設定が正常に機能していることを確認します。
ループバック インターフェイスに適用されたファイアウォール フィルターの表示
目的
ファイアウォールフィルター filter_bgp179 が、論理インターフェイス lo0.0でIPv4入力トラフィックに適用されていることを確認します。
アクション
論理インターフェイスlo0.0には show interfaces statistics operational mode コマンドを使用し、detail オプションを含めます。コマンド出力セクションの Protocol inet セクションの Input Filters フィールドには、入力方向の論理インターフェイスに適用されているステートレス ファイアウォール フィルターの名前が表示されます。
[edit]
user@host> show interfaces statistics lo0.0 detail
Logical interface lo0.0 (Index 321) (SNMP ifIndex 16) (Generation 130)
Flags: SNMP-Traps Encapsulation: Unspecified
Traffic statistics:
Input bytes : 0
Output bytes : 0
Input packets: 0
Output packets: 0
Local statistics:
Input bytes : 0
Output bytes : 0
Input packets: 0
Output packets: 0
Transit statistics:
Input bytes : 0 0 bps
Output bytes : 0 0 bps
Input packets: 0 0 pps
Output packets: 0 0 pps
Protocol inet, MTU: Unlimited, Generation: 145, Route table: 0
Flags: Sendbcast-pkt-to-re
Input Filters: filter_bgp179
Addresses, Flags: Primary
Destination: Unspecified, Local: 127.0.0.1, Broadcast: Unspecified, Generation: 138