路由重发布
- 1. 定义 👨🏻🎓
- 1.1. 原则
- 2. 种子度量值
- 2.1. 默认种子度量值
- 3. 协议间重发布
- 3.1. => RIP (metric 1)
- 3.2. => OSPF (subnets)
- 3.3. => EIGRP (10000 100 255 1 1500)
- 4. 重发布静态路由
- 5. 重发布直连接口
- 6. 实验
- 6.1. 单点双向重发布
- 6.2. 单点重分发次优路径问题
- 6.3. 多点单向重发布存在的问题
- 6.4. 多点双向重发布产生环路的问题
- 7. 路由协议迁移套路
1 定义 👨🏻🎓
在路由器上,当将路由协议 A 重发布进路由协议 B 时, 会将路由器上 所有运行 A 协议的接口以及所有学习到的 A 协议路由 重分布进 B 协议中。
换句话说,可以被重分布的路由条目有两种:
- 因为重分布是 基于路由表 的, 只有在路由表中呈现为协议 A 的路由条目时,才会重分布进路由协议 B
- 被 A 协议所 network 的 直连接口 也会被重分布进 B 协议
1.1 原则
(其实就是上面所描述的内容的总结)
- 重分布总是 向外的 ,执行重分发的路由器不会修改其自身的路由表,否则就是 过河拆桥
- 要发布出去的路由必须要 存在 于路由表中(且 类型为源路由协议或与源协议路由器直连的网段)才能被重分发
2 种子度量值
种子度量值也叫初始度量值,默认度量值。是在重分发配置期间定义的,可使用命令 default-metric
或在 redistribute
命令中使用 metric 来指定。
2.1 默认种子度量值
重分布 进入 的协议 | 默认度量值 | 备注 |
---|---|---|
RIP | ∞ | 重分布时必须手工指定 metric 值 [重分布直连,静态默认为 1] |
EIGRP | ∞ | 重分布时必须手工指定 metric 值(10000 100 255 1 1500)[重分布直连,静态会自动计算,EIGRP 进程间重分布不需要指定] |
OSPF | BGP 为 1 ,其他路由为 20 | 注意加上 subnets 关键字,否则自由主类路由会被重分布 |
ISIS | 0 | |
BGP | set to IGP metric value |
3 协议间重发布
3.1 => RIP (metric 1)
指定 metric 为 1 即可。
3.2 => OSPF (subnets)
3.3 => EIGRP (10000 100 255 1 1500)
需要指定 带宽/延迟/可靠性/负载/MTU 作为 metric 。
4 重发布静态路由
redistribute static
5 重发布直连接口
通常用于不想通告接口,但又想让其他协议路由器学习到直连网络的信息。比如下图, R1 并不想 e0/1
向外发送 OSPF 消息(通常接口直接连着 PC),但希望 R2 又能学习到 R1 连接的网络。
Figure 4: 实验拓扑
R1#show running-config | s ospf ip ospf 1 area 0 router ospf 1 router-id 1.1.1.1 redistribute connected metric 10 subnets R1#
R2 可以学到直连网络( 包括逻辑接口上的网络 ):
R2#show ip route Gateway of last resort is not set 11.0.0.0/32 is subnetted, 1 subnets O E2 11.11.11.11 [110/10] via 192.168.12.1, 00:00:03, Ethernet0/0 O E2 192.168.1.0/24 [110/10] via 192.168.12.1, 01:03:23, Ethernet0/0 192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.12.0/24 is directly connected, Ethernet0/0 L 192.168.12.2/32 is directly connected, Ethernet0/0
6 实验
6.1 单点双向重发布 1
Figure 5: 实验拓扑
R2(config)#router ospf 1 ! 进入目标协议配置模式 R2(config-router)#redistribute rip ! 最好加上 subnets 参数,否则只会将主类网络发布过来,从下面的显示看,这个参数好像是默认的 R2(config-router)#do sh run | s ospf ip ospf 1 area 0 router ospf 1 router-id 2.2.2.2 redistribute rip subnetsR3 路由信息
R3#show ip route | begin Gateway Gateway of last resort is not set 1.0.0.0/32 is subnetted, 1 subnets O E2 1.1.1.1 [110/20] via 192.168.23.2, 00:02:46, Ethernet0/0 3.0.0.0/32 is subnetted, 1 subnets C 3.3.3.3 is directly connected, Loopback0 O E2 192.168.12.0/24 [110/20] via 192.168.23.2, 00:07:39, Ethernet0/0 192.168.23.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.23.0/24 is directly connected, Ethernet0/0 L 192.168.23.3/32 is directly connected, Ethernet0/0R1 路由信息
R1#show ip route Gateway of last resort is not set 1.0.0.0/32 is subnetted, 1 subnets C 1.1.1.1 is directly connected, Loopback0 192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.12.0/24 is directly connected, Ethernet0/0 L 192.168.12.1/32 is directly connected, Ethernet0/0将 OSPF 发布进 RIPv2
R2(config)#router rip R2(config-router)#redistribute ospf 1 metric 3R1 路由信息(重发布后)
R1#show ip route Gateway of last resort is not set 1.0.0.0/32 is subnetted, 1 subnets C 1.1.1.1 is directly connected, Loopback0 3.0.0.0/32 is subnetted, 1 subnets R 3.3.3.3 [120/3] via 192.168.12.2, 00:00:01, Ethernet0/0 # metric 为 3 192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.12.0/24 is directly connected, Ethernet0/0 L 192.168.12.1/32 is directly connected, Ethernet0/0 R 192.168.23.0/24 [120/3] via 192.168.12.2, 00:00:01, Ethernet0/0使用静态路由覆盖动态路由
R2(config)#ip route 1.1.1.1 255.255.255.255 null 0 R2(config)#do show ip route Gateway of last resort is not set 1.0.0.0/32 is subnetted, 1 subnets S 1.1.1.1 is directly connected, Null0 3.0.0.0/32 is subnetted, 1 subnets O 3.3.3.3 [110/11] via 192.168.23.3, 00:22:29, Ethernet0/1 192.168.12.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.12.0/24 is directly connected, Ethernet0/0 L 192.168.12.2/32 is directly connected, Ethernet0/0 192.168.23.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.23.0/24 is directly connected, Ethernet0/1 L 192.168.23.2/32 is directly connected, Ethernet0/1R3 路由信息
R3#show ip route Gateway of last resort is not set 3.0.0.0/32 is subnetted, 1 subnets C 3.3.3.3 is directly connected, Loopback0 O E2 192.168.12.0/24 [110/20] via 192.168.23.2, 00:26:14, Ethernet0/0 ! 只剩与 RIP 直连网络路由信息了 192.168.23.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.23.0/24 is directly connected, Ethernet0/0 L 192.168.23.3/32 is directly connected, Ethernet0/0
6.2 单点重分发次优路径问题
Figure 6: 实验拓扑
在 R3 上将 RIP 路由重分发进 OSPF ,由于 OSPF 的 AD 值大于 RIP ,因此 R4 去往 192.168.1.0/24
网段的路由指向 R2 ,这就造成了次优路径。
R4#show ip route | begin Gateway Gateway of last resort is not set R 192.168.1.0/24 [120/1] via 192.168.45.5, 00:00:02, Ethernet0/1 O 192.168.12.0/24 [110/20] via 192.168.24.2, 00:07:32, Ethernet0/0 O 192.168.13.0/24 [110/30] via 192.168.24.2, 00:07:32, Ethernet0/0 192.168.24.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.24.0/24 is directly connected, Ethernet0/0 L 192.168.24.4/32 is directly connected, Ethernet0/0 R 192.168.35.0/24 [120/1] via 192.168.45.5, 00:00:02, Ethernet0/1 192.168.45.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.45.0/24 is directly connected, Ethernet0/1 L 192.168.45.4/32 is directly connected, Ethernet0/1R4 路由 (重分布后)
R4#show ip route | begin Gateway Gateway of last resort is not set O E2 192.168.1.0/24 [110/23] via 192.168.24.2, 00:00:20, Ethernet0/0 # 选择 OSPF 发布的路由(次优路径) O 192.168.12.0/24 [110/20] via 192.168.24.2, 00:11:26, Ethernet0/0 O 192.168.13.0/24 [110/30] via 192.168.24.2, 00:11:26, Ethernet0/0 192.168.24.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.24.0/24 is directly connected, Ethernet0/0 L 192.168.24.4/32 is directly connected, Ethernet0/0 O E2 192.168.35.0/24 [110/23] via 192.168.24.2, 00:00:20, Ethernet0/0 192.168.45.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.45.0/24 is directly connected, Ethernet0/1 L 192.168.45.4/32 is directly connected, Ethernet0/1
6.3 多点单向重发布存在的问题
在上面的例子中,假设 R4 也配置了重分布(向 OSPF 发布 RIP 路由) ,但是由于 192.168.1.0/24
已属于 O E2
,因此重分布无效。
6.4 多点双向重发布产生环路的问题 2
从低 AD 值协议区域重分布到高 AD 值协议区域不会产生问题,反过来就会产生问题。
Figure 7: 实验拓扑
7 路由协议迁移套路
- 将现有路由协议 AD 值改小,小于即将安装的新路由协议
- 配置新路由协议
- 将旧路由协议 AD 改大,让新路由协议生效
- 删除旧路由协议
From:http://ruanhao.cc/blog/redistribute.html