Extended Communityとは
Extended Community(RFC 4360)は、経路に付ける「タグ」の拡張版です。 標準のCOMMUNITYが4バイトの値を並べるだけなのに対し、Extended Communityは8バイトで、先頭に「型」を持ちます。 型によって残りのバイトの構造と意味が決まり、AS を越えて運ぶかどうかも型に含まれるビットで決まります。
| 項目 | COMMUNITY | Extended Community |
|---|---|---|
| Type code | 8 | 16 |
| 分類 | Optional transitive | Optional 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を使わずに属性の中身と振る舞いを確認します。
フォーマット
属性(Type code 16)の値は8バイトのExtended Communityを必要な数だけ並べたものです。1つの中身は次の3つです。
| フィールド | 長さ | 内容 |
|---|---|---|
| Type high | 1バイト | 上位ビットから I(IANAの割り当て区分)、T(0 = transitive、1 = non-transitive)、残り6ビットがValueの構造 |
| Type low(Sub-Type) | 1バイト | その構造の中での用途(Route Target = 0x02、Route Origin = 0x03 など) |
| Value | 6バイト | 構造ごとに分かれる |
Valueの構造は4種類あります。
| Type high | 構造 | Global Administrator | Local Administrator | 出典 |
|---|---|---|---|---|
| 0x00 / 0x40 | 2バイトAS固有 | AS番号(2バイト) | 4バイト | RFC 4360 3.1 |
| 0x01 / 0x41 | IPv4アドレス固有 | IPv4アドレス(4バイト) | 2バイト | RFC 4360 3.2 |
| 0x02 / 0x42 | 4バイトAS固有 | AS番号(4バイト) | 2バイト | RFC 5668 |
| 0x03 / 0x43 | Opaque | (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-Type | transitive | 用途 |
|---|---|---|---|
| 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)。同じサイトへ経路を戻さないために使う |
| Color | 0x03 : 0x0B | ○ | 経路に色を付ける(Segment Routingのポリシー選択など) |
| Link Bandwidth | 0x40 : 0x04 | × | eBGPリンクの帯域。マルチパスの重み付けに使う |
| Cost Community | 0x43 : 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-familyにsend-extended-community-ebgpが必要です(標準のCOMMUNITYのsend-community-ebgpと別)。iBGPには既定で送ります。
IOS XRでの設定
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 outextcommunity-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-every、sooも同様 |
delete extcommunity rt in <セット名> | 取り除く |
show bgp <プレフィックス> | Extended community:の行にRT:65001:100の形で出る |
set extcommunityはadditiveを付けないと、その型だけでなく拡張コミュニティ属性を丸ごと置き換えます。
型が違えば共存すると考えてadditiveなしで並べると、後の行が前の行を消します。
2つ目以降には必ずadditiveを付けてください。
実機での検証
XRd 26.1.1のルータ4台で確認します。
- 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/24をnetwork文で広告する。R1が192.168.1.0/24にExtended Communityを付け、R2・R3・R4でどう見えるかを追う - 出方向ポリシーはネイバーごとに別名(中身は
pass)、全ネイバーにsoft-reconfiguration inbound always、eBGPにsend-community-ebgp。send-extended-community-ebgpはR3 - R4間に最初から入れ、R1 → R2はSTEP 2で入れる
各STEPの概要
| STEP | 操作 | 確認したこと | 結果 | 主な根拠 |
|---|---|---|---|---|
| 0 | Extended Communityなし | 初期状態 | Extended community:の行が無く、UPDATEにもType 16が無い | R2 show bgp 192.168.1.0/24、pcap |
| 1 | R1がRT:65001:100を付ける(send-extended-community-ebgpなし) | eBGPへ送られるか | 送られない。R2に届かず、UPDATEにもType 16が無い | R2 show bgp 192.168.1.0/24、pcap |
| 2 | R1にsend-extended-community-ebgp | 符号化と伝搬範囲 | Type 0x00 / Sub-Type 0x02で届き、R3(iBGP)・R4(別AS)まで伝わる | pcap No.1、R4 show bgp 192.168.1.0/24 |
| 3 | RT 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 |
| 4 | R2の入方向でLink BandwidthとCostを付ける | non-transitiveの伝搬範囲 | AS 65002内(iBGP)では残り、AS境界(R3 → R4)で落ちる | pcap(R2-R3は7個、R3-R4は5個) |
| 5 | R2の入方向でRTに一致したらLOCAL_PREF 200 | ポリシーでの一致 | R2・R3の192.168.1.0/24が200になる | R2・R3 show bgp |
| 6 | R3の出方向でSoOに一致したらdrop | SoOによる広告の抑止 | R4から192.168.1.0/24が消え、WITHDRAWが飛ぶ | R4 show bgp、pcap No.1 |
| 7 | STEP 5・6のポリシーを戻す(最終状態) | 復旧 | R4に経路と拡張コミュニティが戻る | R4 show bgp 192.168.1.0/24 |
STEP 0:Extended Communityなし
R2が受け取った192.168.1.0/24です。Extended community:の行がありません。
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は含まれていません。
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 MessageSTEP 1:付けただけではeBGPへ送られない
R1の出方向ポリシーでRT:65001:100を付けます。
extcommunity-set rt RT-R1
65001:100
end-set
route-policy TO-R2
set extcommunity rt RT-R1
pass
end-policyRP/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と変わりません。
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を送らないためです。
3 10.407532 10.1.2.1 → 10.1.2.2 BGP 133 UPDATE Message, KEEPALIVE MessageSTEP 2:send-extended-community-ebgpで届く
R1のネイバー設定に1行足します。
router bgp 65001
neighbor 10.1.2.2
address-family ipv4 unicast
send-extended-community-ebgpR1が送った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が入っています。
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: 100R2にRT:65001:100が入りました。
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まで同じ値が届きます。
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が要ります。
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-policyRP/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)と展開されます。
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)R2に届いたのはこの5つで、標準のCOMMUNITYも別の行に出ています。 設定したLink BandwidthとCostは入っていません。 どちらもnon-transitiveで、 R1 - R2はAS境界(eBGP)なので、R1が送出時に取り除いています。
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つが見えます。
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を付けます。
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-policyRP/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:16とCOST:129:1:100を含む7つが届きます。
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)として入っています。
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)AS境界を越えるR3 → R4では5つに減り、non-transitiveの2つが消えています。
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)R4のテーブルでも5つのままです。
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にする条件を足します。
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-policyRP/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/24がLocPrf 200になり、iBGPでR3にも伝わります。
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 pathsRP/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 pathsSTEP 6:SoOで広告を止める
SoOは「どのサイトが入れた経路か」を示すので、その値を持つ経路を出さないようにすれば、 同じサイトへ経路を戻さない制御になります。R3の出方向ポリシーで、SoOが一致したらdropします。
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-policyRP/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が消えました。
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 pathsR3 → R4のUPDATEはWITHDRAWです。
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.0STEP 7:ポリシーを戻す(最終状態)
R2のPASS-ALLとR3のTO-R4をpassだけに戻すと、経路と拡張コミュニティがR4に戻ります。
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 pathsRP/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 extcommunityはadditiveを付けないと属性を丸ごと置き換える。型が違っても共存しない(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.txt | show 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-routes・routes・received 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出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
STEP 1:R1がRTを付ける(send-extended-community-ebgpなし)
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
STEP 2:R1にsend-extended-community-ebgp
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
STEP 3:RT 3構造・SoO・Color・Link Bandwidth・Cost・COMMUNITYを付ける
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
STEP 4:R2の入方向でLink BandwidthとCostを付ける
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
STEP 5:R2の入方向でRTに一致したらLOCAL_PREF 200
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
STEP 6:R3の出方向でSoOに一致したらdrop
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
STEP 7:ポリシーを戻す(最終状態)
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
パケットキャプチャーはSTEPごとに取得しています(キャプチャーしていない区間は「—」)。
| STEP | R1-R2間 | R2-R3間 | R3-R4間 |
|---|---|---|---|
| 0 | pcap | — | pcap |
| 1 | pcap | — | — |
| 2 | pcap | — | pcap |
| 3 | pcap | pcap | pcap |
| 4 | pcap | pcap | pcap |
| 5 | — | pcap | — |
| 6 | — | — | pcap |
参考
| 資料 | タイトル | 概要 |
|---|---|---|
| RFC 4360 | BGP Extended Communities Attribute | 属性の定義(2)、3つの構造(3)、Route Target(4)、Route Origin(5)、運用規則(6) |
| RFC 5668 | 4-Octet AS Specific BGP Extended Community | 4バイトAS固有の構造(Type high 0x02 / 0x42) |
| RFC 7153 | IANA Registries for BGP Extended Communities | Type / Sub-Typeレジストリの整理 |
| RFC 4364 | BGP/MPLS IP Virtual Private Networks (VPNs) | Route TargetとSite of Originの使い方(4.3.1、4.3.5) |
| RFC 1997 | BGP Communities Attribute | 標準のCOMMUNITY |
| IANA BGP Extended Communities | Border Gateway Protocol (BGP) Extended Communities | Type / Sub-Typeの一覧 |