在大型的企业中,可能在同一网内使用到多种路由协议,为了实现多种路由协议的协同工作,路由器可以使用路由重分发(route redistribution)将其学习到的一种路由协议的路由通过另一种路由协议广播出去,这样网络的所有部分都可以连通了。 为了实现重分发,路由器必须同时运行多种路由协议,这样,每种路由协议才可以取路由表中的所有或部分其他协议的路由来进行广播。
以上内容摘取自百度百科
rip和ospf路由之间的重分发
?
?在执行路由重发布之前,先查看三台路由器的路由表,特权模式输入show ip route
R1
Codes: L - local, 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, E - EGP
i - IS-IS, 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
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
L 192.168.1.1/32 is directly connected, GigabitEthernet0/0
R2
Codes: L - local, 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, E - EGP
i - IS-IS, 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
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/24 is directly connected, GigabitEthernet0/1
L 172.16.0.1/32 is directly connected, GigabitEthernet0/1
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
L 192.168.1.2/32 is directly connected, GigabitEthernet0/0
R3
Codes: L - local, 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, E - EGP
i - IS-IS, 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
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/24 is directly connected, GigabitEthernet0/0
L 172.16.0.2/32 is directly connected, GigabitEthernet0/0
R1和R3之间因为配置了不同的路由协议所以无法学习到对方的路由表,但是R2上既配置了rip协议也配置了ospf协议,并且拥有整个网络的路由信息,因此可以在R2上进行路由重发布,将rip的路由信息注入到ospf中,将ospf中的路由信息注入到rip中,以实现全网互通
在R2上的配置如下
Router(config)#router ospf 1
Router(config-router)#redistribute rip subnets
Router(config)#router rip
Router(config-router)#redistribute ospf 1 metric 1
再次查看R1和R3的路由表
R1
Codes: L - local, 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, E - EGP
i - IS-IS, 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
172.16.0.0/24 is subnetted, 1 subnets
R 172.16.0.0/24 [120/1] via 192.168.1.2, 00:00:16, GigabitEthernet0/0
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/24 is directly connected, GigabitEthernet0/0
L 192.168.1.1/32 is directly connected, GigabitEthernet0/0
R3
Codes: L - local, 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, E - EGP
i - IS-IS, 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
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.0.0/24 is directly connected, GigabitEthernet0/0
L 172.16.0.2/32 is directly connected, GigabitEthernet0/0
O E2 192.168.1.0/24 [110/20] via 172.16.0.1, 00:02:06, GigabitEthernet0/0
可以看到R1和R3已经可以学习到对方的路由信息了
值得注意的是,这里对于R2来说,192.168.1.0/24和172.16.0.0/24网段都是它的直连网段,因此,也可以直接重发布直连网段,效果也是一样的
Router(config)#router rip
Router(config-router)#redistribute connected metric 1
类似的,如果配置了静态路由,也可以用这种方式将静态路由重发布出去
|