【實驗環境】
C3640-IK9O3S-M Version 12.4(10)
【實驗目的】
驗證BGP的路由聚合
【實驗拓撲】
【實驗描述】
1、在R2上使用手工創建聚合靜態路由并宣告靜態路由實現BGP路由聚合
2、在R2上使用BGP路由聚合命令aggregate-address實現實現BGP路由聚合
3、在R1上使用BGP路由聚合命令aggregate-address實現實現BGP路由聚合
4、在R1上結合使用suppress-map實現部分BGP路由集合
【實驗步驟】
1、R1基本配置
!
interface Serial0/0
ip address 12.0.0.1 255.255.255.0
serial restart-delay 0
clock rate 64000
!
router bgp 1
no synchronization
bgp router-id 1.1.1.1
neighbor 12.0.0.2 remote-as 2
no auto-summary
!
2、R2基本配置
!
interface Loopback0
ip address 200.1.16.1 255.255.255.0
!
interface Loopback1
ip address 200.1.17.1 255.255.255.0
!
interface Loopback2
ip address 200.1.18.1 255.255.255.0
!
interface Loopback3
ip address 200.1.19.1 255.255.255.0
!
interface Serial0/0
ip address 12.0.0.2 255.255.255.0
!
router bgp 2
no synchronization
bgp router-id 2.2.2.2
neighbor 12.0.0.1 remote-as 1
no auto-summary
!
3、在R2上使用手工創建聚合靜態路由并宣告靜態路由實現BGP路由聚合
該方法只能使用在產生明細路由的路由器R2上,并且無需在R2上通告明細路由,首先創建一條指向NULL0接口的匯總靜態路由:
R2(config)#ip route 200.1.16.0 255.255.252.0 Null0
接著將匯總的靜態路由從BGP發布出去
R2(config)#router bgp 2
R2(config-router)#network 200.1.16.0 mask 255.255.252.0
此時在R1上就可以看到匯總路由了
R1#sh ip bgp
BGP table version is 2, local router ID is 1.1.1.1
Network Next Hop Metric LocPrf Weight Path
*> 200.1.16.0/22 12.0.0.2 0 0 2 i
4、清除3的配置,在R2上使用BGP路由聚合命令aggregate-address實現實現BGP路由聚合
R2(config)#no ip route 200.1.16.0 255.255.252.0 null 0
R2(config)#router bgp 2
R2(config-router)#no network 200.1.16.0 mask 255.255.252.0
需要先將明細路由通告進BGP:
R2(config)#router bgp 2
R2(config-router)#network 200.1.16.0
R2(config-router)#network 200.1.17.0
R2(config-router)#network 200.1.18.0
R2(config-router)#network 200.1.19.0
不帶mask參數,默認為網絡號的主類子網掩碼
使用aggregate-address宣告聚合路由:
R2(config)#router bgp 2
R2(config-router)#aggregate-address 200.1.16.0 255.255.252.0 summary-only
summary-only參數表示只宣告聚合路由,抑制明細路由
在R2上查看BGP路由表,明細路由被抑制:
R2#sh ip bgp
BGP table version is 12, local router ID is 2.2.2.2
Network Next Hop Metric LocPrf Weight Path
s> 200.1.16.0 0.0.0.0 0 32768 i
*> 200.1.16.0/22 0.0.0.0 32768 i
s> 200.1.17.0 0.0.0.0 0 32768 i
s> 200.1.18.0 0.0.0.0 0 32768 i
s> 200.1.19.0 0.0.0.0 0 32768 i
在R1上查看BGP路由表,只有一條聚合路由:
R1#sh ip bgp
BGP table version is 4, local router ID is 1.1.1.1
Network Next Hop Metric LocPrf Weight Path
*> 200.1.16.0/22 12.0.0.2 0 0 2 i
5、保留明細路由,清除R2上的聚合路由配置,在R1上使用BGP路由聚合命令aggregate-address實現實現BGP路由聚合
R2(config)#router bgp 2
R2(config-router)#no aggregate-address 200.1.16.0 255.255.252.0 summary-only
在R1上執行路由匯總命令:
R1(config)#router bgp 1
R1(config-router)#aggregate-address 200.1.16.0 255.255.252.0 summary-only
在R1上查看BGP路由表:
R1#sh ip bgp
BGP table version is 14, local router ID is 1.1.1.1
Network Next Hop Metric LocPrf Weight Path
s> 200.1.16.0 12.0.0.2 0 0 2 i
*> 200.1.16.0/22 0.0.0.0 32768 i
s> 200.1.17.0 12.0.0.2 0 0 2 i
s> 200.1.18.0 12.0.0.2 0 0 2 i
s> 200.1.19.0 12.0.0.2 0 0 2 i
在R2上查看BGP路由表:
R2#sh ip bgp
BGP table version is 18, local router ID is 2.2.2.2
Network Next Hop Metric LocPrf Weight Path
*> 200.1.16.0 0.0.0.0 0 32768 i
*> 200.1.16.0/22 12.0.0.1 0 0 1 i
*> 200.1.17.0 0.0.0.0 0 32768 i
*> 200.1.18.0 0.0.0.0 0 32768 i
*> 200.1.19.0 0.0.0.0 0 32768 i
問題:R1的匯總路由Path屬性為空,由于EBGP的水平分割是基于Path屬性的,因此該路由條目不滿足水平分割,將會回傳給R2,所以在R2上可以看到Next Hop值為R1的匯總路由。如果明細路由中的某一條down掉,將有可能導致一些帶寬流量的浪費。因此我們需要在aggregate-address命令后加多另外一個參數as-set,這個參數會將明細路由中的一些屬性保留給匯總路由,其中包括了as-path屬性。
R1(config)#router bgp 1
R1(config-router)#no aggregate-address 200.1.16.0 255.255.252.0 summary-only
R1(config-router)#aggregate-address 200.1.16.0 255.255.252.0 summary-only as-set
重新在R1上查看BGP路由表:
R1#sh ip bgp
BGP table version is 20, local router ID is 1.1.1.1
Network Next Hop Metric LocPrf Weight Path
s> 200.1.16.0 12.0.0.2 0 0 2 i
*> 200.1.16.0/22 0.0.0.0 100 32768 2 i
s> 200.1.17.0 12.0.0.2 0 0 2 i
s> 200.1.18.0 12.0.0.2 0 0 2 i
s> 200.1.19.0 12.0.0.2 0 0 2 i
重新在R2上查看BGP路由表:
R2#sh ip bgp
BGP table version is 19, local router ID is 2.2.2.2
Network Next Hop Metric LocPrf Weight Path
*> 200.1.16.0 0.0.0.0 0 32768 i
*> 200.1.17.0 0.0.0.0 0 32768 i
*> 200.1.18.0 0.0.0.0 0 32768 i
*> 200.1.19.0 0.0.0.0 0 32768 i
EBGP水平分割起作用了,R2上不會出現回傳的聚合路由
6、清除R1上的聚合路由配置,結合使用suppress-map實現部分BGP路由聚合。需求為抑制200.1.18.0/24和200.1.19.0/24網段,其他網段及聚合路由顯示。
R1(config)#router bgp 1
R1(config-router)#no aggregate-address 200.1.16.0 255.255.252.0 summary-only as-set
使用前綴列表抓取路由條目:
R1(config)#ip prefix-list 10 permit 200.1.18.0/23 ge 24 le 24
創建route-map處理路由條目
R1(config)#route-map SU permit 10
R1(config-route-map)#match ip address prefix-list 10
R1(config-route-map)#exit
使用suppress-map創建聚合路由
R1(config)#router bgp 1
R1(config-router)#aggregate-address 200.1.16.0 255.255.252.0 suppress-map SU as-set
硬清除BGP路由表
R1#clear ip bgp *
在R1上查看BGP路由表:
R1#sh ip bgp
BGP table version is 8, local router ID is 1.1.1.1
Network Next Hop Metric LocPrf Weight Path
*> 200.1.16.0 12.0.0.2 0 0 2 i
*> 200.1.16.0/22 0.0.0.0 100 32768 2 i
*> 200.1.17.0 12.0.0.2 0 0 2 i
s> 200.1.18.0 12.0.0.2 0 0 2 i
s> 200.1.19.0 12.0.0.2 0 0 2 i
可以發現18、19兩個網段被抑制,其余網段best