例:プレフィックスリストに基づいてポートへのTCPアクセスを制限するフィルターの設定
この例では、許可されたBGPピアを含むプレフィックスソースのリストを指定することで、ルーティングエンジンを宛先とする特定のTCPおよびインターネット制御メッセージプロトコル(ICMP)トラフィックを制限する標準的なステートレスファイアウォールフィルターを設定する方法を示しています。
要件
この例を設定する前に、デバイスの初期化以外の特別な設定を行う必要はありません。
概要
この例では、指定されたプレフィックスを持つBGPピアを除くすべてのリクエスターからのポート 179へのすべてのTCP接続試行をブロックするステートレスBGPファイアウォールフィルターを作成します。
トポロジー
許可されたBGPピアを含む送信元プレフィックスのリストを指定するソースプレフィックスリスト plist_bgp179が作成されます。
ステートレスファイアウォールフィルターは、送信元プレフィックスリストplist_bgp179から宛先ポート番号 179までのすべてのパケットをfilter_bgp179一致させます。
設定
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 を展開して、 プロトコルbgpグループ<*>ネイバー<*>で定義された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 firewall、 show 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 <*>";
}
デバイスの設定が完了したら、設定モードから コミット を入力します。
検証
設定が正常に機能していることを確認します。
ループバックインターフェイスに適用されるファイアウォールフィルターの表示
目的
ファイアウォールフィルター 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