路由重发布相关知识

不同协议之间的路由,是不会相互交换的。

一、路由重发布的意义:

1、把一种协议的路由注入到另一种协议当中,譬如把RIP的路由注入到OSPF当中

2、把同一种路由协议的一个进程注入到另一个进程中,譬如把OSPF的进程31注入到32当中

二、重发布需要考虑的问题:

1、只有在路由表中的路由才可以被重分发

2、路由回馈问题

首先,R4是可以通过RIP学习到192.168.1.0这个网段的路由。如果在R3上把1.0这段路由重发布到OSPF当中的话,R4又会通过OSPF学习到这段路由:R4---R2---R1---R3--R5。那么根据AD值越小越优先的原则,R4就会选择从OSPF(110)中学到的路由作为最优路径。因此,实际R4获取到的是次优路径。

 

3、度量值(metric)不一致的问题

不同的协议对于metric的理解是不一样的。譬如,RIP是以hop作为metric值;OSPF是以cost作为metric值。

1)重分发的时候可以指定注入后的路由的metric值

redistribute metric 20

2)或者不指定,使用默认值(种子度量值)

default metric

路由重发布相关知识_第1张图片

4、收敛时间不一致的问题

三、实验汇总:

1、不同协议路由之间的重分发

 

R1#show ip route 
C 192.168.12.0/24 is directly connected, FastEthernet0/0
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0

R2#show ip route 
C 192.168.12.0/24 is directly connected, FastEthernet1/0
R 1.0.0.0/8 [120/1] via 192.168.12.1, 00:00:00, FastEthernet1/0
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback0
3.0.0.0/32 is subnetted, 1 subnets
O 3.3.3.3 [110/2] via 192.168.23.3, 00:18:56, FastEthernet0/0
C 192.168.23.0/24 is directly connected, FastEthernet0/0

R3#show ip route 
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/2] via 192.168.23.2, 00:08:14, FastEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
C 3.3.3.3 is directly connected, Loopback0
C 192.168.23.0/24 is directly connected, FastEthernet0/0

R2配置路由重分发以后:

R2(config)#router ospf 1
R2(config-router)#redistribute rip subnets

#subnets:把rip的所有子网路由也注入到ospf当中,没有定义metric,则用默认的20

R3#show ip route 
O E2 192.168.12.0/24 [110/20] via 192.168.23.2, 00:00:20, FastEthernet0/0
O E2 1.0.0.0/8 [110/20] via 192.168.23.2, 00:00:20, FastEthernet0/0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/2] via 192.168.23.2, 00:00:20, FastEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
C 3.3.3.3 is directly connected, Loopback0
C 192.168.23.0/24 is directly connected, FastEthernet0/0

-----------------------------------------------

R2(config)#router rip 
R2(config-router)#redistribute ospf 1

R1#show ip route 
C 192.168.12.0/24 is directly connected, FastEthernet0/0
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0

R1依旧没有学习到OSPF的路由,因为R2注入OSPF路由时没有指定metric,根据种子度量值,metric为0,无穷大,所以没有被写入R1的路由表当中

R2(config-router)#redistribute ospf 1 metric 5

R1#show ip route 
C 192.168.12.0/24 is directly connected, FastEthernet0/0
1.0.0.0/32 is subnetted, 1 subnets
C 1.1.1.1 is directly connected, Loopback0
R 2.0.0.0/8 [120/5] via 192.168.12.2, 00:00:04, FastEthernet0/0
R 3.0.0.0/8 [120/5] via 192.168.12.2, 00:00:04, FastEthernet0/0
R 192.168.23.0/24 [120/5] via 192.168.12.2, 00:00:04, FastEthernet0/0

2、直连路由重分发

R3的loopback0不要宣告进OSPF,而是在R3上重分发直连路由,R2也一样可以学习到.3的路由

R3(config)#router ospf 1
R3(config-router)#redistribute connected subnets metric 30

R2#show ip route 
C 192.168.12.0/24 is directly connected, FastEthernet1/0
R 1.0.0.0/8 [120/1] via 192.168.12.1, 00:00:10, FastEthernet1/0
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback0
3.0.0.0/32 is subnetted, 1 subnets
O E2 3.3.3.3 [110/30] via 192.168.23.3, 00:01:27, FastEthernet0/0
C 192.168.23.0/24 is directly connected, FastEthernet0/0

3、静态路由重分发

R1 R2不要运行RIP,R2写一条静态路由指向.1网段,然后R2把静态路由重分发进OSPF,R3就可以学习到.1的网段了

R2(config)#ip route 1.1.1.0 255.255.255.0 192.168.12.1 
R2(config)#router ospf 1
R2(config-router)#redistribute static subnets

R3#show ip route 
1.0.0.0/24 is subnetted, 1 subnets
O E2 1.1.1.0 [110/20] via 192.168.23.2, 00:00:03, FastEthernet0/0
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/2] via 192.168.23.2, 00:14:04, FastEthernet0/0
3.0.0.0/32 is subnetted, 1 subnets
C 3.3.3.3 is directly connected, Loopback0
C 192.168.23.0/24 is directly connected, FastEthernet0/0

CCIE - 重分发路由控制(Tag过滤)

R2:

route-map RIP_TO_OSPF deny 10
match tag 110

!

route-map RIP_TO_OSPF permit 20
set tag 120
!

router ospf 1
 redistribute rip subnets route-map RIP_TO_OSPF

!

route-map OSPF_TO_RIP deny 10
match tag 120
!
route-map OSPF_TO_RIP permit 20
set tag 110
!
router rip
 redistribute ospf 1 metric 1 route-map OSPF_TO_RIP

在双向重分布时,将OSPF自己的路由打上Tag 110,将RIP自己的路由打上Tag 120,并且通过匹配Tag拒绝原本属于自己的路由再返回,也就是OSPF重分布进RIP时,拒绝Tag为120的路由返回,RIP重分布进OSPF时,拒绝Tag为110的路由返回,因为它们原本就是自己的路由。

----------------------------------------------------------------------------------------------------

R4:

route-map RIP_TO_OSPF deny 10
match tag 110
!
route-map RIP_TO_OSPF permit 20
set tag 120

!

router ospf 1
 redistribute rip subnets route-map RIP_TO_OSPF
!

route-map OSPF_TO_RIP deny 10
match tag 120
!
route-map OSPF_TO_RIP permit 20
set tag 110

!
router rip
 redistribute ospf 1 metric 1 route-map OSPF_TO_RIP
-----------------------------------------------------------
R5#sh ip route 100.1.1.0
Routing entry for 100.1.1.0/24
  Known via "ospf 1", distance 110, metric 20
  Tag 120, type extern 2, forward metric 1
  Last update from 45.1.1.4 on FastEthernet1/0, 00:20:20 ago
  Routing Descriptor Blocks:
  * 45.1.1.4, from 45.1.1.4, 00:20:20 ago, via FastEthernet1/0
      Route metric is 20, traffic share count is 1
      Route tag 120

你可能感兴趣的:(路由重发布相关知识)