项目说明:

1.R2、R3、R4运行ospf协议; 2.R1和R5分别运行BGP 100和500; 3.R2和R4用回环接口建立ibgp邻居,id为234; 4.PC1和PC5可以ping通。

项目拓扑如下图:

基本网络配置如下:

R1 system-view sysname R1 interface GigabitEthernet0/0/2 ip address 192.168.1.254 255.255.255.0 interface GigabitEthernet0/0/0 ip address 192.168.12.1 255.255.255.0 quit R2 system-vieW sysname R2 interface GigabitEthernet0/0/1 ip address 192.168.12.2 255.255.255.0 interface GigabitEthernet0/0/0 ip address 192.168.23.2 255.255.255.0 interface LoopBack 2 ip address 10.10.2.2 255.255.255.0 quit R3 system-view sysname R3 interface GigabitEthernet0/0/1 ip address 192.168.23.3 255.255.255.0 interface GigabitEthernet0/0/0 ip address 192.168.34.3 255.255.255.0 quit R4 system-view sysname R4 interface GigabitEthernet0/0/1 ip address 192.168.34.4 255.255.255.0 interface GigabitEthernet0/0/0 ip address 192.168.45.4 255.255.255.0 interface LoopBack 4 ip address 10.10.4.4 255.255.255.0 quit R5 system-view sysname R5 interface GigabitEthernet0/0/1 ip address 192.168.45.5 255.255.255.0 interface GigabitEthernet0/0/2 ip address 192.168.5.254 255.255.255.0 quit

OSPF配置如下:

R2 ospf 1 router-id 2.2.2.2 area 0 network 192.168.23.0 0.0.0.255 network 10.10.2.0 0.0.0.255 R3 ospf 1 router-id 3.3.3.3 area 0 network 192.168.23.0 0.0.0.255 network 192.168.34.0 0.0.0.255 R4 ospf 1 router-id 4.4.4.4 area 0 network 192.168.34.0 0.0.0.255 network 10.10.4.0 0.0.0.255 R5

	配置bgp

R1 bgp 100 router-id 1.1.1.1 network 192.168.1.0 peer 192.168.12.2 as-number 234 R2 bgp 234 router-id 2.2.2.2 peer 192.168.12.1 as-number 100 peer 10.10.4.4 as-number 234 peer 10.10.4.4 connect-interface LoopBack 2 //非直连接口建立邻居,需要指定接口 peer 10.10.4.4 next-hop-local //内部邻居传递路由,需要指定下一跳,否则网络不可达 R4 bgp 234 router-id 4.4.4.4 peer 192.168.45.5 as-number 500 peer 10.10.2.2 as-number 234 peer 10.10.2.2 connect-interface LoopBack 4 peer 10.10.2.2 next-hop-local R5 bgp id500 router-id 5.5.5.5 peer 192.168.45.4 as-number 234 network 192.168.5.0

至此可以查看到R2和R4上的BGP路由和ip路由,路由信息如下:

R2如下

R4如下

	可以看到R2和R4通过BGP协议可以学习到192.168.1.0/24和192.168.5.0/24的路由信息,此时可以用PC1去ping PC5,如下:

	测试结果网络不通,原因是R3上无192.168.1.0/24和192.168.5.0/24的路由信息,网络不通,
为使得R3上有相关路由信息,可以配置静态路由或者在OSPF中引入BGP路由,本项目我引入
BGP路由,配置如下:

配置路由重发布 R2 ospf 1 import-route bgp R4 ospf 1 import-route bgp

	配置后查看R路由表如下:

 测试两台PC机网络已通

有兴趣的伙伴可以查看配置路由重发布前后R2和R4的路由表变化,如下图:

至此
	项目完成!!!!