最终实验效果:
全网可达:R1,R7路由表都有r1-r7环回,R1汇总0.0/22和1.0/24,R7另一环回172.16.2.1/32
用tracert命令来R1 ping R7环回,实现全网通
实现代码:
首先配置好接口ip和环回,然后:
[r1]
rip 1
version 2
network 1.0.0.0
network 12.0.0.0
network 192.168.1.0
network 192.168.2.0
bgp 100
router-id 1.1.1.1
peer 2.2.2.2 as-number 100
peer 2.2.2.2 connect-interface LoopBack0
[r2]
bgp 100
router-id 2.2.2.2
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
peer 23.1.1.2 as-number 101
aggregate 192.168.0.0 22 #后面不加别的,display bgp routing-table会出现汇总和明细都有
aggregate 192.168.0.0 22 detail-suppressed suppress-policy yy #汇总抑制2.0/24
network 192.168.1.0 24 #在bgp 100里宣告自己路由表里存在的IP,分享给egp
network 192.168.2.0 24
import-route rip 1 #重发布
peer 1.1.1.1 next-hop-local #解决igp传igp下一跳不优问题,此处是优化r1
ip ip-prefix xx permit 192.168.2.0 24 #抓取2.0/24
route-policy yy permit node 10 #抑制组
if-match ip-prefix xx #匹配条件
[r3]
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 34.1.1.0 0.0.0.255
bgp 101
router-id 3.3.3.3
peer 4.4.4.4 as-number 101
peer 4.4.4.4 connect-interface LoopBack0
peer 23.1.1.1 as-number 100
import-route ospf 1 #重发布
peer 4.4.4.4 next-hop-local
[r4]
ospf 1 router-id 4.4.4.4
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 34.1.1.0 0.0.0.255
network 45.1.1.0 0.0.0.255
bgp 101
router-id 4.4.4.4
peer 3.3.3.3 as-number 101
peer 3.3.3.3 connect-interface LoopBack0
peer 5.5.5.5 as-number 101
peer 5.5.5.5 connect-interface LoopBack0
peer 3.3.3.3 reflect-client #反射器,能有条件的打破igp之间的水平分割
peer 3.3.3.3 next-hop-local
peer 5.5.5.5 reflect-client #再做一个反射器,使r4自己为RR,r5为客户端
peer 5.5.5.5 next-hop-local
[r5]
ospf 1 router-id 5.5.5.5
area 0.0.0.0
network 5.5.5.5 0.0.0.0
network 45.1.1.0 0.0.0.255
bgp 101
router-id 5.5.5.5
peer 4.4.4.4 as-number 101
peer 4.4.4.4 connect-interface LoopBack0
peer 56.1.1.2 as-number 102
import-route ospf 1 #重发布
peer 4.4.4.4 next-hop-local
[r6]
ospf 2 router-id 6.6.6.6
area 0.0.0.0
network 6.6.6.6 0.0.0.0
network 67.1.1.0 0.0.0.255
bgp 102
router-id 6.6.6.6
peer 7.7.7.7 as-number 102
peer 7.7.7.7 connect-interface LoopBack0
peer 56.1.1.1 as-number 101
network 172.16.1.1 32
network 172.16.2.1 32
import-route ospf 2 #重发布
peer 7.7.7.7 next-hop-local
peer 56.1.1.1 route-policy yy export #bgp出口做抑制
ip ip-prefix xx permit 172.16.1.1 32 #抓1.1/32
route-policy yy deny node 10
if-match ip-prefix xx
route-policy yy permit node 20
[r7]
ospf 2 router-id 7.7.7.7
area 0.0.0.0
network 7.7.7.7 0.0.0.0
network 67.1.1.0 0.0.0.255
network 172.16.1.0 0.0.0.255
network 172.16.2.0 0.0.0.255
bgp 102
router-id 7.7.7.7
peer 6.6.6.6 as-number 102
peer 6.6.6.6 connect-interface LoopBack0