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

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

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

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

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

starstarstarstarstar
Go to English page
免責事項:

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

例:BGPコミュニティを削除するルーティングポリシーの設定

date_range 19-Jan-25

この例では、BGPルートを受け入れるが、ルートからBGPコミュニティを削除するポリシーを作成する方法を示しています。

要件

この例を構成する前に、デバイスの初期化以上の特別な構成は必要ありません。

概要

この例では、外部BGP(EBGP)接続を持つ2つのルーティングデバイスを示しています。デバイスR2は、BGPセッションを使用して、デバイスR1に2つのスタティックルートを送信します。デバイスR1では、インポートポリシーにより、すべてのBGPコミュニティをルートから削除する必要があることが指定されています。

デフォルトでは、EBGPピアにコミュニティが設定されている場合、送信および承認されます。ネイバーから受信したコミュニティの受け入れを抑制するには、すべてのコミュニティまたは指定したコミュニティのセットを削除します。ポリシーの結果が空のコミュニティセットである場合、コミュニティ属性は含まれません。すべてのコミュニティを削除するには、まずワイルドカードのコミュニティ セットを定義します(ここでは、コミュニティの名前は wild )。

content_copy zoom_out_map
[edit policy-options]
community wild members "* : *";

次に、ルーティングポリシーステートメントで、 community delete アクションを指定します。

content_copy zoom_out_map
[edit policy-options]
policy-statement policy-name {
    term term-name {
        then community delete wild;
    }
}

自律システム(AS)から特定のコミュニティを抑制するには、コミュニティを community wild members "*:community-value"として定義します。

トポロジー

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

図 1: コミュニティを削除する BGP ポリシーコミュニティを削除する BGP ポリシー

設定

CLIクイック構成

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

デバイスR1

content_copy zoom_out_map
set interfaces fe-1/1/0 unit 0 description to-R2
set interfaces fe-1/1/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 external-peers type external
set protocols bgp group external-peers peer-as 2
set protocols bgp group external-peers neighbor 10.0.0.2 import remove-communities
set policy-options policy-statement remove-communities term 1 from protocol bgp
set policy-options policy-statement remove-communities term 1 then community delete wild
set policy-options policy-statement remove-communities term 1 then accept
set policy-options policy-statement remove-communities term 2 then reject
set policy-options community wild members *:*
set routing-options router-id 192.168.0.1
set routing-options autonomous-system 1

デバイスR2

content_copy zoom_out_map
set interfaces fe-1/1/0 unit 0 description to-R1
set interfaces fe-1/1/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 external-peers type external
set protocols bgp group external-peers export statics
set protocols bgp group external-peers peer-as 1
set protocols bgp group external-peers neighbor 10.0.0.1
set policy-options policy-statement statics from protocol static
set policy-options policy-statement statics then community add 1
set policy-options policy-statement statics then accept
set policy-options community 1 members 2:1
set policy-options community 1 members 2:2
set policy-options community 1 members 2:3
set policy-options community 1 members 2:4
set policy-options community 1 members 2:5
set policy-options community 1 members 2:6
set policy-options community 1 members 2:7
set policy-options community 1 members 2:8
set policy-options community 1 members 2:9
set policy-options community 1 members 2:10
set routing-options static route 10.2.0.0/16 reject
set routing-options static route 10.2.0.0/16 install
set routing-options static route 10.3.0.0/16 reject
set routing-options static route 10.3.0.0/16 install
set routing-options router-id 192.168.0.3
set routing-options autonomous-system 2

手順

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

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

Device R1を設定するには:

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

    content_copy zoom_out_map
    [edit interfaces]
    user@R1# set fe-1/1/0 unit 0 description to-R2
    user@R1# set fe-1/1/0 unit 0 family inet address 10.0.0.1/30
    user@R1# set lo0 unit 0 family inet address 192.168.0.1/32
    
  2. BGP を設定します。

    デバイスR2とのBGPピアリングセッションにインポートポリシーを適用します。

    content_copy zoom_out_map
    [edit protocols bgp group external-peers]
    user@R1# set type external
    user@R1# set peer-as 2
    user@R1# set neighbor 10.0.0.2 import remove-communities
    
  3. コミュニティを削除するルーティングポリシーを設定します。

    content_copy zoom_out_map
    [edit policy-options policy-statement remove-communities]
    user@R1# set term 1 from protocol bgp
    user@R1# set term 1 then community delete wild
    user@R1# set term 1 then accept
    user@R1# set term 2 then reject
    
  4. 自律システム(AS)番号とルーターIDを設定します。

    content_copy zoom_out_map
    [edit routing-options ]
    user@R1# set router-id 192.168.0.1
    user@R1# set autonomous-system 1
    

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

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

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

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

    content_copy zoom_out_map
    [edit interfaces]
    user@R2# set fe-1/1/0 unit 0 description to-R1
    user@R2# set fe-1/1/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
    
  2. ルーターIDと自律システム(AS)番号を設定する。

    content_copy zoom_out_map
    [edit routing-options]
    user@R2# set router-id 192.168.0.3
    user@R2# set autonomous-system 2
    
  3. BGP を設定します。

    content_copy zoom_out_map
    [edit  protocols bgp group external-peers]
    user@R2# set type external
    user@R2# set peer-as 1
    user@R2# set neighbor 10.0.0.1
    
  4. 複数のコミュニティを設定するか、複数のメンバーを持つ単一のコミュニティを設定します。

    content_copy zoom_out_map
    [edit policy-options community 1]
    user@R2# set members 2:1
    user@R2# set members 2:2
    user@R2# set members 2:3
    user@R2# set members 2:4
    user@R2# set members 2:5
    user@R2# set members 2:6
    user@R2# set members 2:7
    user@R2# set members 2:8
    user@R2# set members 2:9
    user@R2# set members 2:10
    
  5. 静的ルートを構成します。

    content_copy zoom_out_map
    [edit routing-options static]
    user@R2# set route 10.2.0.0/16 reject
    user@R2# set route 10.2.0.0/16 install
    user@R2# set route 10.3.0.0/16 reject
    user@R2# set route 10.3.0.0/16 install
    
  6. スタティックルートをBGPにアドバタイズし、BGPコミュニティをルートに追加するルーティングポリシーを設定します。

    content_copy zoom_out_map
    [edit policy-options policy-statement statics]
    user@R2# set from protocol static
    user@R2# set then community add 1
    user@R2# set then accept
    
  7. エクスポートポリシーを適用します。

    content_copy zoom_out_map
    [edit protocols bgp group external-peers]
    user@R2# set export statics
    

結果

設定モードから、show interfacesshow protocolsshow policy-options、およびshow routing-options のコマンドを入力して設定を確認します。出力結果に意図した設定内容が表示されない場合は、この例の手順を繰り返して設定を修正します。

デバイスR1

content_copy zoom_out_map
user@R1# show interfaces
fe-1/1/0 {
    unit 0{
        description to-R2;
        family inet {
            address 10.0.0.1/30;
        }
    }
}
lo0 {
    unit 0 {
        family inet {
            address 192.168.0.1/32;
        }
    }
}
content_copy zoom_out_map
user@R1# show protocols
bgp {
    group external-peers {
        type external;
        peer-as 2;
        neighbor 10.0.0.2 {
            import remove-communities;
        }
    }
}
content_copy zoom_out_map
user@R1# show policy-options
policy-statement remove-communities {
    term 1 {
        from protocol bgp;
        then {
            community delete wild;
            accept;
        }
    }
    term 2 {
        then reject;
    }
}
community wild members *:*;
content_copy zoom_out_map
user@R1# show routing-options
router-id 192.168.0.1;
autonomous-system 1;

デバイスR2

content_copy zoom_out_map
user@R2# show interfaces
fe-1/1/0 {
    unit 0 {
        description to-R1;
        family inet {
            address 10.0.0.2/30;
        }
    }
}
lo0 {
    unit 0 {
        family inet {
            address 192.168.0.2/32;
        }
    }
}
content_copy zoom_out_map
user@R2# show protocols
bgp {
    group external-peers {
        type external;
        export statics;
        peer-as 1;
        neighbor 10.0.0.1;
    }
}
content_copy zoom_out_map
user@R2# show policy-options
policy-statement statics {
    from protocol static;
    then {
        community add 1;
        accept;
    }
}
community 1 members [ 2:1 2:2 2:3 2:4 2:5 2:6 2:7 2:8 2:9 2:10 ];
content_copy zoom_out_map
user@R2# show routing-options
static {
    route 10.2.0.0/16 {
        reject;
        install;
    }
    route 10.3.0.0/16 {
        reject;
        install;
    }
}
router-id 192.168.0.3;
autonomous-system 2;

デバイスの設定が完了したら、設定モードからcommitを入力します。

検証

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

BGP ルートの検証

目的

デバイスR1のルーティングテーブルにBGPコミュニティが含まれていないことを確認します。

アクション

  1. デバイスR1で、 show route protocols bgp extensive コマンドを実行します。

    content_copy zoom_out_map
    user@R1> show route protocols bgp extensive
    
    inet.0: 5 destinations, 5 routes (5 active, 0 holddown, 0 hidden)
    10.2.0.0/16 (1 entry, 1 announced)
    TSI:
    KRT in-kernel 10.2.0.0/16 -> {10.0.0.2}
            *BGP    Preference: 170/-101
                    Next hop type: Router, Next hop index: 671
                    Address: 0x9458270
                    Next-hop reference count: 4
                    Source: 10.0.0.2
                    Next hop: 10.0.0.2 via lt-1/1/0.5, selected
                    Session Id: 0x100001
                    State: <Active Ext>
                    Local AS:     1 Peer AS:     2
                    Age: 20:39:01 
                    Validation State: unverified 
                    Task: BGP_2.10.0.0.2+179
                    Announcement bits (1): 0-KRT 
                    AS path: 2 I
                    Accepted
                    Localpref: 100
                    Router ID: 192.168.0.3
    
    10.3.0.0/16 (1 entry, 1 announced)
    TSI:
    KRT in-kernel 10.3.0.0/16 -> {10.0.0.2}
            *BGP    Preference: 170/-101
                    Next hop type: Router, Next hop index: 671
                    Address: 0x9458270
                    Next-hop reference count: 4
                    Source: 10.0.0.2
                    Next hop: 10.0.0.2 via lt-1/1/0.5, selected
                    Session Id: 0x100001
                    State: <Active Ext>
                    Local AS:     1 Peer AS:     2
                    Age: 20:39:01 
                    Validation State: unverified 
                    Task: BGP_2.10.0.0.2+179
                    Announcement bits (1): 0-KRT 
                    AS path: 2 I
                    Accepted
                    Localpref: 100
                    Router ID: 192.168.0.3
  2. デバイスR1で、インポートポリシーで community remove 設定を無効にします。

    content_copy zoom_out_map
    [edit policy-options policy-statement remove-communities term 1]
    user@R1# deactivate then community delete wild
    user@R1# commit
    
  3. デバイスR1で、 show route protocols bgp extensive コマンドを実行して、アドバタイズされたコミュニティを表示します。

    content_copy zoom_out_map
    user@R1> show route protocols bgp extensive
    inet.0: 5 destinations, 5 routes (5 active, 0 holddown, 0 hidden)
    10.2.0.0/16 (1 entry, 1 announced)
    TSI:
    KRT in-kernel 10.2.0.0/16 -> {10.0.0.2}
            *BGP    Preference: 170/-101
                    Next hop type: Router, Next hop index: 671
                    Address: 0x9458270
                    Next-hop reference count: 4
                    Source: 10.0.0.2
                    Next hop: 10.0.0.2 via lt-1/1/0.5, selected
                    Session Id: 0x100001
                    State: <Active Ext>
                    Local AS:     1 Peer AS:     2
                    Age: 20:40:53 
                    Validation State: unverified 
                    Task: BGP_2.10.0.0.2+179
                    Announcement bits (1): 0-KRT 
                    AS path: 2 I
                    Communities: 2:1 2:2 2:3 2:4 2:5 2:6 2:7 2:8 2:9 2:10
                    Accepted
                    Localpref: 100
                    Router ID: 192.168.0.3
    
    10.3.0.0/16 (1 entry, 1 announced)
    TSI:
    KRT in-kernel 10.3.0.0/16 -> {10.0.0.2}
            *BGP    Preference: 170/-101
                    Next hop type: Router, Next hop index: 671
                    Address: 0x9458270
                    Next-hop reference count: 4
                    Source: 10.0.0.2
                    Next hop: 10.0.0.2 via lt-1/1/0.5, selected
                    Session Id: 0x100001
                    State: <Active Ext>
                    Local AS:     1 Peer AS:     2
                    Age: 20:40:53 
                    Validation State: unverified 
                    Task: BGP_2.10.0.0.2+179
                    Announcement bits (1): 0-KRT 
                    AS path: 2 I
                    Communities: 2:1 2:2 2:3 2:4 2:5 2:6 2:7 2:8 2:9 2:10
                    Accepted
                    Localpref: 100
                    Router ID: 192.168.0.3
    
    

意味

出力からは、デバイスR1のルーティングテーブルで、デバイスR2から送信されたBGPルートでコミュニティが抑制されていることがわかります。デバイスR1の読み込みポリシーの community remove 設定が無効化されると、コミュニティは抑制されなくなります。

footer-navigation