RIPngインポートポリシー
ルートをフィルタリングするためのRIPngインポートポリシーの理解
デフォルトのRIPngインポートポリシーは、有効チェックに合格したすべてのRIPngルートを受け入れることです。ローカル ルーティング デバイスによってネイバーからインポートされるルートをフィルタリングするには、 ステートメントを import
含め、評価する 1 つ以上のポリシーの名前をリストします。複数のポリシーを指定した場合、そのポリシーは順番に(最初から最後まで)評価され、最初の一致ポリシーがルートに適用されます。一致するものが見つからない場合、ローカル ルーティング デバイスはルートをインポートしません。
例:ネイバーからインポートされたRIPngルートにポリシーを適用する
この例では、RIPngネットワークでインポートポリシーを設定する方法を示しています。
要件
この例を設定する前に、デバイス初期化以外の特別な設定は必要ありません。
概要
この例では、デバイスR2には、追加のネットワークをシミュレートするために、いくつかの追加のループバックインターフェイスアドレスが設定されています。
デバイスR1には、fe80::/64および2001:db8::/64ルートを受け入れ、その他すべてのルートを拒否するインポートポリシーがあります。これは、デバイスR2によってアドバタイズされた追加のネットワークが、デバイスR1のルーティングテーブルに受け入れられないことを意味します。
RIPngの最小設定の一部としてエクスポート・ポリシーが必要であるため、エクスポート・ポリシーも表示されます。
図 1 は、この例で使用したトポロジーを示しています。

CLI クイック設定 は、 図 1 にすべてのデバイスの設定を示しています。セクション #d81e58__d81e204 では、デバイス R1 の手順について説明します。
トポロジ
構成
手順
CLI クイックコンフィギュレーション
この例を迅速に設定するには、以下のコマンドをコピーしてテキスト ファイルに貼り付け、改行を削除し、ネットワーク設定に合わせて必要な詳細を変更してから、 階層レベルの CLI にコマンドを [edit]
コピー アンド ペーストします。
デバイス R1
set interfaces fe-1/2/0 unit 1 description to-R2 set interfaces fe-1/2/0 unit 1 family inet6 address 2001:db8:0:1::/64 eui-64 set interfaces lo0 unit 1 family inet6 address 2001:db8::1/128 set protocols ripng group ripng-group export advertise-routes-through-ripng set protocols ripng group ripng-group neighbor fe-1/2/0.1 import ripng-import set policy-options policy-statement advertise-routes-through-ripng term 1 from protocol direct set policy-options policy-statement advertise-routes-through-ripng term 1 from protocol ripng set policy-options policy-statement advertise-routes-through-ripng term 1 then accept set policy-options policy-statement ripng-import term 1 from route-filter fe80::/64 orlonger set policy-options policy-statement ripng-import term 1 from route-filter 2001:db8::/64 orlonger set policy-options policy-statement ripng-import term 1 then accept set policy-options policy-statement ripng-import term 2 then reject
デバイスR2
set interfaces fe-1/2/0 unit 2 description to-R1 set interfaces fe-1/2/0 unit 2 family inet6 address 2001:db8:0:2::/64 eui-64 set interfaces fe-1/2/1 unit 5 description to-R3 set interfaces fe-1/2/1 unit 5 family inet6 address 2001:db8:0:3::/64 eui-64 set interfaces lo0 unit 2 family inet6 address 2001:db8::2/128 set interfaces lo0 unit 2 family inet6 address 2002:db8::2/128 set interfaces lo0 unit 2 family inet6 address 2002:db9::2/128 set interfaces lo0 unit 2 family inet6 address 2002:db7::2/128 set protocols ripng group ripng-group export advertise-routes-through-ripng set protocols ripng group ripng-group neighbor fe-1/2/0.2 set protocols ripng group ripng-group neighbor fe-1/2/1.5 set policy-options policy-statement advertise-routes-through-ripng term 1 from protocol direct set policy-options policy-statement advertise-routes-through-ripng term 1 from protocol ripng set policy-options policy-statement advertise-routes-through-ripng term 1 then accept
デバイスR3
set interfaces fe-1/2/0 unit 6 description to-R2 set interfaces fe-1/2/0 unit 6 family inet6 address 2001:db8:0:4::/64 eui-64 set interfaces lo0 unit 3 family inet6 address 2001:db8::3/128 set protocols ripng group ripng-group export advertise-routes-through-ripng set protocols ripng group ripng-group neighbor fe-1/2/0.6 set policy-options policy-statement advertise-routes-through-ripng term 1 from protocol direct set policy-options policy-statement advertise-routes-through-ripng term 1 from protocol ripng set policy-options policy-statement advertise-routes-through-ripng term 1 then accept
手順
次の例では、設定階層内のさまざまなレベルに移動する必要があります。CLIのナビゲーションについては、 CLIユーザーガイドの設定モードでのCLIエディターの使用を参照してください。
RIPngインポートポリシーを設定するには:
ネットワーク インターフェイスを設定します。
この例では、複数のループバックインターフェイスアドレスを示し、接続されたネットワークをシミュレートします。
[edit interfaces] user@R1# set fe-1/2/0 unit 1 description to-R2 user@R1# set fe-1/2/0 unit 1 family inet6 address 2001:db8:0:1::/64 eui-64 user@R1# set lo0 unit 1 family inet6 address 2001:db8::1/128
RIPngグループを作成し、インターフェイスを追加します。
Junos OSでRIPngを設定するには、RIPngが有効になっているインターフェイスを含むグループを設定する必要があります。ループバックインターフェイスでRIPngを有効にする必要はありません。
[edit protocols ripng group ripng-group] user@R1# set neighbor fe-1/2/0.1
直接ルートとRIPng学習ルートの両方をアドバタイズするルーティングポリシーを作成します。
[edit policy-options policy-statement advertise-routes-through-ripng term 1] user@R1# set from protocol direct user@R1# set from protocol ripng user@R1# set then accept
ルーティング ポリシーを適用します。
Junos OSでは、RIPngエクスポートポリシーのみをグループレベルで適用できます。
[edit protocols ripng group ripng-group] user@R1# set export advertise-routes-through-ripng
インポートポリシーを設定します。
[edit policy-options policy-statement ripng-import] user@R1# set term 1 from route-filter fe80::/64 orlonger user@R1# set term 1 from route-filter 2001:db8::/64 orlonger user@R1# set term 1 then accept user@R1# set term 2 then reject
インポートポリシーを適用します。
[edit protocols ripng group ripng-group] user@R1# set neighbor fe-1/2/0.1 import ripng-import
結果
設定モードから、 、 、 show protocols
コマンドを入力して設定をshow interfaces
show policy-options
確認します。出力に意図した設定が表示されない場合は、この例の設定手順を繰り返して修正します。
user@R1# show interfaces
fe-1/2/0 {
unit 1 {
description to-R2;
family inet6 {
address 2001:db8:0:1::/64 {
eui-64;
}
}
}
}
lo0 {
unit 1 {
family inet6 {
address 2001:db8::1/128;
}
}
}
user@R1# show protocols
ripng {
group ripng-group {
export advertise-routes-through-ripng;
neighbor fe-1/2/0.1 {
import ripng-import;
}
}
}
user@R1# show policy-options
policy-statement advertise-routes-through-ripng {
term 1 {
from protocol [ direct ripng ];
then accept;
}
}
policy-statement ripng-import {
term 1 {
from {
route-filter fe80::/64 orlonger;
route-filter 2001:db8::/64 orlonger;
}
then accept;
}
term 2 {
then reject;
}
}
デバイスの設定が完了したら、設定モードから コミット を入力します。
検証
設定が正しく機能していることを確認します。
デバイスR2のネイバーアドレスの参照
目的
デバイスR2がデバイスR1に使用しているネイバーアドレスを決定します。
アクション
動作モードから、 コマンドを show ripng neighbor
入力します。
user@R2> show ripng neighbor fe-1/2/0.2 Source Dest In Neighbor State Address Address Send Recv Met -------- ----- ------- ------- ---- ---- --- fe-1/2/0.2 Up fe80::2a0:a514:0:24c ff02::9 yes yes 1
意味
デバイスR2は、fe80::2a0:a514:0:24cアドレスを使用して、デバイスR1にルートを送信します。
デバイスR2がデバイスR1にアドバタイズしているルートを確認する
目的
デバイスR2が予想ルートを送信していることを確認します。
アクション
動作モードから、 コマンドを show route advertising-protocol ripng
入力します。
user@R2> show route advertising-protocol ripng fe80::2a0:a514:0:24c inet6.0: 17 destinations, 18 routes (17 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 2001:db8::2/128 *[Direct/0] 3d 22:00:34 > via lo0.2 2001:db8::3/128 *[RIPng/100] 3d 21:47:00, metric 2, tag 0 > to fe80::2a0:a514:0:64c via fe-1/2/1.5 2001:db8:0:2::/64 *[Direct/0] 3d 22:00:34 > via fe-1/2/0.2 2001:db8:0:3::/64 *[Direct/0] 3d 22:00:34 > via fe-1/2/1.5 2001:db8:0:4::/64 *[RIPng/100] 3d 21:47:00, metric 2, tag 0 > to fe80::2a0:a514:0:64c via fe-1/2/1.5 2002:db7::2/128 *[Direct/0] 00:29:05 > via lo0.2 2002:db8::2/128 *[Direct/0] 00:31:49 > via lo0.2 2002:db9::2/128 *[Direct/0] 00:29:05 > via lo0.2
意味
デバイスR2は、追加のループバックインターフェイス/128ルートをデバイスR1に送信しています。
デバイスR1がデバイスR2から受信しているルートを確認する
目的
デバイスR1が予想されるルートを受信していることを確認します。
アクション
動作モードから、 コマンドを show route receive-protocol ripng
入力します。
user@R1> show route receive-protocol ripng fe80::2a0:a514:0:24c inet6.0: 9 destinations, 9 routes (9 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 2001:db8::2/128 *[RIPng/100] 3d 21:55:49, metric 2, tag 0 > to fe80::2a0:a514:0:24c via fe-1/2/0.1 2001:db8::3/128 *[RIPng/100] 3d 21:55:46, metric 3, tag 0 > to fe80::2a0:a514:0:24c via fe-1/2/0.1
意味
出力では、余分なループバックインターフェイスアドレスが除外されていることを示しています。
ルーティング テーブルの確認
目的
ルーティングテーブルに期待ルートが入力されていることを確認します。
アクション
動作モードから、 コマンドを show route protocol ripng
入力します。
user@R1> show route protocol ripng inet6.0: 9 destinations, 9 routes (9 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 2001:db8::2/128 *[RIPng/100] 3d 22:01:40, metric 2, tag 0 > to fe80::2a0:a514:0:24c via fe-1/2/0.1 2001:db8::3/128 *[RIPng/100] 3d 22:01:37, metric 3, tag 0 > to fe80::2a0:a514:0:24c via fe-1/2/0.1 ff02::9/128 *[RIPng/100] 00:00:08, metric 1 MultiRecv
意味
出力は、ルートがデバイスR2とデバイスR3から学習されたことを示しています。
インポートポリシーを削除または無効化すると、ルーティングテーブルには追加のループバックインターフェイスルートが含まれます。
例:複雑な正規表現を使用したルーティングポリシーのテスト
この例では、 コマンドを使用してルーティングポリシーをテストし test policy
、実稼働環境に適用する前に期待した結果がポリシーに出力されることを確認する方法を示します。正規表現、特に複雑な正規表現は、正しく取得するのが難しい場合があります。この例では、 コマンドを test policy
使用して、正規表現が意図した効果を持っていることを確認する方法を示しています。
要件
この例を設定する前に、デバイスの初期化以外の特別な設定は必要ありません。
概要
この例では、それらの間に外部BGP(EBGP)接続を持つ2つのルーティングデバイスを示しています。デバイスR2は、BGPセッションを使用して、カスタマールートをデバイスR1に送信します。これらの静的ルートには、複数のコミュニティ値がアタッチされています。
user@R2> show route match-prefix 172.16.* detail inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden) 172.16.1.0/24 (1 entry, 1 announced) *Static Preference: 5 Next hop type: Reject Address: 0x8fd0dc4 Next-hop reference count: 8 State: <Active Int Ext> Local AS: 64511 Age: 21:32:13 Validation State: unverified Task: RT Announcement bits (1): 0-KRT AS path: I Communities: 64510:1 64510:10 64510:11 64510:100 64510:111 172.16.2.0/24 (1 entry, 1 announced) *Static Preference: 5 Next hop type: Reject Address: 0x8fd0dc4 Next-hop reference count: 8 State: <Active Int Ext> Local AS: 64511 Age: 21:32:13 Validation State: unverified Task: RT Announcement bits (1): 0-KRT AS path: I Communities: 64510:2 64510:20 64510:22 64510:200 64510:222 172.16.3.0/24 (1 entry, 1 announced) *Static Preference: 5 Next hop type: Reject Address: 0x8fd0dc4 Next-hop reference count: 8 State: <Active Int Ext> Local AS: 64511 Age: 21:32:13 Validation State: unverified Task: RT Announcement bits (1): 0-KRT AS path: I Communities: 64510:3 64510:30 64510:33 64510:300 64510:333 172.16.4.0/24 (1 entry, 1 announced) *Static Preference: 5 Next hop type: Reject Address: 0x8fd0dc4 Next-hop reference count: 8 State: <Active Int Ext> Local AS: 64511 Age: 21:32:13 Validation State: unverified Task: RT Announcement bits (1): 0-KRT AS path: I Communities: 64510:4 64510:40 64510:44 64510:400 64510:444
複雑な正規表現をテストするために、デバイスR2にはルートを探索する と呼ばれる test-regex
ポリシーがあります。ポリシーは次のように設定されます。
policy-statement test-regex { term find-routes { from community complex-regex; then accept; } term reject-the-rest { then reject; } } community complex-regex members "^64510:[13].*$";
この正規表現は、1 または 3 で始まるコミュニティ値に一致します。
トポロジ
図 2 は、サンプル ネットワークを示しています。

CLIクイックコンフィギュレーション は、 図2のすべてのデバイスの設定を示しています。
セクション #d82e83__d82e261 では、デバイス R2 の手順について説明します。
構成
CLI クイックコンフィギュレーション
この例を迅速に設定するには、以下のコマンドをコピーしてテキスト ファイルに貼り付け、改行を削除し、ネットワーク設定に合わせて必要な詳細を変更してから、 階層レベルの CLI にコマンドを [edit]
コピー アンド ペーストします。
デバイス R1
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.1/30 set interfaces lo0 unit 0 family inet address 192.168.0.1/32 set protocols bgp group ext type external set protocols bgp group ext peer-as 64511 set protocols bgp group ext neighbor 10.0.0.2 set routing-options router-id 192.168.0.1 set routing-options autonomous-system 64510
デバイスR2
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.2/30 set interfaces lo0 unit 0 family inet address 192.168.0.2/32 set protocols bgp group ext type external set protocols bgp group ext peer-as 64510 set protocols bgp group ext neighbor 10.0.0.1 set policy-options policy-statement send-static term 1 from protocol static set policy-options policy-statement send-static term 1 then accept set policy-options policy-statement send-static term 2 then reject set policy-options policy-statement test-regex term find-routes from community complex-regex set policy-options policy-statement test-regex term find-routes then accept set policy-options policy-statement test-regex term reject-the-rest then reject set policy-options community complex-regex members "^64510:[13].*$" set routing-options static route 172.16.1.0/24 reject set routing-options static route 172.16.1.0/24 community 64510:1 set routing-options static route 172.16.1.0/24 community 64510:10 set routing-options static route 172.16.1.0/24 community 64510:11 set routing-options static route 172.16.1.0/24 community 64510:100 set routing-options static route 172.16.1.0/24 community 64510:111 set routing-options static route 172.16.2.0/24 reject set routing-options static route 172.16.2.0/24 community 64510:2 set routing-options static route 172.16.2.0/24 community 64510:20 set routing-options static route 172.16.2.0/24 community 64510:22 set routing-options static route 172.16.2.0/24 community 64510:200 set routing-options static route 172.16.2.0/24 community 64510:222 set routing-options static route 172.16.3.0/24 reject set routing-options static route 172.16.3.0/24 community 64510:3 set routing-options static route 172.16.3.0/24 community 64510:30 set routing-options static route 172.16.3.0/24 community 64510:33 set routing-options static route 172.16.3.0/24 community 64510:300 set routing-options static route 172.16.3.0/24 community 64510:333 set routing-options static route 172.16.4.0/24 reject set routing-options static route 172.16.4.0/24 community 64510:4 set routing-options static route 172.16.4.0/24 community 64510:40 set routing-options static route 172.16.4.0/24 community 64510:44 set routing-options static route 172.16.4.0/24 community 64510:400 set routing-options static route 172.16.4.0/24 community 64510:444 set routing-options router-id 192.168.0.2 set routing-options autonomous-system 64511
手順
手順
次の例では、設定階層内のさまざまなレベルに移動する必要があります。CLIのナビゲーションについては、 CLIユーザーガイドの設定モードでのCLIエディターの使用を参照してください。
デバイスR2を設定するには:
インターフェイスを設定します。
[edit interfaces] user@R2# set fe-1/2/0 unit 0 family inet address 10.0.0.2/30 user@R2# set lo0 unit 0 family inet address 192.168.0.2/32
BGPを設定します。
デバイスR2とのBGPピアリングセッションにインポートポリシーを適用します。
[edit protocols bgp group ext] user@R2# set type external user@R2# set peer-as 64510 user@R2# set neighbor 10.0.0.1
スタティックルートを送信するルーティングポリシーを設定します。
[edit policy-options policy-statement send-static] user@R2# set term 1 from protocol static user@R2# set term 1 then accept user@R2# set term 2 then reject
正規表現をテストするルーティングポリシーを設定します。
[edit policy-options policy-statement test-regex] user@R2# set term find-routes from community complex-regex user@R2# set term find-routes then accept user@R2# set term reject-the-rest then reject [edit policy-options community] user@R2# set complex-regex members "^64510:[13].*$"
静的ルートを設定し、コミュニティ値をアタッチします。
[edit routing-options static route 172.16.1.0/24] user@R2# set reject user@R2# set community [ 64510:1 64510:10 64510:11 64510:100 64510:111 ] [edit routing-options static route 172.16.2.0/24] user@R2# set reject user@R2# set community [ 64510:2 64510:20 64510:22 64510:200 64510:222 ] [edit routing-options static route 172.16.3.0/24] user@R2# set reject user@R2# set community [ 64510:3 64510:30 64510:33 64510:300 64510:333 ] [edit routing-options static route 172.16.4.0/24] user@R2# set reject user@R2# set community [ 64510:4 64510:40 64510:44 64510:400 64510:444 ]
自律システム(AS)番号とルーターIDを設定します。
これは、デバイスR2のルーティングテーブルに影響を与え、デバイスR1およびデバイスR3には影響しません。
[edit routing-options ] user@R2# set router-id 192.168.0.2 user@R2# set autonomous-system 64511
結果
設定モードから、 、show policy-options
show protocols
および のコマンドをshow interfaces
入力して設定をshow routing-options
確認します。出力結果に意図した設定が表示されない場合は、この例の手順を繰り返して設定を修正します。
user@R2# show interfaces fe-1/2/0 { unit 0 { family inet { address 10.0.0.2/30; } } } lo0 { unit 0 { family inet { address 192.168.0.2/32; } } }
user@R2# show protocols bgp { group ext { type external; peer-as 64510; neighbor 10.0.0.1; } }
user@R2# show policy-options policy-statement send-static { term 1 { from protocol static; then accept; } term 2 { then reject; } } policy-statement test-regex { term find-routes { from community complex-regex; then accept; } term reject-the-rest { then reject; } } community complex-regex members "^64510:[13].*$";
user@R2# show routing-options static { route 172.16.1.0/24 { reject; community [ 64510:1 64510:10 64510:11 64510:100 64510:111 ]; } route 172.16.2.0/24 { reject; community [ 64510:2 64510:20 64510:22 64510:200 64510:222 ]; } route 172.16.3.0/24 { reject; community [ 64510:3 64510:30 64510:33 64510:300 64510:333 ]; } route 172.16.4.0/24 { reject; community [ 64510:4 64510:40 64510:44 64510:400 64510:444 ]; } } router-id 192.168.0.2; autonomous-system 64511;
デバイスの設定が完了したら、設定モードから を入力します commit
。
検証
設定が正しく機能していることを確認します。
正規表現に一致するコミュニティを確認するテスト
目的
コマンドを使用して、正規表現とそのポリシーを test policypolicy-name
テストできます。
アクション
デバイスR2で、 コマンドを
test policy test-regex 0/0
実行します。user@R2> test policy test-regex 0/0 inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 172.16.1.0/24 *[Static/5] 1d 00:32:50 Reject 172.16.3.0/24 *[Static/5] 1d 00:32:50 Reject Policy test-regex: 2 prefix accepted, 5 prefix rejected
デバイスR2で、正規表現を変更して、数字2のインスタンス数を含むコミュニティ値に一致させます。
[edit policy-options community complex-regex] user@R2# delete members "^64510:[13].*$" user@R2# set members "^65020:2+$" user@R2# commit
デバイスR2で、 コマンドを再実行してください
test policy test-regex 0/0
。user@R2> test policy test-regex 0/0 inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 172.16.2.0/24 *[Static/5] 1d 00:31:36 Reject Policy test-regex: 1 prefix accepted, 6 prefix rejected
意味
172.16.1.0/24 および 172.16.3.0/24 ルートには、^64510:[13].*$ 表現と一致するコミュニティがアタッチされています。172.16.2.0/24 ルートには、^65020:2+$ 表現と一致するコミュニティがあります。