实验拓朴:
 
 

 

R1----------------- R2 --------------------R3
          IBGP          
全网OSPF
 
 
实验基本配置:

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 ospf 1
 router-id 1.1.1.1
 log-adjacency-changes
 network 10.1.12.0 0.0.0.255 area 0
!
router bgp 1
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 neighbor 10.1.12.2 remote-as 1
 no auto-summary
!

 

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 ospf 1
 router-id 2.2.2.2
 log-adjacency-changes
 network 10.1.12.0 0.0.0.255 area 0
 network 10.1.23.0 0.0.0.255 area 0
!
router bgp 1
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
 network 3.3.3.3 mask 255.255.255.255

 neighbor 10.1.12.1 remote-as 1
 no auto-summary
!

 

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 ospf 1
 router-id 3.3.3.3
 log-adjacency-changes
 network 3.3.3.3 0.0.0.0 area 0
 network 10.1.23.0 0.0.0.255 area 0
!

 

实验现象:

R1#sh ip bgp

BGP table version is 1, 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
* i3.3.3.3/32       10.1.23.3               65    100      0 i

R1#sh ip bgp 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
  Local
    10.1.23.3 (metric 128) from 10.1.12.2 (2.2.2.2)

      Origin IGP, metric 65, localpref 100, valid, internal, not synchronized

R1#sh ip route 3.3.3.3

Routing entry for 3.3.3.3/32
  Known via "ospf 1", distance 110, metric 129, type intra area
  Last update from 10.1.12.2 on Serial1/1, 00:01:01 ago
  Routing Descriptor Blocks:
  * 10.1.12.2, from 3.3.3.3, 00:01:01 ago, via Serial1/1
      Route metric is 129, traffic share count is 1

 

R3 lo0  3.3.3.3  R2 上通过 BGP network 通告给 R1 ,但 R1 收到的 OSPF 路由的 router-id (show ip route 3.3.3.3) 3.3.3.3 R1 BGP 路由的 router-id (show ip bgp 3.3.3.3) 2.2.2.2 ,两者不一致,未同步, show ip bgp 中有 3.3.3.3 ,但非最优路径   > .

 

更改 R2 BGP 配置中的 router-id 3.3.3.3 ,结果:

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
*>i3.3.3.3/32       10.1.23.3               65    100      0 i
R1#sh ip bgp 3.3.3.3
BGP routing table entry for 3.3.3.3/32, version 2
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x208
  Not advertised to any peer
  Local
    10.1.23.3 (metric 128) from 10.1.12.2 (3.3.3.3)

      Origin IGP, metric 65, localpref 100, valid, internal, synchronized, best

 

 

扩展

R2#sh ip route 3.3.3.3

Routing entry for 3.3.3.3/32
  Known via "ospf 1", distance 110, metric 65, type intra area
  Advertised by bgp 1
  Last update from 10.1.23.3 on Serial1/1, 00:12:34 ago
  Routing Descriptor Blocks:
  * 10.1.23.3, from 3.3.3.3, 00:12:34 ago, via Serial1/1
      Route metric is 65, traffic share count is 1
R2#sh ip bgp 3.3.3.3

BGP routing table entry for 3.3.3.3/32, version 2
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Advertised to non peer-group peers:
  10.1.12.1
  Local
    10.1.23.3 from 0.0.0.0 (2.2.2.2)

      Origin IGP, metric 65, localpref 100, weight 32768, valid, sourced, local, best

 

R2 在开启同步的情况下  show ip bgp 3.3.3.3 始终有> ,本地通告 net 3.3.3.3 ,同样OSPFBGProuter-id 不一致 , 但路由可以最优.
理解同步检查用在什么时候 IBGP 传过来的路由,进行检查 .