BGP的同步規則分析

   BGP的同步規則:學習自IBGP鄰居的路由在進入IGP路由表或者被宣告給BGP對等體以前,必須首先經過IGP來知曉該路由,下面經過實驗進行分析。ide

   wKioL1SVR5jRgXCOAACyR5SV2y4919.jpg

如上圖:oop

R1R2之間是EBGP鄰居關係,R2R3之間是IBGP鄰居關係,而R1通告1.1.1.1/32的路由,R3通告3.3.3.3/32的路由,基礎配置略,R2的同步開啓的時候(高版本的IOS默認狀況下同步是關閉的),查看R1R2的路由狀況;學習

R1#show ip bgpspa

BGP table version is 2, local router ID is 1.1.1.1code

Status codes: s suppressed, d damped, h history, * valid, > best,i - internal,router

              r RIB-failure, SStalexml

Origin codes: i - IGP, e - EGP, ? - incompleteblog

   Network          Next Hop            Metric LocPrf Weight Pathip

*> 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,以下:

R2(config)#ip route3.3.3.3 255.255.255.255 23.1.1.2

如今再次查看R2R1BGP路由狀況

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的同步關閉,並刪除配置的靜態路,配置以下:

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 *

清除鄰居以後,再次查看R2R1BGP路由狀況:

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上配置靜態路由:

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

再次查看R3BGP路由狀況:

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路由表的。

相關文章
相關標籤/搜索