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

BGP COMMUNITY属性

目次

COMMUNITYとは

COMMUNITY(コミュニティ)は、経路に「印」を付けて運ぶためのパス属性です。BGPパス属性とベストパス選択で扱ったAS_PATHLOCAL_PREFと違い、それ自体はベストパス選択に一切影響しません。印を見たルータが自分のポリシーで何をするかを決めて、はじめて意味を持ちます。

項目内容
Type code8
属性の分類Optional Transitive(省略可能・推移的)
32ビット(4オクテット)を1個とし、複数個を並べられる
表記AS番号:値(上位16ビット:下位16ビット)
予約範囲0x000000000x0000FFFF0xFFFF00000xFFFFFFFF
ベストパス選択影響しない。印を付けるだけ
定義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:429do not advertise to any peers(どのピアにも広告しない)
2914:4212914:423全ピア向けにAS_PATHを1〜3回prependする
2914:490customer default(LOCAL_PREF 120)
2914:450peer fallback(LOCAL_PREF 96)
65500:nnn指定したピアAS nnnにだけ広告しない
2914:666blackhole(該当プレフィックス宛のトラフィックを破棄)

顧客は自分の経路にこれらを付けて広告するだけで、AS2914の中でのLOCAL_PREFや、どのピアへ広告するかを制御できます。AS2914側の設定変更は不要。後述のSTEP 8では、この2914:429にならった65001:429をラボで再現します。

既知のコミュニティ(Well-known Communities)

RFC 1997は、どのASでも同じ意味を持つ値を3つ定義しています。いずれも上位16ビットが0xFFFFの予約範囲にあります。

名前16進値RFC 1997の規定
NO_EXPORT0xFFFFFF01BGPコンフェデレーション境界の外へ広告してはならない
NO_ADVERTISE0xFFFFFF02他のBGPピアへ一切広告してはならない
NO_EXPORT_SUBCONFED0xFFFFFF03外部BGPピアへ広告してはならない(コンフェデレーション内の他メンバASを含む)

コンフェデレーションを使っていない普通の構成では、NO_EXPORTは「自ASの外(eBGPピア)へ出さない。iBGPでは配る」、NO_ADVERTISEは「iBGPを含めてどこへも出さない」という違いになります。STEP 6とSTEP 7で実際に見ます。

後から追加された既知のコミュニティもあります。

名前16進値AS:値表記定義
GRACEFUL_SHUTDOWN0xFFFF000065535:0RFC 8326 Graceful BGP Session Shutdown(Standards Track)。計画メンテナンス時のパケットロスを減らす
BLACKHOLE0xFFFF029A65535:666RFC 7999 BLACKHOLE Community(Informational)。隣接ASに該当宛先のトラフィック破棄を要求する

拡張コミュニティ・ラージコミュニティ

コミュニティには派生が2つあります。この記事では扱いませんが、位置づけを整理しておきます。

属性Type code1個あたりの長さ構造定義
COMMUNITY84オクテット16ビット+16ビットRFC 1997
Extended Community168オクテットType/Sub-Type+値。MPLS-VPNのRoute Targetなどに使うRFC 4360
Large Community3212オクテット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-policy

set 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 neighborCommunity attribute sent to this neighborで確認できます。この行が無いeBGPネイバーには、set communityしても値が届きません。

実機での検証

XRd(IOS XR 26.1.1)6台のラボで、ここまでに述べた動作を9つのSTEPで確認します。

COMMUNITY検証ラボのトポロジ。AS 65001のR1・R2がAS 65002のR4とeBGPで接続し、R4はAS 65003のR5とも接続する。R5はAS 65004のR6と、R6はR1とも接続する。R6が192.168.6.0/24にコミュニティを付けてR1へ広告する
ASルータ役割
65001R1・R2AS境界。R3とiBGPフルメッシュ(Loopback0、next-hop-self)+OSPF area 0
65001R3AS内部。eBGPピアを持たない
65002R4R1・R2・R5とeBGP
65003R5R4・R6とeBGP。192.168.5.0/24を広告
65004R6R5・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ポリシーなしコミュニティが付いていない状態
1R6がset community (65004:1000)eBGPで値が届き、iBGPを越えてR2・R3・R4まで伝わる
2R1がmatches-anyLOCAL_PREF 200印を見て動く側の実装
3R1がset community (65001:100)additiveなし)元の65004:1000が消える
4additiveを付ける2つ並ぶ
5R1の入方向をPASS-ALLに戻す元の値だけに戻る
6R6がNO_EXPORTを付けるR1・R2がeBGPへ出さなくなる。iBGPでは配られる
7R6がNO_ADVERTISEを付けるR1がiBGPにも出さず、R2・R3へWITHDRAWを送る
8R6が65001:429、R1がTO-R4でdropユーザー定義コミュニティによる広告先制御

すべてのeBGPネイバーには最初からsend-community-ebgpと、ネイバーごとに別名の出方向ポリシー(TO-R1TO-R4など、中身はpassのみ)を入れてあります。ポリシー名をネイバーごとに分けているのは、update-groupの構成をSTEP間で固定するためです。同じポリシー名を共有するネイバーは同じupdate-groupにまとめられ、広告内容がまとまってしまいます。各STEPではポリシーの中身だけを書き換えます。

STEP 0:初期状態

R1が受け取った192.168.6.0/24です。

R1 show bgp 192.168.6.0/24(STEP 0)
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/2465004:1000を付ける

R6のR1向け出方向ポリシーTO-R1を書き換えます。

R6 show rpl route-policy TO-R1(STEP 1)
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:の行が現れます。

R1 show bgp 192.168.6.0/24(STEP 1)
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です。

No.213 UPDATE(R6 → R1)tshark -V
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: 1000

Flags: 0xc0, Optional, Transitive, Completeが、この属性がOptional Transitiveであることを示しています。

上のtshark出力のパケット(No.213 UPDATE)のpcapをダウンロード

iBGPホップを越えて伝わる

R1はこの経路をiBGPでR2・R3へ渡します。IOS XRはiBGPピアへコミュニティを既定で送るので、設定を足さなくても値はそのまま届きます。

R2 show bgp 192.168.6.0/24(STEP 1)
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:1000

R1-R3間のiBGPキャプチャーのNo.427がそのUPDATEです。

iBGPキャプチャーのNo.427 UPDATE(R1 → R3)tshark -V
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
上のtshark出力のパケット(No.427 UPDATE)のpcapをダウンロード

さらにR1はR4へもeBGPで広告するので、AS 65002のR4にも65004:1000が届きます。AS 65004が付けた印が、AS 65001を素通りしてAS 65002まで運ばれたということです。Optional Transitiveであることの効果がこれです。

R4 show bgp community 65004:1000(STEP 1)
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 paths

STEP 2:R1がコミュニティを見てLOCAL_PREFを上げる

ここまでは印を付けただけです。次はR1側に「印を見て動く」設定を入れます。

R1 show rpl community-set CS-FROM-R6(STEP 2)
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
!
R1 show rpl route-policy FROM-R6(STEP 2)
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になります。

R1 show bgp 192.168.6.0/24(STEP 2)
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 communityadditiveを付けないと元の値が消える

FROM-R6set community (65001:100)を足します。additiveは付けません。

R1 show rpl route-policy FROM-R6(STEP 3)
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
!
R1 show bgp 192.168.6.0/24(STEP 3)
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 communityifブロックの外にあるので、R6から受け取るすべての経路に適用されます。R6経由の192.168.5.0/24(Path #3)にも65001:100が付いています。

R1 show bgp 192.168.5.0/24(STEP 3)
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です。

iBGPキャプチャーのNo.559 UPDATE(R1 → R3)tshark -V
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: 100
上のtshark出力のパケット(No.559 UPDATE)のpcapをダウンロード

STEP 4:additiveを付けると両方残る

同じ行にadditiveを足します。

R1 show rpl route-policy FROM-R6(STEP 4)
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
!
R1 show bgp 192.168.6.0/24(STEP 4)
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が要ります

iBGPキャプチャーのNo.605 UPDATE(R1 → R2)tshark -V
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: 1000
上のtshark出力のパケット(No.605 UPDATE)のpcapをダウンロード

Length: 8となっていて、4オクテットのコミュニティが2個入っていることが分かります。

STEP 5:R1の入方向ポリシーを外す

ここから既知のコミュニティの検証に移るので、R1のR6向け入方向をPASS-ALLに戻します。

R1 show bgp 192.168.6.0/24(STEP 5)
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-R1set community (no-export)に変更します。

R6 show rpl route-policy TO-R1(STEP 6)
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テーブルです。

R1 show bgp 192.168.6.0/24(STEP 6)
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が消えています。

R1 show bgp neighbors 10.1.4.4 advertised-routes(STEP 6)
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へは出さない」状態になります。

R2 show bgp 192.168.6.0/24(STEP 6)
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)
R2 show bgp neighbors 10.2.4.4 advertised-routes(STEP 6)
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 paths

R2には何の設定もしていません。R1がiBGPでNO_EXPORTごと渡したので、R2も自動的にeBGPへ出さなくなりました。「AS 65001の外へ出さない」がAS単位で効いていることになります。

R1・R2の両方が止めた結果、AS 65002のR4は192.168.6.0/24をAS 65001経由で受け取れなくなり、R5経由(65003 65004)だけになります

R4 show bgp 192.168.6.0/24(STEP 6)
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です。

No.321 UPDATE(R6 → R1)tshark -V
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の値がそのまま入っています。

上のtshark出力のパケット(No.321 UPDATE)のpcapをダウンロード

STEP 7:NO_ADVERTISEはiBGPにも出さない

TO-R1set community (no-advertise)に変えます。

R6 show rpl route-policy TO-R1(STEP 7)
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になります。

R1 show bgp 192.168.6.0/24(STEP 7)
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が消えました。

R1 show bgp neighbors 10.0.0.2 advertised-routes(STEP 7)
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 paths

STEP 6ではここに192.168.6.0/24が載っていましたNO_EXPORTはiBGPには配りますが、NO_ADVERTISEはiBGPにも配りません。

このときR1は、単に「次から送らない」のではなく、すでに送ってあった経路をWITHDRAWで取り消します。iBGPキャプチャーのNo.681がそれです。

iBGPキャプチャーのNo.681 UPDATE(R1 → R3、WITHDRAW)tshark -V
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
上のtshark出力のパケット(No.681 WITHDRAW)のpcapをダウンロード

これでR3は192.168.6.0/24を失う……のではなく、R2経由の別経路に切り替わります。R2はR4から65002 65003 65004のパスを受け取っており、R1からの経路が消えたことでそれがベストになるためです。

R3 show bgp 192.168.6.0/24(STEP 7)
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 17

AS_PATHが65004(R1経由・1ホップ)から65002 65003 65004(R2 → R4 → R5 → R6・3ホップ)に伸びました。NO_ADVERTISEは経路そのものを消すのではなく、その1つのパスの配布を止めるだけなので、他に経路があればそちらが使われます。

eBGPキャプチャーのNo.335NO_ADVERTISEを運んだUPDATEです。

No.335 UPDATE(R6 → R1)tshark -V
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)
上のtshark出力のパケット(No.335 UPDATE)のpcapをダウンロード

STEP 8:ユーザー定義コミュニティで広告先を絞る(最終状態)

最後に、冒頭で紹介したNTTの2914:429(どのピアにも広告しない)と同じ形をラボで作ります。AS 65001が65001:429を「R4(AS 65002)へは広告しない」の意味で公開し、R6がそれを付けて広告する、という想定です。

R6側はset community (65001:429)に変えるだけです。自分のAS番号ではなく、相手(AS 65001)のAS番号を上位に置く点に注意してください。このコミュニティの意味を決めているのはAS 65001だからです。

R6 show rpl route-policy TO-R1(STEP 8)
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を入れます。

R1 show rpl community-set CS-NO-ADV-R4(STEP 8)
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
!
R1 show rpl route-policy TO-R4(STEP 8)
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 ...のような特別な表示は出ません。

R1 show bgp 192.168.6.0/24(STEP 8)
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が落ちています。

R1 show bgp neighbors 10.1.4.4 advertised-routes(STEP 8)
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向け出方向ポリシーで落としているだけ」だからです。

R1 show bgp neighbors 10.0.0.2 advertised-routes(STEP 8)
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の設定を入れていません

R2 show bgp neighbors 10.2.4.4 advertised-routes(STEP 8)
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 paths

192.168.6.0/24がR4へ広告されています。R4側にもコミュニティ付きで届いています。

R4 show bgp 192.168.6.0/24(STEP 8)
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.34765001:429を運んだUPDATEです。

No.347 UPDATE(R6 → R1)tshark -V
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
上のtshark出力のパケット(No.347 UPDATE)のpcapをダウンロード

検証のまとめ

STEPR6が付けたコミュニティR1の挙動R2・R3(iBGP)R4(AS 65002)
165004:1000そのまま中継届く届く
3(R1が65001:100で上書き)元の値を破棄65001:100のみ65001:100のみ
4(R1がadditiveで追加)両方保持2つとも届く2つとも届く
6NO_EXPORTeBGPへ出さない届く。R2もeBGPへ出さなくなる届かない
7NO_ADVERTISEどこへも出さない届かない(WITHDRAWを受ける)届かない
865001:429TO-R4でdrop届くR1からは届かない。R2からは漏れる

検証Configおよびshow結果

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

ファイル内容
..._show.txtshow 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-R1set community (65001:429)、R1にcommunity-set CS-NO-ADV-R4と、それにマッチしたらdropするTO-R4が入っています。R1のFROM-R6CS-FROM-R6はSTEP 5で適用をやめましたが、定義自体は残してあります。

STEP 0:初期状態

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

STEP 1:R6が192.168.6.0/2465004:1000を付ける

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

STEP 2:R1がコミュニティを見てLOCAL_PREFを上げる

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

STEP 3:set communityadditiveを付けない

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

STEP 4:additiveを付ける

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

STEP 5:R1の入方向ポリシーを外す

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

STEP 6:R6がNO_EXPORTを付ける

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

STEP 7:R6がNO_ADVERTISEを付ける

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

STEP 8:ユーザー定義コミュニティ65001:429で広告先を絞る(最終状態)

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

キャプチャーは2本取っています。R1-R6間(eBGP)がbgp-community.pcap、R1-R3間(iBGP)がbgp-community-ibgp.pcapです。

R1-R6間(eBGP)のキャプチャー全体をダウンロード

R1-R3間(iBGP)のキャプチャー全体をダウンロード

参考

資料タイトル概要
RFC 1997BGP Communities AttributeCOMMUNITY属性の定義。Type code 8、optional transitive、4オクテット、予約範囲、NO_EXPORTNO_ADVERTISENO_EXPORT_SUBCONFEDの規定。
RFC 4360BGP Extended Communities Attribute拡張コミュニティ(Type code 16、8オクテット)の定義。
RFC 8092BGP Large Communities Attributeラージコミュニティ(Type code 32、12オクテット、32ビット×3)の定義。4バイトAS番号を名前空間に使える。
RFC 7999BLACKHOLE Community65535:6660xFFFF029A)の定義。Informational。
RFC 8326Graceful BGP Session ShutdownGRACEFUL_SHUTDOWN65535:00xFFFF0000)の定義。
NTTRouting - NTT-GINAS2914が顧客向けに公開しているコミュニティ一覧。2914:42965500:nnnなど、実運用での使われ方が分かる。

関連記事