iBGP では AS 内のルータをフルメッシュでつなぐ必要があり、大規模なネットワークでは構成が複雑になります。BGP コンフェデレーションは、AS を複数のサブ AS に分けて、フルメッシュが必要な範囲をサブ AS の中だけにする方法です。外部の AS からは、これまでどおり1つの AS に見えます。
この記事では、Cisco ルータで BGP コンフェデレーションを設定し、経路がサブ AS をまたいで伝わるときの AS_PATH や経路の種類の変化、ベストパスと実際の転送経路の関係を確認します。
- サブ AS235(R2・R3・R5)にコンフェデレーションを設定する
- サブ AS6(R6)を設定し、サブ AS 間でピアを張る
- 外部 AS(R1・R4)から1つの AS(AS2356)として見えるようにする
- 経路が伝わるときの AS_PATH と confed-internal/confed-external を確認する
BGP コンフェデレーションの概要
コンフェデレーションでは、1つの AS(ここでは AS2356)を内部で複数のサブ AS に分けます。サブ AS の中は通常の iBGP なのでフルメッシュ(またはルートリフレクタ)が必要ですが、サブ AS 同士は eBGP に近い形でつなぐので、AS 全体をフルメッシュにする必要はありません。
サブ AS 間のピアは、セッションの張り方は eBGP と同じですが、経路の属性の扱いは iBGP と同じです。
| 観点 | サブ AS 間のピアの動き |
|---|---|
| eBGP と同じ点 | BGP パケットはデフォルトで TTL=1(ループバック同士なら ebgp-multihop が必要)。受け取った経路を別のサブ AS のピアへ広告できる。AS_PATH にサブ AS 番号が追加され、ループを検出できる |
| iBGP と同じ点 | Next Hop、Local Preference、MED を書き換えずに渡す。ベストパスの選択では内部の経路として扱われる |
外部の AS へ広告するときは、サブ AS の番号は AS_PATH から取り除かれ、代わりにコンフェデレーション全体の AS 番号(公開 AS 番号)が付きます。外部からはサブ AS の構成は見えません。
BGP コンフェデレーションの設定
次の構成で設定します。IGP には EIGRP を使い、AS2356 の中の BGP ピアはループバックアドレス(R2 は 2.2.2.2、R3 は 3.3.3.3 のように、ルータ番号を並べたアドレス)で張ります。
| ルータ | 所属 | 役割・接続 |
|---|---|---|
| R5 | サブ AS235 | ルートリフレクタ。クライアントは R2(192.168.25.0/24)と R3(192.168.35.0/24) |
| R2 | サブ AS235 | R1(AS1)と eBGP(192.168.12.0/24)、R6 とサブ AS 間(192.168.26.0/24) |
| R3 | サブ AS235 | R4(AS4)と eBGP(192.168.34.0/24)、R6 とサブ AS 間(192.168.36.0/24) |
| R6 | サブ AS6 | R2・R3 とサブ AS 間でピア |
| R1・R4 | AS1・AS4 | 外部 AS。相手の AS は 2356 として設定する |
サブ AS235 を設定する
R5(ルートリフレクタ)
R5 はサブ AS235 に属し、ルートリフレクタとして動作します。router bgp にはサブ AS の番号(235)を指定し、bgp confederation identifier で公開 AS 番号(2356)を指定します。R2 と R3 はループバックでピアを張るルートリフレクタのクライアントです。
R5
R5(config)#router bgp 235
R5(config-router)#bgp confederation identifier 2356
R5(config-router)#neighbor 2.2.2.2 remote-as 235
R5(config-router)#neighbor 2.2.2.2 update-source loopback 0
R5(config-router)#neighbor 2.2.2.2 route-reflector-client
R5(config-router)#neighbor 3.3.3.3 remote-as 235
R5(config-router)#neighbor 3.3.3.3 update-source loopback 0
R5(config-router)#neighbor 3.3.3.3 route-reflector-client
R2
R2 はサブ AS235 のメンバーで、R5、R6、R1 とピアを張ります。R6 は別のサブ AS(6)なので、bgp confederation peers 6 で「AS6 は同じコンフェデレーションのサブ AS」と指定します。ループバック同士でピアを張るので、eBGP と同じく ebgp-multihop を設定します。
R2
R2(config)#router bgp 235 R2(config-router)#bgp confederation identifier 2356 R2(config-router)#neighbor 5.5.5.5 remote-as 235 R2(config-router)#neighbor 5.5.5.5 update-source loopback 0 R2(config-router)#neighbor 6.6.6.6 remote-as 6 R2(config-router)#neighbor 6.6.6.6 update-source loopback 0 R2(config-router)#neighbor 6.6.6.6 ebgp-multihop R2(config-router)#bgp confederation peers 6 R2(config-router)#neighbor 192.168.12.1 remote-as 1
R3
R3 もサブ AS235 のメンバーで、R5 のルートリフレクタのクライアントです。R5、R6、R4 とピアを張ります。設定は R2 と同じ形です。
R3
R3(config)#router bgp 235 R3(config-router)#bgp confederation identifier 2356 R3(config-router)#neighbor 5.5.5.5 remote-as 235 R3(config-router)#neighbor 5.5.5.5 update-source loopback 0 R3(config-router)#neighbor 6.6.6.6 remote-as 6 R3(config-router)#neighbor 6.6.6.6 update-source loopback 0 R3(config-router)#neighbor 6.6.6.6 ebgp-multihop R3(config-router)#bgp confederation peers 6 R3(config-router)#neighbor 192.168.34.4 remote-as 4
サブ AS6 を設定する
R6 はサブ AS6 に属し、サブ AS235 の R2・R3 とピアを張ります。公開 AS 番号として 2356 を指定し、bgp confederation peers 235 で AS235 を同じコンフェデレーションのサブ AS として指定します。
R6
R6(config)#router bgp 6 R6(config-router)#bgp confederation identifier 2356 R6(config-router)#neighbor 2.2.2.2 remote-as 235 R6(config-router)#neighbor 2.2.2.2 update-source loopback 0 R6(config-router)#neighbor 2.2.2.2 ebgp-multihop R6(config-router)#neighbor 3.3.3.3 remote-as 235 R6(config-router)#neighbor 3.3.3.3 update-source loopback 0 R6(config-router)#neighbor 3.3.3.3 ebgp-multihop R6(config-router)#bgp confederation peers 235
外部 AS(R1・R4)を設定する
R1 と R4 は外部 AS です。相手の AS 番号には、サブ AS ではなく公開 AS 番号の 2356 を指定します。外部 AS からは、コンフェデレーション全体が1つの AS2356 に見えます。
R1
R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.12.2 remote-as 2356
R4
R4(config)#router bgp 4
R4(config-router)#neighbor 192.168.34.3 remote-as 2356
設定のポイント
| コマンド | 意味 |
|---|---|
| router bgp 235 | 自分のサブ AS 番号を指定する |
| bgp confederation identifier 2356 | 外部に見せる公開 AS 番号。コンフェデレーション内の全ルータで同じ値にする |
| bgp confederation peers 6 | 同じコンフェデレーションに属する、別のサブ AS の番号を指定する。ここに書いた AS のピアはサブ AS 間のピアとして扱われ、書いていない AS のピアは本当の外部 AS として扱われる。別のサブ AS のピアを持たない R5 には不要 |
| ebgp-multihop | サブ AS 間をループバックでつなぐときに必要(eBGP と同じく TTL=1 のため) |
R2–R6、R3–R6 は直結なので、TTL を必要以上に広げない ebgp-multihop 2 や、直結チェックだけを外す disable-connected-check でも足ります。詳しくは update-source と ebgp-multihop の記事 を参照してください。
動作確認
経路の伝わり方を確認する
R1 のループバック 1.1.1.1/32 を BGP で広告し、コンフェデレーション内と外部 AS のルータでどう見えるかを確認します。
R1
R1(config)#router bgp 1
R1(config-router)#network 1.1.1.1 mask 255.255.255.255
R2:外部 AS から学習
R2#sh ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.1/32, version 2
Paths: (1 available, best #1, table default)
Advertised to update-groups:
9 11
Refresh Epoch 1
1
192.168.12.1 from 192.168.12.1 (1.1.1.1)
Origin IGP, metric 0, localpref 100, valid, external, best
rx pathid: 0, tx pathid: 0x0
R2 は R1 から eBGP(external)で 1.1.1.1/32 を学習しています。AS_PATH は 1 です。
R5:同じサブ AS から学習(confed-internal)
R5#sh ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.1/32, version 6
Paths: (1 available, best #1, table default)
Advertised to update-groups:
2
Refresh Epoch 1
1, (Received from a RR-client)
192.168.12.1 (metric 307200) from 2.2.2.2 (2.2.2.2)
Origin IGP, metric 0, localpref 100, valid, confed-internal, best
rx pathid: 0, tx pathid: 0x0
R5 では、経路の種類が confed-internal になっています。同じサブ AS(235)のピア(R2)から学習した経路という意味です。confed-internal や confed-external は BGP の属性ではなく、Cisco が経路をどの種類のピアから学習したかを示す表示です。
R6:別のサブ AS から学習(confed-external)
R6#sh ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.1/32, version 8
Paths: (2 available, best #2, table default)
Advertised to update-groups:
1
(235) 1
192.168.12.1 (metric 307200) from 3.3.3.3 (3.3.3.3)
Origin IGP, metric 0, localpref 100, valid, confed-external
rx pathid: 0, tx pathid: 0
(235) 1
192.168.12.1 (metric 307200) from 2.2.2.2 (2.2.2.2)
Origin IGP, metric 0, localpref 100, valid, confed-external, best
rx pathid: 0, tx pathid: 0x0
R6 では confed-external になっています。同じコンフェデレーション内の、別のサブ AS(235)のピアから学習した経路という意味です。eBGP のように別の AS から受け取っていますが、Next Hop は 192.168.12.1(R1)のまま変わっていません。
AS_PATH は (235) 1 です。R2 が R6 に経路を送るときに、自分のサブ AS 番号 235 を AS_PATH の先頭に追加しています。括弧で囲まれた部分は AS_CONFED_SEQUENCE という AS_PATH の種類で、コンフェデレーション内で通ってきたサブ AS を順番に記録します。
R3:ルートリフレクタ経由で学習
R3#sh ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.1/32, version 6
Paths: (1 available, best #1, table default)
Advertised to update-groups:
2 3
Refresh Epoch 1
1
192.168.12.1 (metric 307200) from 5.5.5.5 (5.5.5.5)
Origin IGP, metric 0, localpref 100, valid, confed-internal, best
Originator: 2.2.2.2, Cluster list: 5.5.5.5
rx pathid: 0, tx pathid: 0x0
R3 は、ルートリフレクタの R5 から 1.1.1.1/32 を学習しています。同じサブ AS 内なので confed-internal で、R5 が反射した経路なので Originator と Cluster list が付いています。
R4:外部 AS から見た AS_PATH
R3 は 1.1.1.1/32 をベストパスとしているので、R4(AS4)に広告します。このとき、AS_PATH からサブ AS の番号(括弧の部分)は取り除かれ、公開 AS 番号の 2356 が付きます。
R4#sh ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.1/32, version 6
Paths: (1 available, best #1, table default)
Not advertised to any peer
Refresh Epoch 1
2356 1
192.168.34.3 from 192.168.34.3 (3.3.3.3)
Origin IGP, localpref 100, valid, external, best
rx pathid: 0, tx pathid: 0x0
| ルータ | 学習元 | AS_PATH の表示 | 経路の種類 |
|---|---|---|---|
| R2 | R1(AS1) | 1 | external |
| R5 | R2(同じサブ AS) | 1 | confed-internal |
| R3 | R5(同じサブ AS) | 1 | confed-internal |
| R6 | R2・R3(サブ AS235) | (235) 1 | confed-external |
| R4 | R3(AS2356) | 2356 1 | external |
補足:ベストパスの選択と転送経路
R6 の BGP テーブルで 1.1.1.1/32 を確認します。
R6#sh ip bgp 1.1.1.1 BGP routing table entry for 1.1.1.1/32, version 8 Paths: (2 available, best #2, table default) Advertised to update-groups: 1 Refresh Epoch 1 (235) 1 192.168.12.1 (metric 307200) from 3.3.3.3 (3.3.3.3) Origin IGP, metric 0, localpref 100, valid, confed-external rx pathid: 0, tx pathid: 0 Refresh Epoch 1 (235) 1 192.168.12.1 (metric 307200) from 2.2.2.2 (2.2.2.2) Origin IGP, metric 0, localpref 100, valid, confed-external, best rx pathid: 0, tx pathid: 0x0
R6 は 1.1.1.1/32 を、ルータID 2.2.2.2(R2)と 3.3.3.3(R3)の2か所から受け取っており、R2 からの経路をベストパスにしています。2つの経路は属性も Next Hop までの IGP メトリック(307200)も同じなので、ベストパス選択の後半にある「ルータIDの小さい方を選ぶ」で決まっています。
Cisco のベストパス選択では、サブ AS 間で学習した経路(confed-external)も内部の経路として扱われます。そのため、eBGP の経路同士で使われる「先に受け取った経路を優先する」ルールは使われず、ルータIDで比較されます。
R6 から R1(1.1.1.1)までは、R2 を経由して通信しています。
R6#traceroute 1.1.1.1
Type escape sequence to abort.
Tracing the route to 1.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 192.168.26.2 1 msec 1 msec 1 msec
2 192.168.12.1 2 msec 1 msec 2 msec
ここで、R2 のルータIDを 222.222.222.222 に変更して、ベストパスの選択結果を確認します。
R2
R2(config)#router bgp 235
R2(config-router)#bgp router-id 222.222.222.222
BGP のルータIDを変更すると、そのルータの BGP セッションはすべて張り直されます。運用中のルータで変更するときは注意してください。
R6 では、ルータID 3.3.3.3(R3)からの経路がベストパスになりました。
R6#sh ip bgp 1.1.1.1 BGP routing table entry for 1.1.1.1/32, version 12 Paths: (2 available, best #1, table default) Advertised to update-groups: 1 Refresh Epoch 1 (235) 1 192.168.12.1 (metric 307200) from 3.3.3.3 (3.3.3.3) Origin IGP, metric 0, localpref 100, valid, confed-external, best rx pathid: 0, tx pathid: 0x0 Refresh Epoch 1 (235) 1 192.168.12.1 (metric 307200) from 2.2.2.2 (222.222.222.222) Origin IGP, metric 0, localpref 100, valid, confed-external rx pathid: 0, tx pathid: 0
再度 R6 から R1 への経路を確認すると、変更前と変わらず R2 経由のままです。
R6#traceroute 1.1.1.1
Type escape sequence to abort.
Tracing the route to 1.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 192.168.26.2 2 msec 0 msec 1 msec
2 192.168.12.1 2 msec 1 msec 2 msec
どちらの経路でも Next Hop は 192.168.12.1 で、ルータIDを変えても変わらないためです。R6 はパケットを転送するとき、Next Hop の 192.168.12.1 に対する IGP(EIGRP)の経路で出力インタフェースを決めます。BGP で経路を受け取ったルータと、実際にパケットが通る経路は一致しないことがよくあります。転送経路は、BGP の経路の Next Hop に対する IGP の経路で決まります。
うまくいかないときの切り分け
| 状態 | よくある原因 | 確認すること |
|---|---|---|
| サブ AS 間が Up しない | bgp confederation peers の書き漏れ、ループバック同士なのに ebgp-multihop がない | show ip bgp neighbors、相手ループバックへの経路 |
| 外部 AS と Up しない | 外部 AS 側で、相手の AS 番号にサブ AS 番号を指定している | 外部 AS 側の remote-as が公開 AS 番号か |
| 外部にサブ AS 番号が見える | bgp confederation identifier の設定漏れ・不一致 | 全ルータの show running-config | section router bgp |
> が付かない | Next Hop(外部 AS とのリンク)への経路がない | show ip route <Next Hop> |
まとめ
| 方法 | 仕組み | 外部からの見え方 |
|---|---|---|
| iBGP フルメッシュ | AS 内の全ルータ同士でピアを張る | 1つの AS |
| ルートリフレクタ | ルートリフレクタが iBGP の経路を反射する | 1つの AS |
| コンフェデレーション | AS をサブ AS に分け、フルメッシュをサブ AS 内に限る。サブ AS 内でルートリフレクタと組み合わせることもできる | 1つの AS(公開 AS 番号) |
BGP コンフェデレーションを使うと、外部からは1つの AS に見せたまま、iBGP のフルメッシュの範囲を小さくできます。今回のように、サブ AS の中ではルートリフレクタを組み合わせることで、ピアの数をさらに減らせます。
コメント