メインコンテンツへスキップ
  1. ネットワーク 記事一覧/
  2. BGP記事一覧/

BGP Extended Community(拡張コミュニティ)

目次

Extended Communityとは

Extended CommunityRFC 4360)は、経路に付ける「タグ」の拡張版です。 標準のCOMMUNITYが4バイトの値を並べるだけなのに対し、Extended Communityは8バイトで、先頭に「型」を持ちます。 型によって残りのバイトの構造と意味が決まり、AS を越えて運ぶかどうかも型に含まれるビットで決まります。

項目COMMUNITYExtended Community
Type code816
分類Optional transitiveOptional transitive
1つの長さ4バイト8バイト
構造値のみ(慣習でAS番号:値)型 + 値。型ごとに構造が決まる
AS を越えるか常に越える(well-knownのNO_EXPORT等で止める)型の transitive ビットで決まる
主な用途運用者が決めるポリシー連携MPLS L3VPN の Route Target、Site of Origin、Cost、Link Bandwidth、Color など

MPLS L3VPN(RFC 4364)でVRF間の経路交換を制御するRoute TargetがExtended Communityの代表的な使い方ですが、属性そのものはVPNとは無関係で、IPv4ユニキャストの経路にも付けられます。この記事はVPNを使わずに属性の中身と振る舞いを確認します。

フォーマット

Extended Communityの8バイトのフォーマットとValueの構造

属性(Type code 16)の値は8バイトのExtended Communityを必要な数だけ並べたものです。1つの中身は次の3つです。

フィールド長さ内容
Type high1バイト上位ビットから I(IANAの割り当て区分)、T(0 = transitive、1 = non-transitive)、残り6ビットがValueの構造
Type low(Sub-Type)1バイトその構造の中での用途(Route Target = 0x02、Route Origin = 0x03 など)
Value6バイト構造ごとに分かれる

Valueの構造は4種類あります。

Type high構造Global AdministratorLocal Administrator出典
0x00 / 0x402バイトAS固有AS番号(2バイト)4バイトRFC 4360 3.1
0x01 / 0x41IPv4アドレス固有IPv4アドレス(4バイト)2バイトRFC 4360 3.2
0x02 / 0x424バイトAS固有AS番号(4バイト)2バイトRFC 5668
0x03 / 0x43Opaque(Sub-Typeごとに6バイトを定義)RFC 4360 3.3

「/」の左が transitive(Tビット0)、右が non-transitive(Tビット1)です。 Global Administratorは値を割り当てた組織(AS番号かIPv4アドレスで識別)、Local Administratorはその組織が自由に決める番号です。 IOS XRでは65001:100(2バイトAS)、10.0.0.1:200(IPv4)、1.2:300(4バイトAS、1.2 = 65538)の書き方で使い分けます。 2バイトのAS番号を持つASは2バイトAS固有を使うべきとされています(RFC 5668 3)。

主な型

Sub-Typeの値はIANAのレジストリRFC 7153で整理)にあります。この記事で扱うものを挙げます。

名前Type high : Sub-Typetransitive用途
Route Target(RT)0x00 / 0x01 / 0x02 : 0x02「この経路を受け取ってよいルータ」(RFC 4360 4)。MPLS L3VPNでVRFへのimport / exportを決める
Route Origin(Site of Origin、SoO)0x00 / 0x01 / 0x02 : 0x03「この経路をBGPに入れたルータ(サイト)」(RFC 4360 5)。同じサイトへ経路を戻さないために使う
Color0x03 : 0x0B経路に色を付ける(Segment Routingのポリシー選択など)
Link Bandwidth0x40 : 0x04×eBGPリンクの帯域。マルチパスの重み付けに使う
Cost Community0x43 : 0x01(0x03 : 0x01 も登録あり)×Cisco独自(IANAにはInternet-Draftとして登録)。ベストパス選択にコストを加える。iBGPとコンフェデレーション内だけ

振る舞いの規則(RFC 4360 6)

規則内容
non-transitiveなものはAS境界で取り除くべき(SHOULD)Link BandwidthやCostは隣のASへ渡らない。コンフェデレーション境界では取り除かない
受け取った側は属性を付けても書き換えてもよい(MAY)ポリシーで自由に扱える
COMMUNITYと両方持てる同じUPDATEにType 8とType 16が並ぶ。それぞれRFC 1997 / RFC 4360の規則で扱う
集約ATOMIC_AGGREGATEが無ければ構成要素のExtended Communityの和集合を持つ(既定)
ベストパス選択転送ループを生むような使い方をしてはならない(MUST NOT)

IOS XRはeBGPピアへ既定でExtended Communityを送りません。 ネイバーのaddress-familysend-extended-community-ebgpが必要です(標準のCOMMUNITYのsend-community-ebgpと別)。iBGPには既定で送ります。

IOS XRでの設定

Extended Communityを付ける(R1)
extcommunity-set rt RT-R1
  65001:100
end-set
extcommunity-set soo SOO-SITE1
  65001:1
end-set
route-policy TO-R2
  set extcommunity rt RT-R1
  set extcommunity soo SOO-SITE1 additive
  pass
end-policy
!
router bgp 65001
 neighbor 10.1.2.2
  address-family ipv4 unicast
   send-extended-community-ebgp
   route-policy TO-R2 out
Extended Communityで一致させる(R2)
extcommunity-set rt RT-R1
  65001:100
end-set
route-policy PASS-ALL
  if extcommunity rt matches-any RT-R1 then
    set local-preference 200
  endif
  pass
end-policy
項目内容
extcommunity-set rt / soo / opaque / bandwidth / cost型ごとに値の集合を定義する
set extcommunity <型> <セット名>付ける。2つ目以降にはadditiveが要る(次項)
extcommunity rt matches-any <セット名>一致条件。matches-everysooも同様
delete extcommunity rt in <セット名>取り除く
show bgp <プレフィックス>Extended community:の行にRT:65001:100の形で出る

set extcommunityadditiveを付けないと、その型だけでなく拡張コミュニティ属性を丸ごと置き換えます。 型が違えば共存すると考えてadditiveなしで並べると、後の行が前の行を消します。 2つ目以降には必ずadditiveを付けてください。

実機での検証

XRd 26.1.1のルータ4台で確認します。

BGP Extended Communityの検証トポロジ
  • R1(AS 65001)- R2(AS 65002)がeBGP、R2 - R3がiBGP(Lo0同士、next-hop-self、OSPF)、R3 - R4(AS 65003)がeBGP
  • 各ルータはLo1の192.168.N.0/24network文で広告する。R1が192.168.1.0/24にExtended Communityを付け、R2・R3・R4でどう見えるかを追う
  • 出方向ポリシーはネイバーごとに別名(中身はpass)、全ネイバーにsoft-reconfiguration inbound always、eBGPにsend-community-ebgpsend-extended-community-ebgpはR3 - R4間に最初から入れ、R1 → R2はSTEP 2で入れる

各STEPの概要

STEP操作確認したこと結果主な根拠
0Extended Communityなし初期状態Extended community:の行が無く、UPDATEにもType 16が無いR2 show bgp 192.168.1.0/24、pcap
1R1がRT:65001:100を付ける(send-extended-community-ebgpなし)eBGPへ送られるか送られない。R2に届かず、UPDATEにもType 16が無いR2 show bgp 192.168.1.0/24、pcap
2R1にsend-extended-community-ebgp符号化と伝搬範囲Type 0x00 / Sub-Type 0x02で届き、R3(iBGP)・R4(別AS)まで伝わるpcap No.1、R4 show bgp 192.168.1.0/24
3RT 3構造・SoO・Color・Link Bandwidth・Cost・COMMUNITYを付ける各構造の符号化4構造すべてが1つの属性に並ぶ。non-transitiveの2つは最初のeBGPで落ちるpcap No.49、R2・R4 show bgp 192.168.1.0/24
4R2の入方向でLink BandwidthとCostを付けるnon-transitiveの伝搬範囲AS 65002内(iBGP)では残り、AS境界(R3 → R4)で落ちるpcap(R2-R3は7個、R3-R4は5個)
5R2の入方向でRTに一致したらLOCAL_PREF 200ポリシーでの一致R2・R3の192.168.1.0/24が200になるR2・R3 show bgp
6R3の出方向でSoOに一致したらdropSoOによる広告の抑止R4から192.168.1.0/24が消え、WITHDRAWが飛ぶR4 show bgp、pcap No.1
7STEP 5・6のポリシーを戻す(最終状態)復旧R4に経路と拡張コミュニティが戻るR4 show bgp 192.168.1.0/24

STEP 0:Extended Communityなし

R2が受け取った192.168.1.0/24です。Extended community:の行がありません。

R2 show bgp 192.168.1.0/24(STEP 0)
RP/0/RP0/CPU0:R2#show bgp 192.168.1.0/24
Thu Sep 10 04:05:33.616 UTC
<snip>
Paths: (1 available, best #1)
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.0.0.3        
  Path #1: Received by speaker 0
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.0.0.3        
  65001, (received & used)
    10.1.2.1 from 10.1.2.1 (10.0.0.1)
      Origin IGP, metric 0, localpref 100, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 17
      Origin-AS validity: (disabled)

R1 - R2間のUPDATEにも属性Type 16は含まれていません。

R1-R2間 パケットキャプチャー(STEP 0、tshark一覧)
   21  32.336113     10.1.2.1 → 10.1.2.2     BGP 137 UPDATE Message, UPDATE Message
   22  32.338147     10.1.2.2 → 10.1.2.1     BGP 190 UPDATE Message, UPDATE Message, UPDATE Message
   24  62.334336     10.1.2.2 → 10.1.2.1     BGP 130 UPDATE Message, KEEPALIVE Message

STEP 1:付けただけではeBGPへ送られない

R1の出方向ポリシーでRT:65001:100を付けます。

R1
extcommunity-set rt RT-R1
  65001:100
end-set
route-policy TO-R2
  set extcommunity rt RT-R1
  pass
end-policy
R1 show rpl route-policy TO-R2(STEP 1)
RP/0/RP0/CPU0:R1#show rpl route-policy TO-R2
Thu Sep 10 04:08:57.030 UTC
route-policy TO-R2
  set extcommunity rt RT-R1
  pass
end-policy
!

ポリシーは入りましたが、R2の192.168.1.0/24はSTEP 0と変わりません。

R2 show bgp 192.168.1.0/24(STEP 1)
RP/0/RP0/CPU0:R2#show bgp 192.168.1.0/24
Thu Sep 10 04:09:16.789 UTC
<snip>
Paths: (1 available, best #1)
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.0.0.3        
  Path #1: Received by speaker 0
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.0.0.3        
  65001, (received & used)
    10.1.2.1 from 10.1.2.1 (10.0.0.1)
      Origin IGP, metric 0, localpref 100, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 17
      Origin-AS validity: (disabled)

UPDATEにもType 16はありません。IOS XRはeBGPピアへ既定でExtended Communityを送らないためです。

R1-R2間 パケットキャプチャー(STEP 1、tshark一覧)
    3  10.407532     10.1.2.1 → 10.1.2.2     BGP 133 UPDATE Message, KEEPALIVE Message

STEP 2:send-extended-community-ebgpで届く

R1のネイバー設定に1行足します。

R1
router bgp 65001
 neighbor 10.1.2.2
  address-family ipv4 unicast
   send-extended-community-ebgp

R1が送ったUPDATE(R1 - R2間のキャプチャーのNo.1)です。属性のフラグは0xc0(Optional / Transitive)、 Type highが0x00(2バイトAS固有・transitive)、Sub-Typeが0x02(Route Target)、 Global Administratorに65001、Local Administratorに100が入っています。

No.1 UPDATE(R1 → R2)tshark -V
Border Gateway Protocol - UPDATE Message
    Marker: ffffffffffffffffffffffffffffffff
    Length: 71
    Type: UPDATE Message (2)
<snip>
        Path Attribute - EXTENDED_COMMUNITIES
            Flags: 0xc0, Optional, Transitive, Complete
            Type Code: EXTENDED_COMMUNITIES (16)
            Length: 8
            Carried extended communities: (1 community)
                Route Target: 65001:100 [Transitive 2-Octet AS-Specific]
                    Type: Transitive 2-Octet AS-Specific (0x00)
                    Subtype (AS2): Route Target (0x02)
                    2-Octet AS: 65001
                    4-Octet AN: 100
上のtshark出力のパケット(No.1 UPDATE)のpcapをダウンロード

R2にRT:65001:100が入りました。

R2 show bgp 192.168.1.0/24(STEP 2)
RP/0/RP0/CPU0:R2#show bgp 192.168.1.0/24
Thu Sep 10 04:12:54.340 UTC
<snip>
Paths: (1 available, best #1)
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.0.0.3        
  Path #1: Received by speaker 0
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.0.0.3        
  65001, (received & used)
    10.1.2.1 from 10.1.2.1 (10.0.0.1)
      Origin IGP, metric 0, localpref 100, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 19
      Extended community: RT:65001:100 
      Origin-AS validity: (disabled)

Route Targetはtransitiveなので、R3(iBGP)を経てAS 65003のR4まで同じ値が届きます。

R4 show bgp 192.168.1.0/24(STEP 2)
RP/0/RP0/CPU0:R4#show bgp 192.168.1.0/24
Thu Sep 10 04:13:40.681 UTC
<snip>
Paths: (1 available, best #1)
  Not advertised to any peer
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002 65001, (received & used)
    10.3.4.3 from 10.3.4.3 (10.0.0.3)
      Origin IGP, localpref 100, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 13
      Extended community: RT:65001:100 
      Origin-AS validity: (disabled)

STEP 3:4つの構造とtransitive / non-transitive

R1で、RTを3つの構造で、SoO・Color・Link Bandwidth・Costと標準のCOMMUNITYも合わせて付けます。 2つ目以降にはadditiveが要ります。

R1
extcommunity-set rt RT-R1
  65001:100,
  10.0.0.1:200,
  1.2:300
end-set
extcommunity-set soo SOO-SITE1
  65001:1
end-set
extcommunity-set opaque COLOR-R1
  42
end-set
extcommunity-set bandwidth BW-R1
  65001:1000
end-set
extcommunity-set cost COST-R1
  igp:1:100
end-set
route-policy TO-R2
  set extcommunity rt RT-R1
  set extcommunity soo SOO-SITE1 additive
  set extcommunity color COLOR-R1 additive
  set extcommunity bandwidth BW-R1 additive
  set extcommunity cost COST-R1 additive
  set community (65001:1)
  pass
end-policy
R1 show rpl route-policy TO-R2(STEP 3)
RP/0/RP0/CPU0:R1#show rpl route-policy TO-R2
Thu Sep 10 04:30:23.622 UTC
route-policy TO-R2
  set extcommunity rt RT-R1
  set extcommunity soo SOO-SITE1 additive
  set extcommunity color COLOR-R1 additive
  set extcommunity bandwidth BW-R1 additive
  set extcommunity cost COST-R1 additive
  set community (65001:1)
  pass
end-policy
!

R1が送ったUPDATE(No.49)です。1つの属性に5つのExtended Communityが並び、 Type highが0x00(2バイトAS固有)・0x01(IPv4アドレス固有)・0x02(4バイトAS固有)・0x03(Opaque)と 4つの構造すべてを含んでいます。1.2:300は4バイトAS固有で65538(1×65536+2)と展開されます。

No.49 UPDATE(R1 → R2)tshark -V
Border Gateway Protocol - UPDATE Message
    Marker: ffffffffffffffffffffffffffffffff
    Length: 110
    Type: UPDATE Message (2)
<snip>
        Path Attribute - EXTENDED_COMMUNITIES
            Flags: 0xc0, Optional, Transitive, Complete
            Type Code: EXTENDED_COMMUNITIES (16)
            Length: 40
            Carried extended communities: (5 communities)
                Route Target: 65001:100 [Transitive 2-Octet AS-Specific]
                    Type: Transitive 2-Octet AS-Specific (0x00)
                    Subtype (AS2): Route Target (0x02)
                    2-Octet AS: 65001
                    4-Octet AN: 100
                Route Origin: 65001:1 [Transitive 2-Octet AS-Specific]
                    Type: Transitive 2-Octet AS-Specific (0x00)
                    Subtype (AS2): Route Origin (0x03)
                    2-Octet AS: 65001
                    4-Octet AN: 1
                Route Target: 10.0.0.1:200 [Transitive IPv4-Address-Specific]
                    Type: Transitive IPv4-Address-Specific (0x01)
                    Subtype (IPv4): Route Target (0x02)
                    IPv4 address: 10.0.0.1
                    2-Octet AN: 200
                Route Target: 1.2(65538):300 [Transitive 4-Octet AS-Specific]
                    Type: Transitive 4-Octet AS-Specific (0x02)
                    Subtype (AS4): Route Target (0x02)
                    4-Octet AS: 65538
                    2-Octet AN: 300
                Color: 0x0000 0x0000 0x002a [Transitive Opaque]
                    Type: Transitive Opaque (0x03)
                    Subtype (Opaque): Color (0x0b)
上のtshark出力のパケット(No.49 UPDATE)のpcapをダウンロード

R2に届いたのはこの5つで、標準のCOMMUNITYも別の行に出ています。 設定したLink BandwidthとCostは入っていません。 どちらもnon-transitiveで、 R1 - R2はAS境界(eBGP)なので、R1が送出時に取り除いています。

R2 show bgp 192.168.1.0/24(STEP 3)
RP/0/RP0/CPU0:R2#show bgp 192.168.1.0/24
Thu Sep 10 04:30:42.437 UTC
<snip>
Paths: (1 available, best #1)
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.0.0.3        
  Path #1: Received by speaker 0
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.0.0.3        
  65001, (received & used)
    10.1.2.1 from 10.1.2.1 (10.0.0.1)
      Origin IGP, metric 0, localpref 100, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 24
      Community: 65001:1
      Extended community: SoO:65001:1 Color:42 RT:65001:100 RT:10.0.0.1:200 RT:65538:300 
      Origin-AS validity: (disabled)

R4でも同じ5つが見えます。

R4 show bgp 192.168.1.0/24(STEP 3)
RP/0/RP0/CPU0:R4#show bgp 192.168.1.0/24
Thu Sep 10 04:31:29.436 UTC
<snip>
Paths: (1 available, best #1)
  Not advertised to any peer
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002 65001, (received & used)
    10.3.4.3 from 10.3.4.3 (10.0.0.3)
      Origin IGP, localpref 100, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 18
      Community: 65001:1
      Extended community: SoO:65001:1 Color:42 RT:65001:100 RT:10.0.0.1:200 RT:65538:300 
      Origin-AS validity: (disabled)

STEP 4:non-transitiveはAS内では残る

non-transitiveなものがAS内で残ることを見るため、AS 65002の入口であるR2の入方向ポリシーで、 Link BandwidthとCostを付けます。

R2
extcommunity-set bandwidth BW-R2
  65002:2000
end-set
extcommunity-set cost COST-R2
  igp:1:100
end-set
route-policy PASS-ALL
  set extcommunity bandwidth BW-R2 additive
  set extcommunity cost COST-R2 additive
  pass
end-policy
R2 show rpl route-policy PASS-ALL(STEP 4)
RP/0/RP0/CPU0:R2#show rpl route-policy PASS-ALL
Thu Sep 10 04:37:22.409 UTC
route-policy PASS-ALL
  set extcommunity bandwidth BW-R2 additive
  set extcommunity cost COST-R2 additive
  pass
end-policy
!

同じAS内のR3には、LB:65002:16COST:129:1:100を含む7つが届きます。

R3 show bgp 192.168.1.0/24(STEP 4)
RP/0/RP0/CPU0:R3#show bgp 192.168.1.0/24
Thu Sep 10 04:37:40.290 UTC
<snip>
Paths: (1 available, best #1)
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.3.4.4        
  Path #1: Received by speaker 0
  Advertised IPv4 Unicast paths to peers (in unique update groups):
    10.3.4.4        
  65001, (received & used)
    10.0.0.2 (metric 2) from 10.0.0.2 (10.0.0.2)
      Origin IGP, metric 0, localpref 100, valid, internal, best, group-best
      Received Path ID 0, Local Path ID 1, version 33
      Community: 65001:1
      Extended community: SoO:65001:1 Color:42 LB:65002:16 COST:129:1:100 RT:65001:100 RT:10.0.0.1:200 RT:65538:300 
                          (LB non-transitive AS:bytes/sec:65002:2000.000)

R2 - R3間のUPDATEを展開すると、CostがNon-Transitive Opaque (0x43) / Cost Community (0x01)、 Link BandwidthがNon-Transitive 2-Octet AS-Specific (0x40) / Link Bandwidth (0x04)として入っています。

No.1 UPDATE(R2 → R3、iBGP)tshark -V
Border Gateway Protocol - UPDATE Message
    Marker: ffffffffffffffffffffffffffffffff
    Length: 133
    Type: UPDATE Message (2)
<snip>
            Carried extended communities: (7 communities)
                Route Origin: 65001:1 [Transitive 2-Octet AS-Specific]
                    Type: Transitive 2-Octet AS-Specific (0x00)
                    Subtype (AS2): Route Origin (0x03)
                    2-Octet AS: 65001
                    4-Octet AN: 1
                Color: 0x0000 0x0000 0x002a [Transitive Opaque]
                    Type: Transitive Opaque (0x03)
                    Subtype (Opaque): Color (0x0b)
                    Raw Value: 0x0000 0x0000 0x002a
                Cost Community: 100, POI: "Smallest IGP Metric" step (Evaluated after) [Non-Transitive Opaque]
                    Type: Non-Transitive Opaque (0x43)
                    Subtype (Non-transitive Opaque): Cost Community (0x01)
                    Point of insertion: "Smallest IGP Metric" step (129)
                    Community ID: 1
                    Cost: 100 (Evaluated after the original attribute value)
                Route Target: 1.2(65538):300 [Transitive 4-Octet AS-Specific]
                    Type: Transitive 4-Octet AS-Specific (0x02)
                    Subtype (AS4): Route Target (0x02)
                    4-Octet AS: 65538
                    2-Octet AN: 300
                Route Target: 10.0.0.1:200 [Transitive IPv4-Address-Specific]
                    Type: Transitive IPv4-Address-Specific (0x01)
                    Subtype (IPv4): Route Target (0x02)
                    IPv4 address: 10.0.0.1
                    2-Octet AN: 200
                Route Target: 65001:100 [Transitive 2-Octet AS-Specific]
                    Type: Transitive 2-Octet AS-Specific (0x00)
                    Subtype (AS2): Route Target (0x02)
                    2-Octet AS: 65001
                    4-Octet AN: 100
                Link Bandwidth: ASN 65002, 0.016 Mbps [Non-Transitive 2-Octet AS-Specific]
                    Type: Non-Transitive 2-Octet AS-Specific (0x40)
                    Subtype (Non-transitive AS2): Link Bandwidth (0x04)
上のtshark出力のパケット(No.1 UPDATE)のpcapをダウンロード

AS境界を越えるR3 → R4では5つに減り、non-transitiveの2つが消えています。

No.1 UPDATE(R3 → R4、eBGP)tshark -V
Border Gateway Protocol - UPDATE Message
    Marker: ffffffffffffffffffffffffffffffff
    Length: 107
    Type: UPDATE Message (2)
<snip>
            Carried extended communities: (5 communities)
                Route Origin: 65001:1 [Transitive 2-Octet AS-Specific]
                    Type: Transitive 2-Octet AS-Specific (0x00)
                    Subtype (AS2): Route Origin (0x03)
                    2-Octet AS: 65001
                    4-Octet AN: 1
                Color: 0x0000 0x0000 0x002a [Transitive Opaque]
                    Type: Transitive Opaque (0x03)
                    Subtype (Opaque): Color (0x0b)
                    Raw Value: 0x0000 0x0000 0x002a
                Route Target: 65001:100 [Transitive 2-Octet AS-Specific]
                    Type: Transitive 2-Octet AS-Specific (0x00)
                    Subtype (AS2): Route Target (0x02)
                    2-Octet AS: 65001
                    4-Octet AN: 100
                Route Target: 10.0.0.1:200 [Transitive IPv4-Address-Specific]
                    Type: Transitive IPv4-Address-Specific (0x01)
                    Subtype (IPv4): Route Target (0x02)
                    IPv4 address: 10.0.0.1
                    2-Octet AN: 200
                Route Target: 1.2(65538):300 [Transitive 4-Octet AS-Specific]
                    Type: Transitive 4-Octet AS-Specific (0x02)
                    Subtype (AS4): Route Target (0x02)
上のtshark出力のパケット(No.1 UPDATE)のpcapをダウンロード

R4のテーブルでも5つのままです。

R4 show bgp 192.168.1.0/24(STEP 4)
RP/0/RP0/CPU0:R4#show bgp 192.168.1.0/24
Thu Sep 10 04:38:04.185 UTC
<snip>
Paths: (1 available, best #1)
  Not advertised to any peer
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002 65001, (received & used)
    10.3.4.3 from 10.3.4.3 (10.0.0.3)
      Origin IGP, localpref 100, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 18
      Community: 65001:1
      Extended community: SoO:65001:1 Color:42 RT:65001:100 RT:10.0.0.1:200 RT:65538:300 
      Origin-AS validity: (disabled)

STEP 5:RTで一致させる

R2の入方向ポリシーに、RTが一致したらLOCAL_PREFを200にする条件を足します。

R2
extcommunity-set rt RT-FROM-R1
  65001:100
end-set
route-policy PASS-ALL
  set extcommunity bandwidth BW-R2 additive
  set extcommunity cost COST-R2 additive
  if extcommunity rt matches-any RT-FROM-R1 then
    set local-preference 200
  endif
  pass
end-policy
R2 show rpl route-policy PASS-ALL(STEP 5)
RP/0/RP0/CPU0:R2#show rpl route-policy PASS-ALL
Thu Sep 10 04:41:18.183 UTC
route-policy PASS-ALL
  set extcommunity bandwidth BW-R2 additive
  set extcommunity cost COST-R2 additive
  if extcommunity rt matches-any RT-FROM-R1 then
    set local-preference 200
  endif
  pass
end-policy
!

R2の192.168.1.0/24LocPrf 200になり、iBGPでR3にも伝わります。

R2 show bgp(STEP 5)
RP/0/RP0/CPU0:R2#show bgp
Thu Sep 10 04:41:13.302 UTC
BGP router identifier 10.0.0.2, local AS number 65002
BGP generic scan interval 60 secs
Non-stop routing is enabled
BGP table state: Active
Table ID: 0xe0000000   RD version: 26
BGP main routing table version 26
BGP NSR Initial initsync version 4 (Reached)
BGP NSR/ISSU Sync-Group versions 0/0
BGP scan interval 60 secs

Status codes: s suppressed, d damped, h history, * valid, > best
              i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network            Next Hop            Metric LocPrf Weight Path
*> 192.168.1.0/24     10.1.2.1                 0    200      0 65001 i
*> 192.168.2.0/24     0.0.0.0                  0         32768 i
*>i192.168.3.0/24     10.0.0.3                 0    100      0 i
*>i192.168.4.0/24     10.0.0.3                 0    100      0 65003 i

Processed 4 prefixes, 4 paths
R3 show bgp(STEP 5)
RP/0/RP0/CPU0:R3#show bgp
Thu Sep 10 04:41:36.503 UTC
BGP router identifier 10.0.0.3, local AS number 65002
BGP generic scan interval 60 secs
Non-stop routing is enabled
BGP table state: Active
Table ID: 0xe0000000   RD version: 34
BGP main routing table version 34
BGP NSR Initial initsync version 3 (Reached)
BGP NSR/ISSU Sync-Group versions 0/0
BGP scan interval 60 secs

Status codes: s suppressed, d damped, h history, * valid, > best
              i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network            Next Hop            Metric LocPrf Weight Path
*>i192.168.1.0/24     10.0.0.2                 0    200      0 65001 i
*>i192.168.2.0/24     10.0.0.2                 0    100      0 i
*> 192.168.3.0/24     0.0.0.0                  0         32768 i
*> 192.168.4.0/24     10.3.4.4                 0             0 65003 i

Processed 4 prefixes, 4 paths

STEP 6:SoOで広告を止める

SoOは「どのサイトが入れた経路か」を示すので、その値を持つ経路を出さないようにすれば、 同じサイトへ経路を戻さない制御になります。R3の出方向ポリシーで、SoOが一致したらdropします。

R3
extcommunity-set soo SOO-SITE1
  65001:1
end-set
route-policy TO-R4
  if extcommunity soo matches-any SOO-SITE1 then
    drop
  endif
  pass
end-policy
R3 show rpl route-policy TO-R4(STEP 6)
RP/0/RP0/CPU0:R3#show rpl route-policy TO-R4
Thu Sep 10 04:45:05.927 UTC
route-policy TO-R4
  if extcommunity soo matches-any SOO-SITE1 then
    drop
  endif
  pass
end-policy
!

R4から192.168.1.0/24が消えました。

R4 show bgp(STEP 6)
RP/0/RP0/CPU0:R4#show bgp
Thu Sep 10 04:45:24.342 UTC
BGP router identifier 10.0.0.4, local AS number 65003
BGP generic scan interval 60 secs
Non-stop routing is enabled
BGP table state: Active
Table ID: 0xe0000000   RD version: 19
BGP main routing table version 19
BGP NSR Initial initsync version 6 (Reached)
BGP NSR/ISSU Sync-Group versions 0/0
BGP scan interval 60 secs

Status codes: s suppressed, d damped, h history, * valid, > best
              i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network            Next Hop            Metric LocPrf Weight Path
*> 192.168.2.0/24     10.3.4.3                               0 65002 i
*> 192.168.3.0/24     10.3.4.3                 0             0 65002 i
*> 192.168.4.0/24     0.0.0.0                  0         32768 i

Processed 3 prefixes, 3 paths

R3 → R4のUPDATEはWITHDRAWです。

No.1 UPDATE(R3 → R4、WITHDRAW)tshark -V
Border Gateway Protocol - UPDATE Message
    Marker: ffffffffffffffffffffffffffffffff
    Length: 27
    Type: UPDATE Message (2)
    Withdrawn Routes Length: 4
    Withdrawn Routes
        192.168.1.0/24
            Withdrawn route prefix length: 24
            Withdrawn prefix: 192.168.1.0
上のtshark出力のパケット(No.1 WITHDRAW)のpcapをダウンロード

STEP 7:ポリシーを戻す(最終状態)

R2のPASS-ALLとR3のTO-R4passだけに戻すと、経路と拡張コミュニティがR4に戻ります。

R4 show bgp(最終状態)
RP/0/RP0/CPU0:R4#show bgp
Thu Sep 10 04:50:03.569 UTC
BGP router identifier 10.0.0.4, local AS number 65003
BGP generic scan interval 60 secs
Non-stop routing is enabled
BGP table state: Active
Table ID: 0xe0000000   RD version: 20
BGP main routing table version 20
BGP NSR Initial initsync version 6 (Reached)
BGP NSR/ISSU Sync-Group versions 0/0
BGP scan interval 60 secs

Status codes: s suppressed, d damped, h history, * valid, > best
              i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network            Next Hop            Metric LocPrf Weight Path
*> 192.168.1.0/24     10.3.4.3                               0 65002 65001 i
*> 192.168.2.0/24     10.3.4.3                               0 65002 i
*> 192.168.3.0/24     10.3.4.3                 0             0 65002 i
*> 192.168.4.0/24     0.0.0.0                  0         32768 i

Processed 4 prefixes, 4 paths
R4 show bgp 192.168.1.0/24(最終状態)
RP/0/RP0/CPU0:R4#show bgp 192.168.1.0/24
Thu Sep 10 04:50:03.756 UTC
<snip>
Paths: (1 available, best #1)
  Not advertised to any peer
  Path #1: Received by speaker 0
  Not advertised to any peer
  65002 65001, (received & used)
    10.3.4.3 from 10.3.4.3 (10.0.0.3)
      Origin IGP, localpref 100, valid, external, best, group-best
      Received Path ID 0, Local Path ID 1, version 20
      Community: 65001:1
      Extended community: SoO:65001:1 Color:42 RT:65001:100 RT:10.0.0.1:200 RT:65538:300 
      Origin-AS validity: (disabled)

検証のまとめ

  • IOS XRはeBGPピアへ既定でExtended Communityを送らない。send-extended-community-ebgpが要る(STEP 1・2)
  • 1つの属性に、4つの構造(0x00 / 0x01 / 0x02 / 0x03)を混ぜて並べられる(STEP 3)
  • transitiveなRT・SoO・ColorはAS境界を越え、non-transitiveなLink Bandwidth・Costは越えない。 AS内(iBGP)では残り、境界のeBGPで取り除かれる(STEP 3・4)
  • set extcommunityadditiveを付けないと属性を丸ごと置き換える。型が違っても共存しない(STEP 3)
  • RT・SoOはVPNでなくてもextcommunity rt matches-any / soo matches-anyで一致条件に使える(STEP 5・6)

検証Configおよびshow結果

各STEPで4台すべてから、次の3種類をルータごとに分けて取得しています。検証Configはこの..._run.txtです(最終状態はSTEP 7のもの)。

ファイル内容
..._show.txtshow version / show interface description / show route / show bgp summary / show bgp / show bgp <プレフィックス>(4本) / show bgp neighbors / show bgp update-group / show ospf neighbor / ピアごとのadvertised-routesroutesreceived routes / show rpl route-policy / show rpl extcommunity-set
..._log.txtそのSTEPの範囲だけに絞ったshow logging。各STEPの開始時にlogmsgでマーカーを入れ、その時刻をshow logging startに指定して取得したもの
..._run.txtそのSTEP時点のshow running-config(=そのSTEPの検証Config)

STEP 0:Extended Communityなし

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

STEP 1:R1がRTを付ける(send-extended-community-ebgpなし)

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

STEP 2:R1にsend-extended-community-ebgp

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

STEP 3:RT 3構造・SoO・Color・Link Bandwidth・Cost・COMMUNITYを付ける

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

STEP 4:R2の入方向でLink BandwidthとCostを付ける

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

STEP 5:R2の入方向でRTに一致したらLOCAL_PREF 200

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

STEP 6:R3の出方向でSoOに一致したらdrop

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

STEP 7:ポリシーを戻す(最終状態)

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

パケットキャプチャーはSTEPごとに取得しています(キャプチャーしていない区間は「—」)。

STEPR1-R2間R2-R3間R3-R4間
0pcappcap
1pcap
2pcappcap
3pcappcappcap
4pcappcappcap
5pcap
6pcap

参考

資料タイトル概要
RFC 4360BGP Extended Communities Attribute属性の定義(2)、3つの構造(3)、Route Target(4)、Route Origin(5)、運用規則(6)
RFC 56684-Octet AS Specific BGP Extended Community4バイトAS固有の構造(Type high 0x02 / 0x42)
RFC 7153IANA Registries for BGP Extended CommunitiesType / Sub-Typeレジストリの整理
RFC 4364BGP/MPLS IP Virtual Private Networks (VPNs)Route TargetとSite of Originの使い方(4.3.1、4.3.5)
RFC 1997BGP Communities Attribute標準のCOMMUNITY
IANA BGP Extended CommunitiesBorder Gateway Protocol (BGP) Extended CommunitiesType / Sub-Typeの一覧

関連記事