このドキュメントでは、ボーダー ゲートウェイ プロトコル(BGP)コミュニティ アトリビュートを使用して、アップストリーム サービス プロバイダー ネットワークのルーティング ポリシーを制御する方法について説明します。
本書の読者は、BGP ルーティング プロトコルおよびその操作方法を理解している必要があります。 詳細については、「BGP ケース スタディ」を参照してください。
このドキュメントは、特定のソフトウェアやハードウェアのバージョンに限定されるものではありません。 ただし、このドキュメントの情報は、次のソフトウェアとハードウェアのバージョンに基づくものです。
Cisco IOS® ソフトウェア リリース 12.2(27)
Cisco 2500 シリーズ ルータ
このドキュメントの情報は、特定のラボ環境にあるデバイスに基づいて作成されたものです。 このドキュメントで使用するすべてのデバイスは、初期(デフォルト)設定の状態から起動しています。 対象のネットワークが実稼働中である場合には、どのような作業についても、その潜在的な影響について確実に理解しておく必要があります。
コミュニティ自体は BGP 意思決定プロセスを変更しませんが、コミュニティは一連のルートをマークするためのフラグとして使用できます。 アップストリーム サービス プロバイダー ルータは、このフラグを使用して、ネットワーク内の特定のルーティング ポリシー(ローカル プリファレンスなど)を適用できます。
プロバイダーはお客様が設定可能なコミュニティ値と対応するローカル プリファレンス値とのマッピングをプロバイダーのネットワーク内で確立します。 つまり、LOCAL_PREF を変更する必要がある特定のポリシーをプロバイダー ネットワーク内で使用するお客様は、ルーティング更新で対応するコミュニティ値を設定します。
コミュニティは、プレフィクスのグループです。このプレフィクスは、共通プロパティを共有し、BGP コミュニティ アトリビュートを使用して設定できます。 BGP コミュニティ アトリビュートは、推移的なオプションのアトリビュートであり、可変長です。 このコミュニティ アトリビュートは、コミュニティを指定する 4 つのオクテット値で構成されています。 コミュニティ アトリビュート値の最初の 2 オクテットは Autonomous System(AS; 自律システム)番号を使用して符号化され、残りの 2 オクテットは AS により定義されます。 プレフィクスには、複数のコミュニティ アトリビュートを設定できます。 1 つのプレフィクスに複数のコミュニティ アトリビュートがあることを認識した BGP スピーカは、1 つ、複数、またはすべてのアトリビュートに基づいて動作できます。 ルータは、ルータが他のピアにアトリビュートを渡す前にコミュニティ アトリビュートを追加または変更するオプションがあります。 コミュニティ アトリビュートの詳細は、「BGP ケース スタディ」を参照してください。
ローカル プリファレンス アトリビュートは AS に対する指標であり、特定のネットワークに到達するためにどのパスが優先されるかを示します。 同じ宛先へのパスが複数ある場合は、プリファレンスの高いパスが優先されます(ローカル プリファレンス アトリビュートのデフォルト値は 100)。 詳細は、「ローカル プリファレンス アトリビュート」を参照してください。
ドキュメント表記の詳細は、『シスコ テクニカル ティップスの表記法』を参照してください。
この項では、このドキュメントで説明する機能の設定に必要な情報を提供します。
注: このドキュメントで使用されているコマンドの詳細を調べるには、Command Lookup Tool(登録ユーザ専用)を使用してください。
単純化するため、次に示すコミュニティ アトリビュートとローカル プリファレンス アトリビュートとのマッピングは、アップストリーム サービス プロバイダー(AS 100)とお客様(AS 30)との間で確立するものとします。
ローカル プリファレンス | コミュニティ値 |
---|---|
130 | 100:300 |
125 | 100:250 |
お客様がコミュニティ アトリビュート付きプレフィクスを 100:300 とアナウンスした場合、アップストリーム サービス プロバイダーは、このルートのローカル プリファレンスを 130 に設定します。コミュニティ アトリビュートが 100:250 の場合は、125 に設定します。
これにより、サービス プロバイダーにアナウンスされたプレフィクスのコミュニティ値を変更した場合、サービス プロバイダー ネットワーク内のルーティング ポリシーを制御できます。
ネットワーク図では、お客様 AS 30 がコミュニティ アトリビュートを使用してこのルーティング ポリシーを実現しようとしています。
AS 100 から着信するネットワーク 6.6.6.0/24 宛てのトラフィックは、R1-R3 リンクを経由します。 R1-R3 リンクで障害が発生した場合は、すべてのトラフィックは R2-R3 を経由します。
AS 100 から着信するネットワーク 7.7.7.0/24 宛てのトラフィックは、R2-R3 リンクを経由します。 R2-R3 リンクで障害が発生した場合は、すべてのトラフィックは R1-R3 を経由します。
このルーティング ポリシーを実現するには、R3 は次のようにプレフィクスをアナウンスします。
R1 に対して:
6.6.6.0/24、コミュニティ アトリビュートは 100:300。
7.7.7.0/24、コミュニティ アトリビュートは 100:250。
R2 に対して:
6.6.6.0/24、コミュニティ アトリビュートは 100:250。
7.7.7.0/24、コミュニティ アトリビュートは 100:300。
BGP 近隣ルータ R1 および R2 は R3 からプレフィクスを受信すると、事前設定されたポリシーをコミュニティ アトリビュートとローカル プリファレンス アトリビュートとのマッピングに基づいて適用するため(この表を参照)、お客様(AS 30)が希望するルーティング ポリシーが実現されます。 R1 は、次のようにプレフィクスを BGP テーブルにインストールします。
6.6.6.0/24、ローカル プリファレンスは 130。
7.7.7.0/24、ローカル プリファレンスは 125。
R2 は、次のようにプレフィクスを BGP テーブルにインストールします。
6.6.6.0/24、ローカル プリファレンスは 125。
7.7.7.0/24、ローカル プリファレンスは 130。
BGP パス選択基準ではローカル プリファレンスの高い方が優先されるため、ローカル プリファレンスが 130 のパス(130 の方が 125 より大きい)が AS 100 の最適パスとして選択され、R1 および R2 の IP ルーティング テーブルにインストールされます。 BGP のパス選択基準についての詳細は、『BGP で最適パスを選択するアルゴリズム』を参照してください。
この文書では、次のダイヤグラムに示すネットワーク設定を使用します。
このドキュメントでは、次の設定を使用します。
R3 |
---|
Current configuration : 2037 bytes ! version 12.2 ! hostname R3 ! interface Loopback0 ip address 6.6.6.1 255.255.255.0 ! interface Ethernet0/0 ip address 7.7.7.1 255.255.255.0 ! interface Serial8/0 ip address 10.10.13.3 255.255.255.0 !--- Interface connected to R1. ! interface Serial9/0 ip address 10.10.23.3 255.255.255.0 !--- Interface connected to R2. ! router bgp 30 network 6.6.6.0 mask 255.255.255.0 network 7.7.7.0 mask 255.255.255.0 !--- Network commands announce prefix 6.6.6.0/24 !--- and 7.7.7.0/24. neighbor 10.10.13.1 remote-as 100 !--- Establishes peering with R1. neighbor 10.10.13.1 send-community - !--- Without this command, the community attributes !--- are not sent to the neighbor. neighbor 10.10.13.1 route-map Peer-R1 out !--- Configures outbound policy as defined by !--- route-map "Peer-R1" when peering with R1. neighbor 10.10.23.2 remote-as 100 !--- Establishes peering with R2. neighbor 10.10.23.2 send-community !--- Configures to send community attribute to R2. neighbor 10.10.23.2 route-map Peer-R2 out !--- Configures outbound policy as defined by !--- route-map "Peer-R2" when peering with R2. no auto-summary ! ip classless ip bgp-community new-format !--- Allows you to configure the BGP community !--- attribute in AA:NN format. ! access-list 101 permit ip host 6.6.6.0 host 255.255.255.0 access-list 102 permit ip host 7.7.7.0 host 255.255.255.0 ! ! route-map Peer-R1 permit 10 match ip address 101 set community 100:300 !--- Sets community 100:300 for routes matching access-list 101. ! route-map Peer-R1 permit 20 match ip address 102 set community 100:250 !--- Sets community 100:250 for routes matching access-list 102. ! route-map Peer-R2 permit 10 match ip address 101 set community 100:250 !--- Sets community 100:250 for routes matching access-list 101. ! route-map Peer-R2 permit 20 match ip address 102 set community 100:300 !--- Sets community 100:300 for routes matching access-list 102. ! end |
R1 |
---|
Version 12.2 ! hostname R1 ! interface Loopback0 ip address 200.200.200.1 255.255.255.0 ! interface Serial8/0 ip address 10.10.13.1 255.255.255.0 !--- Connected to R3. ! interface Serial10/0 ip address 10.10.12.1 255.255.255.0 !--- Connected to R2. ! router bgp 100 no synchronization bgp log-neighbor-changes neighbor 10.10.12.2 remote-as 100 !--- Establishes peering with R2. neighbor 10.10.12.2 next-hop-self neighbor 10.10.13.3 remote-as 30 !--- Establishes peering with R3. neighbor 10.10.13.3 route-map Peer-R3 in !--- Configures the inbound policy as defined by !--- route-map "Peer-R3" when peering with R3. no auto-summary ! ip bgp-community new-format !--- Allows you to configure the BGP community !--- attribute in AA:NN format. ip community-list 1 permit 100:300 ip community-list 2 permit 100:250 !--- Defines community list 1 and 2. ! route-map Peer-R3 permit 10 match community 1 set local-preference 130 !--- Sets local preference 130 for all routes !--- matching community list 1. ! route-map Peer-R3 permit 20 match community 2 set local-preference 125 !--- Sets local preference 125 for all routes !--- matching community list 2. ! route-map Peer-R3 permit 30 !--- Without this permit 30 statement, updates that do not !--- match the permit 10 or permit 20 statements are dropped. ! end |
R2 |
---|
Version 12.2 ! hostname R2 ! interface Loopback0 ip address 192.168.50.1 255.255.255.0 ! interface Serial9/0 ip address 10.10.23.2 255.255.255.0 !--- Connected to R3. ! interface Serial10/0 ip address 10.10.12.2 255.255.255.0 !--- Connected to R1. ! router bgp 100 no synchronization bgp log-neighbor-changes neighbor 10.10.12.1 remote-as 100 !--- Establishes iBGP peering with R1. neighbor 10.10.12.1 next-hop-self neighbor 10.10.23.3 remote-as 30 !--- Establishes peering with R3. neighbor 10.10.23.3 route-map Peer-R3 in !--- Configures inbound policy as defined by !--- route-map "Peer-R3" when peering with R3. no auto-summary ! ip bgp-community new-format !--- Allows you to configure the BGP community !--- attribute in AA:NN format. ! ip community-list 1 permit 100:300 ip community-list 2 permit 100:250 !--- Defines community list 1 and 2. ! route-map Peer-R3 permit 10 match community 1 set local-preference 130 !--- Sets local preference 130 for all routes !--- matching community list 1. ! route-map Peer-R3 permit 20 match community 2 set local-preference 125 !--- Sets local preference 125 for all routes !--- matching community list 2. ! route-map Peer-R3 permit 30 !--- Without this permit 30 statement, updates that do not !--- match the permit 10 or permit 20 statements are dropped. ! end |
R1 はこの項の show ip bgp 出力に太字で示されているように、コミュニティ 100:300 および 100:250 でプレフィクス 6.6.6.0/24 および 7.7.7.0/24 を受信します。
注: 設定したポリシーに基づいた BGP テーブルにこれらのルートがインストールされると、コミュニティ 100:300 のプレフィクスはローカル プリファレンス 130 に割り当てられ、コミュニティ 100:250 のプレフィクスはローカル プリファレンス 125 に割り当てられます。
R1# show ip bgp 6.6.6.0 BGP routing table entry for 6.6.6.0/24, version 2 Paths: (1 available, best #1, table Default-IP-Routing-Table) Advertised to non peer-group peers: 10.10.12.2 30 10.10.13.3 from 10.10.13.3 (6.6.6.1) Origin IGP, metric 0, localpref 130, valid, external, best Community: 100:300 !--- Prefix 6.6.6.0/24 with community 100:300 received from !--- 10.10.13.3 (R3) is assigned local preference 130.
R1# show ip bgp 7.7.7.0 BGP routing table entry for 7.7.7.0/24, version 4 Paths: (2 available, best #1, table Default-IP-Routing-Table) Advertised to non peer-group peers: 10.10.13.3 30 10.10.12.2 from 10.10.12.2 (192.168.50.1) Origin IGP, metric 0, localpref 130, valid, internal, best !--- Received prefix 7.7.7.0/24 over iBGP from 10.10.12.2 !--- (R2) with local preference 130.
30 10.10.13.3 from 10.10.13.3 (6.6.6.1) Origin IGP, metric 0, localpref 125, valid, external Community: 100:250 !--- Prefix 7.7.7.0/24 with community 100:250 received from !--- 10.10.13.3 (R3) is assigned local preference 125.
R1# show ip bgp BGP table version is 4, local router ID is 200.200.200.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 6.6.6.0/24 10.10.13.3 0 130 0 30 i *>i7.7.7.0/24 10.10.12.2 0 130 0 30 i * 10.10.13.3 0 125 0 30 i
R1 の show ip bgp コマンドにより、R1 で選択された最適パスには、ローカル プリファレンス(LoclPrf)= 130 が設定されていることが確認されます。
同様に、R2 はこの項の show ip bgp コマンド出力に太字で示されているように、コミュニティ 100:250 および 100:300 でプレフィクス 6.6.6.0/24 および 7.7.7.0/24 を受信します。
注: 設定したポリシーに基づいた BGP テーブルにこれらのルートがインストールされると、コミュニティ 100:300 のプレフィクスはローカル プリファレンス 130 に割り当てられ、コミュニティ 100:250 のプレフィクスはローカル プリファレンス 125 に割り当てられます。
R2# show ip bgp 6.6.6.0 BGP routing table entry for 6.6.6.0/24, version 2 Paths: (2 available, best #2, table Default-IP-Routing-Table) Advertised to non peer-group peers: 10.10.23.3 30 10.10.23.3 from 10.10.23.3 (6.6.6.1) Origin IGP, metric 0, localpref 125, valid, external Community: 100:250 !--- Prefix 6.6.6.0/24 with community 100:250 received from !--- 10.10.23.3 (R3) is assigned local preference 125.
30 10.10.12.1 from 10.10.12.1 (200.200.200.1) Origin IGP, metric 0, localpref 130, valid, internal, best !--- Received prefix 6.6.6.0/24 over iBGP from 10.10.12.1 !--- (R1) with local preference 130.
R2# show ip bgp 7.7.7.0 BGP routing table entry for 7.7.7.0/24, version 3 Paths: (1 available, best #1, table Default-IP-Routing-Table) Advertised to non peer-group peers: 10.10.12.1 30 10.10.23.3 from 10.10.23.3 (6.6.6.1) Origin IGP, metric 0, localpref 130, valid, external, best Community: 100:300 !--- Prefix 7.7.7.0/24 with community 100:300 received from !--- 10.10.23.3 (R3) is assigned local preference 130.
R2# show ip bgp BGP table version is 3, local router ID is 192.168.50.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path * 6.6.6.0/24 10.10.23.3 0 125 0 30 i *>i 10.10.12.1 0 130 0 30 i *> 7.7.7.0/24 10.10.23.3 0 130 0 30 i
R2 の show ip bgp コマンド出力により、R2 で選択された最適パスには、ローカル プリファレンス(LoclPrf)= 130 が設定されていることが確認されます。
プレフィックス 6.6.6.0/24 への IP ルートとして、AS100 から AS 30 へ向かう R1-R3 リンクが優先します。 R1 および R2 で show ip route コマンドを発行するとこのことが確認されます。
R1# show ip route 6.6.6.0 Routing entry for 6.6.6.0/24 Known via "bgp 100", distance 20, metric 0 Tag 30, type external Last update from 10.10.13.3 3d21h ago Routing Descriptor Blocks: * 10.10.13.3, from 10.10.13.3, 3d21h ago Route metric is 0, traffic share count is 1 AS Hops 1 !--- On R1, the IP route to prefix 6.6.6.0/24 points !--- to next hop 10.10.13.3 which is R3 serial 8/0 !--- interface on the R1-R3 link.
R2# show ip route 6.6.6.0 Routing entry for 6.6.6.0/24 Known via "bgp 100", distance 200, metric 0 Tag 30, type internal Last update from 10.10.12.1 3d21h ago Routing Descriptor Blocks: * 10.10.12.1, from 10.10.12.1, 3d21h ago Route metric is 0, traffic share count is 1 AS Hops 1 !--- On R2, IP route to prefix 6.6.6.0/24 points !--- to next hop R1 (10.10.12.1) on its iBGP link. !--- Thus traffic to network 6.6.6.0/24 from R2 !--- exits through R2-R1 and then R1-R3 link from !--- AS 100 towards AS 30.
プレフィックス 7.7.7.0/24 への IP ルートとして、AS100 から AS 30 へ向かう R2-R3 リンクが優先します。 R1 および R2 で show ip route コマンドを発行するとこのことが確認されます。
R2# show ip route 7.7.7.0 Routing entry for 7.7.7.0/24 Known via "bgp 100", distance 20, metric 0 Tag 30, type external Last update from 10.10.23.3 3d22h ago Routing Descriptor Blocks: * 10.10.23.3, from 10.10.23.3, 3d22h ago Route metric is 0, traffic share count is 1 AS Hops 1 !--- On R2, IP route to prefix 7.7.7.0/24 points !--- to next hop 10.10.23.3 which is R3 serial 9/0 !--- interface on R2-R3 link.
R1# show ip route 7.7.7.0 Routing entry for 7.7.7.0/24 Known via "bgp 100", distance 200, metric 0 Tag 30, type internal Last update from 10.10.12.2 3d22h ago Routing Descriptor Blocks: * 10.10.12.2, from 10.10.12.2, 3d22h ago Route metric is 0, traffic share count is 1 AS Hops 1 !--- On R1, IP route to prefix 7.7.7.0/24 points !--- to next hop R2 (10.10.12.2) on its iBGP link. !--- Thus traffic to network 7.7.7.0/24 from R1 !--- exits through R1-R2 and then R2-R3 link !--- from AS 100 towards AS 30.
1 つのリンク(たとえば R1-R3 リンク)で障害が発生した場合、すべてのトラフィックは R2-R3 リンクに従う必要があります。 R1-R3 リンクをシャット ダウンした場合、これをシミュレートできます。
R1# conf t Enter configuration commands, one per line. End with CNTL/Z. R1(config)#int s8/0 R1(config-if)#shut R1(config-if)# 3d22h: %BGP-5-ADJCHANGE: neighbor 10.10.13.3 Down Interface flap 3d22h: %LINK-5-CHANGED: Interface Serial8/0, changed state to administratively down 3d22h: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial8/0, changed state to down
R1 および R2 上のプレフィクス 6.6.6.0/24 と 7.7.7.0/24 の IP ルーティング テーブルに注意します。 R2-R3 リンクを使用して AS 100 から終了します。
R1# show ip route 6.6.6.0 Routing entry for 6.6.6.0/24 Known via "bgp 100", distance 200, metric 0 Tag 30, type internal Last update from 10.10.12.2 00:01:47 ago Routing Descriptor Blocks: * 10.10.12.2, from 10.10.12.2, 00:01:47 ago Route metric is 0, traffic share count is 1 AS Hops 1
R1# show ip route 7.7.7.0 Routing entry for 7.7.7.0/24 Known via "bgp 100", distance 200, metric 0 Tag 30, type internal Last update from 10.10.12.2 3d22h ago Routing Descriptor Blocks: * 10.10.12.2, from 10.10.12.2, 3d22h ago Route metric is 0, traffic share count is 1 AS Hops 1
この show コマンド出力では、プレフィクス 6.6.6.0/24 および 7.7.7.0/24 へのルートがネクストホップ 10.10.12.2(R2)を指しており、予期したとおりの結果となっています。 ここで R2 の IP ルーティング テーブルを見て、プレフィックス 6.6.6.0/24 と 7.7.7.0/24 のネクスト ホップを調べます。 設定したポリシーが正常に動作するには、ネクスト ホップが R3 である必要があります。
R2# show ip route 6.6.6.0 Routing entry for 6.6.6.0/24 Known via "bgp 100", distance 20, metric 0 Tag 30, type external Last update from 10.10.23.3 00:04:10 ago Routing Descriptor Blocks: * 10.10.23.3, from 10.10.23.3, 00:04:10 ago Route metric is 0, traffic share count is 1 AS Hops 1
R2# show ip route 7.7.7.0 Routing entry for 7.7.7.0/24 Known via "bgp 100", distance 20, metric 0 Tag 30, type external Last update from 10.10.23.3 3d22h ago Routing Descriptor Blocks: * 10.10.23.3, from 10.10.23.3, 3d22h ago Route metric is 0, traffic share count is 1 AS Hops 1
ネクスト ホップ 10.10.23.3 は R2-R3 リンク の R3 シリアル 9/0 インターフェイスです。 これにより、設定したポリシーが予期したとおりに動作していることが確認されます。