取消
显示结果 
搜索替代 
您的意思是: 
cancel
2331
查看次数
0
有帮助
2
评论
碧云天
Spotlight
Spotlight
本帖最后由 碧云天 于 2020-2-27 15:22 编辑
一.测试拓扑
152013t7jpzy71k7a1czkp.png
测试总结:
1.高版本的IOS,向OSPF重分发的时候subnets可以不用手工添加,会自动添加
2.路由进程下的default-metric对直连路由没有影响
3.某个网段宣告到动态路由,同时重分布该动态路由和直连路由进入另外一种动态路由,直连路由优先
二.基本配置
1.R2路由器

hostname R2
interface Loopback0
ip address 2.2.2.2 255.255.255.0
interface Ethernet0/0
ip address 12.1.1.2 255.255.255.0
no shutdown
router rip
version 2
network 2.0.0.0
network 12.0.0.0
no auto-summary
2.R1路由器
hostname R1
interface Loopback0
ip address 1.1.1.1 255.255.255.0
interface Loopback200
ip address 200.1.1.1 255.255.255.0
interface Ethernet0/0
ip address 12.1.1.1 255.255.255.0
no shutdown
interface Ethernet0/1
ip address 13.1.1.1 255.255.255.0
ip ospf network point-to-point
no shutdown
ip route 4.4.4.0 255.255.255.0 Null0
ip route 0.0.0.0 0.0.0.0 null 0
router rip
version 2
network 12.0.0.0
no auto-summary
router ospf 1
router-id 1.1.1.1
passive-interface Loopback0
network 1.1.1.1 0.0.0.0 area 0
network 13.1.1.1 0.0.0.0 area 0
3.R3路由器
hostname R3
interface Loopback0
ip address 3.3.3.3 255.255.255.0
interface Ethernet0/0
ip address 13.1.1.3 255.255.255.0
ip ospf network point-to-point
no shutdown
router ospf 1
router-id 3.3.3.3
passive-interface Loopback0
network 3.3.3.3 0.0.0.0 area 0
network 13.1.1.3 0.0.0.0 area 0
三.向RIP中重分发路由
1.重分发OSPF路由

①如果不指定Seed metric,无法成功重分布
R1(config)#router rip
R1(config-router)#redistribute ospf 1
R1(config-router)#
R2#show ip route rip | begin Gate
Gateway of last resort is not set
R2#
②指定Seed metric,第一跳为指定的metric,而不是加1
R1(config)#router rip
R1(config-router)#no redistribute ospf 1
R1(config-router)#redistribute ospf 1 metric 5
R2#show ip route rip | begin Gate
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/5] via 12.1.1.1, 00:00:05, Ethernet0/0
3.0.0.0/32 is subnetted, 1 subnets
R 3.3.3.3 [120/5] via 12.1.1.1, 00:00:05, Ethernet0/0
13.0.0.0/24 is subnetted, 1 subnets
R 13.1.1.0 [120/5] via 12.1.1.1, 00:00:05, Ethernet0/0
R2#
2.重分发静态路由
R1(config)#router rip
R1(config-router)#redistribute static
R2#show ip route rip | begin Gate
Gateway of last resort is 12.1.1.1 to network 0.0.0.0
R* 0.0.0.0/0 [120/1] via 12.1.1.1, 00:00:02, Ethernet0/0
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/5] via 12.1.1.1, 00:00:13, Ethernet0/0
3.0.0.0/32 is subnetted, 1 subnets
R 3.3.3.3 [120/5] via 12.1.1.1, 00:00:13, Ethernet0/0
4.0.0.0/24 is subnetted, 1 subnets
R 4.4.4.0 [120/1] via 12.1.1.1, 00:00:13, Ethernet0/0
13.0.0.0/24 is subnetted, 1 subnets
R 13.1.1.0 [120/5] via 12.1.1.1, 00:00:13, Ethernet0/0
R2#
备注:可以看到,将静态路由重分发到RIP,可以不指定Seed metric值,默认为1,并且默认路由也能进入
3.重分发直连路由
R1(config)#router rip
R1(config-router)#redistribute connected
R2#show ip route rip | include 200
R 200.1.1.0/24 [120/1] via 12.1.1.1, 00:00:05, Ethernet0/0
R2#
备注:可以看到,将直连路由重分发到RIP,可以不指定Seed metric值,默认为1
4.default-metric
R1(config)#router rip
R1(config-router)#no redistribute ospf 1 metric 5
R1(config-router)#default-metric 10
R1(config-router)#redistribute connected
R1(config-router)# redistribute static
R1(config-router)#
R2#show ip route rip | begin Gate
Gateway of last resort is 12.1.1.1 to network 0.0.0.0
R* 0.0.0.0/0 [120/10] via 12.1.1.1, 00:00:20, Ethernet0/0
1.0.0.0/24 is subnetted, 1 subnets
R 1.1.1.0 [120/1] via 12.1.1.1, 00:00:20, Ethernet0/0
3.0.0.0/32 is subnetted, 1 subnets
R 3.3.3.3 [120/10] via 12.1.1.1, 00:00:20, Ethernet0/0
4.0.0.0/24 is subnetted, 1 subnets
R 4.4.4.0 [120/10] via 12.1.1.1, 00:00:20, Ethernet0/0
13.0.0.0/24 is subnetted, 1 subnets
R 13.1.1.0 [120/1] via 12.1.1.1, 00:00:20, Ethernet0/0
R 200.1.1.0/24 [120/1] via 12.1.1.1, 00:00:20, Ethernet0/0
R2#
备注:可以看到,default-metric只会影响协议路由和静态路由,对直连路由没有影响,并且直连路由优先进入RIP。
四.向OSPF中重分发路由
1.重分发OSPF路由
①如果不指定subnets,会自动带上

R1(config)#router ospf 1
R1(config-router)#redistribute rip
R1#show running-config | sec router ospf
router ospf 1
router-id 1.1.1.1
redistribute rip subnets
passive-interface Loopback0
network 1.1.1.1 0.0.0.0 area 0
network 13.1.1.1 0.0.0.0 area 0
R1#
R3#show ip route ospf | include O E2
O E2 2.2.2.0 [110/20] via 13.1.1.1, 00:03:18, Ethernet0/0
O E2 12.1.1.0 [110/20] via 13.1.1.1, 00:03:18, Ethernet0/0
R3#
②默认为O E2,可以通过metric-type修改
R1(config)#router ospf 1
R1(config-router)#no redistribute rip subnets
R1(config-router)#redistribute rip metric-type 1
R3#show ip route ospf | include O E1
O E1 2.2.2.0 [110/30] via 13.1.1.1, 00:00:01, Ethernet0/0
O E1 12.1.1.0 [110/30] via 13.1.1.1, 00:00:01, Ethernet0/0
R3#
2.重分发静态路由
R1(config)#router ospf 1
R1(config-router)# redistribute static
R1(config-router)#do show run | sec router ospf
router ospf 1
router-id 1.1.1.1
redistribute static subnets
redistribute rip metric-type 1 subnets
passive-interface Loopback0
network 1.1.1.1 0.0.0.0 area 0
network 13.1.1.1 0.0.0.0 area 0
R1(config-router)#
R3#show ip route ospf | include O E
O E1 2.2.2.0 [110/30] via 13.1.1.1, 00:07:13, Ethernet0/0
O E2 4.4.4.0 [110/20] via 13.1.1.1, 00:01:06, Ethernet0/0
O E1 12.1.1.0 [110/30] via 13.1.1.1, 00:01:16, Ethernet0/0
R3#
备注:可以看到,subnets也会自动添加,并且缺省路由无法进入。
3.重分发直连路由
R1(config)#router ospf 1
R1(config-router)#redistribute connected
R1(config-router)#do show run | sec router ospf
router ospf 1
router-id 1.1.1.1
redistribute connected subnets
redistribute static subnets
redistribute rip metric-type 1 subnets
passive-interface Loopback0
network 1.1.1.1 0.0.0.0 area 0
network 13.1.1.1 0.0.0.0 area 0
R1(config-router)#
R3#show ip route ospf | include O E
O E1 2.2.2.0 [110/30] via 13.1.1.1, 00:08:33, Ethernet0/0
O E2 4.4.4.0 [110/20] via 13.1.1.1, 00:02:26, Ethernet0/0
O E2 12.1.1.0 [110/20] via 13.1.1.1, 00:00:31, Ethernet0/0
O E2 200.1.1.0/24 [110/20] via 13.1.1.1, 00:00:31, Ethernet0/0
R3#
备注:可以看到,subnets也会自动添加,并且直连路由优先,因为12网段的路由由OE1变成了OE2。
4.default-metric
R1(config)#router ospf 1
R1(config-router)#default-metric 100
R3#show ip route ospf | include O E
O E1 2.2.2.0 [110/110] via 13.1.1.1, 00:00:03, Ethernet0/0
O E2 4.4.4.0 [110/100] via 13.1.1.1, 00:00:03, Ethernet0/0
O E2 12.1.1.0 [110/20] via 13.1.1.1, 00:04:48, Ethernet0/0
O E2 200.1.1.0/24 [110/20] via 13.1.1.1, 00:04:48, Ethernet0/0
R3#
备注:可以看到,跟rip相同,default-metric不会影响直连路由。
评论
one-time
Level 13
Level 13
感谢楼主分享,谢谢~
likuo
Spotlight
Spotlight
认真学习。
入门指南

使用上面的搜索栏输入关键字、短语或问题,搜索问题的答案。

我们希望您在这里的旅程尽可能顺利,因此这里有一些链接可以帮助您快速熟悉思科社区:









快捷链接