BGP手动汇总
是我们最长用的方式
特点:
1、只要在BGP路由表中存在的路由,都能被手动汇总。
2、可以实现精确汇总,可以支持CIDR(超网)。
3、可以对汇总路由的属性做编辑。
4、可以继承明细路由的相关属性,防止环路
5、明细路由全部失效,汇总路由才会失效。
BGP路由聚合带来的问题:

因为BGP在做路由汇总的时候丢失了AS_Path属性,导致一旦AS 300 10.1.10.0/24明细路由失效,通过聚合会引起环路。
解决办法就是继承明细路由的AS_Path属性,如果AS300在接收到10.1.0.0/16的路由里收到了来自自身的AS标记,就会直接丢弃防环。
4、可以继承明细路由的相关属性,防止环路
还是之前的拓扑
我们输入命令
[R3-bgp]undo summary automatic
[R3-bgp]undo import-route static
将上次做的自动汇总取消掉,
[R3-bgp]aggregate 172.16.0.0 22
[R3-bgp]aggregate 192.168.0.0 22
这样我们查看BGP路由表,


我们发现这次标识是聚合路由,但是它丢失了AS_Path属性,并且汇总路由做了之后,。明细路由还是会发送出去
我们需要继续设置,抑制明细路由并且继承明细路由的AS号
[R3-bgp]aggregate 172.16.0.0 22 detail-suppressed as-set
[R3-bgp]aggregate 192.168.0.0 22 detail-suppressed as-set
我们此时查看邻居bgp路由表

查看被抑制的明细路由

并且R1只能接收R3将R2汇聚的路由,R2只能接收R3将R1汇聚的路由

5、明细路由全部失效,汇总路由才会失效。
我们先将R2上的一条静态路由进行undo操作,不发布
[R2-bgp]undo network 172.16.1.0 24

再undo另一条
[R2-bgp]undo network 172.16.2.0 24

我们甚至可以给聚合路由添加策略
[R3]route-policy att permit node 10
Info: New Sequence of this List.
[R3-route-policy]apply cost 999
[R3-route-policy]apply origin incomplete
[R3-route-policy]apply community no-advertise
[R3-route-policy]apply community no-export 暂时不要传给邻居
[R3-route-policy]q
[R3]bgp 3
[R3-bgp]aggregate 192.168.0.0 22 as-set detail-suppressed attribute-policy att

[R3]route-policy att permit node 10
[R3-route-policy]apply community 3:100
[R3-route-policy]q
[R3]bgp 3
[R3-bgp]peer 10.1.34.4 advertise-community
继续试验,我们可以复原之前在R2上做的ip配置。做以下实验,我们之前在R1上配置了192.168.的环回口,现在我们在R2上也开始配置环回口
[R2]int l3
[R2-LoopBack3]ip add 192.168.3.1 24
[R2-LoopBack3]q
[R2]int l4
[R2-LoopBack4]ip add 192.168.4.1 24
因为我们设置的手动汇总路由是掩的22位,说明只有192.168.0/1/2/3可以进行手动汇总,我们添加的R2里的ip add 192.168.4.1 24不会被掩到。


能汇总的就会汇总起来。
[R3-bgp]aggregate 192.168.0.0 255.255.248.0 as-set detail-suppressed
我们继续做一个

as-path 表明路由传递的AS的次序,有序的
as-set { }无序的AS-PATH,防止环路用的,并不表明路由传递的次序。
{ }中的AS号,只算1个AS长度。
但是我们现在发现,R3和R4可以正常访问R1和R2的环回口路由,但R1,R2却因为AS-Path机制无法进行互访。
[R3]ip ip-prefix 1 permit 192.168.0.0 21
[R3]route-policy as1 permit node 10
[R3-route-policy]if-match ip-prefix 1
[R3-route-policy]apply as-path 2 overwrite
Warning: The AS-Path lists of routes to which this route-policy is applied will
be overwritten. Continue? [Y/N]Y
[R3-route-policy]q
[R3]route-policy as2 permit node 10
[R3-route-policy]if-match ip-prefix 1
[R3-route-policy]apply as-path 1 overwrite
Warning: The AS-Path lists of routes to which this route-policy is applied will
be overwritten. Continue? [Y/N]y
[R3-route-policy]q
[R3]route-policy as1 permit node 20
[R3-route-policy]route-policy as2 permit node 20
[R3-route-policy]q
[R3]bgp 3
[R3-bgp]peer 10.1.13.1 route-policy as1 export
[R3-bgp]peer 10.1.23.2 route-policy as2 export
主要的策略思想就是在走10.1.13.1 的时候把策略 192.168.0.0 21的AS path属性改为2
走10.1.23.2 的时候把策略 192.168.0.0 21的AS path属性改为1
网友评论