例:信頼できる送信元からのトラフィックを受け入れるようにステートレス ファイアウォール フィルターを構成する
この例では、信頼できないソースから発生するトラフィックからルーティングエンジンを保護するステートレスファイアウォールフィルターを作成する方法を示しています。
要件
ステートレスファイアウォールフィルターを設定する前に、デバイスの初期化以外の特別な設定を行う必要はありません。
概要
この例では、指定された信頼できる送信元からのSSHおよびBGPプロトコルパケットを除く、ルーティングエンジン宛てのすべてのトラフィックを破棄するprotect-REと呼ばれるステートレスファイアウォールフィルターを作成します。この例では、以下のファイアウォールフィルター条件が含まれています。
-
ssh-term—送信元アドレスが192.168.122.0/24で、宛先ポートがSSHを指定するTCPパケットを受け入れます。 -
bgp-term—送信元アドレスが10.2.1.0/24で、宛先ポートがBGPを指定するTCPパケットを受け入れます。 -
discard-rest-term—ssh-termまたはbgp-termによって受け入れられないすべてのパケットについて、ファイアウォールフィルターログとシステムログレコードを作成し、すべてのパケットを破棄します。
insertコマンドを使用して、ファイアウォールフィルター内で用語を移動できます。『Junos OS CLIユーザーガイド』の「挿入」を参照してください。
設定
手順
CLIクイックコンフィグレーション
この例を簡単に設定するには、以下のコマンドをコピーしてテキストファイルに貼り付け、改行を削除して、ネットワーク構成に合わせて必要な詳細を変更し、コマンドを [edit] 階層レベルのCLIにコピー&ペーストしてください。
set firewall family inet filter protect-RE term ssh-term from source-address 192.168.122.0/24 set firewall family inet filter protect-RE term ssh-term from protocol tcp set firewall family inet filter protect-RE term ssh-term from destination-port ssh set firewall family inet filter protect-RE term ssh-term then accept set firewall family inet filter protect-RE term bgp-term from source-address 10.2.1.0/24 set firewall family inet filter protect-RE term bgp-term from protocol tcp set firewall family inet filter protect-RE term bgp-term from destination-port bgp set firewall family inet filter protect-RE term bgp-term then accept set firewall family inet filter protect-RE term discard-rest-term then log set firewall family inet filter protect-RE term discard-rest-term then syslog set firewall family inet filter protect-RE term discard-rest-term then discard set interfaces lo0 unit 0 family inet filter input protect-RE
ステップバイステップの手順
次の例では、設定階層のさまざまなレベルに移動する必要があります。その方法の詳細については、『Junos OS CLIユーザーガイド』の「設定モードでCLIエディタを使用する」を参照してください。
ステートレスファイアウォールフィルターを設定するには:
-
ステートレスファイアウォールフィルターを作成します。
[edit] user@host# edit firewall family inet filter protect-RE
-
最初のフィルター条件を作成します。
[edit firewall family inet filter protect-RE] user@host# edit term ssh-term
-
条件のプロトコル、宛先ポート、送信元アドレス一致条件を定義します。
[edit firewall family inet filter protect-RE term ssh-term] user@host# set from protocol tcp destination-port ssh source-address 192.168.122.0/24
-
用語のアクションを定義します。
[edit firewall family inet filter protect-RE term ssh-term] user@host# set then accept
-
2 番目のフィルター条件を作成します。
[edit firewall family inet filter protect-RE] user@host# edit term bgp-term
-
条件のプロトコル、宛先ポート、送信元アドレス一致条件を定義します。
[edit firewall family inet filter protect-RE term bgp-term] user@host# set from protocol tcp destination-port bgp source-address 10.2.1.0/24
-
用語のアクションを定義します。
[edit firewall family inet filter protect-RE term bgp-term] user@host# set then accept
-
3 番目のフィルター条件を作成します。
[edit firewall family inet filter protect-RE] user@host# edit term discard-rest-term
-
用語のアクションを定義します。
[edit firewall family inet filter protect-RE term discard-rest] user@host# set then log syslog discard
-
ルーティングエンジンインターフェイスの入力側にフィルターを適用します。
[edit] user@host# set interfaces lo0 unit 0 family inet filter input protect-RE
結果
コンフィギュレーション・モードから show firewall コマンドと show interfaces lo0 コマンドを入力し、コンフィギュレーションを確認します。出力に意図した設定が表示されない場合は、この例の手順を繰り返して設定を修正します。
user@host# show firewall
family inet {
filter protect-RE {
term ssh-term {
from {
source-address {
192.168.122.0/24;
}
protocol tcp;
destination-port ssh;
}
then accept;
}
term bgp-term {
from {
source-address {
10.2.1.0/24;
}
protocol tcp;
destination-port bgp;
}
then accept;
}
term discard-rest-term {
then {
log;
syslog;
discard;
}
}
}
}
user@host# show interfaces lo0
unit 0 {
family inet {
filter {
input protect-RE;
}
address 127.0.0.1/32;
}
}
デバイスの設定が完了したら、設定モードから commit を入力します。
[edit] user@host# commit
検証
設定が正常に機能していることを確認するには、以下のタスクを実行します。
ステートレス ファイアウォール フィルター設定の表示
目的
ファイアウォールフィルターの設定を確認します。
アクション
設定モードから、 show firewall コマンドと show interfaces lo0 コマンドを入力します。
意味
出力がファイアウォールフィルターの意図した設定になっていることを確認します。さらに、パケットをテストする順序で用語が表示されていることを確認します。 insert CLIコマンドを使用して、ファイアウォールフィルター内で用語を移動できます。
サービス、プロトコル、信頼できるソースの検証 ファイアウォールフィルター
目的
ファイアウォールフィルター条件のアクションが実行されていることを確認します。
アクション
条件に一致するパケットをデバイスに送信します。さらに、一致しないパケットに対してフィルターアクションが not 実行されていることを確認します。
-
192.168.122.0/24に一致するIPアドレスのホストからssh host-nameコマンドを使用して、このアドレスプレフィックスを持つホストからSSHのみを使用してデバイスにログインできることを確認します。 -
show route summaryコマンドを使用して、デバイス上のルーティングテーブルに、Direct、Local、BGP、またはStatic以外のプロトコルを持つエントリーが含まれていないことを確認します。
出力例
コマンド名
% ssh 192.168.249.71 %ssh host user@host's password: --- JUNOS 6.4-20040518.0 (JSERIES) #0: 2004-05-18 09:27:50 UTC user@host>
コマンド名
user@host> show route summary
Router ID: 192.168.249.71
inet.0: 34 destinations, 34 routes (33 active, 0 holddown, 1 hidden)
Direct: 10 routes, 9 active
Local: 9 routes, 9 active
BGP: 10 routes, 10 active
Static: 5 routes, 5 active
...
意味
次の情報を確認します。
-
SSHを使用してデバイスに正常にログインできます。
-
show route summaryコマンドは、Direct、Local、BGP、またはStatic以外のプロトコルを表示しません。
ステートレスファイアウォールフィルターログの表示
目的
パケットがログに記録されていることを確認します。 log または syslog アクションを条件に含めた場合、条件に一致するパケットがファイアウォールログまたはシステムロギング機能に記録されていることを確認します。
アクション
動作モードから、 show firewall log コマンドを入力します。
出力例
コマンド名
user@host> show firewall log Log : Time Filter Action Interface Protocol Src Addr Dest Addr 15:11:02 pfe D ge-0/0/0.0 TCP 172.17.28.19 192.168.70.71 15:11:01 pfe D ge-0/0/0.0 TCP 172.17.28.19 192.168.70.71 15:11:01 pfe D ge-0/0/0.0 TCP 172.17.28.19 192.168.70.71 15:11:01 pfe D ge-0/0/0.0 TCP 172.17.28.19 192.168.70.71 ...
意味
出力の各レコードには、ログに記録されたパケットに関する情報が含まれています。次の情報を確認します。
-
Timeの下には、パケットがフィルタリングされた時刻が表示されます。 -
Filter出力は常にpfeです。 -
Actionでは、条件の設定されたアクションは、パケットに対して実行されたアクション(A(受け入れ)、D(破棄)、R(拒否)と一致します。 -
Interfaceでは、パケットが到着したインバウンド(イングレス)インターフェイスがフィルターに適しています。 -
Protocolでは、パケットのIPヘッダー内のプロトコルがフィルターに適しています。 -
Src Addrでは、パケットのIPヘッダーの送信元アドレスがフィルターに適しています。 -
Dest Addrでは、パケットのIPヘッダーの宛先アドレスがフィルターに適切です。