取消
显示结果 
搜索替代 
您的意思是: 
cancel
6278
查看次数
20
有帮助
3
评论
碧云天
Spotlight
Spotlight
本帖最后由 碧云天 于 2020-3-11 00:06 编辑
一.测试拓扑
175403gg3sbbw2sse1r1gz.png
测试总结:
1.distance只是本地有效,OSPF的distance命令可以调用ACL来修改内部和外部路由的管理距离。
2.路由反馈可以通过修改distance来实现,但是不能通过修改metric实现
3.尝试用OSPF的distribute-list调用route-map在in和out方向修改metric和metric-type,都没有修改成功
4.OSPF没有offset-list可供使用
5.OSPF重分布的metric,只能在重分布的时候调用route-map做出修改,也可以使用route-map修改metric-type,自动修改metric
二.基本配置
1.R1路由器

hostname R1
int l0
ip add 1.1.1.1 255.255.255.0
int f0/0
ip add 12.1.1.1 255.255.255.0
no shutdown
router ospf 1
router-id 1.1.1.1
network 12.1.1.1 0.0.0.0 a 0
2.R2路由器
hostname R2
int l0
ip add 2.2.2.2 255.255.255.0
ip ospf network point-to-point
int l1
ip add 22.22.22.222 255.255.255.0
int f0/0
ip add 12.1.1.2 255.255.255.0
no shutdown
router ospf 1
router-id 2.2.2.2
passive-interface l0
network 12.1.1.2 0.0.0.0 a 0
network 2.2.2.2 0.0.0.0 a 0
redistribute connected subnet

三.修改distance测试
1.R1修改之前先查看路由表

R1#show ip route ospf | in FastEthernet
O 2.2.2.2 [110/2] via 12.1.1.2, 00:00:53, FastEthernet0/0
O E2 22.22.22.0 [110/20] via 12.1.1.2, 00:00:53, FastEthernet0/0
R1#
备注:可以看到,OSPF默认内部和外部路由的管理距离110
2.R1修改所有OSPF外部路由的管理距离
router ospf 1
distance ospf external 111
R1#show ip route ospf | in FastEthernet
O 2.2.2.2 [110/2] via 12.1.1.2, 00:00:09, FastEthernet0/0
O E2 22.22.22.0 [111/20] via 12.1.1.2, 00:00:09, FastEthernet0/0
R1#
R1(config-router)#distance ospf ?
external External type 5 and type 7 routes
inter-area Inter-area routes
intra-area Intra-area routes
备注:可以看到OSPF可以修改多种OSPF路由的管理距离。
3.R1用ACL匹配路由,再用distance修改
no access-list 10
access-list 10 permit 2.2.2.0
access-list 10 permit 22.22.22.0
router ospf 1
no distance ospf external 111
distance 111 2.2.2.2 0.0.0.0 10
R1#show ip route ospf | in FastEthernet
O 2.2.2.0 [111/2] via 12.1.1.2, 00:00:31, FastEthernet0/0
O E2 22.22.22.0 [111/20] via 12.1.1.2, 00:01:19, FastEthernet0/0
R1#
备注:可以看到,这种方式可以用ACL匹配路由,与EIGRP不同,既能修改内部路由也能修改外部路由的管理距离。
四.修改metric测试
1.distribute-list修改metric
①ospf的distribute-list的out方向不支持调用route-map修改metric

--R2路由器
route-map SetMetric permit 10
set metric 21
R2(config)# router ospf 1
R2(config-router)# distribute-list route-map SetMetric out
% OUT direction is not allowed in case of OSPF
R2(config-router)#
int l2
ip add 100.1.1.2 255.255.255.0
access-list 10 permit 100.1.1.0
router ospf 1
distribute-list 10 out
R1#show ip route ospf | in FastEthernet
O 2.2.2.0 [111/2] via 12.1.1.2, 00:36:47, FastEthernet0/0
O E2 100.1.1.0 [110/20] via 12.1.1.2, 00:01:58, FastEthernet0/0
R1#
备注:可以看到,distribute-list的out方向虽然不能调用route-map修改metric,但是可以控制外部路由条目的发送
②OSPF的distribute-list的in方向也不能调用route-map修改metric
--R1路由器

no route-map SetMetric
route-map SetMetric permit 10
set metric 21
router ospf 1
no distance 111 2.2.2.2 0.0.0.0 10
distribute-list route-map SetMetric in
R1(config-router)# distribute-list route-map SetMetric in ?

R1(config-router)#
备注:可以看到,distribute-list 调用route-map后面不能接接口
--R1上面的metric没有修改
R1#show ip route ospf | in FastEthernet
O 2.2.2.0 [110/2] via 12.1.1.2, 00:07:48, FastEthernet0/0
O E2 100.1.1.0 [110/20] via 12.1.1.2, 00:07:48, FastEthernet0/0
R1#
③OSPF的distribute-list的in方向也不能调用route-map修改metric-type
--R2取消 distribute-list
router ospf 1
no distribute-list 10 out
--R1配置 distribute-list
no access-list 10
no route-map SetMetric
access-list 10 permit 22.22.22.0
route-map SetMetric permit 10
match ip address 10
set metric-type type-1
route-map SetMetric permit 20
router ospf 1
distribute-list route-map SetMetric in
--R1上外部路由仍然是O E2
R1#show ip route ospf | in FastEtherne
O 2.2.2.0 [110/2] via 12.1.1.2, 00:03:56, FastEthernet0/0
O E2 22.22.22.0 [110/20] via 12.1.1.2, 00:03:56, FastEthernet0/0
O E2 100.1.1.0 [110/20] via 12.1.1.2, 00:03:56, FastEthernet0/0
R1#
2.redistribute的时候调用route-map修改metric
①R1清除之前的odistribute-list配置

router ospf 1
no distribute-list route-map SetMetric in
②修改之前查看R1的路由表
R1#show ip route ospf | in FastEtherne
O 2.2.2.0 [110/2] via 12.1.1.2, 00:06:33, FastEthernet0/0
O E2 22.22.22.0 [110/20] via 12.1.1.2, 00:06:33, FastEthernet0/0
O E2 100.1.1.0 [110/20] via 12.1.1.2, 00:06:33, FastEthernet0/0
R1#
③R2重新配置redistribute
no access-list 20
no route-map SetMetric
access-list 20 permit 22.22.22.0
route-map SetMetric permit 10
match ip address 20
set metric 21
route-map SetMetric permit 20
router ospf 1
no redistribute connected subnets
redistribute connected subnets route-map SetMetric
④修改之后R1路由表
R1#show ip route ospf | in FastEtherne
O 2.2.2.0 [110/2] via 12.1.1.2, 00:08:44, FastEthernet0/0
O E2 22.22.22.0 [110/21] via 12.1.1.2, 00:00:05, FastEthernet0/0
O E2 100.1.1.0 [110/20] via 12.1.1.2, 00:00:10, FastEthernet0/0
R1#
备注:可以看到已经成功被修改
3.redistribute的时候调用route-map修改metric-type,从而自动修改metric
①R2上重新配置redistribute
no access-list 20
no route-map SetMetric
access-list 20 permit 22.22.22.0
route-map SetMetric permit 10
match ip address 20
set metric-type type-1
route-map SetMetric permit 20
router ospf 1
redistribute connected subnets route-map SetMetric
②R1上指定的路由类型和metric已经被修改
R1#show ip route ospf | in FastEtherne
O 2.2.2.0 [110/2] via 12.1.1.2, 00:11:53, FastEthernet0/0
O E1 22.22.22.0 [110/21] via 12.1.1.2, 00:00:04, FastEthernet0/0
O E2 100.1.1.0 [110/20] via 12.1.1.2, 00:03:19, FastEthernet0/0
R1#
评论
one-time
Level 13
Level 13
感谢楼主分享,谢谢~
l8310892118l
Level 1
Level 1

谢谢版主分享!
likuo
Spotlight
Spotlight
测试需要按步骤来。
入门指南

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

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









快捷链接