9、发现只要去traceroute 跟踪一下通过10.1.255.5学到的地址,它就会变成走10.1.255.9,只要路由表显示通过10.1.255.9 的话。到目的网段就能通。但过一会就又会变成走10.1.255.5了。因为我们之前手动地指定了它的邻居,所以当用路径跟踪这条路由后会发现自己的邻居路由器的地址是10.1.255.9,进而把10.1.255.9当作最佳路径来转发了。
 

R4#traceroute 10.1.255.4
 
Type escape sequence to abort.
Tracing the route to 10.1.255.4
 
1 10.1.255.9 36 msec 56 msec 20 msec
  2
R4#sh ip bgp
BGP table version is 245, local router ID is 10.1.255.13
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
* i10.1.255.0/30    10.1.255.5               0    100      0 i
* i10.1.255.4/30    10.1.255.5               0    100      0 i
*>i                 10.1.255.9               0    100      0 i (成为最佳路径了)
*> 10.1.255.8/30    0.0.0.0                  0         32768 i
* i                 10.1.255.9               0    100      0 i
*> 10.1.255.12/30   0.0.0.0                  0         32768 i
*                   10.1.255.14              0             0 64514 i
* i130.130.1.0/24   10.1.255.1               0    100      0 64512 i
*> 150.150.1.0/24   10.1.255.14              0             0 64514 i
R4#
 
R4#sh ip bgp 10.1.255.4
BGP routing table entry for 10.1.255.4/30, version 317
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Flag: 0x840
  Advertised to update-groups:
     2        
  Local
    10.1.255.5 (inaccessible) from 10.1.255.5 (10.1.255.5)     (发现选这条就是inaccessiable)
      Origin IGP, metric 0, localpref 100, valid, internal
  Local
    10.1.255.9 from 10.1.255.9 (10.1.255.9)      (选这条就可以通了)
      Origin IGP, metric 0, localpref 100, valid, internal, best
 
10、过一会之后,我们再看一下bgp表:
 
R4#sh ip bgp
BGP table version is 219, local router ID is 10.1.255.13
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
*>i10.1.255.0/30    10.1.255.5               0    100      0 i
*>i10.1.255.4/30    10.1.255.5               0    100      0 i
* i                 10.1.255.9               0    100      0 i(没有成为最佳路径了,这样就不通)
*> 10.1.255.8/30    0.0.0.0                  0         32768 i
* i                 10.1.255.9               0    100      0 i
*> 10.1.255.12/30   0.0.0.0                  0         32768 i
*                   10.1.255.14              0             0 64514 i
* i130.130.1.0/24   10.1.255.1               0    100      0 64512 i
*> 150.150.1.0/24   10.1.255.14              0             0 64514 i
11 、再来看一下130.130.1.0/24BGP表中的情况:
R4#sh ip bgp 130.130.1.0
BGP routing table entry for 130.130.1.0/24, version 0
Paths: (1 available, no best path)
  Not advertised to any peer
  64512
    10.1.255.1 (inaccessible) from 10.1.255.5 (10.1.255.5)(只有一条路径,显示下一跳不可达。)
      Origin IGP, metric 0, localpref 100, valid, internal
 
12 、再来看一下到10.1.255.0/30bgp表:
 
R4#sh ip bgp 10.1.255.0
BGP routing table entry for 10.1.255.0/30, version 374
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
  Not advertised to any peer
  Local
    10.1.255.5 from 10.1.255.5 (10.1.255.5)
      Origin IGP, metric 0, localpref 100, valid, internal, best(虽然是最佳的,但是下一跳是 错误的)
 
R4#sh ip bgp 10.1.255.5
BGP routing table entry for 10.1.255.4/30, version 1053
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Flag: 0x840
  Advertised to update-groups:
     2        
  Local
    10.1.255.5 (inaccessible) from 10.1.255.5 (10.1.255.5)(在这里10.1.255.5并不可达。)
      Origin IGP, metric 0, localpref 100, valid, internal
  Local
    10.1.255.9 from 10.1.255.9 (10.1.255.9)
      Origin IGP, metric 0, localpref 100, valid, internal, best
R4#
 
13、通过上图分析,发现其实这些路由都存在于BGP表当中,能不能ping 通就看BGP有没有把它当作最佳路径和下一跳是否正确与可达。
三、造成以上的原因是:当两条路由度量值(metric)都相等时,而且都来自于相同的自治系统的iBGP的邻居,那么会优先选择router-id较小的iBGP邻居的路由。从之前的图中我们可以看到R4àR3R4àR2 (我们手动指定的邻居产生的) metric都为0
 
1、通过上述论述,我们需要在R2上指定一个较高的router-id,以让R4放弃从R2而选择R3这条路径,那么我们要把R2router-id指定成比10.1.255.5 要高。
R2(config)#router bgp 64513
R2(config-router)#bgp router-id 172.1.255.5(指成172.1.255.5的话比10.1.255.9要高)
 
2、现在再来看一下R4上的路由表和BGP表,现在能全部学到了:
     10.0.0.0/30 is subnetted, 4 subnets
B       10.1.255.4 [200/0] via 10.1.255.9, 00:03:21
B       10.1.255.0 [200/0] via 10.1.255.5, 00:02:28
C       10.1.255.12 is directly connected, Serial1/1
C       10.1.255.8 is directly connected, Serial1/0
     130.130.0.0/24 is subnetted, 1 subnets
B       130.130.1.0 [200/0] via 10.1.255.1, 00:02:23
     150.150.0.0/24 is subnetted, 1 subnets
B       150.150.1.0 [20/0] via 10.1.255.14, 03:23:35  
 
R4#sh ip bgp
BGP table version is 1083, local router ID is 10.1.255.13
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
*>i10.1.255.0/30    10.1.255.5               0    100      0 i
* i10.1.255.4/30    10.1.255.5               0    100      0 i
*>i                 10.1.255.9               0    100      0 i
*> 10.1.255.8/30    0.0.0.0                  0         32768 i
* i                 10.1.255.9               0    100      0 i
*> 10.1.255.12/30   0.0.0.0                  0         32768 i
*                   10.1.255.14              0             0 64514 i
*>i130.130.1.0/24   10.1.255.1               0    100      0 64512 i
*> 150.150.1.0/24   10.1.255.14              0             0 64514 i
R4#
 
3、从上面看出学到的10.1.255.4/30 是通过10.1.255.9/30 这个地址,这个地址是可达的。而10.1.255.0/30是通过10.1.255.5/30,之前是不可达。现在我们通过改router-id之后就变成可达的了:
R4#sh ip bgp 10.1.255.0
BGP routing table entry for 10.1.255.0/30, version 1082
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Advertised to update-groups:
     2        
  Local
    10.1.255.5 from 10.1.255.5 (192.16.255.5)
      Origin IGP, metric 0, localpref 100, valid, internal, best
R4#ping 10.1.255.1
 
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.255.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/43/72 ms
R4#
 
四、总结:IBGP邻居学来的信息,不会传递给另外的IBGP邻居,需要再手动去指定邻居,BGP这条路径能不能通,要看这条路径否成为最佳路径和下一跳是否正确与可达。当某个路由器到达一个网络有两条路径,而且两条路由度量值(metric)都相等时,并且都来自于相同的自治系统的iBGP的邻居,那么会优先选择router-id较小的iBGP邻居的路由。