はじめに
このドキュメントでは、BGPコミュニティ値を使用して、アップストリームプロバイダーネットワークのルーティングポリシーを制御する方法について説明します。
前提条件
要件
このドキュメントでは、BGP ルーティング プロトコルとその動作を理解している必要があります。
使用するコンポーネント
このドキュメントの内容は、特定のソフトウェアやハードウェアのバージョンに限定されるものではありません。ただし、このドキュメントの情報は、次のソフトウェアのバージョンに基づいています。
このドキュメントの情報は、特定のラボ環境にあるデバイスに基づいて作成されました。このドキュメントで使用するすべてのデバイスは、クリアな(デフォルト)設定で作業を開始しています。本稼働中のネットワークでは、各コマンドによって起こる可能性がある影響を十分確認してください。
背景説明
コミュニティ自体はBGPベストパスプロセスを変更しませんが、コミュニティは一連のルートをマークするためのフラグとして使用できます。アップストリームのサービスプロバイダールータは、これらのフラグを使用して、ネットワーク内の特定のルーティングポリシー(ローカルプリファレンスなど)を適用できます。
プロバイダーは、設定可能なコミュニティ値と対応するローカルプリファレンス値をプロバイダーネットワーク内でマッピングします。プロバイダーネットワーク内のLOCAL_PREFの変更を必要とする特定のポリシーを設定して、ルーティングアップデート内の対応するコミュニティ値を設定できます。
コミュニティは、共通のプロパティを共有するプレフィックスのグループであり、BGP コミュニティ属性で設定できます。BGP コミュニティ属性は、可変長のオプショナル通過属性属性です。この属性は、コミュニティを指定する 4 つのオクテット値で構成されます。コミュニティアトリビュート値は、最初の2つのオクテットの自律システム(AS)番号でエンコードされ、他の2つのオクテットはASで定義されます。プレフィックスには、複数のコミュニティ属性を設定できます。プレフィクス内の複数のコミュニティアトリビュートを認識するBGPスピーカは、1つ、一部、またはすべてのアトリビュートに基づいて動作できます。ルータは、他のピアに属性を渡す前に、コミュニティ属性を追加または変更することもできます。コミュニティ属性の詳細については、『BGP 導入事例』を参照してください。
ローカルプリファレンス属性は、特定のネットワークに到達するために優先されるパスをASに示します。同じ宛先へのパスが複数ある場合は、優先順位の高いパスが選択されます(local preferenceアトリビュートのデフォルト値は100)。詳細は、『ケーススタディ』を参照してください。
表記法
表記法の詳細については、『シスコ テクニカル ティップスの表記法』を参照してください。
ルーティングポリシーの設定と制御
注:このドキュメントで使用されているコマンドの詳細を調べるには、Command Lookup Toolを使用してください。
単純化のため、コミュニティアトリビュートとローカルプリファレンスアトリビュートマッピングは、アップストリームサービスプロバイダー(AS 100)とデバイス(AS 30)の間で確立されるものと想定されています。
ローカル設定 |
コミュニティ値 |
130 |
100:300 |
125 |
100:250 |
プレフィックスがコミュニティアトリビュート100:300でアナウンスされる場合、アップストリームサービスプロバイダーは、コミュニティアトリビュートが100:250であれば、これらのルートのローカルプリファレンスを130に設定し、125に設定します。
これにより、サービスプロバイダーにアナウンスされたプレフィクスのコミュニティ値を変更した場合に、サービスプロバイダーネットワーク内のルーティングポリシーを制御できます。
ネットワーク図(Vダイアグラム)では、AS 30はコミュニティ属性でこのルーティングポリシーを使用することを望んでいます。
このルーティングポリシーを実現するために、R3は次の方法でプレフィックスをアナウンスします。
R1 に対して:
- 10.0.10.0/24 とコミュニティ属性 100:300
- 10.1.0.0/24 とコミュニティ属性 100:250
R2 に対して:
BGPネイバーのR1とR2がR3からプレフィックスを受信すると、R1とR2はコミュニティアトリビュートとローカルプリファレンスアトリビュート間のマッピングに基づいて設定済みのポリシー(上記の表を参照)を適用し、これによりユーザが指定したルーティングポリシー(AS 30)を実現します。R1 は BGP テーブルにプレフィックスをインストールします。
R2 は BGP テーブルにプレフィックスをインストールします。
BGP パス選択条件では高いローカル設定が優先されるため、ローカル設定が 130 のパスが(130 は 125 より大きいため)AS 100 内のベスト パスとして選択され、R1 および R2 の IP ルーティング テーブルにインストールされます。BGP パスの選択基準の詳細については、『BGP でベスト パスを選択するアルゴリズム』を参照してください。
ネットワーク図
BGPネットワーキング
コンフィギュレーション
このドキュメントでは、次のコンフィギュレーションを使用します。
R3
hostname R3
!
interface Loopback0
ip address 10.0.10.0 255.255.255.0
!
interface Ethernet0/0
ip address 10.1.0.0 255.255.255.1
!
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 10.0.10.0 mask 255.255.255.0
network 10.1.0.0 mask 255.255.255.1
!--- Network commands announce prefix 10.0.10.0/24 and 10.1.0.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 10.0.10.0 host 255.255.255.0
access-list 102 permit ip host 10.1.0.0 host 255.255.255.1
!
!
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
hostname R1
!
interface Loopback0
ip address 200.200.10.1 255.255.255.0
!
interface Serial8/0
ip address 10.10.13.1 255.255.255.1
!--- 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
hostname R2
!
interface Loopback0
ip address 10.0.10.0 255.255.255.0
!
interface Serial9/0
ip address 10.10.23.2 255.255.255.1
!--- 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は、次に示すように、コミュニティ100:300および100:250でプレフィクス10.0.10.0/24および10.1.0.0/24を受信します show ip bgp
コマンドの出力結果
注:設定したポリシーに基づいた BGP テーブルにこれらのルートがインストールされると、コミュニティ 100:300 のプレフィクスはローカル プリファレンス 130 に割り当てられ、コミュニティ 100:250 のプレフィクスはローカル プリファレンス 125 に割り当てられます。
R1#show ip bgp 10.0.10.0
BGP routing table entry for 10.0.10.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 (10.0.10.0)
Origin IGP, metric 0, localpref 130, valid, external, best
Community: 100:300
!--- Prefix 10.0.10.0/24 with community 100:300 received from 10.10.13.3 (R3) is assigned local preference 130.
R1#show ip bgp 10.1.0.0
BGP routing table entry for 10.1.0.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 (10.1.0.0)
Origin IGP, metric 0, localpref 130, valid, internal, best
!--- Received prefix 10.1.0.0/24 over iBGP from 10.10.12.2 (R2) with local preference 130
30 10.10.13.3 from 10.10.13.3 (198.50.100.0) Origin IGP, metric 0, localpref 125, valid, external Community: 100:250 !--- Prefix 10.1.0.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.10.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
*> 10.0.10.0/24 10.10.13.3 0 130 0 30 i
*>i 10.1.0.0/24 10.10.12.2 0 130 0 30 i
* 10.10.13.3 0 125 0 30 i
「 show ip bgp
コマンドをR1で実行すると、R1で選択されたベストパスがローカルプリファレンス(LoclPrf) = 130であることを確認できます。 同様に、R2は、次の太字で示すように、コミュニティ100:250および100:300でプレフィクス10.0.10.0/24および10.1.0.0/24を受信します show ip bgp
コマンド出力:
注:設定したポリシーに基づいた BGP テーブルにこれらのルートがインストールされると、コミュニティ 100:300 のプレフィクスはローカル プリファレンス 130 に割り当てられ、コミュニティ 100:250 のプレフィクスはローカル プリファレンス 125 に割り当てられます。
R2#show ip bgp 10.0.10.0
BGP routing table entry for 10.0.10.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 (10.0.10.0)
Origin IGP, metric 0, localpref 125, valid, external
Community: 100:250
!--- Prefix 10.0.10.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.10.1) Origin IGP, metric 0, localpref 130, valid, internal, best !--- Received prefix 10.0.10.0/24 over iBGP from 10.10.12.1 (R1) with local preference 130
R2#show ip bgp 10.1.0.0
BGP routing table entry for 10.1.0.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 (10.1.0.0)
Origin IGP, metric 0, localpref 130, valid, external, best
Community: 100:300
!--- Prefix 10.1.0.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
* 10.0.10.0/24 10.10.23.3 0 125 0 30 i
*>i 10.10.12.1 0 130 0 30 i
*> 10.1.0.0/24 10.10.23.3 0 130 0 30 i
これは show ip bgp
r2のコマンド出力は、R2で選択されたベストパスがlocal preference(loclPrf) = 130であることを確認します。 プレフィクス10.0.10.0/24へのIPルートは、AS 100からAS 30に向けて出力するためにR1-R3リンクを優先します。「 show ip route
コマンドをR1とR2で実行すると、この設定が確認されます。
R1#show ip route 10.0.10.0
Routing entry for 10.0.10.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 10.0.10.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 10.1.0.0
Routing entry for 10.1.0.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 10.1.0.0/24 points to next hop R1 (10.10.12.1) on its iBGP link
!--- Thus traffic to network 10.1.0.0/24 from R2 exits through R2-R1 and then R1-R3 link from AS 100 towards AS 30
プレフィクス10.1.0.0/24へのIPルートは、AS 100からAS 30に向けて出て行くためにR2-R3リンクを優先します。「 show ip route
コマンドをR1とR2で実行すると、この設定が確認されます。
R2#show ip route 10.1.0.0
Routing entry for 10.1.0.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 10.1.0.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 10.1.0.0
Routing entry for 10.1.0.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 10.1.0.0/24 points to next hop R2 (10.10.12.2) on its iBGP link.
!--- Thus traffic to network 10.1.0.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#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#interface serial8/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のプレフィクス10.0.10.0/24と10.1.0.0/24のIPルーティングテーブルに注目してください。AS 100 から出るために R2-R3 リンクを使用します。
R1#show ip route 10.0.10.0
Routing entry for 10.0.10.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 10.1.0.0
Routing entry for 10.1.0.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
コマンド出力には、プレフィックス10.0.10.0/24および10.1.0.0/24へのルートがネクストホップ10.10.12.2(R2)を指していることが示されています。これは予想どおりの結果です。次に、R2のIPルーティングテーブルを調べて、プレフィクス10.0.10.0/24および10.1.0.0/24のネクストホップを確認します。設定されたポリシーが正常に動作するには、ネクスト ホップが R3 になっている必要があります。
R2#show ip route 10.0.10.0
Routing entry for 10.0.10.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 10.1.0.0
Routing entry for 10.1.0.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 インターフェイスです。これにより、設定されたポリシーが正常に動作していることが確認されます。
関連情報