实验拓扑:

IP路由和BGP路由 路由器bgp协议配置_静态路由

路由器各接口IP配置:

R1#conf t
R1(config)#interface s1/0
R1(config-if)# clock rate 64000
R1(config-if)#ip address 12.52.52.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#interface s1/1
R1(config-if)#ip address 13.52.52.1 255.255.255.0
R1(config-if)# clock rate 64000
R1(config-if)#no shutdown
R1(config)#interface lo0
R1(config-if)#ip address 1.1.1.1 255.255.255.0 
R1(config-if)#end
 
R2#conf t
R2(config)#int lo0
R2(config-if)#ip address 2.2.2.2 255.255.255.0 
R2(config-if)#interface s1/0
R2(config-if)#ip address 12.52.52.2 255.255.255.0
R2(config-if)#no shutdown 
R2(config-if)#interface s1/1
R2(config-if)#ip address 24.52.52.2 255.255.255.0
R2(config-if)# clock rate 64000
R2(config-if)#no shutdown
R2(config-if)#
 
R3#conf t
R3(config)#inter lo0
R3(config-if)#ip address 3.3.3.3 255.255.255.0 
R3(config-if)#interface s1/1
R3(config-if)#ip address 13.52.52.3 255.255.255.0
R3(config-if)#no shut
R3(config-if)#interface s1/0
R3(config-if)#ip address 35.52.52.3 255.255.255.0
R3(config-if)# clock rate 64000
 
R3(config-if)#no shutdown
R3(config-if)#
 
R4#conf t
R4(config)#inter lo0
R4(config-if)#ip address 4.4.4.4 255.255.255.0
R4(config-if)#interface s1/1
R4(config-if)#ip address 24.52.52.4 255.255.255.0
R4(config-if)#no shutdown
R4(config)#interface lo1
R4(config-if)#ip address 172.52.1.1 255.255.255.0   
R4(config-if)#ip address 172.52.9.1 255.255.255.0 secondary 
R4(config-if)#ip address 172.52.4.1 255.255.252.0 secondary
R4(config-if)#ip address 172.52.10.1 255.255.254.0 secondary
 
R5#conf t
R5(config)#int lo0                         
R5(config-if)#ip address 5.5.5.5 255.255.255.0
R5(config-if)#interface s1/0
R5(config-if)#ip address 35.52.52.5 255.255.255.0
R5(config-if)#no shutdown 
R5(config-if)#
 
3、在路由器 R2 和 R4 上配置 BGP 邻居关系。参考命令如下:
R2(config)#router bgp 1052
R2(config-router)#bgp router 
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#neighbor 24.52.52.4 remot
R2(config-router)#neighbor 24.52.52.4 remote-as 4052
 
R4(config)#router bgp 4052
R4(config-router)#bgp router-id 4.4.4.4
R4(config-router)#neighbor 24.52.52.2 remote
R4(config-router)#neighbor 24.52.52.2 remote-as 1052

 

 

 

问题 1:配置后在 R4 上查看邻居关系,R2 和 R4 之间是否形成邻居关系?

     参考命令:show  ip  bgp   summary

       答:此时在R4上已经能够看到邻居R2

IP路由和BGP路由 路由器bgp协议配置_静态路由_02

IP路由和BGP路由 路由器bgp协议配置_静态路由_03

4、在 R1、R2、R3 之间配置 OSPF 路由选择协议,使各路由器之间可以进行通信。

R1(config)#router ospf 52
R1(config-router)#network 12.52.52.0 0.0.0.255 area 0
R1(config-router)#network 1.1.1.0 0.0.0.255 area 0   
R1(config-router)#network 13.52.52.0 0.0.0.255 area 0
 
R2(config)#router ospf 52
R2(config-router)#network 2.2.2.0 0.0.0.255 area 0
R2(config-router)#network 12.52.52.0 0.0.0.255 area 0
R2(config-router)#network 24.52.52.0 0.0.0.255 area 0
R2(config-router)#
 
 
R3(config)#router ospf 52
R3(config-router)#network 13.52.52.0 0.0.0.255 area 0
R3(config-router)#
*May  7 12:15:02.067: %OSPF-5-ADJCHG: Process 52, Nbr 1.1.1.1 on Serial1/1 from LOADING to FULL, Loading Done
R3(config-router)#network 3.3.3.0 0.0.0.255 area 0

IP路由和BGP路由 路由器bgp协议配置_R3_04

IP路由和BGP路由 路由器bgp协议配置_静态路由_05

 

5、在 R2 和 R3 之间使用回环接口配置邻居关系。

R2(config-router)#router bgp 1052
R2(config-router)#bgp router 
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#n
R2(config-router)#ne
R2(config-router)#neigh
R2(config-router)#neighbor 3.3.3.3 remote
R2(config-router)#neighbor 3.3.3.3 remote-as 1052
R2(config-router)#nei
R2(config-router)#neighbor 3.3.3.3 upda
R2(config-router)#neighbor 3.3.3.3 update-source Loopback0
 
R3(config-router)#router bgp 1052
R3(config-router)#bgp router 
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neigh                                 
R3(config-router)#neighbor 2.2.2.2 remote
R3(config-router)#neighbor 2.2.2.2 remote-as 1052
R3(config-router)#neighbor 2.2.2.2 update-source Loopback0 
*May  7 12:26:45.091: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Up 
R3(config-router)#neighbor 2.2.2.2 update-source Loopback0

 

6、参考步骤 5 的配置在 R3 和 R5 之间使用回环接口配置邻居关系。

R3(config-router)#router bgp 1052
R3(config-router)#bgp router 
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neig
R3(config-router)#neighbor 5.5.5.5 remo
R3(config-router)#neighbor 5.5.5.5 remote
R3(config-router)#neighbor 5.5.5.5 remote-as 5052
R3(config-router)#neighbor 5.5.5.5 update-source Loopback0
 
R5(config-if)#router bgp 5052
R5(config-router)#bgp router
R5(config-router)#bgp router-id 5.5.5.5
R5(config-router)#neigh
R5(config-router)#neighbor 3.3.3.3 remo
R5(config-router)#neighbor 3.3.3.3 remote
R5(config-router)#neighbor 3.3.3.3 remote-as 1052
R5(config-router)#neigh
R5(config-router)#neighbor 3.3.3.3 upda
R5(config-router)#neighbor 3.3.3.3 update-source 
R5(config-router)#neighbor 3.3.3.3 update-source Lo 
R5(config-router)#neighbor 3.3.3.3 update-source Loopback0

 

 

 

 

 

 

问题 2:步骤 6 配置后,在 R3 和 R5 上查看 BGP 邻居关系,能否形成邻居关系?为什么?

答:

IP路由和BGP路由 路由器bgp协议配置_OSPF_06

IP路由和BGP路由 路由器bgp协议配置_R3_07

7、在 R3 和 R5 上添加静态路由使得回环接口之间进行通信。参考命令:

R3(config)#ip route 5.5.5.5 255.255.255.255 s1/0
 
R5(config)#ip route 3.3.3.3 255.255.255.255 s1/0

 

问题 3:步骤 7 配置后,在 R3 和 R5 上查看 BGP 邻居关系,能否形成邻居关系?为什么?

答:

IP路由和BGP路由 路由器bgp协议配置_IP路由和BGP路由_08

 

 

8、修改 EBGP 的默认跳数,参考命令:

R3(config)#router bgp 1052
R3(config-router)#nei
R3(config-router)#neighbor 5.5.5.5 eb
R3(config-router)#neighbor 5.5.5.5 ebgp-multihop 2
 
R5(config)#router bgp 5052
R5(config-router)#nei
R5(config-router)#neighbor 3.3.3.3 eb
R5(config-router)#neighbor 3.3.3.3 ebgp-multihop 2
R5(config-router)#
*May  7 12:42:46.291: %BGP-5-ADJCHANGE: neighbor 3.3.3.3 Up

 

9、将 R4 和 R5 上的所有回环接口都宣告进 BGP,参考命令如下:

R4(config)#router bgp 4052
R4(config-router)#network 4.4.4.0 mask 255.255.255.0
R4(config-router)#network 172.52.4.0 mask 255.255.252.0
R4(config-router)#network 172.52.10.0 mask 255.255.254.0
R4(config-router)#network 172.52.1.0 mask 255.255.255.0
R4(config-router)#network 172.52.9.0 mask 255.255.255.0
 
R5(config-router)#router bgp 5052
R5(config-router)#network 5.5.5.0 mask 255.255.255.0

 

问题 4:在 R4 上查看路由表,能否看到 BGP 生成的路由?在 R2 上查看路由表,能看到几条 BGP 路由,缺少哪个网络地址的路由?

答:

IP路由和BGP路由 路由器bgp协议配置_OSPF_09

IP路由和BGP路由 路由器bgp协议配置_R3_10

 

 

 

 

 

问题 5:在 R4 上查看 BGP 表,哪些是最优?哪些不是?什么原因造成的?

答:

IP路由和BGP路由 路由器bgp协议配置_R3_11

 

10、在 R2 和 R3 上关闭 BGP 同步,参考命令如下:

R2(config)#router bgp 1052
R2(config-router)#no syn
R2(config-router)#no synchronization
 
R3(config)#router bgp 1052
R3(config-router)#no sy
R3(config-router)#no synchronization

11、在 R2 和 R3 上配置宣告 IBGP 下一跳为自己,参考命令如下:

R2(config-router)#neigh
R2(config-router)#neighbor 3.3.3.3 next 
R2(config-router)#neighbor 3.3.3.3 next-hop-self
 
R3(config-router)#neighbor 2.2.2.2 next
R3(config-router)#neighbor 2.2.2.2 next-hop-self

问题 6:此时在 R4 上能否看到 R5 上的路由?

答:

IP路由和BGP路由 路由器bgp协议配置_静态路由_12

 

问题 7:在 R4 上以 4.4.4.4 为源 ping 5.5.5.5,能否 ping 通?为什么?

答:

IP路由和BGP路由 路由器bgp协议配置_静态路由_13

12、在 R1 上配置 IBGP,使它和 R2 和 R3 互为邻居,在 R2 和 R3 上添加 R1 为邻居。

R1(config)#router bgp 1052
R1(config-router)#bgp rou
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#nei
R1(config-router)#neighbor zjb pee
R1(config-router)#neighbor zjb peer-group 
R1(config-router)#neigh
R1(config-router)#neighbor zjb remo
R1(config-router)#neighbor zjb remote
R1(config-router)#neighbor zjb remote-as 1052
R1(config-router)#neig
R1(config-router)#neighbor zjb up
R1(config-router)#neighbor zjb update-source lo0
R1(config-router)#
R1(config-router)#neig
R1(config-router)#neighbor zjb ne
R1(config-router)#neighbor zjb next-hop-self
R1(config-router)#neigh
R1(config-router)#neighbor 2.2.2.2 peer
R1(config-router)#neighbor 2.2.2.2 peer-group zjb
R1(config-router)#neighbor 3.3.3.3 peer-group zjb
 
R2(config-router)#router bgp 1052
R2(config-router)#bgp rout
R2(config-router)#bgp router-id 2.2.2.2 
R2(config-router)#neigh
R2(config-router)#neighbor zjb p             
R2(config-router)#neighbor zjb pee
R2(config-router)#neighbor zjb peer-group 
R2(config-router)#neigh                   
R2(config-router)#neighbor zjb remote
R2(config-router)#neighbor zjb remote-as  1052
R2(config-router)#neigh
R2(config-router)#neighbor zjb up
R2(config-router)#neighbor zjb update-source lo0
R2(config-router)#neigh
R2(config-router)#neighbor zjb next
R2(config-router)#neighbor zjb next-hop-self
R2(config-router)#neigh
R2(config-router)#neighbor 1.1.1.1 pee
R2(config-router)#neighbor 1.1.1.1 peer-group  zjb
R2(config-router)#neighbor 3.3.3 peer-group  zjb  
*May  7 13:04:00.471: %BGP-5-ADJCHANGE: neighbor 1.1.1.1 Up 
R2(config-router)#neighbor 3.3.3.3 peer-group  zjb
R2(config-router)#
*May  7 13:04:05.703: %BGP-5-ADJCHANGE: neighbor 3.3.3.3 Down Member added to peergroup
 
R3(config-router)#router bgp 1052
R3(config-router)#bgp rou
R3(config-router)#bgp router-id 3.3.3.3 
R3(config-router)#nei
R3(config-router)#neighbor zjb peer
R3(config-router)#neighbor zjb peer-group 
R3(config-router)#nei
R3(config-router)#neighbor zjb remo
R3(config-router)#neighbor zjb remote
R3(config-router)#neighbor zjb remote-as 1052
R3(config-router)#niegh
R3(config-router)#nei  
R3(config-router)#neighbor zjb up            
R3(config-router)#neighbor zjb update-source lo0
R3(config-router)#neigh
R3(config-router)#neighbor zjb ne  
R3(config-router)#neighbor zjb next-hop-self
R3(config-router)#neigh 2.2.2.2 pee
R3(config-router)#neigh 2.2.2.2 peer-group  zjb
R3(config-router)#neigh 2.2.2.2 peer-group  zjb
*May  7 13:07:26.643: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Down Member added to peergroup
R3(config-router)#neigh 1 peer-group  zjb      
*May  7 13:07:30.567: %BGP-5-ADJCHANGE: neighbor 2.2.2.2 Up 
R3(config-router)#neigh 1.1.1.1 peer-group  zjb

 

 

 

问题 8:此时在 R4 上以 4.4.4.4 为源 ping 5.5.5.5,能否 ping 通?

答:能

IP路由和BGP路由 路由器bgp协议配置_静态路由_14

13、在 R4 上配置 null0 静态路由实现路由汇总,参考命令如下:

R4(config)#ip route 172.52.0.0 255.255.240.0 null 0
R4(config)#
R4(config)#router bgp 4052
R4(config-router)#network 172.52.0.0 mask 255.255.240.0

IP路由和BGP路由 路由器bgp协议配置_IP路由和BGP路由_15

14、将步骤 13 的配置删除,使用聚合属性配置路由汇总。

R4(config-router)#no network 172.52.0.0 mask 255.255.240.0
R4(config-router)#exit
R4(config)#no ip route 172.52.0.0 255.255.240.0 null 0
R4(config)#
 
 
R4(config)#router bgp 4052
R4(config-router)#agg
R4(config-router)#aggregate-address 172.52.0.0 255.255.240.0 sum
R4(config-router)#aggregate-address 172.52.0.0 255.255.240.0 summary-only

问题 10:配置后 R5 上关于 172 的路由还有几条?在 R5 中以 5.5.5.5 为源 ping 172.16.1.1, 能否 ping 通?

IP路由和BGP路由 路由器bgp协议配置_OSPF_16

IP路由和BGP路由 路由器bgp协议配置_静态路由_17

15、在 R4 和 R2 之间配置认证,参考命令如下:

R2(config)#router bgp 1052
R2(config-router)#nei
R2(config-router)#neighbor 24.52.52.4 pass
R2(config-router)#neighbor 24.52.52.4 password  0 zjb
R2(config-router)#
 
 
 
R2#clear ip bgp * soft
R2#

 

问题 11:在 R4 上能否看到 R5 上的路由?

IP路由和BGP路由 路由器bgp协议配置_IP路由和BGP路由_18

16、参考步骤 15 配置 R4。

R4(config)#router bgp 4052
R4(config-router)#neigh
R4(config-router)#neighbor 24.52.52.2 pa
R4(config-router)#neighbor 24.52.52.2 password  0 zjb
 
R4#clear ip bgp * soft
R4#