重分布,no auto-summary, 路由聚合
AS 12lo0:2.2.2.2/24OSPFiBGPlo0:1.1.1.1/24AS 3eBGPR2R1s0/1 192.168.13.0/24 s0/0R3lo0:3.3.3.3/24s0/0 192.168.12.0/24 s0/0 【实验要求】
按照拓扑需求,运行BGP协议,并实现BGP的重分布,no auto-summary 和路由聚合,并对现象进行分析。
【实验步骤】
一、首先将R1、R2和R3的基本配置完成,使得BGP网络可达。
R1(config)#int s0/0
R1(config-if)#ip add 192.168.12.1 255.255.255.0 R1(config-if)#no sh R1(config-if)#int s0/1
R1(config-if)#ip add 192.168.13.1 255.255.255.0 R1(config-if)#no sh R1(config-if)#int l0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config)#router os 1
R1(config-router)#router-id 1.1.1.1
R1(config-router)#net 1.1.1.0 0.0.0.255 a 0
R1(config-router)#net 192.168.12.0 0.0.0.255 a 0
R1(config-router)#router bgp 12
R1(config-router)#bg router-id 1.1.1.1 R1(config-router)#nei 2.2.2.2 remot 12
R1(config-router)#nei 2.2.2.2 update-source l0 R1(config-router)#nei 2.2.2.2 next-hop-s
R1(config)#ip route 3.3.3.3 255.255.255.255 192.168.13.3
R1(config)#router bgp 12
R1(config-router)#nei 3.3.3.3 remot 3 R1(config-router)#nei 3.3.3.3 up l0
R1(config-router)#nei 3.3.3.3 ebgp-multihop 2
R2(config)#int s0/0
R2(config-if)#ip add 192.168.12.2 255.255.255.0 R2(config-if)#no sh R2(config-if)#int l0
R2(config-if)#ip add 2.2.2.2 255.255.255.0 R2(config-if)#no sh
R2(config-if)#router os 1
R2(config-router)#router-id 2.2.2.2
R2(config-router)#net 2.2.2.0 0.0.0.255 a 0
R2(config-router)#net 192.168.12.0 0.0.0.255 a 0
R2(config-router)#router bgp 12
R2(config-router)#bgp router-id 2.2.2.2 R2(config-router)#nei 1.1.1.1 remot 12 R2(config-router)#nei 1.1.1.1 up l0 R2(config-router)#nei 1.1.1.1 ne
R2(config-router)#nei 1.1.1.1 next-hop-s
R3(config)#int s0/1
R3(config-if)#ip add 192.168.13.3 255.255.255.0 R3(config-if)#no sh R3(config-if)#int l0
R3(config-if)#ip add 3.3.3.3 255.255.255.0 R3(config-if)#no sh
R3(config)#ip route 1.1.1.1 255.255.255.255 192.168.13.1 R3(config-if)#router bgp 3
R3(config-router)#bgp router-id 3.3.3.3 R3(config-router)#nei 1.1.1.1 remot 12 R3(config-router)#nei 1.1.1.1 up l0 R3(config-router)#nei 1.1.1.1 e 2
R3(config)#router bgp 3 //在R3的BGP中,宣告3.3.3.0的路由 R3(config-router)#network 3.3.3.0
//在R3的BGP表中没有该路由
因为3.3.3.0这条路由默认会汇总成主类路由3.0.0.0,但是在R3 的路由表中不存在,所有宣告失败,必须加掩码
R3(config-router)#net 3.3.3.0 mask 255.255.255.0
R3#sh ip bgp //查看R3 的BGP表中,将3.3.3.0成功宣告 Network Next Hop Metric LocPrf Weight Path *> 3.3.3.0/24 0.0.0.0 0 32768 i
R2#sh ip bgp //查看R2 的BGP表中,学习到了这条路由 Network Next Hop Metric LocPrf Weight Path *>i3.3.3.0/24 1.1.1.1 0 100 0 3 i
二、 在R1上将OSPF重分发到BGP,并origin属性进行分析
R1(config)#router bg 12
R1(config-router)#redistribute os 1
R1#sh ip bgp //查看R1的BGP表
Network Next Hop Metric LocPrf Weight Path *> 1.1.1.0/24 0.0.0.0 0 32768 ? *> 2.2.2.2/32 192.168.12.2 65 32768 ? *> 3.3.3.0/24 3.3.3.3 0 0 3 i *> 192.168.12.0 0.0.0.0 0 32768 ?
?表示这条BGP路由,是通过IGP重分布学到的,重分布会携带 IGP路由的metric和下一跳。
R2#sh ip bgp//查看R2的BGP 表
Network Next Hop Metric LocPrf Weight Path *>i1.1.1.0/24 1.1.1.1 0 100 0 ? r>i2.2.2.2/32 1.1.1.1 65 100 0 ? *>i3.3.3.0/24 1.1.1.1 0 100 0 3 i r>i192.168.12.0 1.1.1.1 0 100 0 ?
当一条路由同时通过IGP和iBGP学习到,选择IGP,因为iBGP 的AD为200, 不会被放入路由表,用r 表示,但是这些路由是 优的,带>,会传给BGP邻居。
R2#sh ip bgp rib-failure //查看R2的失效RIB表
Network Next Hop RIB-failure RIB-NH Matches 2.2.2.2/32 1.1.1.1 Own IP address n/a 192.168.12.0 1.1.1.1 Higher admin distance n/a
查看R1向邻居R3宣告了哪些BGP路由
R1#sh ip bgp neighbors 3.3.3.3 advertised-routes
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.0/24 0.0.0.0 0 32768 ? *> 2.2.2.2/32 192.168.12.2 65 32768 ? *> 192.168.12.0 0.0.0.0 0 32768 ?
查看R3从邻居R1收到了哪些BGP路由 R3#sh ip bgp nei 1.1.1.1 received-routes
% Inbound soft reconfiguration not enabled on 1.1.1.1 //默认in方向信息不保存
R3(config)#router bgp 3
R3(config-router)#nei 1.1.1.1 soft-reconfiguration inbound
R3#sh ip bgp nei 1.1.1.1 received-routes // 再次查看R3从R1学
到了哪些路由
Network Next Hop Metric LocPrf Weight Path *> 1.1.1.0/24 1.1.1.1 0 0 12 ? *> 2.2.2.2/32 1.1.1.1 65 0 12 ? *> 192.168.12.0 1.1.1.1 0 0 12 ?
三、 No auto-summary
由于路由器IOS版本较高,默认no auto-summary 在BGP进程 中都有了,在R1上开启自动汇总。
R1(config)#router bgp 12
R1(config-router)#auto-summary
R1#sh ip bgp//查看R1的BGP表
Network Next Hop Metric LocPrf Weight Path *> 1.0.0.0 0.0.0.0 0 32768 ? *> 2.0.0.0 0.0.0.0 0 32768 ? *> 3.3.3.0/24 3.3.3.3 0 0 3 i *> 192.168.12.0 0.0.0.0 0 32768 ?
在BGP中auto-summary只是对于BGP重分布来说的,3.3.3.0/24 仍然没有汇总。
Auto-summary:
不携带IGP的下一跳和metric,下一跳改为自己0.0.0.0, Metric为0,将IGP的路由主类汇总。
No auto-summary:
不汇总,携带IGP的下一跳和metric,不进行汇总
四、 路由聚合
1. 在R3 上开启四个换回口,并用BGP宣告。 R3(config)#int l10
R3(config-if)#ip add 200.1.16.1 255.255.255.0 R3(config-if)#int l11 R3(config-if)#ip add 200.1.17.1 255.255.255.0 R3(config-if)#int l12 R3(config-if)#ip add 200.1.18.1 255.255.255.0 R3(config-if)#int l13 R3(config-if)#ip add 200.1.19.1 255.255.255.0
R3(config-if)#router bgp 3
R3(config-router)#net 200.1.16.0 mask 255.255.255.0 R3(config-router)#net 200.1.17.0 mask 255.255.255.0 R3(config-router)#net 200.1.18.0 mask 255.255.255.0 R3(config-router)#net 200.1.19.0 mask 255.255.255.0
R1#sh ip bgp//在R1上查看BGP表,可以学到所有的明细路由 Network Next Hop Metric LocPrf Weight Path
*> 1.0.0.0 0.0.0.0 0 32768 ? *> 2.0.0.0 0.0.0.0 0 32768 ? *> 3.3.3.0/24 3.3.3.3 0 0 3 i *> 192.168.12.0 0.0.0.0 0 32768 ? *> 200.1.16.0 3.3.3.3 0 0 3 i *> 200.1.17.0 3.3.3.3 0 0 3 i *> 200.1.18.0 3.3.3.3 0 0 3 i *> 200.1.19.0 3.3.3.3 0 0 3 i
2. 在R3上做路由聚合
R3(config-router)#aggregate-address 200.1.16.0 255.255.252.0
R1#sh ip bgp //R1的BGP表中,既有明细,又有汇总 Network Next Hop Metric LocPrf Weight Path *> 1.0.0.0 0.0.0.0 0 32768 ? *> 2.0.0.0 0.0.0.0 0 32768 ? *> 3.3.3.0/24 3.3.3.3 0 0 3 i *> 192.168.12.0 0.0.0.0 0 32768 ? *> 200.1.16.0 3.3.3.3 0 0 3 i *> 200.1.16.0/22 3.3.3.3 0 0 3 i *> 200.1.17.0 3.3.3.3 0 0 3 i *> 200.1.18.0 3.3.3.3 0 0 3 i *> 200.1.19.0 3.3.3.3 0 0 3 i
R3(config-router)#aggregate-address 200.1.16.0 255.255.252.0 summary-only R3#sh ip bgp
Network Next Hop Metric LocPrf Weight Path *> 1.0.0.0 1.1.1.1 0 0 12 ? *> 2.0.0.0 1.1.1.1 0 0 12 ? *> 3.3.3.0/24 0.0.0.0 0 32768 i *> 192.168.12.0 1.1.1.1 0 0 12 ? 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
s: 被聚合抑制掉的路由,不会通过给BGP邻居
R1#sh ip bgp//R1的BGP表中只有汇总路由
Network Next Hop Metric LocPrf Weight Path *> 1.0.0.0 0.0.0.0 0 32768 ? *> 2.0.0.0 0.0.0.0 0 32768 ? *> 3.3.3.0/24 3.3.3.3 0 0 3 i *> 192.168.12.0 0.0.0.0 0 32768 ? *> 200.1.16.0/22 3.3.3.3 0 0 3 i
3. 聚合的时候挂suppress-map,使得只有200.1.16.0和200.1.17.0
被抑制,放过200.1.18.0和200.1.19.0
R3(config)#ip prefix-list 1 permit 200.1.16.0/23 ge 24 le 24//抓路由
R3(config)#route-map jhy permit 10
R3(config-route-map)#match ip address prefix-list 1 //
R3(config-router)#aggregate-address 200.1.16.0 255.255.252.0 summary-only suppress-map jhy
R3#sh ip bgp
Network Next Hop Metric LocPrf Weight Path *> 1.0.0.0 1.1.1.1 0 0 12 ? *> 2.0.0.0 1.1.1.1 0 0 12 ? *> 3.3.3.0/24 0.0.0.0 0 32768 i *> 192.168.12.0 1.1.1.1 0 0 12 ? 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 *> 200.1.18.0 0.0.0.0 0 32768 i *> 200.1.19.0 0.0.0.0 0 32768 i //只有200.1.16.0和200.1.17.0被抑制。
R1#sh ip bgp //查看R1的BGP表,达到效果
Network Next Hop Metric LocPrf Weight Path *> 1.0.0.0 0.0.0.0 0 32768 ? *> 2.0.0.0 0.0.0.0 0 32768 ? *> 3.3.3.0/24 3.3.3.3 0 0 3 i *> 192.168.12.0 0.0.0.0 0 32768 ? *> 200.1.16.0/22 3.3.3.3 0 0 3 i *> 200.1.18.0 3.3.3.3 0 0 3 i *> 200.1.19.0 3.3.3.3 0 0 3 i
4. network和aggravation不在同一台路由器,即在R1上做聚合
R3(config-router)# no aggregate-address 200.1.16.0 255.255.252.0 summary-only suppress-map jhy//将R3上的聚合 no 掉
R1(config)# router bg 12
R1(config-router)#aggregate-address 200.1.16.0 255.255.252.0 summary-only
R1#sh ip bgp
Network Next Hop Metric LocPrf Weight Path *> 1.0.0.0 0.0.0.0 0 32768 ? *> 2.0.0.0 0.0.0.0 0 32768 ? *> 3.3.3.0/24 3.3.3.3 0 0 3 i *> 192.168.12.0 0.0.0.0 0 32768 ? s> 200.1.16.0 3.3.3.3 0 0 3 i *> 200.1.16.0/22 0.0.0.0 32768 i s> 200.1.17.0 3.3.3.3 0 0 3 i s> 200.1.18.0 3.3.3.3 0 0 3 i s> 200.1.19.0 3.3.3.3 0 0 3 i
在R1上,明细路由都被抑制掉了,只有汇总路由宣告出去,汇总路由 的AS起点是本AS
R2#sh ip bgp
Network Next Hop Metric LocPrf Weight Path *>i1.0.0.0 1.1.1.1 0 100 0 ? *>i2.0.0.0 1.1.1.1 0 100 0 ? *>i3.3.3.0/24 1.1.1.1 0 100 0 3 i r>i192.168.12.0 1.1.1.1 0 100 0 ? *>i200.1.16.0/22 1.1.1.1 0 100 0 i
R3#sh ip bgp//在R3上重新学习到了这条汇总路由
Network Next Hop Metric LocPrf Weight Path *> 1.0.0.0 1.1.1.1 0 0 12 ? *> 2.0.0.0 1.1.1.1 0 0 12 ? *> 3.3.3.0/24 0.0.0.0 0 32768 i *> 192.168.12.0 1.1.1.1 0 0 12 ? *> 200.1.16.0 0.0.0.0 0 32768 i *> 200.1.16.0/22 1.1.1.1 0 0 12 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上汇总的汇总路由,不携带原来的BGP路由属性,如AS,所有当这条 汇总路由回传给R3时,EBGP水平分割没有作用。
R1(config)# router bg 12
R1(config-router)#aggregate-address 200.1.16.0 255.255.252.0 summary-only as-set
在R1汇总BGP路由时,使用as-set携带其部分BGP路由特性。
R1#sh ip bgp//此时汇总路由的初始AS号为3
Network Next Hop Metric LocPrf Weight Path *> 1.0.0.0 0.0.0.0 0 32768 ? *> 2.0.0.0 0.0.0.0 0 32768 ? *> 3.3.3.0/24 3.3.3.3 0 0 3 i *> 192.168.12.0 0.0.0.0 0 32768 ? s> 200.1.16.0 3.3.3.3 0 0 3 i *> 200.1.16.0/22 0.0.0.0 100 32768 3 i s> 200.1.17.0 3.3.3.3 0 0 3 i s> 200.1.18.0 3.3.3.3 0 0 3 i s> 200.1.19.0 3.3.3.3 0 0 3 i R1#
R1# sh ip bgp nei 3.3.3.3 advertised-routes //查看R1向R3发送了的路由 Network Next Hop Metric LocPrf Weight Path *> 1.0.0.0 0.0.0.0 0 32768 ? *> 2.0.0.0 0.0.0.0 0 32768 ? *> 192.168.12.0 0.0.0.0 0 32768 ? *> 200.1.16.0/22 0.0.0.0 100 32768 3 i
R3#sh ip bgp nei 1.1.1.1 received-routes //查看R3从R1收到了的路由 Network Next Hop Metric LocPrf Weight Path *> 1.0.0.0 1.1.1.1 0 0 12 ? *> 2.0.0.0 1.1.1.1 0 0 12 ? *> 192.168.12.0 1.1.1.1 0 0 12 ?
由于EBGP水平分割,所有200.1.16.0/22的汇总路由,被R3抑制了。
因篇幅问题不能全部显示,请点此查看更多更全内容