实验配置:
R2:
interface Ethernet0
ip address 23.23.23.2 255.255.255.0
interface Serial1
ip address 24.24.24.2 255.255.255.0
router rip
version 2
network 23.0.0.0
no auto-summary
router bgp 123
bgp router-id 2.2.2.2
bgp cluster-id 3355443202
bgp log-neighbor-changes
 neighbor 23.23.23.3 remote-as 123
 neighbor 24.24.24.4 remote-as 140
 
R3:
interface Ethernet0
ip address 23.23.23.3 255.255.255.0
interface Serial1
ip address 35.35.35.3 255.255.255.0
router rip
version 2
network 23.0.0.0
no auto-summary
router bgp 123
no synchronization
bgp router-id 3.3.3.3
bgp log-neighbor-changes
neighbor 23.23.23.2 remote-as 123
neighbor 35.35.35.5 remote-as 150
no auto-summary
 
R4:
interface Serial0
ip address 24.24.24.4 255.255.255.0
router bgp 140
bgp router-id 4.4.4.4
bgp cluster-id 3355443203
bgp log-neighbor-changes
neighbor 24.24.24.2 remote-as 123
 
R5:
interface Loopback0
ip address 105.5.0.5 255.255.0.0
interface Serial0
ip address 35.35.35.5 255.255.255.0
router bgp 150
no synchronization
bgp router-id 5.5.5.5
bgp log-neighbor-changes
network 105.5.0.0 mask 255.255.0.0
neighbor 35.35.35.3 remote-as 123
no auto-summary
 
此时的实验结果为:
R5#show ip bgp
BGP table version is 2, local router ID is 5.5.5.5
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
*> 105.5.0.0/16      0.0.0.0                  0         32768 i
 
R3#show ip bgp
BGP table version is 2, local router ID is 3.3.3.3
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
*> 105.5.0.0/16      35.35.35.5               0             0 150 i
 
R2#show ip bgp
BGP table version is 1, 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
* i105.5.0.0/16      35.35.35.5               0    100      0 150 i
此时在 R2上的bgp路由并没有优化,原因为下一跳不可达。
 
R4#show ip bgp
R4上的 bgp路由为空,因为R2不会将没有优化的路由向下传递。
 
要使得R2上能学到优化的路由,要配置以下参数:
R3(config-router)# neighbor 23.23.23.2 next-hop-self   向邻居指明下一跳是自己
R2(config-router)# no synchronization   关闭同步
   同步:同步指 R2不能从另一个AS种以IGP:RIP协议学习到路由时,要关闭同步,不然R2上学到的bgp路由不能为优化
 
此时的实验结果为:
R2#show ip bgp
BGP table version is 2, 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
*>i105.5.0.0/16      23.23.23.3               0    100      0 150 i
 
R4#show ip bgp
BGP table version is 2, local router ID is 4.4.4.4
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
*> 105.5.0.0/16      24.24.24.2                             0 123 150 i
 
R3#show ip bgp summary
Neighbor         V    AS MsgRcvd MsgSent   TblVer InQ OutQ Up/Down State/PfxRcd
23.23.23.2       4   123      19      21        2    0    0 00:16:00        0
35.35.35.5       4   150      20      19        2    0    0 00:15:12        1