实验拓扑:
试验要求:R1R2运行RIPR3R2之间运行OSPF,要求在R2上配置路由重发布,使R1能够学习到R3的路由,同样R3能够学到R1上的路由。并且配置汇总路由。
试验目的:掌握路由重发布的基本配置与在配置路由重发布之前应该注意的地方。
 
试验配置:
R1
R1(config)#int s1/0
R1(config-if)#ip add 199.99.1.2 255.255.255.0
R1(config-if)#no shu
R1(config-if)#exit
R1(config)#int loop0
R1(config-if)#ip add 192.168.1.1 255.255.255.224
R1(config-if)#exit
R1(config)#int loop1
R1(config-if)#ip add 192.168.1.33 255.255.255.224
R1(config-if)#exit
R1(config)#int loop2
R1(config-if)#ip add 192.168.1.65 255.255.255.224
R1(config-if)#exit
R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#network 199.99.1.0
R1(config-router)#network 192.168.1.0
R1(config-router)#network 192.168.1.32
R1(config-router)#network 192.168.1.64
R1(config-router)#no auto-summary
R1(config-router)#exit
 
R2
R2(config)#int s1/0
R2(config-if)#ip add 199.99.1.1 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#no shu
R2(config-if)#exit
R2(config)#int s1/1
R2(config-if)#ip add 199.99.2.1 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#no shu
R2(config-if)#exit
R2(config)#router rip
R2(config-router)#network 199.99.1.0
R2(config-router)#version 2
R2(config-router)#no auto-summary
R2(config-router)#exit
R2(config)#router ospf 100
R2(config-router)#network 199.99.2.0 0.0.0.255 a 0
R2(config-router)#end
 
R3
R3(config)#int s1/0
R3(config-if)#ip add 199.99.2.2 255.255.255.0
R3(config-if)#no shu
R3(config-if)#exit
R3(config)#int loop0
R3(config-if)#ip add 172.16.1.1 255.255.255.0
R3(config-if)#exit       
R3(config)#int loop1
R3(config-if)#ip add 172.16.2.1 255.255.255.0
R3(config-if)#exit
R3(config)#int loop2
R3(config-if)#ip add 172.16.3.1 255.255.255.0
R3(config-if)#exit
R3(config)#router ospf 100
R3(config-router)#network 199.99.2.0 0.0.0.255 a 0
R3(config-router)#network 172.16.1.0 0.0.0.255 a 1
R3(config-router)#network 172.16.2.0 0.0.0.255 a 1
R3(config-router)#network 172.16.3.0 0.0.0.255 a 1
R3(config-router)#exit
好了,以上为基本的配置,下面我们在每台路由器上查看一下路由表:
R1#show ip route
 
C    199.99.1.0/24 is directly connected, Serial1/0
     192.168.1.0/27 is subnetted, 3 subnets
C       192.168.1.64 is directly connected, Loopback2
C       192.168.1.32 is directly connected, Loopback1
C       192.168.1.0 is directly connected, Loopback0
 
R2#show ip route
 
     172.16.0.0/32 is subnetted, 3 subnets
O IA    172.16.1.1 [110/65] via 199.99.2.2, 00:00:09, Serial1/1
O IA    172.16.3.1 [110/65] via 199.99.2.2, 00:00:09, Serial1/1
O IA    172.16.2.1 [110/65] via 199.99.2.2, 00:00:09, Serial1/1
C    199.99.2.0/24 is directly connected, Serial1/1
C    199.99.1.0/24 is directly connected, Serial1/0
     192.168.1.0/27 is subnetted, 3 subnets
R       192.168.1.64 [120/1] via 199.99.1.2, 00:00:05, Serial1/0
R       192.168.1.32 [120/1] via 199.99.1.2, 00:00:05, Serial1/0
R       192.168.1.0 [120/1] via 199.99.1.2, 00:00:05, Serial1/0
 
R3#show ip route
 
     172.16.0.0/24 is subnetted, 3 subnets
C       172.16.1.0 is directly connected, Loopback0
C       172.16.2.0 is directly connected, Loopback1
C       172.16.3.0 is directly connected, Loopback2
C    199.99.2.0/24 is directly connected, Serial1/0
 
可以看到R1上只显示了自己直连的路由,R2上显示了通过RIPOSPF学到的所有路由,R3上也只有自己直连的路由,下面在R2上配之路由重发布,在配置之前需要注意的是在把其他路由协议重发布到RIP,IGRP,EIGRP的时候,是需要手动添加度量,否则度量为无穷,但是重发布直连和静态路由时,度量默认为1 在把其他路由协议重发布到OSPF时,可以不用手动添加度量值,默认OSPF为重发布的路由分配的度量值为20
R2(config)#router rip
R2(config-router)#redistribute ospf 100 metric 3
 
这样配置完成后就把OSPF 100的路由重发布到RIP路由协议中,并且定义度量值为3跳,然后在R1上查看路由表:
R1#show ip route
 
     172.16.0.0/32 is subnetted, 3 subnets
R       172.16.1.1 [120/3] via 199.99.1.1, 00:00:05, Serial1/0
R       172.16.3.1 [120/3] via 199.99.1.1, 00:00:05, Serial1/0
R       172.16.2.1 [120/3] via 199.99.1.1, 00:00:05, Serial1/0
R    199.99.2.0/24 [120/3] via 199.99.1.1, 00:00:05, Serial1/0
C    199.99.1.0/24 is directly connected, Serial1/0
     192.168.1.0/27 is subnetted, 3 subnets
C       192.168.1.64 is directly connected, Loopback2
C       192.168.1.32 is directly connected, Loopback1
C       192.168.1.0 is directly connected, Loopback0
 
OK,学到了到R3上的路由,然后我们在R2上配置,把RIP重发布到OSPF中:
R2(config)#router ospf 100
R2(config-router)#redistribute rip subnets
在重发布到OSPF中时,需要带subnets参数,然后我们在R3上查看路由表:
R3#show ip route 
     172.16.0.0/24 is subnetted, 3 subnets
C       172.16.1.0 is directly connected, Loopback0
C       172.16.2.0 is directly connected, Loopback1
C       172.16.3.0 is directly connected, Loopback2
C    199.99.2.0/24 is directly connected, Serial1/0
O E2 199.99.1.0/24 [110/20] via 199.99.2.1, 00:00:09, Serial1/0
     192.168.1.0/27 is subnetted, 3 subnets
O E2    192.168.1.64 [110/20] via 199.99.2.1, 00:00:04, Serial1/0
O E2    192.168.1.32 [110/20] via 199.99.2.1, 00:00:03, Serial1/0
O E2    192.168.1.0 [110/20] via 199.99.2.1, 00:00:03, Serial1/0
好的,可以看到有O E2的路由了,表示OSPF自治系统外部路由,是从RIP重发布过来的。是类型2的外部路由,我们可以手动修改:
R2(config-router)#redistribute rip metric 40 metric-type 1 subnets
然后再到R3上查看路由表:
R3#show ip route 
 
     172.16.0.0/24 is subnetted, 3 subnets
C       172.16.1.0 is directly connected, Loopback0
C       172.16.2.0 is directly connected, Loopback1
C       172.16.3.0 is directly connected, Loopback2
C    199.99.2.0/24 is directly connected, Serial1/0
O E1 199.99.1.0/24 [110/104] via 199.99.2.1, 00:00:00, Serial1/0
     192.168.1.0/27 is subnetted, 3 subnets
O E1    192.168.1.64 [110/104] via 199.99.2.1, 00:00:00, Serial1/0
O E1    192.168.1.32 [110/104] via 199.99.2.1, 00:00:00, Serial1/0
O E1    192.168.1.0 [110/104] via 199.99.2.1, 00:00:00, Serial1/0
类型变成1类外部路由,度量值也变大了。
下面我们开始路由汇总的配置,首先在R1上汇总RIP路由:
R1(config)#int s1/0
R1(config-if)#ip summary-address rip 192.168.1.0 255.255.255.0
然后在R2R3上验证:
R2#show ip route  
 
     172.16.0.0/32 is subnetted, 3 subnets
O IA    172.16.1.1 [110/65] via 199.99.2.2, 00:00:09, Serial1/1
O IA    172.16.3.1 [110/65] via 199.99.2.2, 00:00:09, Serial1/1
O IA    172.16.2.1 [110/65] via 199.99.2.2, 00:00:09, Serial1/1
C    199.99.2.0/24 is directly connected, Serial1/1
C    199.99.1.0/24 is directly connected, Serial1/0
R    192.168.1.0/24 [120/1] via 199.99.1.2, 00:00:09, Serial1/0
 
R3#show ip route
 
     172.16.0.0/24 is subnetted, 3 subnets
C       172.16.1.0 is directly connected, Loopback0
C       172.16.2.0 is directly connected, Loopback1
C       172.16.3.0 is directly connected, Loopback2
C    199.99.2.0/24 is directly connected, Serial1/0
O E1 199.99.1.0/24 [110/104] via 199.99.2.1, 00:00:48, Serial1/0
O E1 192.168.1.0/24 [110/104] via 199.99.2.1, 00:00:33, Serial1/0
现在从RIP学到的路由变成了一条汇总的路由,注意在汇总路由时应注意,子网掩码应该大于或者等于默认主网络掩码。然后我们在R3上做汇总:
R3(config)#router ospf 100
R3(config-router)#area 1 rang 172.16.0.0 255.255.0.0
这里值得注意的问题:使用该命令时有 Summarize routes matching address/mask (border routers only) 也就是说只有边界路由器可以用range 172.16.0.0 255.255.0.0
border router (边界路由器)-----通常在开放最短路径优先 (OSPF)中定义为连接一个地区到骨干区的路由器,因此汇总的路由需是在非骨干区域的其他区域
 
然后我们在R1R2上验证:
R2#show ip route  
O IA 172.16.0.0/16 [110/65] via 199.99.2.2, 00:00:22, Serial1/1
C    199.99.2.0/24 is directly connected, Serial1/1
C    199.99.1.0/24 is directly connected, Serial1/0
R    192.168.1.0/24 [120/1] via 199.99.1.2, 00:00:04, Serial1/0
 
R1#show ip route  
 
R    172.16.0.0/16 [120/3] via 199.99.1.1, 00:00:07, Serial1/0
R    199.99.2.0/24 [120/3] via 199.99.1.1, 00:00:07, Serial1/0
C    199.99.1.0/24 is directly connected, Serial1/0
     192.168.1.0/27 is subnetted, 3 subnets
C       192.168.1.64 is directly connected, Loopback2
C       192.168.1.32 is directly connected, Loopback1
C       192.168.1.0 is directly connected, Loopback0
现在从OSPF重发布的路由也变成了一条缺省路由。