BGP COMMUNITY - Cisco Config 2



 COMMUNITY値は32ビットの数値であり、以下のいずれかのパターンで扱えます。今回は 2 を紹介します。

パターン 内容 説明
1  32ビットの任意の整数  10進数で表示されるデフォルトの表示
2  AS番号(16ビット)+ 識別子(16ビット)  AA:NNの形式で前半がAS番号、後半は2バイトの番号の表示
3  32ビットのWell-knownコミュニティ値  no-export、no-advertise、local-as の表示



 ◆ COMMUNITYアトリビュート - 設定( AA:NN形式 )

 BGPネイバーにCOMMUNITY値を伝達するためにBGPルートの送信側、受信側ともに以下を設定します。

 ◆ COMMUNITYアトリビュート値を通知させるための設定( BGPルートの送信側、受信側の共通設定 )
 (config)# router bgp as-number
 (config-router)# neighbor ip-address send-community


 次に、IOSでCOMMUNITY値を「AS番号+識別子」として扱うためには、以下の設定が必要となります。

 ◆ COMMUNITY値のフォーマットの宣言( BGPルートの送信側、受信側の共通設定 )
 (config)#
ip bgp-community new-format


 次に、付加するCOMMUNIT値をroute-mapコマンドで定義します。付加する値は自由に決められます。

 ◆ COMMUNITYアトリビュートを付加する設定( BGPルートの送信側の設定 )
 (config)# route-map map-tag permit | deny [ seq-number ]
 (config-route-map)# match condition
 (config-route-map)#
set community AS:NN

 
◆ COMMUNITYアトリビュートを付加したBGPルートを通知する設定( BGPルートの送信側の設定 )
 (config)#
router bgp as-number
 (config-router)#
neighbor ip-address route-map map-tag out



 次に、付加されたCOMMUNIT値に基づいて制御が行えるように、受信側でCOMMUNITリストを定義します。

 ◆ BGP COMMUNITYリストの設定( BGPルートの受信側の設定 )
 (config)# ip community-list number
permit | deny AA:NN


 最後に、受信側でCOMMUNITYアトリビュートを参照して、ルートフィルタリングや制御を行います。

 ◆ COMMUNITY値に基づいたルートフィルタリングや制御の設定( BGPルートの受信側の設定 )
 (config)#
route-map map-tag permit | deny [ seq-number ]
 (config-route-map)#
match community community-list
 (config-route-map)#
set action

 (config)# router bgp as-number
 (config-router)#
neighbor ip-address route-map map-tag in

 set actionは「set metric」でMED値を付加して送信したり、「set as-path prepend」でASパスを加算したり
 しますが、現在のCOMMUNITY値に追加のCOMMUNITY値を加算したい場合、
set comunity number additive
 コマンドで設定します。引数の「 additive 」を指定しない場合、COMMUNITY値が書き変わってしまいます。


 ◆ COMMUNITYアトリビュート - 設定例( AA:NN形式 )

 下図のように、AS10にあるルート情報に対して以下のようにCOMMUNITYアトリビュート値を割り当てます。
 ⇒ 1.1.1.0/24、1.1.2.0/24、1.1.3.0/24、1.1.4.0/24 をグループ化してCOMMUNITY値「100:200」を割当
 ⇒ 2.1.1.0/24、2.1.2.0/24、2.1.3.0/24、2.1.4.0/24 をグループ化してCOMMUNITY値「100:300」を割当

 そして「100:200」のCOMMUNITY値のルート情報はAS200にアドバタイズされないようにして、それ以外
 のルート情報はアドバタイズされるようにします。また「 100:300 」のルート情報はAS300にアドバタイズ
 される際に、as-prependコマンドによって、AS_PATHアトリビュート値を加算させてアドバタイズします。


   



 R1(config)# access-list 1 permit 1.1.1.0
 R1(config)# access-list 1 permit 1.1.2.0
 R1(config)# access-list 1 permit 1.1.3.0
 R1(config)# access-list 1 permit 1.1.4.0

 R1(config)# access-list 2 permit 2.1.1.0
 R1(config)# access-list 2 permit 2.1.2.0
 R1(config)# access-list 2 permit 2.1.3.0
 R1(config)# access-list 2 permit 2.1.4.0


 R1(config)# ip bgp-community new-format

 R1(config)# route-map R-COMMUNITY permit 10
 R1(config-route-map)#match ip address 1
 R1(config-route-map)#set community 100:1


 R1(config)# route-map R-COMMUNITY permit 20
 
R1(config-route-map)#match ip address 2

 R1(config-route-map)#set community 100:2


 R1(config)# route-map R-COMMUNITY permit 30


 R1(config)# router bgp 1
 R1(config-router)# neighbor 1.0.0.2 remote-as 100
 R1(config-router)# neighbor 1.0.0.2 send-community
 R1(config-router)# neighbor 1.0.0.2 route-map R-COMMUNITY out


 R2(config)# ip bgp-community new-format

 R2(config)# ip community-list 1 permit 100:1
 R2(config)# ip community-list 2 permit 100:2


 R2(config)# route-map R-COMMUNITY-TOR3 deny 10
 R2(config-route-map)#match community 1

 R2(config)# route-map R-COMMUNITY-TOR3 permit 20


 R2(config)# route-map R-COMMUNITY-TOR4 permit 10
 R2(config-route-map)#match community 2
 
R2(config-route-map)#set as-path prepend 100

 R2(config)# route-map R-COMMUNITY-TOR4 permit 20


 R2(config)# router bgp 100
 R2(config-router)# neighbor 3.0.0.3 remote-as 300
 R2(config-router)# neighbor 3.0.0.3 send-community
 R2(config-router)# neighbor 3.0.0.3 route-map R-COMMUNITY-TOR3 out

 R2(config-router)# neighbor 4.0.0.4 remote-as 300
 R2(config-router)# neighbor 4.0.0.4 send-community
 R2(config-router)# neighbor 4.0.0.4 route-map R-COMMUNITY-TOR4 out




 COMMUNITYアトリビュート値はASを越えて伝達できるため、より広範囲に柔軟なルート制御やフィルタリングが可能となります。



BGP(Border Gateway Protocol)

ネットワークエンジニアとして

Copyright (C) 2002-2024 ネットワークエンジニアとして All Rights Reserved.