在一些网络中,由于某种需要,配置多个动态学习路由协议,而在默认情况下各个路由协议之间不能互相学习路由信息(末梢路由器除外),那就需要我们通过手工配置实现路由器间互相学习路由信息。
在单协议网络中,路由协议是把本地网段通告给本路由协议,在多协议的网络中,在中间的路由器把本地网段通告给其他路由协议,即路由重分发
路由重分布的作用:可以使得多种路由协议之间,多重厂商环境中进行路由信息交换
模拟实验环境:IP分布和拓扑如图
根据拓扑图,我们可以实现RIPV2、EIGRP、OSPF之间的兼容
配置命令:
router(config)#router 路由协议 参数
router(config-router)#network XXXX 通告本地网段
router(config-router)# redistribute 路由协议2 参数 metric 度量值
实验步骤:
1、根据实验图配置基本步骤 略
2、配置路由器1 配置RIPV2路由协议
r1(config)#router rip //配置RIPV2
r1(config-router)#version 2
r1(config-router)#network 172.1.1.0
r1(config-router)#network 1.1.1.0
3、配置路由器3
r3(config)#router eigrp 10 //配置EIGRP AS=10
r3(config-router)#network 172.2.1.0
r3(config-router)#network 2.2.2.0
4、配置路由器4
r4(config)#router ospf 1 //配置OSPF AREA=0
r4(config-router)#network 172.3.1.0 0.0.0.255 area 0
r4(config-router)#network 3.3.3.0 0.0.0.255 area 0
5、配置路由器2
r2(config)#router rip
r2(config-router)#version 2
r2(config-router)#network 172.1.1.0
r2(config-router)#network 172.2.1.0
r2(config-router)#network 172.3.1.0
r2(config-router)#redistribute eigrp 10 metric 1
//EIGRP向RIPV2重定向,10为AS号,跳数是1
r2(config-router)#redistribute ospf 1 metric 1
//OSPF向RIPV2重定向,OSPF 1为进程号 metric 1为跳数
r2(config)#router eigrp 10
r2(config-router)#network 172.1.1.0
r2(config-router)#network 172.2.1.0
r2(config-router)#network 172.3.1.0
r2(config-router)#redistribute rip metric 1544 20000 255 1 1500 //RIP向EIGRP重定向
r2(config-router)#redistribute ospf 1 metric 1544 20000 255 1 1500 //OSPF向EIGRP重定向
metric 后面值依次为:带宽、延迟、可靠性、负载、MTU
注意:顺序不能改变
r2(config)#router ospf 1
r2(config-router)#network 172.1.1.0 0.0.0.255 area 0
r2(config-router)#network 172.2.1.0 0.0.0.255 area 0
r2(config-router)#network 172.3.1.0 0.0.0.255 area 0
r2(config-router)#redistribute rip metric 100 subnets
r2(config-router)#redistribute eigrp 10 metric 100 subnets
//metric 100 为COST 值
六、测试联通性
在路由器1上查看路由表
r1#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
R 2.0.0.0/8 [120/1] via 172.1.1.1, 00:00:24, Serial0/0
R 3.0.0.0/8 [120/1] via 172.1.1.1, 00:00:24, Serial0/0
172.1.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.1.1.0/24 is directly connected, Serial0/0
R 172.1.0.0/16 [120/1] via 172.1.1.1, 00:00:24, Serial0/0
R 172.2.0.0/16 [120/1] via 172.1.1.1, 00:00:24, Serial0/0
R 172.3.0.0/16 [120/1] via 172.1.1.1, 00:00:24, Serial0/0
在路由器2上查看路由表
r2#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
R 1.0.0.0/8 [120/1] via 172.1.1.2, 00:00:06, Serial0/0
D 2.0.0.0/8 [90/2297856] via 172.2.1.2, 00:03:59, Serial0/1
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/65] via 172.3.1.2, 00:02:35, Serial0/2
172.1.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.1.1.0/24 is directly connected, Serial0/0
D 172.1.0.0/16 is a summary, 00:03:59, Null0
172.2.0.0/16 is variably subnetted, 2 subnets, 2 masks
D 172.2.0.0/16 is a summary, 00:03:59, Null0
C 172.2.1.0/24 is directly connected, Serial0/1
172.3.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.3.1.0/24 is directly connected, Serial0/2
D 172.3.0.0/16 is a summary, 00:03:55, Null0
在路由器3上查看路由表
r3#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
D EX 1.0.0.0/8 [170/7289856] via 172.2.1.1, 00:03:56, Serial0/0
2.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 2.2.2.0/24 is directly connected, Loopback0
D 2.0.0.0/8 is a summary, 00:04:40, Null0
3.0.0.0/32 is subnetted, 1 subnets
D EX 3.3.3.3 [170/7289856] via 172.2.1.1, 00:03:07, Serial0/0
D 172.1.0.0/16 [90/2681856] via 172.2.1.1, 00:04:31, Serial0/0
172.2.0.0/16 is variably subnetted, 2 subnets, 2 masks
D 172.2.0.0/16 is a summary, 00:04:40, Null0
C 172.2.1.0/24 is directly connected, Serial0/0
D 172.3.0.0/16 [90/2681856] via 172.2.1.1, 00:04:27, Serial0/0
在路由器4上查看路由表
r4#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
O E2 1.0.0.0/8 [110/100] via 172.3.1.1, 00:03:35, Serial0/0
O E2 2.0.0.0/8 [110/100] via 172.3.1.1, 00:03:35, Serial0/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
172.1.0.0/16 is variably subnetted, 2 subnets, 2 masks
O 172.1.1.0/24 [110/128] via 172.3.1.1, 00:03:35, Serial0/0
O E2 172.1.0.0/16 [110/100] via 172.3.1.1, 00:03:35, Serial0/0
172.2.0.0/16 is variably subnetted, 2 subnets, 2 masks
O E2 172.2.0.0/16 [110/100] via 172.3.1.1, 00:03:35, Serial0/0
O 172.2.1.0/24 [110/128] via 172.3.1.1, 00:03:35, Serial0/0
172.3.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.3.1.0/24 is directly connected, Serial0/0
O E2 172.3.0.0/16 [110/100] via 172.3.1.1, 00:03:35, Serial0/0
利用PING命令测试
r1#ping 2.2.2.2 source 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 68/123/208 ms
r1#ping 3.3.3.3 source 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 52/105/200 ms