实验说明
Purpose: IBGP learned routes are not installed in the IP routing table if the route has not been learned by an IGP or if the advertised next hop is inaccessible. This is called synchronization.
如果没有从IGP 中学到这些路由,或者是下一跳不可达, IBGP 学习到的路由就不会放入IP路由表中,这叫同步. BGP表中路由也不会最优,同时也不会通告路由信息给EBGP 邻居(这里强调是EBGP邻居,是因为不通告给IBGP邻居的原因是BGP的水平分割)
 
 
实验拓朴:
 
 
R1----------------- R2 --------------------R3
              IBGP                          EBGP
 

实验基本配置:
R1
interface Loopback0
 ip address 1.1.1 .1 255.255.255.255
!
interface Serial1/1
 ip address 10.1.12 .1 255.255.255.0
!  
router bgp 1
 bgp router-id 1.1.1 .1
 bgp log-neighbor-changes
 network 1.1.1 .1 mask 255.255.255.255
 neighbor 10.1.12 .2 remote-as 1
!  
 
R2
interface Loopback0
 ip address 2.2.2 .2 255.255.255.255
!
interface Serial1/0
 ip address 10.1.12 .2 255.255.255.0
!
interface Serial1/1
 ip address 10.1.23 .2 255.255.255.0
!
router bgp 1
 bgp router-id 2.2.2 .2
 bgp log-neighbor-changes
 network 2.2.2 .2 mask 255.255.255.255
 neighbor 10.1.12 .1 remote-as 1
 neighbor 10.1.23 .3 remote-as 2
!
 
R3
interface Loopback0
 ip address 3.3.3 .3 255.255.255.255
!
interface Serial1/0
 ip address 10.1.23 .3 255.255.255.0
!
router bgp 2
 bgp router-id 3.3.3 .3
 bgp log-neighbor-changes
 network 3.3.3 .3 mask 255.255.255.255
 neighbor 10.1.23 .2 remote-as 1
!
 
实验现象:
R1#sh 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
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
* i 2.2.2 .2/32       10.1.12 .2                0    100      0 i
* i 3.3.3 .3/32       10.1.23 .3                0    100      0 2 i
R1#sh ip bg p 2.2.2 .2
BGP routing table entry for 2.2.2 .2/32, version 0
Paths: (1 available, no best path)
  Not advertised to any peer
  Local
    10.1.12 .2 from 10.1.12.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal, not synchronized
R1#sh ip bg p 3.3.3 .3
BGP routing table entry for 3.3.3 .3/32, version 0
Paths: (1 available, no best path)
  Not advertised to any peer
  2
    10.1.23 .3 (inaccessible) from 10.1.12.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal, not synchronized
R1#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF , IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, su - IS-IS summary, 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 - periodic downloaded static route
 
Gateway of last resort is not set
 
     1.0.0 .0/32 is subnetted, 1 subnets
C       1.1.1 .1 is directly connected, Loopback0
     10.0.0 .0/24 is subnetted, 1 subnets
C       10.1.12 .0 is directly connected, Serial1/1
R1#
 
R1结论:
在同步开启时, 2.2.2 .2/323.3.3.3/32 都因未从IGP中学到相应路由,因此not synchronized
BGP表中没有> best IP路由表中无相应路由.
 
关闭同步:no synchronization
R1#sh 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
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
*>i 2.2.2 .2/32       10.1.12 .2                0    100      0 i
* i 3.3.3 .3/32       10.1.23 .3                0    100      0 2 i
R1#sh ip bg p 3.3.3 .3
BGP routing table entry for 3.3.3 .3/32, version 0
Paths: (1 available, no best path)
  Not advertised to any peer
  2
    10.1.23 .3 (inaccessible) from 10.1.12.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal
R1#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF , IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, su - IS-IS summary, 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 - periodic downloaded static route
 
Gateway of last resort is not set
 
     1.0.0 .0/32 is subnetted, 1 subnets
C       1.1.1 .1 is directly connected, Loopback0
     2.0.0 .0/32 is subnetted, 1 subnets
B       2.2.2 .2 [200/0] vi a 10.1.12 .2, 00:00:21
     10.0.0 .0/24 is subnetted, 1 subnets
C       10.1.12 .0 is directly connected, Serial1/1
 
R1 依然没有 3.3.3 .3/32 的路由,是R1不知道下一跳10.1.23.3的原因,这里增加静态路由
ip route 10.1.23 .0 255.255.255.0 s1/1
 
R1#sh ip bgp
BGP table version is 4, local router ID is 1.1.1 .1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
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
*>i 2.2.2 .2/32       10.1.12 .2                0    100      0 i
*>i 3.3.3 .3/32       10.1.23 .3                0    100      0 2 i
 
 
R2结论
在同步开启时, 1.1.1 .1/32未从IGP中学到相应路由,因此显示not synchronized BGP表中没有> best IP路由表中无相应路由.   3.3.3 .3/32 EBGP邻居学到,BGP表和IP路由表都有相应路由信息.
 
R2#sh 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
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
* i 1.1.1 .1/32       10.1.12 .1                0    100      0 i
*> 2.2.2 .2/32       0.0.0 .0                  0         32768 i
*> 3.3.3 .3/32       10.1.23 .3                0             0 2 i
R2#sh ip bg p 1.1.1 .1
BGP routing table entry for 1.1.1 .1/32, version 0
Paths: (1 available, no best path)
  Not advertised to any peer
  Local
    10.1.12 .1 from 10.1.12.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, internal, not synchronized
R2#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF , IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, su - IS-IS summary, 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 - periodic downloaded static route
 
Gateway of last resort is not set
 
     2.0.0 .0/32 is subnetted, 1 subnets
C       2.2.2 .2 is directly connected, Loopback0
     3.0.0 .0/32 is subnetted, 1 subnets
B       3.3.3 .3 [20/0] vi a 10.1.23 .3, 00:10:10
     10.0.0 .0/24 is subnetted, 2 subnets
C       10.1.12 .0 is directly connected, Serial1/0
C       10.1.23 .0 is directly connected, Serial1/1
 
关闭同步:no synchronization
R2#sh ip bgp
BGP table version is 4, local router ID is 2.2.2 .2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*>i 1.1.1 .1/32       10.1.12 .1                0    100      0 i
*> 2.2.2 .2/32       0.0.0 .0                  0         32768 i
*> 3.3.3 .3/32       10.1.23 .3                0             0 2 i
R2#
R2#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF , IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, su - IS-IS summary, 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 - periodic downloaded static route
 
Gateway of last resort is not set
 
     1.0.0 .0/32 is subnetted, 1 subnets
B       1.1.1 .1 [200/0] vi a 10.1.12 .1, 00:00:11
     2.0.0 .0/32 is subnetted, 1 subnets
C       2.2.2 .2 is directly connected, Loopback0
     3.0.0 .0/32 is subnetted, 1 subnets
B       3.3.3 .3 [20/0] vi a 10.1.23 .3, 00:10:38
     10.0.0 .0/24 is subnetted, 2 subnets
C       10.1.12 .0 is directly connected, Serial1/0
C       10.1.23 .0 is directly connected, Serial1/1
 
 
R3结论
R3#sh ip bgp
BGP table version is 8, local router ID is 3.3.3 .3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
 
   Network          Next Hop            Metric LocPrf Weight Path
*> 1.1.1 .1/32       10.1.23 .2                              0 1 i
*> 2.2.2 .2/32       10.1.23 .2                0             0 1 i
*> 3.3.3 .3/32       0.0.0 .0                  0         32768 i
R3#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF , IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, su - IS-IS summary, 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 - periodic downloaded 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] vi a 10.1.23 .2, 00:00:22
     2.0.0 .0/32 is subnetted, 1 subnets
B        2.2.2 .2 [20/0] vi a 10.1.23 .2, 00:10:49
     3.0.0 .0/32 is subnetted, 1 subnets
C       3.3.3 .3 is directly connected, Loopback0
     10.0.0 .0/24 is subnetted, 1 subnets
C       10.1.23 .0 is directly connected, Serial1/0
R3#
 
注:
1.实验中没有做互ping 的实验,如需要互相ping 通的话,还需相应手工增加目的路由。
2.在开启同步的情况下,R1R2之间可运行IGP路由协议,学到相应路由达到同步结果.