DynagenでCCIEを目指す
20100616 BGP 経路集約 属性の取り扱い
最終更新:
it_certification
-
view
目的
- BGPの経路集約時に、BGP属性をどのように伝えるかを確認します。
構成
- 設定概要
- 初期設定はip addressのみです
- 構成図

- netファイル
model = 3620 [localhost] [[3620]] image = C:\Program Files\Dynamips\images\c3620-j1s3-mz.123-18.bin ram = 128 [[ROUTER R1]] f0/0 = R2 f0/0 [[ROUTER R2]] f1/0 = R3 f1/0 [[ROUTER R3]]
- 初期設定 R1
! version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R1 ! boot-start-marker boot-end-marker ! ! no aaa new-model ip subnet-zero ! ! ! ip cef ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Loopback0 ip address 1.1.1.1 255.255.255.255 ! interface FastEthernet0/0 ip address 192.168.12.1 255.255.255.0 duplex auto speed auto ! ip http server ip classless ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
- 初期設定 R2
! version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R2 ! boot-start-marker boot-end-marker ! ! no aaa new-model ip subnet-zero ! ! ! ip cef ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Loopback0 ip address 2.2.2.2 255.255.255.255 ! interface FastEthernet0/0 ip address 192.168.12.2 255.255.255.0 duplex auto speed auto ! interface FastEthernet1/0 ip address 192.168.23.2 255.255.255.0 duplex auto speed auto ! ip http server ip classless ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
- 初期設定 R3
! version 12.3 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R3 ! boot-start-marker boot-end-marker ! ! no aaa new-model ip subnet-zero ! ! ! ip cef ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Loopback0 ip address 3.3.3.3 255.255.255.255 ! interface FastEthernet1/0 ip address 192.168.23.3 255.255.255.0 duplex auto speed auto ! ip http server ip classless ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
検証1 環境構築
- BGP neighborの設定
R1, R2, R3間でeBGP neighborを確立させます。
R1(config)#router bgp 1 R1(config-router)#neighbor 192.168.12.2 remote-as 2 R1(config-router)#network 1.1.1.1 mask 255.255.255.255 R2(config)#router bgp 2 R2(config-router)#neighbor 192.168.12.1 remote-as 1 R2(config-router)#neighbor 192.168.23.3 remote-as 3 R2(config-router)#network 2.2.2.2 mask 255.255.255.255 R3(config)#router bgp 3 R3(config-router)#neighbor 192.168.23.2 remote-as 2 R3(config-router)#network 3.3.3.3 mask 255.255.255.255
- BGP neighborの確認
eBGP neighborが確立され、経路が交換された事を確認します。
R1#show ip route bgp 2.0.0.0/32 is subnetted, 1 subnets B 2.2.2.2 [20/0] via 192.168.12.2, 00:04:51 3.0.0.0/32 is subnetted, 1 subnets B 3.3.3.3 [20/0] via 192.168.12.2, 00:04:11 R1#
- ネットワークの再現
R3に接続されているネットワークを再現します。再現したルートはR2に通知します。
R3(config)#interface Loopback 0 R3(config-if)#ip address 172.16.1.3 255.255.255.0 secondary R3(config-if)#ip address 172.16.2.3 255.255.255.0 secondary R3(config-if)#ip address 172.16.3.3 255.255.255.0 secondary R3(config-if)#exit R3(config)# R3(config)# R3(config)#access-list 1 permit 172.16.1.0 0.0.0.255 R3(config)#access-list 2 permit 172.16.2.0 0.0.0.255 R3(config)#access-list 3 permit 172.16.3.0 0.0.0.255 R3(config)# R3(config)# R3(config)# R3(config)#route-map ADV_ROUTE permit 10 R3(config-route-map)#match ip address 1 R3(config-route-map)#set as-path prepend 4 10 R3(config-route-map)#set community 300:1 R3(config-route-map)#exit R3(config)#route-map ADV_ROUTE permit 20 R3(config-route-map)#match ip address 2 R3(config-route-map)#set as-path prepend 4 20 R3(config-route-map)#set community 300:2 R3(config-route-map)#exit R3(config)#route-map ADV_ROUTE permit 30 R3(config-route-map)#match ip address 3 R3(config-route-map)#set as-path prepend 4 30 R3(config-route-map)#set community 300:3 R3(config-route-map)#exit R3(config)#route-map ADV_ROUTE permit 1000 R3(config-route-map)#exit R3(config)# R3(config)# R3(config)#ip bgp-community new-format R3(config)# R3(config)# R3(config)#router bgp 3 R3(config-router)#neighbor 192.168.23.2 route-map ADV_ROUTE out R3(config-router)#neighbor 192.168.23.2 send-community R3(config-router)#network 172.16.1.0 mask 255.255.255.0 R3(config-router)#network 172.16.2.0 mask 255.255.255.0 R3(config-router)#network 172.16.3.0 mask 255.255.255.0
- コミュニティの設定
R1, R2に対して、コミュニティを通知できるように設定します。
R1(config)#ip bgp-community new-format R1(config)# R1(config)# R1(config)#router bgp 1 R1(config-router)#neighbor 192.168.12.2 send-community R2(config)#ip bgp-community new-format R2(config)# R2(config)# R2(config)#router bgp 2 R2(config-router)#neighbor 192.168.12.1 send-community R2(config-router)#neighbor 192.168.23.3 send-community R2(config-router)#^Z
- 再現したネットワークの確認
再現したネットワークを確認します。AS PATHおよびCOMMUNITY属性が付加されている事を確認します。
R2#show ip bgp BGP table version is 10, local router ID is 2.2.2.2 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 192.168.12.1 0 0 1 i *> 2.2.2.2/32 0.0.0.0 0 32768 i *> 3.3.3.3/32 192.168.23.3 0 0 3 i *> 172.16.1.0/24 192.168.23.3 0 0 3 4 10 i <- AS PATHを確認 *> 172.16.2.0/24 192.168.23.3 0 0 3 4 20 i <- AS PATHを確認 *> 172.16.3.0/24 192.168.23.3 0 0 3 4 30 i <- AS PATHを確認 R2# R2# R2#show ip bg R2#show ip bgp 172.16.1.0 BGP routing table entry for 172.16.1.0/24, version 7 Paths: (1 available, best #1, table Default-IP-Routing-Table) Advertised to non peer-group peers: 192.168.12.1 3 4 10 192.168.23.3 from 192.168.23.3 (3.3.3.3) Origin IGP, metric 0, localpref 100, valid, external, best Community: 300:1 <- COMMUNITYを確認します。 R2#show ip bgp 172.16.2.0 BGP routing table entry for 172.16.2.0/24, version 10 Paths: (1 available, best #1, table Default-IP-Routing-Table) Advertised to non peer-group peers: 192.168.12.1 3 4 20 192.168.23.3 from 192.168.23.3 (3.3.3.3) Origin IGP, metric 0, localpref 100, valid, external, best Community: 300:2 <- COMMUNITYを確認します。 R2#show ip bgp 172.16.3.0 BGP routing table entry for 172.16.3.0/24, version 9 Paths: (1 available, best #1, table Default-IP-Routing-Table) Advertised to non peer-group peers: 192.168.12.1 3 4 30 192.168.23.3 from 192.168.23.3 (3.3.3.3) Origin IGP, metric 0, localpref 100, valid, external, best Community: 300:3 <- COMMUNITYを確認します。 R2#
検証2 経路集約の設定
- 経路集約の設定
R2に経路集約の設定を投入します。
R2(config)#router bgp 2 R2(config-router)#aggregate-address 172.16.0.0 255.255.252.0 R2(config-router)#^Z R2# *Mar 1 00:35:54.503: %SYS-5-CONFIG_I: Configured from console by console R2#clear ip bgp 192.168.12.1 out R2#
- BGP属性の確認
集約されたルートのBGP属性を確認します。デフォルトの設定では、AS PATHやCOMMUNITYが通知されていない事が読み取れます。
R1#show ip bgp BGP table version is 13, local router ID is 1.1.1.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 0.0.0.0 0 32768 i *> 2.2.2.2/32 192.168.12.2 0 0 2 i *> 3.3.3.3/32 192.168.12.2 0 2 3 i *> 172.16.0.0/22 192.168.12.2 0 0 2 i *> 172.16.1.0/24 192.168.12.2 0 2 3 4 10 i *> 172.16.2.0/24 192.168.12.2 0 2 3 4 20 i *> 172.16.3.0/24 192.168.12.2 0 2 3 4 30 i R1# R1# R1#show ip bgp 172.16.0.0 BGP routing table entry for 172.16.0.0/22, version 10 Paths: (1 available, best #1, table Default-IP-Routing-Table) Not advertised to any peer 2, (aggregated by 2 2.2.2.2) 192.168.12.2 from 192.168.12.2 (2.2.2.2) Origin IGP, metric 0, localpref 100, valid, external, atomic-aggregate, best R1#
検証3 as-setオプション
- as-setの付加
経路集約時にas-pathオプションを付加します。
R2(config)#router bgp 2 R2(config-router)#aggregate-address 172.16.0.0 255.255.252.0 as-set
- BGP属性の確認
AP PATHおよびCOMMUNITYが集約後に引き継がれている事が読み取れます。
R1#show ip bgp 172.16.0.0 BGP routing table entry for 172.16.0.0/22, version 14 Paths: (1 available, best #1, table Default-IP-Routing-Table) Not advertised to any peer 2 {3,4,10,20,30}, (aggregated by 2 2.2.2.2) <- 集約前のAS PATHが確認できます。 192.168.12.2 from 192.168.12.2 (2.2.2.2) Origin IGP, metric 0, localpref 100, valid, external, best Community: 300:1 300:2 300:3 <- 集約前のCOMMUNITYが確認できます。 R1#
検証4 advertise-map
- advertise-mapの付加
as-setに、さらにadvertise-mapを付加する事で、継承するAS PATHとCOMMUNITYを制限する事ができます。以下は、172.16.1.0/24, 172.16.2.0/24のみのAS PATHとCOMMUNITYを継承する設定です。
R2(config)#access-list 1 permit 172.16.1.0 0.0.0.255 R2(config)#access-list 2 permit 172.16.2.0 0.0.0.255 R2(config)# R2(config)# R2(config)# R2(config)#route-map ADV_ROUTE permit 10 R2(config-route-map)#match ip address 1 R2(config-route-map)#exit R2(config)#route-map ADV_ROUTE permit 20 R2(config-route-map)#match ip address 2 R2(config-route-map)#exit R2(config)# R2(config)# R2(config)# R2(config)#router bgp 2 R2(config-router)#aggregate-address 172.16.0.0 255.255.252.0 as-set ad R2(config-router)#$.16.0.0 255.255.252.0 as-set advertise-map ADV-MAP
- BGPテーブルの確認
検証3と比較すると、172.16.3.0/24のAS PATHとCOMMUNITYが含まれていない事が分かります。
R1#show ip bgp 172.16.0.0 BGP routing table entry for 172.16.0.0/22, version 15 Paths: (1 available, best #1, table Default-IP-Routing-Table) Not advertised to any peer 2 {3,4,10,20}, (aggregated by 2 2.2.2.2) <- 検証3と比較すると、30がなくなっています。 192.168.12.2 from 192.168.12.2 (2.2.2.2) Origin IGP, metric 0, localpref 100, valid, external, atomic-aggregate, best Community: 300:1 300:2 <- 検証3と比較すると、300:3がなくなっています。 R1#
検証5 attribute-map
- attribute-mapの付加
as-setにattribute-mapを付加すると、MEDやLOCAL PREFERENCEを定義する事ができます。
R2(config)#route-map ATT-MAP permit 10 R2(config-route-map)#set metric 50 R2(config-route-map)#set local-preference 50 R2(config-route-map)#exit R2(config)# R2(config)# R2(config)# R2(config)#router bgp 2 R2(config-router)#aggregate-address 172.16.0.0 255.255.252.0 as-set ad R2(config-router)#$.16.0.0 255.255.252.0 as-set advertise-map ADV-MAP att R2(config-router)#$0 as-set advertise-map ADV-MAP attribute-map ATT-MAP R2(config-router)#^Z R2# *Mar 1 00:53:57.279: %SYS-5-CONFIG_I: Configured from console by console R2# R2#show ip bgp neighbors 192.168.12.1 advertised-routes BGP table version is 16, local router ID is 2.2.2.2 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 2.2.2.2/32 0.0.0.0 0 32768 i *> 3.3.3.3/32 192.168.23.3 0 0 3 i *> 172.16.0.0/22 0.0.0.0 50 50 32768 {3,4,10,20} i <- MED LocPrfが付加された事を確認します。 *> 172.16.1.0/24 192.168.23.3 0 0 3 4 10 i *> 172.16.2.0/24 192.168.23.3 0 0 3 4 20 i *> 172.16.3.0/24 192.168.23.3 0 0 3 4 30 i R2#
- BGPテーブルの確認
R1のBGPテーブルを確認し、MED値が伝わっている事を確認します。
(LocPrfはASの出口を定義するためのパラメタですので、eBGP neighbor間は伝わらない仕様になっています)
(LocPrfはASの出口を定義するためのパラメタですので、eBGP neighbor間は伝わらない仕様になっています)
R1#show ip bgp BGP table version is 18, local router ID is 1.1.1.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 0.0.0.0 0 32768 i *> 2.2.2.2/32 192.168.12.2 0 0 2 i *> 3.3.3.3/32 192.168.12.2 0 2 3 i *> 172.16.0.0/22 192.168.12.2 50 0 2 {3,4,10,20} i <- MEDが伝わった事を確認します。 *> 172.16.1.0/24 192.168.12.2 0 2 3 4 10 i *> 172.16.2.0/24 192.168.12.2 0 2 3 4 20 i *> 172.16.3.0/24 192.168.12.2 0 2 3 4 30 i R1# R1# R1#show ip bgp 172.16.0.0 BGP routing table entry for 172.16.0.0/22, version 18 Paths: (1 available, best #1, table Default-IP-Routing-Table) Not advertised to any peer 2 {3,4,10,20}, (aggregated by 2 2.2.2.2) 192.168.12.2 from 192.168.12.2 (2.2.2.2) Origin IGP, metric 50, localpref 100, valid, external, atomic-aggregate, best Community: 300:1 300:2 R1#
添付ファイル