サービスの改善にご協力お願いします。

お客様のご意見をお聞かせください。

アンケートの所要時間はおよそ 2 分です。

header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
list Table of Contents
このページで
keyboard_arrow_right

この機械翻訳はお役に立ちましたでしょうか?

starstarstarstarstar
Go to English page
免責事項:

このページは、サードパーティー製機械翻訳ソフトウェアを使用して翻訳されます。質の高い翻訳を提供するために合理的な対応はされていますが、ジュニパーネットワークスがその正確性を保証することはできかねます。この翻訳に含まれる情報の正確性について疑問が生じた場合は、英語版を参照してください. ダウンロード可能なPDF (英語版のみ).

例:条件付きデフォルト ルート ポリシーの設定

date_range 19-Jan-25

この例では、1台のルーティング・デバイスで条件付きデフォルト・ルートを設定し、そのデフォルト・ルートをOSPFに再配布する方法を示しています。

要件

この例を設定する前に、デバイス初期化以外の特別な設定を行う必要はありません。

概要

この例では、OSPFエリア0には3つのルーティングデバイスが含まれています。デバイスR3には、インターネットサービスプロバイダ(ISP)などの外部ピアとのBGPセッションがあります。

この例では、スタティック ルートを BGP に伝送するために、ルートを定義する際に discard ステートメントを含めています。ISPはBGPにデフォルトの静的ルートを挿入し、外部ネットワークに到達するためのデフォルトの静的ルートを顧客ネットワークに提供します。スタティック ルートには廃棄ネクストホップがあります。つまり、パケットがより具体的なルートに一致しない場合、パケットは拒否され、この宛先の拒否ルートがルーティング テーブルにインストールされますが、インターネット制御メッセージ プロトコル(ICMP)到達不能メッセージは送信されません。廃棄ネクストホップは、ダイナミック ルーティング プロトコルを通じてアドバタイズ可能なサマリー ルートを発信することを可能にします。

デバイスR3は、デフォルトルートをOSPFにエクスポートします。デバイス R3 のルート ポリシーは、ISP への接続がダウンした場合、ルーティング テーブルでアクティブではなくなるため、デフォルト ルートが OSPF にエクスポートされなくなるという条件です。このポリシーは、パケットが予告なしにサイレントに破棄されることを防ぎます(ヌルルートフィルタリングとも呼ばれます)。

この例では、すべてのデバイスの設定と、デバイス R3 でのステップバイステップの設定を示します。

トポロジー

図 1は、サンプルのネットワークを示しています。

図 1: ISP への条件付きデフォルト ルートを持つ OSPFISP への条件付きデフォルト ルートを持つ OSPF

設定

CLIクイック構成

この例をすばやく設定するには、次のコマンドをコピーしてテキストファイルに貼り付け、改行を削除して、ネットワーク構成に合わせて必要な詳細を変更し、[edit]階層レベルのCLIにコマンドをコピー&ペーストしてください。

デバイスR1

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 0 description R1->R3
set interfaces fe-1/2/0 unit 0 family inet address 10.0.1.2/30
set interfaces fe-1/2/1 unit 2 description R1->R2
set interfaces fe-1/2/1 unit 2 family inet address 10.0.0.1/30
set protocols ospf area 0.0.0.0 interface fe-1/2/0.0
set protocols ospf area 0.0.0.0 interface fe-1/2/1.2

デバイスR2

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 1 description R2->R1
set interfaces fe-1/2/0 unit 1 family inet address 10.0.0.2/30
set interfaces fe-1/2/1 unit 4 description R2->R3
set interfaces fe-1/2/1 unit 4 family inet address 10.0.2.2/30
set protocols ospf area 0.0.0.0 interface fe-1/2/0.1
set protocols ospf area 0.0.0.0 interface fe-1/2/1.4

デバイスR3

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 3 description R3->R2
set interfaces fe-1/2/0 unit 3 family inet address 10.0.2.1/30
set interfaces fe-1/2/1 unit 5 description R3->R1
set interfaces fe-1/2/1 unit 5 family inet address 10.0.1.1/30
set interfaces ge-0/0/2 unit 0 description R3->ISP
set interfaces ge-0/0/2 unit 0 family inet address 10.0.45.2/30
set protocols bgp group ext type external
set protocols bgp group ext peer-as 64500
set protocols bgp group ext neighbor 10.0.45.1
set protocols ospf export gendefault
set protocols ospf area 0.0.0.0 interface fe-1/2/1.4
set protocols ospf area 0.0.0.0 interface fe-1/2/0.3
set policy-options policy-statement gendefault term upstreamroutes from protocol bgp
set policy-options policy-statement gendefault term upstreamroutes from as-path upstream
set policy-options policy-statement gendefault term upstreamroutes from route-filter 0.0.0.0/0 upto /16
set policy-options policy-statement gendefault term upstreamroutes then next-hop 10.0.45.1
set policy-options policy-statement gendefault term upstreamroutes then accept
set policy-options policy-statement gendefault term end then reject
set policy-options as-path upstream "^64500 "
set routing-options autonomous-system 64501

デバイスISP

content_copy zoom_out_map
set interfaces ge-0/0/2 unit 0 family inet address 10.0.45.1/30
set protocols bgp group ext type external
set protocols bgp group ext export advertise-default
set protocols bgp group ext peer-as 64501
set protocols bgp group ext neighbor 10.0.45.2
set policy-options policy-statement advertise-default term 1 from route-filter 0.0.0.0/0 exact
set policy-options policy-statement advertise-default term 1 then accept
set routing-options static route 0.0.0.0/0 discard
set routing-options autonomous-system 64500

手順

ステップバイステップでの手順

次の例では、設定階層のいくつかのレベルに移動する必要があります。CLIのナビゲーションについては、Junos OS CLIユーザーガイド設定モードでCLIエディターを使用する を参照してください。

デバイス R3 を設定するには:

  1. インターフェイスを設定します。

    content_copy zoom_out_map
    [edit interfaces]
    user@R3# set fe-1/2/0 unit 3 description R3->R2
    user@R3# set fe-1/2/0 unit 3 family inet address 10.0.2.1/30
    user@R3# set fe-1/2/1 unit 5 description R3->R1
    user@R3# set fe-1/2/1 unit 5 family inet address 10.0.1.1/30
    user@R3# set ge-0/0/2 unit 0 description R3->ISP
    user@R3# set ge-0/0/2 unit 0 family inet address 10.0.45.2/30
    
  2. 自律システム(AS)番号を設定します。

    content_copy zoom_out_map
    [edit routing-options]
    user@R3# set autonomous-system 64501
    
  3. ISPデバイスとのBGPセッションを設定します。

    content_copy zoom_out_map
    [edit protocols bgp group ext]
    user@R3# set type external
    user@R3# set peer-as 64500
    user@R3# set neighbor 10.0.45.1
    
  4. OSPFを設定します。

    content_copy zoom_out_map
    [edit protocols ospf area 0.0.0.0]
    user@R3# set interface fe-1/2/1.4
    user@R3# set interface fe-1/2/0.3
    
  5. ルーティングポリシーを設定します。

    content_copy zoom_out_map
    [edit policy-options policy-statement gendefault]
    user@R3# set term upstreamroutes from protocol bgp
    user@R3# set term upstreamroutes from as-path upstream
    user@R3# set term upstreamroutes from route-filter 0.0.0.0/0 upto /16
    user@R3# set term upstreamroutes then next-hop 10.0.45.1
    user@R3# set term upstreamroutes then accept
    user@R3# set term end then reject
    [edit policy-options]
    user@R3# set as-path upstream "^64500 "
    
  6. OSPFにエクスポートポリシーを適用します。

    content_copy zoom_out_map
    [edit protocols ospf]
    user@R3# set export gendefault
    
  7. デバイスの設定が完了したら、設定をコミットします。

    content_copy zoom_out_map
    [edit]
    user@R3# commit
    

結果

show コマンドを発行して、構成を確認します。出力結果に意図した設定内容が表示されない場合は、この例の手順を繰り返して設定を修正します。

content_copy zoom_out_map
user@R3# show
interfaces {
    fe-1/2/0 {
        unit 3 {
            description R3->R2;
            family inet {
                address 10.0.2.1/30;
            }
        }
    }
    fe-1/2/1 {
        unit 5 {
            description R3->R1;
            family inet {
                address 10.0.1.1/30;
            }
        }
    }
    ge-1/2/0 {
        unit 0 {
            description R3->ISP;
            family inet {
                address 10.0.45.2/30;
            }
        }
    }
}
protocols {
    bgp {
        group ext {
            type external;
            peer-as 64500;
            neighbor 10.0.45.1;
        }
    }
    ospf {
        export gendefault;
        area 0.0.0.0 {
            interface fe-1/2/1.4;
            interface fe-1/2/0.3;
        }
    }
}
policy-options {
    policy-statement gendefault {
        term upstreamroutes {
            from {
                protocol bgp;
                as-path upstream;
                route-filter 0.0.0.0/0 upto /16;
            }
            then {
                next-hop 10.0.45.1;
                accept;
            }
        }
        term end {
            then reject;
        }
    }
    as-path upstream "^64500 ";
}
routing-options {
    autonomous-system 64501;
}

検証

設定が正常に機能していることを確認します。

ISP へのルートが機能していることの確認

目的

デバイスR3とISPのルーターの間に接続が確立されていることを確認します。

アクション

content_copy zoom_out_map
user@R3> ping 10.0.45.1
PING 10.0.45.1 (10.0.45.1): 56 data bytes
64 bytes from 10.0.45.1: icmp_seq=0 ttl=64 time=1.185 ms
64 bytes from 10.0.45.1: icmp_seq=1 ttl=64 time=1.199 ms
64 bytes from 10.0.45.1: icmp_seq=2 ttl=64 time=1.186 ms

意味

ping コマンドは、到達可能性を確認します。

スタティック ルートが再配布されていることの確認

目的

BGPポリシーが、デバイスR3のルーティングテーブルに静的ルートを再配布していることを確認します。また、OSPF ポリシーが、デバイスR1とデバイスR2のルーティングテーブルに静的ルートを再配布していることを確認してください。

アクション

content_copy zoom_out_map
user@R3> show route protocol bgp

inet.0: 9 destinations, 10 routes (9 active, 0 holddown, 1 hidden)
+ = Active Route, - = Last Active, * = Both

0.0.0.0/0          *[BGP/170] 00:00:25, localpref 100
                      AS path: 64500 I
                    > to 10.0.45.1 via ge-0/0/2.6
content_copy zoom_out_map
user@R1> show route protocol ospf

inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

0.0.0.0/0          *[OSPF/150] 00:03:58, metric 0, tag 0
                    > to 10.0.1.1 via fe-1/2/0.0
10.0.2.0/30        *[OSPF/10] 03:37:45, metric 2
                      to 10.0.1.1 via fe-1/2/0.0
                    > to 10.0.0.2 via fe-1/2/1.2
172.16.233.5/32       *[OSPF/10] 03:38:41, metric 1
                      MultiRecv
content_copy zoom_out_map
user@R2> show route protocol ospf
inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

0.0.0.0/0          *[OSPF/150] 00:04:04, metric 0, tag 0
                    > to 10.0.2.1 via fe-1/2/1.4
10.0.1.0/30        *[OSPF/10] 03:37:46, metric 2
                      to 10.0.0.1 via fe-1/2/0.1
                    > to 10.0.2.1 via fe-1/2/1.4
172.16.233.5/32       *[OSPF/10] 03:38:47, metric 1
                      MultiRecv

意味

ルーティング テーブルには、デフォルトの 0.0.0.0/0 ルートが含まれています。デバイスR1とデバイスR2が、ルーティングテーブルに指定されていないネットワーク宛てのパケットを受信した場合、それらのパケットはデバイスR3に送信され、さらに処理されます。デバイスR3がルーティングテーブルで指定されていないネットワーク宛てのパケットを受信した場合、それらのパケットはISPに送信されてさらに処理されます。

ポリシー条件のテスト

目的

外部ネットワークが到達不能になった場合に、ルーティングテーブルからルートが削除されるようにするために、インターフェイスを無効にします。

アクション

content_copy zoom_out_map
user@R3> deactivate interfaces ge-0/0/2 unit 0 family inet address 10.0.45.2/30
user@R3> commit
content_copy zoom_out_map
user@R1> show route protocol ospf

inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.0.2.0/30        *[OSPF/10] 03:41:48, metric 2
                      to 10.0.1.1 via fe-1/2/0.0
                    > to 10.0.0.2 via fe-1/2/1.2
172.16.233.5/32       *[OSPF/10] 03:42:44, metric 1
                      MultiRecv

user@R2> show route protocol ospf
inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.0.1.0/30        *[OSPF/10] 03:42:10, metric 2
                      to 10.0.0.1 via fe-1/2/0.1
                    > to 10.0.2.1 via fe-1/2/1.4
172.16.233.5/32       *[OSPF/10] 03:43:11, metric 1
                      MultiRecv

意味

デバイスR1とデバイスR2のルーティングテーブルには、デフォルトの0.0.0.0/0ルートは含まれません。これにより、デフォルト ルートが OSPF ドメインに存在しないことが確認されます。ge-0/0/2.6インターフェイスを再アクティブにするには、 activate interfaces ge-0/0/2 unit 0 family inet address 10.0.45.2/30 設定モードコマンドを発行します。

footer-navigation