BGP的同步规则:学习自IBGP邻居的路由在进入IGP路由表或者被宣告给BGP对等体之前,必须首先通过IGP来知晓该路由,下面通过实验进行分析。
如上图: R1与R2之间是EBGP邻居关系,R2和R3之间是IBGP邻居关系,而R1通告1.1.1.1/32的路由,R3通告3.3.3.3/32的路由,基础配置略,当R2的同步开启的时候(高版本的IOS默认情况下同步是关闭的),查看R1、R2的路由情况; R1#show ip bgp BGP table version is 2, local router ID is 1.1.1.1 Status codes: s suppressed, d damped, h history, * valid, > best,i - internal, r RIB-failure, SStale 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 R2#show ip bgp BGP table version is 6, 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 12.1.1.1 0 0 10 i * i3.3.3.3/32 23.1.1.2 0 100 0 i R2#show ip route Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRPexternal, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA externaltype 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type1, E2 - OSPF external type 2 i - IS-IS, su - IS-ISsummary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area,* - candidate default, U - per-user static route o - ODR, P - periodicdownloaded static route Gateway of last resort is not set 1.0.0.0/32 is subnetted,1 subnets B 1.1.1.1 [20/0] via12.1.1.1, 00:05:15 2.0.0.0/32 is subnetted,1 subnets C 2.2.2.2 is directlyconnected, Loopback0 23.0.0.0/30 is subnetted,1 subnets C 23.1.1.0 is directlyconnected, Serial1/0 12.0.0.0/30 is subnetted,1 subnets C 12.1.1.0 is directlyconnected, FastEthernet0/0 R1并没有收到3.3.3.3/32的路由,而R2收到3.3.3.3/32的路由,但是不是最优的,只是可用,并且R2上的IGP表中没有3.3.3.3/32的路由,这是由于BGP的同步规则,在同步开启的情况下,从IBGP学到的路由是不会传递给他的EBGP邻居的,除非IGP路由信息中有该路由; 现在R2上配置一条静态路由3.3.3.3/32,下一跳指向R3,如下: 1
| R2(config)#ip route3.3.3.3 255.255.255.255 23.1.1.2
|
现在再次查看R2及R1的BGP路由情况
R2#show ip bgp BGP table version is 8, local router ID is 2.2.2.2 Status codes: s suppressed, d damped, h history, * valid, > best,i - internal, r RIB-failure, SStale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 12.1.1.1 0 0 10 i r>i3.3.3.3/32 23.1.1.2 0 100 0 i R1#show ip bgp BGP table version is 3, local router ID is 1.1.1.1 Status codes: s suppressed, d damped, h history, * valid, > best,i - internal, r RIB-failure, SStale 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 *> 3.3.3.3/32 12.1.1.2 0 23 i R2上的3.3.3.3/32路由成为最优的,并且R1上收到了3.3.3.3/32的路由,并且也是最优的。 因此验证了,从IBGP邻居学到的路由,除非也从IGP学习到该路由,否则不会把该路由装载到BGP路由表中,也不会传递给他的EBGP邻居。 上述情况是在R2同步开启的情况下,现将R2的同步关闭,并删除配置的静态路,配置如下: 1
2
3
| R2(config)#no ip route 3.3.3.3 255.255.255.255 23.1.1.2
R2(config)#router bgp 23
R2(config-router)#no synchronization
|
R2#clear ip bgp *
清除邻居之后,再次查看R2及R1的BGP路由情况: R2#show ip bgp BGP table version is 3, local router ID is 2.2.2.2 Status codes: s suppressed, d damped, h history, * valid, > best,i - internal, r RIB-failure, SStale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 1.1.1.1/32 12.1.1.1 0 0 10 i *>i3.3.3.3/32 23.1.1.2 0 100 0 i R1#show ip bgp BGP table version is 5, local router ID is 1.1.1.1 Status codes: s suppressed, d damped, h history, * valid, > best,i - internal, r RIB-failure, SStale 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 *> 3.3.3.3/32 12.1.1.2 0 23 i R3#show ip bgp BGP table version is 9, local router ID is 3.3.3.3 Status codes: s suppressed, d damped, h history, * valid, > best,i - internal, r RIB-failure, SStale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path * i1.1.1.1/32 12.1.1.1 0 100 0 10 i *> 3.3.3.3/32 0.0.0.0 0 32768 i R3收到1.1.1.1/32的路由不优,下一跳是12.1.1.1,在R3上该下一跳地址是不可达的。现采取下面两种方式,然后再次来查看BGP路由情况; 现在R3上配置静态路由: 1
2
3
4
| R3(config)#ip route 12.1.1.1 255.255.255.255 23.1.1.1
或者
R2(config)#router bgp 23
R2(config-router)#neighbor 23.1.1.2 next-hop-self
|
再次查看R3的BGP路由情况: R3#show ip bgp BGP table version is 10, local router ID is 3.3.3.3 Status codes: s suppressed, d damped, h history, * valid, > best,i - internal, r RIB-failure, SStale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *>i1.1.1.1/32 12.1.1.1 0 100 0 10 i *> 3.3.3.3/32 0.0.0.0 0 32768 i 从上述输出可知,当BGP同步关闭,并且IGP表中没有3.3.3.3/32的路由情况下,从IBGP学到的路由,可以传递给EBGP邻居,但是在R3上看见1.1.1.1/32的路由并不是最优的,其原因是下一跳不可达,当配置静态路由或者针对R3修改IBGP的下一跳时,1.1.1.1/32就变成最优的路由。
因此验证了,如果不是通告IGP学到的路由,或者下一跳不可达,从IBGP邻居学到的路由是不会装载至BGP路由表的。
|