COMMUNITYとは
COMMUNITY(コミュニティ)は、経路に「印」を付けて運ぶためのパス属性です。BGPパス属性とベストパス選択で扱ったAS_PATHやLOCAL_PREFと違い、それ自体はベストパス選択に一切影響しません。印を見たルータが自分のポリシーで何をするかを決めて、はじめて意味を持ちます。
| 項目 | 内容 |
|---|---|
| Type code | 8 |
| 属性の分類 | Optional Transitive(省略可能・推移的) |
| 値 | 32ビット(4オクテット)を1個とし、複数個を並べられる |
| 表記 | AS番号:値(上位16ビット:下位16ビット) |
| 予約範囲 | 0x00000000〜0x0000FFFFと0xFFFF0000〜0xFFFFFFFF |
| ベストパス選択 | 影響しない。印を付けるだけ |
| 定義 | RFC 1997 BGP Communities Attribute(Standards Track) |
Optional Transitiveなので、そのコミュニティを知らないルータでも捨てずに次へ渡します。これがコミュニティの要で、AS 65004が付けた印がAS 65001を通り抜けてAS 65002まで届く、といったことが起こります。
表記はAS番号:値
32ビットを上位16ビットと下位16ビットに分けて65004:1000のように書きます。慣習として上位16ビットに自分のAS番号、下位16ビットに自組織で意味を決めた値を入れます。RFC 1997自体はこの分け方を強制していませんが、AS番号を名前空間として使うことで他社の付けた印と衝突しなくなります。
なおAS番号:値は上位が16ビットしかないため、4バイトAS番号を持つ組織は自分のAS番号を上位に入れられません。これを解決するのが後述のラージコミュニティです。
「印を付ける側」と「印を見る側」は別のAS
コミュニティは単独では何もしません。実際に使うときは、必ず2つの役割がペアになります。
| 役割 | やること | 典型的な立場 |
|---|---|---|
| 付ける側 | 経路にset communityで印を付けて広告する | 顧客・下位AS |
| 見る側 | 受信時にcommunity matches-anyで印を判定し、LOCAL_PREFを変えたり広告先を絞ったりする | 上位ISP |
見る側が何もしなければ、印は付いたまま運ばれるだけで終わります。逆に言えば、上位ISPが「このコミュニティを付けてくれればこう扱います」と公開しておくことで、顧客が自分で経路制御できるようになります。これが実運用での主な使い方です。
ここで、ユーザーが定義したコミュニティ自体に強制力は無いことに注意が必要です。後述のNO_EXPORTのような既知のコミュニティと違い、意味を決めているのは受け取る側のASなので、そのASのすべての境界ルータに同じ判定を入れて初めて期待どおりに動きます。1台でも入れ忘れれば、そのルータからは普通に広告されます。
実例:NTT(AS2914)が公開しているコミュニティ
NTTのGlobal IP Network(AS2914)は、顧客が使えるコミュニティをRouting Policiesで公開しています。抜粋します。
| コミュニティ | 意味 |
|---|---|
2914:429 | do not advertise to any peers(どのピアにも広告しない) |
2914:421〜2914:423 | 全ピア向けにAS_PATHを1〜3回prependする |
2914:490 | customer default(LOCAL_PREF 120) |
2914:450 | peer fallback(LOCAL_PREF 96) |
65500:nnn | 指定したピアAS nnnにだけ広告しない |
2914:666 | blackhole(該当プレフィックス宛のトラフィックを破棄) |
顧客は自分の経路にこれらを付けて広告するだけで、AS2914の中でのLOCAL_PREFや、どのピアへ広告するかを制御できます。AS2914側の設定変更は不要。後述のSTEP 8では、この2914:429にならった65001:429をラボで再現します。
既知のコミュニティ(Well-known Communities)
RFC 1997は、どのASでも同じ意味を持つ値を3つ定義しています。いずれも上位16ビットが0xFFFFの予約範囲にあります。
| 名前 | 16進値 | RFC 1997の規定 |
|---|---|---|
NO_EXPORT | 0xFFFFFF01 | BGPコンフェデレーション境界の外へ広告してはならない |
NO_ADVERTISE | 0xFFFFFF02 | 他のBGPピアへ一切広告してはならない |
NO_EXPORT_SUBCONFED | 0xFFFFFF03 | 外部BGPピアへ広告してはならない(コンフェデレーション内の他メンバASを含む) |
コンフェデレーションを使っていない普通の構成では、NO_EXPORTは「自ASの外(eBGPピア)へ出さない。iBGPでは配る」、NO_ADVERTISEは「iBGPを含めてどこへも出さない」という違いになります。STEP 6とSTEP 7で実際に見ます。
後から追加された既知のコミュニティもあります。
| 名前 | 16進値 | AS:値表記 | 定義 |
|---|---|---|---|
GRACEFUL_SHUTDOWN | 0xFFFF0000 | 65535:0 | RFC 8326 Graceful BGP Session Shutdown(Standards Track)。計画メンテナンス時のパケットロスを減らす |
BLACKHOLE | 0xFFFF029A | 65535:666 | RFC 7999 BLACKHOLE Community(Informational)。隣接ASに該当宛先のトラフィック破棄を要求する |
拡張コミュニティ・ラージコミュニティ
コミュニティには派生が2つあります。この記事では扱いませんが、位置づけを整理しておきます。
| 属性 | Type code | 1個あたりの長さ | 構造 | 定義 |
|---|---|---|---|---|
| COMMUNITY | 8 | 4オクテット | 16ビット+16ビット | RFC 1997 |
| Extended Community | 16 | 8オクテット | Type/Sub-Type+値。MPLS-VPNのRoute Targetなどに使う | RFC 4360 |
| Large Community | 32 | 12オクテット | 32ビット×3(Global Administrator+Local Data Part 1・2) | RFC 8092 |
ラージコミュニティは、4バイトAS番号をそのまま名前空間に使えることが本質です。64500:1:2のように、32ビットのAS番号を先頭に置いたまま2つの値を運べます。
IOS XRでの設定方法
コミュニティはRPL(Routing Policy Language)で扱います。
付ける
route-policy TO-UPSTREAM
if destination in (192.168.6.0/24) then
set community (65004:1000)
endif
pass
end-policyset communityは既にある値を置き換えます。既存のコミュニティを残して追加したいときはadditiveを付けます。
set community (65001:100) additiveこの違いはSTEP 3とSTEP 4で実測します。
見る
判定にはcommunity-setで値の集合を定義し、community matches-any(どれか1つでも一致)またはmatches-every(すべて一致)で照合します。
community-set CS-FROM-CUSTOMER
65004:1000
end-set
!
route-policy FROM-CUSTOMER
if community matches-any CS-FROM-CUSTOMER then
set local-preference 200
endif
pass
end-policy判定はポリシーに入ってきた時点の値に対して行われます。 同じポリシーの中でset communityを実行しても、その手前に書いたif community matches-anyの判定結果は変わりません。書き換えた後の値で判定したい場合は、ポリシーを分けて2段階で適用します。
消す
delete community all ! すべて削除
delete community in CS-FROM-CUSTOMER ! community-setに載っているものだけ削除eBGPへ送るにはsend-community-ebgpが要る
IOS XRは、iBGPピアへはコミュニティを既定で送りますが、eBGPピアへは送りません。eBGPで運ぶにはネイバーのアドレスファミリにsend-community-ebgpを入れます。
router bgp 65004
neighbor 10.1.6.1
address-family ipv4 unicast
send-community-ebgp
route-policy TO-UPSTREAM out入っているかはshow bgp neighborのCommunity attribute sent to this neighborで確認できます。この行が無いeBGPネイバーには、set communityしても値が届きません。
実機での検証
XRd(IOS XR 26.1.1)6台のラボで、ここまでに述べた動作を9つのSTEPで確認します。
| AS | ルータ | 役割 |
|---|---|---|
| 65001 | R1・R2 | AS境界。R3とiBGPフルメッシュ(Loopback0、next-hop-self)+OSPF area 0 |
| 65001 | R3 | AS内部。eBGPピアを持たない |
| 65002 | R4 | R1・R2・R5とeBGP |
| 65003 | R5 | R4・R6とeBGP。192.168.5.0/24を広告 |
| 65004 | R6 | R5・R1とeBGP。192.168.6.0/24を広告 |
観測対象はR6が広告する192.168.6.0/24です。この経路は R6 →(eBGP)→ R1 →(iBGP)→ R2・R3、さらに R1 →(eBGP)→ R4 と流れます。eBGPホップとiBGPホップの両方を通るので、コミュニティがどこまで運ばれてどこで止まるかを1本の経路で追えます。
| STEP | 操作 | 見たいこと |
|---|---|---|
| 0 | ポリシーなし | コミュニティが付いていない状態 |
| 1 | R6がset community (65004:1000) | eBGPで値が届き、iBGPを越えてR2・R3・R4まで伝わる |
| 2 | R1がmatches-anyでLOCAL_PREF 200 | 印を見て動く側の実装 |
| 3 | R1がset community (65001:100)(additiveなし) | 元の65004:1000が消える |
| 4 | additiveを付ける | 2つ並ぶ |
| 5 | R1の入方向をPASS-ALLに戻す | 元の値だけに戻る |
| 6 | R6がNO_EXPORTを付ける | R1・R2がeBGPへ出さなくなる。iBGPでは配られる |
| 7 | R6がNO_ADVERTISEを付ける | R1がiBGPにも出さず、R2・R3へWITHDRAWを送る |
| 8 | R6が65001:429、R1がTO-R4でdrop | ユーザー定義コミュニティによる広告先制御 |
すべてのeBGPネイバーには最初からsend-community-ebgpと、ネイバーごとに別名の出方向ポリシー(TO-R1/TO-R4など、中身はpassのみ)を入れてあります。ポリシー名をネイバーごとに分けているのは、update-groupの構成をSTEP間で固定するためです。同じポリシー名を共有するネイバーは同じupdate-groupにまとめられ、広告内容がまとまってしまいます。各STEPではポリシーの中身だけを書き換えます。
STEP 0:初期状態
R1が受け取った192.168.6.0/24です。
RP/0/RP0/CPU0:R1#show bgp 192.168.6.0/24
Wed Sep 9 05:50:59.631 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 7 7
Last Modified: Sep 9 05:14:11.774 for 00:36:47
Paths: (1 available, best #1)
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.1.4.4
Path #1: Received by speaker 0
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.1.4.4
65004, (received & used)
10.1.6.6 from 10.1.6.6 (10.0.0.6)
Origin IGP, metric 0, localpref 100, valid, external, best, group-best
Received Path ID 0, Local Path ID 1, version 7
Origin-AS validity: (disabled)Community:の行がありません。R6の出方向ポリシーがpassのみなので、コミュニティは付いていません。
STEP 1:R6が192.168.6.0/24に65004:1000を付ける
R6のR1向け出方向ポリシーTO-R1を書き換えます。
RP/0/RP0/CPU0:R6#show rpl route-policy TO-R1
Wed Sep 9 06:14:29.887 UTC
route-policy TO-R1
if destination in (192.168.6.0/24) then
set community (65004:1000)
endif
pass
end-policy
!R1で見るとCommunity:の行が現れます。
RP/0/RP0/CPU0:R1#show bgp 192.168.6.0/24
Wed Sep 9 06:12:17.878 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 9 9
Last Modified: Sep 9 06:10:23.774 for 00:01:54
Paths: (1 available, best #1)
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.1.4.4
Path #1: Received by speaker 0
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.1.4.4
65004, (received & used)
10.1.6.6 from 10.1.6.6 (10.0.0.6)
Origin IGP, metric 0, localpref 100, valid, external, best, group-best
Received Path ID 0, Local Path ID 1, version 9
Community: 65004:1000
Origin-AS validity: (disabled)キャプチャーでも確認できます。添付のeBGPキャプチャーのNo.213が、R6(10.1.6.6)からR1(10.1.6.1)へ送られたUPDATEです。
Border Gateway Protocol - UPDATE Message
Marker: ffffffffffffffffffffffffffffffff
Length: 67
Type: UPDATE Message (2)
Withdrawn Routes Length: 0
Total Path Attribute Length: 44
Path attributes
Path Attribute - MP_REACH_NLRI
Flags: 0x90, Optional, Extended-Length, Non-transitive, Complete
<snip>
Type Code: MP_REACH_NLRI (14)
Length: 13
Address family identifier (AFI): IPv4 (1)
Subsequent address family identifier (SAFI): Unicast (1)
Next hop: 10.1.6.6
IPv4 Address: 10.1.6.6
Number of Subnetwork points of attachment (SNPA): 0
Network Layer Reachability Information (NLRI)
192.168.6.0/24
MP Reach NLRI prefix length: 24
MP Reach NLRI IPv4 prefix: 192.168.6.0
Path Attribute - ORIGIN: IGP
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: ORIGIN (1)
Length: 1
Origin: IGP (0)
Path Attribute - AS_PATH: 65004
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: AS_PATH (2)
Length: 6
AS Path segment: 65004
Segment type: AS_SEQUENCE (2)
Segment length (number of ASN): 1
AS4: 65004
Path Attribute - MULTI_EXIT_DISC: 0
Flags: 0x80, Optional, Non-transitive, Complete
<snip>
Type Code: MULTI_EXIT_DISC (4)
Length: 4
Multiple exit discriminator: 0
Path Attribute - COMMUNITIES: 65004:1000
Flags: 0xc0, Optional, Transitive, Complete
<snip>
Type Code: COMMUNITIES (8)
Length: 4
Communities: 65004:1000
Community: 65004:1000
Community AS: 65004
Community value: 1000Flags: 0xc0, Optional, Transitive, Completeが、この属性がOptional Transitiveであることを示しています。
iBGPホップを越えて伝わる
R1はこの経路をiBGPでR2・R3へ渡します。IOS XRはiBGPピアへコミュニティを既定で送るので、設定を足さなくても値はそのまま届きます。
RP/0/RP0/CPU0:R2#show bgp 192.168.6.0/24
Wed Sep 9 06:12:46.531 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 9 9
Last Modified: Sep 9 06:10:23.774 for 00:02:22
Paths: (1 available, best #1)
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.2.4.4
Path #1: Received by speaker 0
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.2.4.4
65004, (received & used)
10.0.0.1 (metric 3) from 10.0.0.1 (10.0.0.1)
Origin IGP, metric 0, localpref 100, valid, internal, best, group-best
Received Path ID 0, Local Path ID 1, version 9
Community: 65004:1000R1-R3間のiBGPキャプチャーのNo.427がそのUPDATEです。
Border Gateway Protocol - UPDATE Message
Marker: ffffffffffffffffffffffffffffffff
Length: 74
Type: UPDATE Message (2)
Withdrawn Routes Length: 0
Total Path Attribute Length: 51
Path attributes
Path Attribute - MP_REACH_NLRI
Flags: 0x90, Optional, Extended-Length, Non-transitive, Complete
<snip>
Type Code: MP_REACH_NLRI (14)
Length: 13
Address family identifier (AFI): IPv4 (1)
Subsequent address family identifier (SAFI): Unicast (1)
Next hop: 10.0.0.1
IPv4 Address: 10.0.0.1
Number of Subnetwork points of attachment (SNPA): 0
Network Layer Reachability Information (NLRI)
192.168.6.0/24
MP Reach NLRI prefix length: 24
MP Reach NLRI IPv4 prefix: 192.168.6.0
Path Attribute - ORIGIN: IGP
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: ORIGIN (1)
Length: 1
Origin: IGP (0)
Path Attribute - AS_PATH: 65004
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: AS_PATH (2)
Length: 6
AS Path segment: 65004
Segment type: AS_SEQUENCE (2)
Segment length (number of ASN): 1
AS4: 65004
Path Attribute - MULTI_EXIT_DISC: 0
Flags: 0x80, Optional, Non-transitive, Complete
<snip>
Type Code: MULTI_EXIT_DISC (4)
Length: 4
Multiple exit discriminator: 0
Path Attribute - LOCAL_PREF: 100
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: LOCAL_PREF (5)
Length: 4
Local preference: 100
Path Attribute - COMMUNITIES: 65004:1000
Flags: 0xc0, Optional, Transitive, Complete
<snip>
Type Code: COMMUNITIES (8)
Length: 4
Communities: 65004:1000
Community: 65004:1000
Community AS: 65004
Community value: 1000さらにR1はR4へもeBGPで広告するので、AS 65002のR4にも65004:1000が届きます。AS 65004が付けた印が、AS 65001を素通りしてAS 65002まで運ばれたということです。Optional Transitiveであることの効果がこれです。
RP/0/RP0/CPU0:R4#show bgp community 65004:1000
Wed Sep 9 06:13:36.383 UTC
BGP router identifier 10.0.0.4, local AS number 65002
BGP generic scan interval 60 secs
Non-stop routing is enabled
BGP table state: Active
Table ID: 0xe0000000 RD version: 11
BGP main routing table version 11
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.6.0/24 10.1.4.1 0 65001 65004 i
* 10.2.4.2 0 65001 65004 i
Processed 1 prefixes, 2 pathsSTEP 2:R1がコミュニティを見てLOCAL_PREFを上げる
ここまでは印を付けただけです。次はR1側に「印を見て動く」設定を入れます。
RP/0/RP0/CPU0:R1#show rpl community-set CS-FROM-R6
Wed Sep 9 06:17:48.295 UTC
community-set CS-FROM-R6
65004:1000
end-set
!RP/0/RP0/CPU0:R1#show rpl route-policy FROM-R6
Wed Sep 9 06:17:48.790 UTC
route-policy FROM-R6
if community matches-any CS-FROM-R6 then
set local-preference 200
endif
pass
end-policy
!これをR6向けネイバーの入方向に適用します。結果、localprefが200になります。
RP/0/RP0/CPU0:R1#show bgp 192.168.6.0/24
Wed Sep 9 06:17:43.938 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 10 10
Last Modified: Sep 9 06:17:31.774 for 00:00:12
Paths: (2 available, best #1)
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.1.4.4
Path #1: Received by speaker 0
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.1.4.4
65004
10.1.6.6 from 10.1.6.6 (10.0.0.6)
Origin IGP, metric 0, localpref 200, valid, external, best, group-best
Received Path ID 0, Local Path ID 1, version 10
Community: 65004:1000
Origin-AS validity: (disabled)
Path #2: Received by speaker 0
Not advertised to any peer
65004, (received-only)
10.1.6.6 from 10.1.6.6 (10.0.0.6)
Origin IGP, metric 0, localpref 100, valid, external
Received Path ID 0, Local Path ID 0, version 0
Community: 65004:1000
Origin-AS validity: (disabled)Path #2の(received-only)は、soft-reconfiguration inbound alwaysが保持している入方向ポリシー適用前のコピーです。localprefは100のままでコミュニティは65004:1000。Path #1がポリシー適用後でlocalpref 200。ポリシーが何をしたかがこの2つの差分で読めます。
STEP 3:set communityにadditiveを付けないと元の値が消える
FROM-R6にset community (65001:100)を足します。additiveは付けません。
RP/0/RP0/CPU0:R1#show rpl route-policy FROM-R6
Wed Sep 9 06:27:05.372 UTC
route-policy FROM-R6
if community matches-any CS-FROM-R6 then
set local-preference 200
endif
set community (65001:100)
pass
end-policy
!RP/0/RP0/CPU0:R1#show bgp 192.168.6.0/24
Wed Sep 9 06:26:59.651 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 12 12
Last Modified: Sep 9 06:26:26.774 for 00:00:32
Paths: (2 available, best #1)
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.1.4.4
Path #1: Received by speaker 0
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.1.4.4
65004
10.1.6.6 from 10.1.6.6 (10.0.0.6)
Origin IGP, metric 0, localpref 200, valid, external, best, group-best
Received Path ID 0, Local Path ID 1, version 12
Community: 65001:100
Origin-AS validity: (disabled)
Path #2: Received by speaker 0
Not advertised to any peer
65004, (received-only)
10.1.6.6 from 10.1.6.6 (10.0.0.6)
Origin IGP, metric 0, localpref 100, valid, external
Received Path ID 0, Local Path ID 0, version 0
Community: 65004:1000
Origin-AS validity: (disabled)Path #1(適用後)のコミュニティが65001:100だけになり、65004:1000が消えています。一方でPath #2(適用前)には65004:1000が残っています。
localpref 200は付いたままです。判定はset communityが動く前の値(65004:1000)に対して行われるという、前述のとおりの動作です。
もう1つ副作用があります。このset communityはifブロックの外にあるので、R6から受け取るすべての経路に適用されます。R6経由の192.168.5.0/24(Path #3)にも65001:100が付いています。
RP/0/RP0/CPU0:R1#show bgp 192.168.5.0/24
Wed Sep 9 06:26:59.411 UTC
BGP routing table entry for 192.168.5.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 11 11
Last Modified: Sep 9 06:26:26.774 for 00:00:32
Paths: (4 available, best #2)
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.1.6.6
Path #1: Received by speaker 0
Not advertised to any peer
65002 65003, (received & used)
10.0.0.2 (metric 3) from 10.0.0.2 (10.0.0.2)
Origin IGP, localpref 100, valid, internal
Received Path ID 0, Local Path ID 0, version 0
Path #2: Received by speaker 0
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.1.6.6
65002 65003, (received & used)
10.1.4.4 from 10.1.4.4 (10.0.0.4)
Origin IGP, localpref 100, valid, external, best, group-best
Received Path ID 0, Local Path ID 1, version 8
Origin-AS validity: (disabled)
Path #3: Received by speaker 0
Not advertised to any peer
65004 65003
10.1.6.6 from 10.1.6.6 (10.0.0.6)
Origin IGP, localpref 100, valid, external, group-best
Received Path ID 0, Local Path ID 0, version 0
Community: 65001:100
Origin-AS validity: (disabled)
Path #4: Received by speaker 0
Not advertised to any peer
65004 65003, (received-only)
10.1.6.6 from 10.1.6.6 (10.0.0.6)
Origin IGP, localpref 100, valid, external
Received Path ID 0, Local Path ID 0, version 0
Origin-AS validity: (disabled)iBGPキャプチャーのNo.559が、この置き換わった値をR3へ運ぶUPDATEです。
Border Gateway Protocol - UPDATE Message
Marker: ffffffffffffffffffffffffffffffff
Length: 74
Type: UPDATE Message (2)
Withdrawn Routes Length: 0
Total Path Attribute Length: 51
Path attributes
Path Attribute - MP_REACH_NLRI
Flags: 0x90, Optional, Extended-Length, Non-transitive, Complete
<snip>
Type Code: MP_REACH_NLRI (14)
Length: 13
Address family identifier (AFI): IPv4 (1)
Subsequent address family identifier (SAFI): Unicast (1)
Next hop: 10.0.0.1
IPv4 Address: 10.0.0.1
Number of Subnetwork points of attachment (SNPA): 0
Network Layer Reachability Information (NLRI)
192.168.6.0/24
MP Reach NLRI prefix length: 24
MP Reach NLRI IPv4 prefix: 192.168.6.0
Path Attribute - ORIGIN: IGP
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: ORIGIN (1)
Length: 1
Origin: IGP (0)
Path Attribute - AS_PATH: 65004
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: AS_PATH (2)
Length: 6
AS Path segment: 65004
Segment type: AS_SEQUENCE (2)
Segment length (number of ASN): 1
AS4: 65004
Path Attribute - MULTI_EXIT_DISC: 0
Flags: 0x80, Optional, Non-transitive, Complete
<snip>
Type Code: MULTI_EXIT_DISC (4)
Length: 4
Multiple exit discriminator: 0
Path Attribute - LOCAL_PREF: 200
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: LOCAL_PREF (5)
Length: 4
Local preference: 200
Path Attribute - COMMUNITIES: 65001:100
Flags: 0xc0, Optional, Transitive, Complete
<snip>
Type Code: COMMUNITIES (8)
Length: 4
Communities: 65001:100
Community: 65001:100
Community AS: 65001
Community value: 100STEP 4:additiveを付けると両方残る
同じ行にadditiveを足します。
RP/0/RP0/CPU0:R1#show rpl route-policy FROM-R6
Wed Sep 9 06:32:15.350 UTC
route-policy FROM-R6
if community matches-any CS-FROM-R6 then
set local-preference 200
endif
set community (65001:100) additive
pass
end-policy
!RP/0/RP0/CPU0:R1#show bgp 192.168.6.0/24
Wed Sep 9 06:32:09.384 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 13 13
Last Modified: Sep 9 06:31:52.774 for 00:00:16
Paths: (2 available, best #1)
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.1.4.4
Path #1: Received by speaker 0
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.1.4.4
65004
10.1.6.6 from 10.1.6.6 (10.0.0.6)
Origin IGP, metric 0, localpref 200, valid, external, best, group-best
Received Path ID 0, Local Path ID 1, version 13
Community: 65001:100 65004:1000
Origin-AS validity: (disabled)
Path #2: Received by speaker 0
Not advertised to any peer
65004, (received-only)
10.1.6.6 from 10.1.6.6 (10.0.0.6)
Origin IGP, metric 0, localpref 100, valid, external
Received Path ID 0, Local Path ID 0, version 0
Community: 65004:1000
Origin-AS validity: (disabled)Community: 65001:100 65004:1000と2つ並びました。上位ISPが自分の印を足しつつ顧客の印も残したいなら、必ずadditiveが要ります。
Border Gateway Protocol - UPDATE Message
Marker: ffffffffffffffffffffffffffffffff
Length: 78
Type: UPDATE Message (2)
Withdrawn Routes Length: 0
Total Path Attribute Length: 55
Path attributes
Path Attribute - MP_REACH_NLRI
Flags: 0x90, Optional, Extended-Length, Non-transitive, Complete
<snip>
Type Code: MP_REACH_NLRI (14)
Length: 13
Address family identifier (AFI): IPv4 (1)
Subsequent address family identifier (SAFI): Unicast (1)
Next hop: 10.0.0.1
IPv4 Address: 10.0.0.1
Number of Subnetwork points of attachment (SNPA): 0
Network Layer Reachability Information (NLRI)
192.168.6.0/24
MP Reach NLRI prefix length: 24
MP Reach NLRI IPv4 prefix: 192.168.6.0
Path Attribute - ORIGIN: IGP
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: ORIGIN (1)
Length: 1
Origin: IGP (0)
Path Attribute - AS_PATH: 65004
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: AS_PATH (2)
Length: 6
AS Path segment: 65004
Segment type: AS_SEQUENCE (2)
Segment length (number of ASN): 1
AS4: 65004
Path Attribute - MULTI_EXIT_DISC: 0
Flags: 0x80, Optional, Non-transitive, Complete
<snip>
Type Code: MULTI_EXIT_DISC (4)
Length: 4
Multiple exit discriminator: 0
Path Attribute - LOCAL_PREF: 200
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: LOCAL_PREF (5)
Length: 4
Local preference: 200
Path Attribute - COMMUNITIES: 65001:100 65004:1000
Flags: 0xc0, Optional, Transitive, Complete
<snip>
Type Code: COMMUNITIES (8)
Length: 8
Communities: 65001:100 65004:1000
Community: 65001:100
Community AS: 65001
Community value: 100
Community: 65004:1000
Community AS: 65004
Community value: 1000Length: 8となっていて、4オクテットのコミュニティが2個入っていることが分かります。
STEP 5:R1の入方向ポリシーを外す
ここから既知のコミュニティの検証に移るので、R1のR6向け入方向をPASS-ALLに戻します。
RP/0/RP0/CPU0:R1#show bgp 192.168.6.0/24
Wed Sep 9 06:34:55.670 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 15 15
Last Modified: Sep 9 06:34:43.774 for 00:00:12
Paths: (1 available, best #1)
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.1.4.4
Path #1: Received by speaker 0
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.1.4.4
65004, (received & used)
10.1.6.6 from 10.1.6.6 (10.0.0.6)
Origin IGP, metric 0, localpref 100, valid, external, best, group-best
Received Path ID 0, Local Path ID 1, version 15
Community: 65004:1000
Origin-AS validity: (disabled)localprefが100に、コミュニティがR6の付けた65004:1000だけに戻りました。
STEP 6:NO_EXPORTは自ASの外へ出さない
R6のTO-R1をset community (no-export)に変更します。
RP/0/RP0/CPU0:R6#show rpl route-policy TO-R1
Wed Sep 9 06:37:59.186 UTC
route-policy TO-R1
if destination in (192.168.6.0/24) then
set community (no-export)
endif
pass
end-policy
!R1のBGPテーブルです。
RP/0/RP0/CPU0:R1#show bgp 192.168.6.0/24
Wed Sep 9 06:38:46.975 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 16 16
Last Modified: Sep 9 06:37:22.774 for 00:01:24
Paths: (2 available, best #2, not advertised to EBGP peer)
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Path #1: Received by speaker 0
Not advertised to any peer
65002 65003 65004, (received & used)
10.1.4.4 from 10.1.4.4 (10.0.0.4)
Origin IGP, localpref 100, valid, external, group-best
Received Path ID 0, Local Path ID 0, version 0
Origin-AS validity: (disabled)
Path #2: Received by speaker 0
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
65004, (received & used)
10.1.6.6 from 10.1.6.6 (10.0.0.6)
Origin IGP, metric 0, localpref 100, valid, external, best, group-best
Received Path ID 0, Local Path ID 1, version 16
Community: no-export
Origin-AS validity: (disabled)Paths:の行の末尾にnot advertised to EBGP peerが付きました。これがNO_EXPORTを受けた印です。実際、R4向けの広告から192.168.6.0/24が消えています。
RP/0/RP0/CPU0:R1#show bgp neighbors 10.1.4.4 advertised-routes
Wed Sep 9 06:38:50.455 UTC
Network Next Hop From AS Path
192.168.1.0/24 10.1.4.1 Local 65001i
192.168.2.0/24 10.1.4.1 10.0.0.2 65001i
192.168.3.0/24 10.1.4.1 10.0.0.3 65001i
Processed 3 prefixes, 3 paths一方でiBGPには配られます。R2もこの経路を受け取り、同じように「eBGPへは出さない」状態になります。
RP/0/RP0/CPU0:R2#show bgp 192.168.6.0/24
Wed Sep 9 06:39:16.253 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 14 14
Last Modified: Sep 9 06:37:22.774 for 00:01:53
Paths: (2 available, best #1, not advertised to EBGP peer)
Not advertised to any peer
Path #1: Received by speaker 0
Not advertised to any peer
65004, (received & used)
10.0.0.1 (metric 3) from 10.0.0.1 (10.0.0.1)
Origin IGP, metric 0, localpref 100, valid, internal, best, group-best
Received Path ID 0, Local Path ID 1, version 14
Community: no-export
Path #2: Received by speaker 0
Not advertised to any peer
65002 65003 65004, (received & used)
10.2.4.4 from 10.2.4.4 (10.0.0.4)
Origin IGP, localpref 100, valid, external, group-best
Received Path ID 0, Local Path ID 0, version 0
Origin-AS validity: (disabled)RP/0/RP0/CPU0:R2#show bgp neighbors 10.2.4.4 advertised-routes
Wed Sep 9 06:39:19.485 UTC
Network Next Hop From AS Path
192.168.1.0/24 10.2.4.2 10.0.0.1 65001i
192.168.2.0/24 10.2.4.2 Local 65001i
192.168.3.0/24 10.2.4.2 10.0.0.3 65001i
Processed 3 prefixes, 3 pathsR2には何の設定もしていません。R1がiBGPでNO_EXPORTごと渡したので、R2も自動的にeBGPへ出さなくなりました。「AS 65001の外へ出さない」がAS単位で効いていることになります。
R1・R2の両方が止めた結果、AS 65002のR4は192.168.6.0/24をAS 65001経由で受け取れなくなり、R5経由(65003 65004)だけになります。
RP/0/RP0/CPU0:R4#show bgp 192.168.6.0/24
Wed Sep 9 06:39:59.467 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 16 16
Last Modified: Sep 9 06:37:22.774 for 00:02:36
Paths: (1 available, best #1)
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.2.4.2 10.1.4.1
Path #1: Received by speaker 0
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.2.4.2 10.1.4.1
65003 65004, (received & used)
10.4.5.5 from 10.4.5.5 (10.0.0.5)
Origin IGP, localpref 100, valid, external, best, group-best
Received Path ID 0, Local Path ID 1, version 16
Origin-AS validity: (disabled)eBGPキャプチャーのNo.321が、NO_EXPORTを運んだUPDATEです。
Border Gateway Protocol - UPDATE Message
Marker: ffffffffffffffffffffffffffffffff
Length: 67
Type: UPDATE Message (2)
Withdrawn Routes Length: 0
Total Path Attribute Length: 44
Path attributes
Path Attribute - MP_REACH_NLRI
Flags: 0x90, Optional, Extended-Length, Non-transitive, Complete
<snip>
Type Code: MP_REACH_NLRI (14)
Length: 13
Address family identifier (AFI): IPv4 (1)
Subsequent address family identifier (SAFI): Unicast (1)
Next hop: 10.1.6.6
IPv4 Address: 10.1.6.6
Number of Subnetwork points of attachment (SNPA): 0
Network Layer Reachability Information (NLRI)
192.168.6.0/24
MP Reach NLRI prefix length: 24
MP Reach NLRI IPv4 prefix: 192.168.6.0
Path Attribute - ORIGIN: IGP
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: ORIGIN (1)
Length: 1
Origin: IGP (0)
Path Attribute - AS_PATH: 65004
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: AS_PATH (2)
Length: 6
AS Path segment: 65004
Segment type: AS_SEQUENCE (2)
Segment length (number of ASN): 1
AS4: 65004
Path Attribute - MULTI_EXIT_DISC: 0
Flags: 0x80, Optional, Non-transitive, Complete
<snip>
Type Code: MULTI_EXIT_DISC (4)
Length: 4
Multiple exit discriminator: 0
Path Attribute - COMMUNITIES: NO_EXPORT
Flags: 0xc0, Optional, Transitive, Complete
<snip>
Type Code: COMMUNITIES (8)
Length: 4
Communities: NO_EXPORT
Community Well-known: NO_EXPORT (0xffffff01)Community Well-known: NO_EXPORT (0xffffff01)と、RFC 1997の値がそのまま入っています。
STEP 7:NO_ADVERTISEはiBGPにも出さない
TO-R1をset community (no-advertise)に変えます。
RP/0/RP0/CPU0:R6#show rpl route-policy TO-R1
Wed Sep 9 06:40:52.536 UTC
route-policy TO-R1
if destination in (192.168.6.0/24) then
set community (no-advertise)
endif
pass
end-policy
!R1ではnot advertised to any peerになります。
RP/0/RP0/CPU0:R1#show bgp 192.168.6.0/24
Wed Sep 9 06:41:35.790 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 17 17
Last Modified: Sep 9 06:40:35.774 for 00:01:00
Paths: (3 available, best #3, not advertised to any peer)
Not advertised to any peer
Path #1: Received by speaker 0
Not advertised to any peer
65002 65003 65004, (received & used)
10.0.0.2 (metric 3) from 10.0.0.2 (10.0.0.2)
Origin IGP, localpref 100, valid, internal
Received Path ID 0, Local Path ID 0, version 0
Path #2: Received by speaker 0
Not advertised to any peer
65002 65003 65004, (received & used)
10.1.4.4 from 10.1.4.4 (10.0.0.4)
Origin IGP, localpref 100, valid, external, group-best
Received Path ID 0, Local Path ID 0, version 0
Origin-AS validity: (disabled)
Path #3: Received by speaker 0
Not advertised to any peer
65004, (received & used)
10.1.6.6 from 10.1.6.6 (10.0.0.6)
Origin IGP, metric 0, localpref 100, valid, external, best, group-best
Received Path ID 0, Local Path ID 1, version 17
Community: no-advertise
Origin-AS validity: (disabled)R1のiBGPピア向け広告からも192.168.6.0/24が消えました。
RP/0/RP0/CPU0:R1#show bgp neighbors 10.0.0.2 advertised-routes
Wed Sep 9 06:41:38.012 UTC
Network Next Hop From AS Path
192.168.1.0/24 10.0.0.1 Local i
192.168.4.0/24 10.0.0.1 10.1.4.4 65002i
192.168.5.0/24 10.0.0.1 10.1.4.4 65002 65003i
Processed 3 prefixes, 3 pathsSTEP 6ではここに192.168.6.0/24が載っていました。NO_EXPORTはiBGPには配りますが、NO_ADVERTISEはiBGPにも配りません。
このときR1は、単に「次から送らない」のではなく、すでに送ってあった経路をWITHDRAWで取り消します。iBGPキャプチャーのNo.681がそれです。
Border Gateway Protocol - UPDATE Message
Marker: ffffffffffffffffffffffffffffffff
Length: 27
Type: UPDATE Message (2)
Withdrawn Routes Length: 4
Withdrawn Routes
192.168.6.0/24
Withdrawn route prefix length: 24
Withdrawn prefix: 192.168.6.0
Total Path Attribute Length: 0これでR3は192.168.6.0/24を失う……のではなく、R2経由の別経路に切り替わります。R2はR4から65002 65003 65004のパスを受け取っており、R1からの経路が消えたことでそれがベストになるためです。
RP/0/RP0/CPU0:R3#show bgp 192.168.6.0/24
Wed Sep 9 06:42:28.378 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 17 17
Last Modified: Sep 9 06:40:36.774 for 00:01:51
Paths: (1 available, best #1)
Not advertised to any peer
Path #1: Received by speaker 0
Not advertised to any peer
65002 65003 65004, (received & used)
10.0.0.2 (metric 2) from 10.0.0.2 (10.0.0.2)
Origin IGP, localpref 100, valid, internal, best, group-best
Received Path ID 0, Local Path ID 1, version 17AS_PATHが65004(R1経由・1ホップ)から65002 65003 65004(R2 → R4 → R5 → R6・3ホップ)に伸びました。NO_ADVERTISEは経路そのものを消すのではなく、その1つのパスの配布を止めるだけなので、他に経路があればそちらが使われます。
eBGPキャプチャーのNo.335がNO_ADVERTISEを運んだUPDATEです。
Border Gateway Protocol - UPDATE Message
Marker: ffffffffffffffffffffffffffffffff
Length: 67
Type: UPDATE Message (2)
Withdrawn Routes Length: 0
Total Path Attribute Length: 44
Path attributes
Path Attribute - MP_REACH_NLRI
Flags: 0x90, Optional, Extended-Length, Non-transitive, Complete
<snip>
Type Code: MP_REACH_NLRI (14)
Length: 13
Address family identifier (AFI): IPv4 (1)
Subsequent address family identifier (SAFI): Unicast (1)
Next hop: 10.1.6.6
IPv4 Address: 10.1.6.6
Number of Subnetwork points of attachment (SNPA): 0
Network Layer Reachability Information (NLRI)
192.168.6.0/24
MP Reach NLRI prefix length: 24
MP Reach NLRI IPv4 prefix: 192.168.6.0
Path Attribute - ORIGIN: IGP
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: ORIGIN (1)
Length: 1
Origin: IGP (0)
Path Attribute - AS_PATH: 65004
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: AS_PATH (2)
Length: 6
AS Path segment: 65004
Segment type: AS_SEQUENCE (2)
Segment length (number of ASN): 1
AS4: 65004
Path Attribute - MULTI_EXIT_DISC: 0
Flags: 0x80, Optional, Non-transitive, Complete
<snip>
Type Code: MULTI_EXIT_DISC (4)
Length: 4
Multiple exit discriminator: 0
Path Attribute - COMMUNITIES: NO_ADVERTISE
Flags: 0xc0, Optional, Transitive, Complete
<snip>
Type Code: COMMUNITIES (8)
Length: 4
Communities: NO_ADVERTISE
Community Well-known: NO_ADVERTISE (0xffffff02)STEP 8:ユーザー定義コミュニティで広告先を絞る(最終状態)
最後に、冒頭で紹介したNTTの2914:429(どのピアにも広告しない)と同じ形をラボで作ります。AS 65001が65001:429を「R4(AS 65002)へは広告しない」の意味で公開し、R6がそれを付けて広告する、という想定です。
R6側はset community (65001:429)に変えるだけです。自分のAS番号ではなく、相手(AS 65001)のAS番号を上位に置く点に注意してください。このコミュニティの意味を決めているのはAS 65001だからです。
RP/0/RP0/CPU0:R6#show rpl route-policy TO-R1
Wed Sep 9 06:44:06.630 UTC
route-policy TO-R1
if destination in (192.168.6.0/24) then
set community (65001:429)
endif
pass
end-policy
!AS 65001側では、R1にコミュニティの判定とdropを入れます。
RP/0/RP0/CPU0:R1#show rpl community-set CS-NO-ADV-R4
Wed Sep 9 06:44:56.006 UTC
community-set CS-NO-ADV-R4
65001:429
end-set
!RP/0/RP0/CPU0:R1#show rpl route-policy TO-R4
Wed Sep 9 06:44:54.180 UTC
route-policy TO-R4
if community matches-any CS-NO-ADV-R4 then
drop
endif
pass
end-policy
!R1のBGPテーブルです。既知のコミュニティではないので、not advertised to ...のような特別な表示は出ません。
RP/0/RP0/CPU0:R1#show bgp 192.168.6.0/24
Wed Sep 9 06:44:49.322 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 18 18
Last Modified: Sep 9 06:43:35.774 for 00:01:13
Paths: (2 available, best #2)
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
Path #1: Received by speaker 0
Not advertised to any peer
65002 65003 65004, (received & used)
10.1.4.4 from 10.1.4.4 (10.0.0.4)
Origin IGP, localpref 100, valid, external, group-best
Received Path ID 0, Local Path ID 0, version 0
Origin-AS validity: (disabled)
Path #2: Received by speaker 0
Advertised IPv4 Unicast paths to update-groups (with more than one peer):
0.2
65004, (received & used)
10.1.6.6 from 10.1.6.6 (10.0.0.6)
Origin IGP, metric 0, localpref 100, valid, external, best, group-best
Received Path ID 0, Local Path ID 1, version 18
Community: 65001:429
Origin-AS validity: (disabled)R4向けの広告からは192.168.6.0/24が落ちています。
RP/0/RP0/CPU0:R1#show bgp neighbors 10.1.4.4 advertised-routes
Wed Sep 9 06:44:51.989 UTC
Network Next Hop From AS Path
192.168.1.0/24 10.1.4.1 Local 65001i
192.168.2.0/24 10.1.4.1 10.0.0.2 65001i
192.168.3.0/24 10.1.4.1 10.0.0.3 65001i
Processed 3 prefixes, 3 paths一方でiBGPには通常どおり流れます。NO_EXPORTと違い、これは「R1がR4向け出方向ポリシーで落としているだけ」だからです。
RP/0/RP0/CPU0:R1#show bgp neighbors 10.0.0.2 advertised-routes
Wed Sep 9 06:44:50.856 UTC
Network Next Hop From AS Path
192.168.1.0/24 10.0.0.1 Local i
192.168.4.0/24 10.0.0.1 10.1.4.4 65002i
192.168.5.0/24 10.0.0.1 10.1.4.4 65002 65003i
192.168.6.0/24 10.0.0.1 10.1.6.6 65004i
Processed 4 prefixes, 4 pathsユーザー定義コミュニティは全境界ルータに入れないと漏れる
ここで、AS 65001のもう1つのAS境界ルータであるR2を見ます。R2にはdropの設定を入れていません。
RP/0/RP0/CPU0:R2#show bgp neighbors 10.2.4.4 advertised-routes
Wed Sep 9 06:45:21.155 UTC
Network Next Hop From AS Path
192.168.1.0/24 10.2.4.2 10.0.0.1 65001i
192.168.2.0/24 10.2.4.2 Local 65001i
192.168.3.0/24 10.2.4.2 10.0.0.3 65001i
192.168.6.0/24 10.2.4.2 10.0.0.1 65001 65004i
Processed 4 prefixes, 4 paths192.168.6.0/24がR4へ広告されています。R4側にもコミュニティ付きで届いています。
RP/0/RP0/CPU0:R4#show bgp 192.168.6.0/24
Wed Sep 9 06:46:02.350 UTC
BGP routing table entry for 192.168.6.0/24
Versions:
Process bRIB/RIB SendTblVer
Speaker 16 16
Last Modified: Sep 9 06:37:22.774 for 00:08:39
Paths: (2 available, best #2)
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.2.4.2 10.1.4.1
Path #1: Received by speaker 0
Not advertised to any peer
65001 65004, (received & used)
10.2.4.2 from 10.2.4.2 (10.0.0.2)
Origin IGP, localpref 100, valid, external, group-best
Received Path ID 0, Local Path ID 0, version 0
Community: 65001:429
Origin-AS validity: (disabled)
Path #2: Received by speaker 0
Advertised IPv4 Unicast paths to peers (in unique update groups):
10.2.4.2 10.1.4.1
65003 65004, (received & used)
10.4.5.5 from 10.4.5.5 (10.0.0.5)
Origin IGP, localpref 100, valid, external, best, group-best
Received Path ID 0, Local Path ID 1, version 16
Origin-AS validity: (disabled)NO_EXPORTはプロトコルの規定なのでどのルータでも同じ動きをしますが、ユーザー定義コミュニティは各ルータのポリシー次第、という前述のとおりの結果です。「このコミュニティを付ければ広告しません」と公開するなら、そのASのすべての境界ルータに同じ判定を入れる必要があります。
eBGPキャプチャーのNo.347が65001:429を運んだUPDATEです。
Border Gateway Protocol - UPDATE Message
Marker: ffffffffffffffffffffffffffffffff
Length: 67
Type: UPDATE Message (2)
Withdrawn Routes Length: 0
Total Path Attribute Length: 44
Path attributes
Path Attribute - MP_REACH_NLRI
Flags: 0x90, Optional, Extended-Length, Non-transitive, Complete
<snip>
Type Code: MP_REACH_NLRI (14)
Length: 13
Address family identifier (AFI): IPv4 (1)
Subsequent address family identifier (SAFI): Unicast (1)
Next hop: 10.1.6.6
IPv4 Address: 10.1.6.6
Number of Subnetwork points of attachment (SNPA): 0
Network Layer Reachability Information (NLRI)
192.168.6.0/24
MP Reach NLRI prefix length: 24
MP Reach NLRI IPv4 prefix: 192.168.6.0
Path Attribute - ORIGIN: IGP
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: ORIGIN (1)
Length: 1
Origin: IGP (0)
Path Attribute - AS_PATH: 65004
Flags: 0x40, Transitive, Well-known, Complete
<snip>
Type Code: AS_PATH (2)
Length: 6
AS Path segment: 65004
Segment type: AS_SEQUENCE (2)
Segment length (number of ASN): 1
AS4: 65004
Path Attribute - MULTI_EXIT_DISC: 0
Flags: 0x80, Optional, Non-transitive, Complete
<snip>
Type Code: MULTI_EXIT_DISC (4)
Length: 4
Multiple exit discriminator: 0
Path Attribute - COMMUNITIES: 65001:429
Flags: 0xc0, Optional, Transitive, Complete
<snip>
Type Code: COMMUNITIES (8)
Length: 4
Communities: 65001:429
Community: 65001:429
Community AS: 65001
Community value: 429検証のまとめ
| STEP | R6が付けたコミュニティ | R1の挙動 | R2・R3(iBGP) | R4(AS 65002) |
|---|---|---|---|---|
| 1 | 65004:1000 | そのまま中継 | 届く | 届く |
| 3 | (R1が65001:100で上書き) | 元の値を破棄 | 65001:100のみ | 65001:100のみ |
| 4 | (R1がadditiveで追加) | 両方保持 | 2つとも届く | 2つとも届く |
| 6 | NO_EXPORT | eBGPへ出さない | 届く。R2もeBGPへ出さなくなる | 届かない |
| 7 | NO_ADVERTISE | どこへも出さない | 届かない(WITHDRAWを受ける) | 届かない |
| 8 | 65001:429 | TO-R4でdrop | 届く | R1からは届かない。R2からは漏れる |
検証Configおよびshow結果
各STEPで6台すべてから、次の3種類をルータごとに分けて取得しています。検証Configはこの..._run.txtです(最終状態は STEP 8 のもの)。
| ファイル | 内容 |
|---|---|
..._show.txt | show version / show interface description / show route / show bgp / show bgp community <値> / show bgp neighbors <ピア> advertised-routes・routes・received routes / show rpl route-policy など |
..._log.txt | そのSTEPの範囲だけに絞ったshow logging。各STEPの開始時にlogmsgでマーカーを入れ、その時刻をshow logging startに指定して取得したもの |
..._run.txt | そのSTEP時点のshow running-config(=そのSTEPの検証Config) |
最終状態では、R6のTO-R1にset community (65001:429)、R1にcommunity-set CS-NO-ADV-R4と、それにマッチしたらdropするTO-R4が入っています。R1のFROM-R6とCS-FROM-R6はSTEP 5で適用をやめましたが、定義自体は残してあります。
STEP 0:初期状態
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 1:R6が192.168.6.0/24に65004:1000を付ける
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 2:R1がコミュニティを見てLOCAL_PREFを上げる
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 3:set communityにadditiveを付けない
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 4:additiveを付ける
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 5:R1の入方向ポリシーを外す
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 6:R6がNO_EXPORTを付ける
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 7:R6がNO_ADVERTISEを付ける
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
STEP 8:ユーザー定義コミュニティ65001:429で広告先を絞る(最終状態)
| ルータ | show出力 | syslog | running-config |
|---|---|---|---|
| R1 | show | log | run |
| R2 | show | log | run |
| R3 | show | log | run |
| R4 | show | log | run |
| R5 | show | log | run |
| R6 | show | log | run |
キャプチャーは2本取っています。R1-R6間(eBGP)がbgp-community.pcap、R1-R3間(iBGP)がbgp-community-ibgp.pcapです。
R1-R6間(eBGP)のキャプチャー全体をダウンロード
R1-R3間(iBGP)のキャプチャー全体をダウンロード
参考
| 資料 | タイトル | 概要 |
|---|---|---|
| RFC 1997 | BGP Communities Attribute | COMMUNITY属性の定義。Type code 8、optional transitive、4オクテット、予約範囲、NO_EXPORT/NO_ADVERTISE/NO_EXPORT_SUBCONFEDの規定。 |
| RFC 4360 | BGP Extended Communities Attribute | 拡張コミュニティ(Type code 16、8オクテット)の定義。 |
| RFC 8092 | BGP Large Communities Attribute | ラージコミュニティ(Type code 32、12オクテット、32ビット×3)の定義。4バイトAS番号を名前空間に使える。 |
| RFC 7999 | BLACKHOLE Community | 65535:666(0xFFFF029A)の定義。Informational。 |
| RFC 8326 | Graceful BGP Session Shutdown | GRACEFUL_SHUTDOWN(65535:0/0xFFFF0000)の定義。 |
| NTT | Routing - NTT-GIN | AS2914が顧客向けに公開しているコミュニティ一覧。2914:429や65500:nnnなど、実運用での使われ方が分かる。 |