请选择 进入手机版 | 继续访问电脑版

设为首页 收藏本站
思科社区 关注
思科社区

搜索
热搜: 邮件服务器
查看: 964|回复: 3

【原创】双点双向路由重分发的路由反馈和次优路径处理测试(ISIS和OSPF)

[复制链接]
发表于 2020-3-12 19:53:59 | 显示全部楼层 |阅读模式
本帖最后由 碧云天 于 2020-3-12 19:58 编辑

一.测试拓扑



测试总结:
1.用distance修改OSPF所有外部路由的管理距离,以及用distance修改指定路由发送的匹配ACL路由的管理距离可以并存
2.对于ISIS,重分发的时候,用route-map来设置metric,只能使metric增加,不能使metric减小,即使设置负值,还是增加,并且是在基数10上面增加

二.基本配置
1.R3路由器

hostname R3
interface Loopback0
    ip address 3.3.3.3 255.255.255.0
interface Loopback33
    ip address 33.33.33.33 255.255.255.0
interface Ethernet0/0
    ip address 23.1.1.3 255.255.255.0
    no shutdown
interface Ethernet0/1
    ip address 13.1.1.3 255.255.255.0
    no shutdown
router isis
    net 49.0001.3333.3333.3333.00
    log-adjacency-changes all
    passive-interface Loopback0
interface Loopback0
    ip router isis
interface range ethernet 0/0 -1
    ip router isis
2.R1路由器
hostname R1
interface Loopback0
    ip address 1.1.1.1 255.255.255.0
interface Loopback11
    ip address 11.11.11.11 255.255.255.0
    ip ospf network point-to-point
interface Ethernet0/0
    ip address 14.1.1.1 255.255.255.0
    ip ospf network point-to-point
    no shutdown
interface Ethernet0/1
    ip address 13.1.1.1 255.255.255.0
    no shutdown
router isis
    net 49.0001.1111.1111.1111.00
    log-adjacency-changes all
   passive-interface Loopback0
interface Loopback0
    ip router isis
interface range ethernet 0/1
    ip router isis
interface Loopback0
router ospf 1
    router-id 1.1.1.1
    passive-interface Loopback11
    network 11.11.11.11 0.0.0.0 area 0
    network 14.1.1.1 0.0.0.0 area 0
3.R2路由器
hostname R2
interface Loopback0
    ip address 2.2.2.2 255.255.255.0
interface Loopback2
    ip address 22.22.22.22 255.255.255.0
interface Ethernet0/0
    ip address 23.1.1.2 255.255.255.0
    no shutdown
interface Ethernet0/1
    ip address 24.1.1.2 255.255.255.0
    ip ospf network point-to-point
    no shutdown
router isis
    net 49.0001.2222.2222.2222.00
    log-adjacency-changes all
    passive-interface Loopback0
interface Loopback0
    ip router isis
interface range ethernet 0/0
    ip router isis
router ospf 1
    router-id 2.2.2.2
    passive-interface Loopback22
    network 22.22.22.22 0.0.0.0 area 0
    network 24.1.1.2 0.0.0.0 area 0
4.R4路由器
interface Loopback0
    ip address 4.4.4.4 255.255.255.0
    ip ospf network point-to-point
interface Loopback44
    ip address 44.44.44.44 255.255.255.0
interface Ethernet0/0
    ip address 14.1.1.4 255.255.255.0
    ip ospf network point-to-point
    no shutdown
interface Ethernet0/1
    ip address 24.1.1.4 255.255.255.0
    ip ospf network point-to-point
    no shutdown
router ospf 1
    router-id 4.4.4.4
    passive-interface Loopback0
    network 4.4.4.4 0.0.0.0 area 0
    network 14.1.1.4 0.0.0.0 area 0
    network 24.1.1.4 0.0.0.0 area 0
三.配置从左到右的路由重分发
1.R3把直连路由重分发到ISIS
①R3配置重分发

router isis
redistribute connected
②路由验证
R1#show ip route | in i L
i L1     2.2.2.0 [115/20] via 13.1.1.3, 00:08:55, Ethernet0/1
i L1     3.3.3.0 [115/10] via 13.1.1.3, 00:03:50, Ethernet0/1
i L1     23.1.1.0 [115/20] via 13.1.1.3, 00:03:50, Ethernet0/1
i L2     33.33.33.0 [115/10] via 13.1.1.3, 00:00:25, Ethernet0/1
R1#
R2#show ip route | in i L
i L1     1.1.1.0 [115/20] via 23.1.1.3, 00:05:42, Ethernet0/0
i L1     3.3.3.0 [115/10] via 23.1.1.3, 00:05:22, Ethernet0/0
i L1     13.1.1.0 [115/20] via 23.1.1.3, 00:05:22, Ethernet0/0
i L2     33.33.33.0 [115/10] via 23.1.1.3, 00:01:58, Ethernet0/0
R2#
2.R1把ISIS路由重分发到OSPF
①R1配置重分发
router ospf 1
redistribute isis subnets
②路由验证
R4#show ip route | in O E2
O E2     33.33.33.0 [110/20] via 14.1.1.1, 00:02:10, Ethernet0/0
R4#
R2#show ip route | in O E2
O E2     33.33.33.0 [110/20] via 24.1.1.4, 00:01:31, Ethernet0/1
R2#
备注:可以看到,默认把ISIS重分发的时候,只重分发L2的路由,另外因为ISIS路由的管理距离为115,而OSPF的为110,R2出现了路由反馈
③解决R1只重分发L2路由:修改重分发命令,指定level-1-2
--修改R1的重分发,添加level-1-2
router ospf 1
redistribute isis level-1-2 subnets
--查看R4的路由,发现把ISIS重分发进OSPF的时候,指定了level-1-2,不会把宣告进ISIS的直连路由重分发
R4#show ip route | in O E2
O E2     2.2.2.0 [110/20] via 14.1.1.1, 00:02:54, Ethernet0/0
O E2     3.3.3.0 [110/20] via 14.1.1.1, 00:02:54, Ethernet0/0
O E2     23.1.1.0 [110/20] via 14.1.1.1, 00:02:54, Ethernet0/0
O E2     33.33.33.0 [110/20] via 14.1.1.1, 00:02:54, Ethernet0/0
R4#
--再次修改R1的重分发,添加level-1-2和直连路由,只能用两句
router ospf 1
redistribute connected subnets
redistribute isis level-1-2 subnets
--这次R4的路由正常了
R4#show ip route | in O E2
O E2     1.1.1.0 [110/20] via 14.1.1.1, 00:00:42, Ethernet0/0
O E2     2.2.2.0 [110/20] via 14.1.1.1, 00:08:28, Ethernet0/0
O E2     3.3.3.0 [110/20] via 14.1.1.1, 00:08:28, Ethernet0/0
O E2     13.1.1.0 [110/20] via 14.1.1.1, 00:00:42, Ethernet0/0
O E2     23.1.1.0 [110/20] via 14.1.1.1, 00:08:28, Ethernet0/0
O E2     33.33.33.0 [110/20] via 14.1.1.1, 00:08:28, Ethernet0/0
R4#
--不过R2出现路由反馈的条目更多了
R2#show ip route | in O E2         
O E2     1.1.1.0 [110/20] via 24.1.1.4, 00:00:07, Ethernet0/1
O E2     3.3.3.0 [110/20] via 24.1.1.4, 00:00:07, Ethernet0/1
O E2     13.1.1.0 [110/20] via 24.1.1.4, 00:00:07, Ethernet0/1
O E2     33.33.33.0 [110/20] via 24.1.1.4, 00:00:07, Ethernet0/1
R2#
③解决R2的路由反馈:用distrance命令修改ospf所有外部路由的管理距离
access-list 33 permit 33.33.33.0
router ospf 1
distance 116 1.1.1.1 0.0.0.0 33
--觉得用上面更合适一些,并且多个上面的语句可以并存
router ospf 1
distance ospf external 116
④处理后,R2的路由恢复正常
R2#show ip route | in i L
i L1     1.1.1.0 [115/20] via 23.1.1.3, 00:14:58, Ethernet0/0
i L1     3.3.3.0 [115/10] via 23.1.1.3, 00:14:38, Ethernet0/0
i L1     13.1.1.0 [115/20] via 23.1.1.3, 00:14:38, Ethernet0/0
i L2     33.33.33.0 [115/10] via 23.1.1.3, 00:00:10, Ethernet0/0
R2#
3.R2把ISIS路由重分发到OSPF
①R2配置重分发

router ospf 1
redistribute connected subnets
redistribute isis level-1-2 subnets
②路由验证
R1#show ip route | in O E2
O E2     33.33.33.0 [110/20] via 14.1.1.4, 00:00:40, Ethernet0/0
R1#
②路由验证
R1#show ip route | in O E2
O E2     2.2.2.0 [110/20] via 14.1.1.4, 00:00:21, Ethernet0/0
O E2     3.3.3.0 [110/20] via 14.1.1.4, 00:00:15, Ethernet0/0
O E2     23.1.1.0 [110/20] via 14.1.1.4, 00:00:21, Ethernet0/0
O E2     33.33.33.0 [110/20] via 14.1.1.4, 00:00:15, Ethernet0/0
R1#

R4#show ip route | in 110
O E2     1.1.1.0 [110/20] via 24.1.1.2, 00:00:06, Ethernet0/1
                 [110/20] via 14.1.1.1, 00:00:06, Ethernet0/0
O E2     2.2.2.0 [110/20] via 24.1.1.2, 00:00:06, Ethernet0/1
O E2     3.3.3.0 [110/20] via 24.1.1.2, 00:00:06, Ethernet0/1
O        11.11.11.0 [110/11] via 14.1.1.1, 00:00:06, Ethernet0/0
O E2     13.1.1.0 [110/20] via 24.1.1.2, 00:00:06, Ethernet0/1
                  [110/20] via 14.1.1.1, 00:00:06, Ethernet0/0
O        22.22.22.0 [110/11] via 24.1.1.2, 00:00:06, Ethernet0/1
O E2     23.1.1.0 [110/20] via 24.1.1.2, 00:00:06, Ethernet0/1
O E2     33.33.33.0 [110/20] via 24.1.1.2, 00:00:06, Ethernet0/1
R4#
备注:可以看到R1出现了路由反馈,R4也出现了次优路径
③解决R1的路由反馈:用distrance命令修改ospf所有外部路由的管理距离
router ospf 1
distance ospf external 116
---处理后,R1的路由恢复正常
R1#show ip route | in i L
i L1     2.2.2.0 [115/30] via 13.1.1.3, 00:00:09, Ethernet0/1
i L1     3.3.3.0 [115/10] via 13.1.1.3, 00:00:09, Ethernet0/1
i L1     23.1.1.0 [115/20] via 13.1.1.3, 00:00:09, Ethernet0/1
i L2     33.33.33.0 [115/10] via 13.1.1.3, 00:00:09, Ethernet0/1
R1#
---但是R4的次优路径多了一条
R4#show ip route | in 110
O E2     1.1.1.0 [110/20] via 24.1.1.2, 00:01:22, Ethernet0/1
                 [110/20] via 14.1.1.1, 00:01:22, Ethernet0/0
O E2     2.2.2.0 [110/20] via 24.1.1.2, 00:01:22, Ethernet0/1
                 [110/20] via 14.1.1.1, 00:00:23, Ethernet0/0
O E2     3.3.3.0 [110/20] via 24.1.1.2, 00:01:22, Ethernet0/1
                 [110/20] via 14.1.1.1, 00:00:23, Ethernet0/0
O        11.11.11.0 [110/11] via 14.1.1.1, 00:01:22, Ethernet0/0
O E2     13.1.1.0 [110/20] via 24.1.1.2, 00:01:22, Ethernet0/1
                  [110/20] via 14.1.1.1, 00:01:22, Ethernet0/0
O        22.22.22.0 [110/11] via 24.1.1.2, 00:01:22, Ethernet0/1
O E2     23.1.1.0 [110/20] via 24.1.1.2, 00:01:22, Ethernet0/1
                  [110/20] via 14.1.1.1, 00:00:23, Ethernet0/0
O E2     33.33.33.0 [110/20] via 24.1.1.2, 00:01:22, Ethernet0/1
                    [110/20] via 14.1.1.1, 00:00:23, Ethernet0/0
R4#
③解决R4的次优路径:R2重分发的时候用route-map设置不同的metric值
no access-list 10
no access-list 20
access-list 10 permit 13.1.1.0
access-list 20 permit 23.1.1.0
route-map SetMetric permit 10
    match ip address 10
    set metric 21
route-map SetMetric permit 20
    match ip address 20
    set metric -1
route-map SetMetric permit 30
router ospf 1
    redistribute isis level-1-2 subnets route-map  SetMetric
     redistribute connected subnets route-map  SetMetric
--处理完成后,R4路由恢复正常
R4#show ip route | in 110
O E2     1.1.1.0 [110/20] via 24.1.1.2, 00:01:37, Ethernet0/1
                 [110/20] via 14.1.1.1, 00:01:37, Ethernet0/0
O E2     2.2.2.0 [110/20] via 24.1.1.2, 00:01:37, Ethernet0/1
                 [110/20] via 14.1.1.1, 00:01:37, Ethernet0/0
O E2     3.3.3.0 [110/20] via 24.1.1.2, 00:01:37, Ethernet0/1
                 [110/20] via 14.1.1.1, 00:01:37, Ethernet0/0
O        11.11.11.0 [110/11] via 14.1.1.1, 00:01:37, Ethernet0/0
O E2     13.1.1.0 [110/20] via 14.1.1.1, 00:01:37, Ethernet0/0
O        22.22.22.0 [110/11] via 24.1.1.2, 00:01:37, Ethernet0/1
O E2     23.1.1.0 [110/19] via 24.1.1.2, 00:00:11, Ethernet0/1
O E2     33.33.33.0 [110/20] via 24.1.1.2, 00:01:37, Ethernet0/1
                    [110/20] via 14.1.1.1, 00:01:37, Ethernet0/0
R4#
三.配置从右到的左路由重分发
1.R4把直连路由重分发到OSPF
①R4配置重分发

router ospf 1
redistribute connected subnets
②路由验证
R1#show ip route | in O E2
O E2     44.44.44.0 [116/20] via 14.1.1.4, 00:00:22, Ethernet0/0
R1#
R2#show ip route | in O E2
O E2     44.44.44.0 [116/20] via 24.1.1.4, 00:00:45, Ethernet0/1
R2#
2.R1把OSPF路由重分发到ISIS
①R1配置重分发

router isis
redistribute ospf 1 level-1-2
②路由验证
R3#show ip route | in 115
i L1     1.1.1.0 [115/20] via 13.1.1.1, 00:00:09, Ethernet0/1
i L1     2.2.2.0 [115/20] via 23.1.1.2, 00:47:42, Ethernet0/0
i L1     4.4.4.0 [115/10] via 13.1.1.1, 00:00:09, Ethernet0/1
i L1     11.11.11.0 [115/10] via 13.1.1.1, 00:00:09, Ethernet0/1
i L1     14.1.1.0 [115/10] via 13.1.1.1, 00:00:09, Ethernet0/1
i L1     22.22.22.0 [115/10] via 13.1.1.1, 00:00:09, Ethernet0/1
i L1     24.1.1.0 [115/10] via 13.1.1.1, 00:00:09, Ethernet0/1
R3#
R1#show ip route | in L2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
i L2     33.33.33.0 [115/10] via 13.1.1.3, 00:00:08, Ethernet0/1
i L2     44.44.44.0 [115/20] via 13.1.1.3, 00:00:08, Ethernet0/1
R1#show ip route | in L2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
i L2     33.33.33.0 [115/10] via 13.1.1.3, 00:00:00, Ethernet0/1
R1#

R2#show ip route | in i L2
i L2     33.33.33.0 [115/10] via 23.1.1.3, 00:00:05, Ethernet0/0
R2#show ip route | in i L2
i L2     33.33.33.0 [115/10] via 23.1.1.3, 00:00:06, Ethernet0/0
i L2     44.44.44.0 [115/20] via 23.1.1.3, 00:00:01, Ethernet0/0
R2#
备注:可以看到R1R2路由都出现了问题,44.44.44.0/24这条路由来回在O E2和i L2漂移
③解决R1和R2的路由反馈问题:在两台设备上都用ACL匹配OSPF的外部路由,并设置其管理距离
access-list 44 permit 44.44.44.0
router ospf 1
distance 111 4.4.4.4 0.0.0.0 44

R1#show ip route | in O E2
O E2     44.44.44.0 [111/20] via 14.1.1.4, 00:06:10, Ethernet0/0
R1#
R2#show ip route | in O E2
O E2     44.44.44.0 [111/20] via 24.1.1.4, 00:01:58, Ethernet0/1
R2#
3.R2把OSPF路由重分发到ISIS
①R2配置重分发

router isis
redistribute ospf 1 level-1-2
②路由验证
R1#show ip route | in O E2
O E2     44.44.44.0 [111/20] via 14.1.1.4, 00:09:37, Ethernet0/0
R1#
R2#show ip route | in O E2
O E2     44.44.44.0 [111/20] via 24.1.1.4, 00:05:57, Ethernet0/1
R2#
R3#SHOW ip route | in 115
i L1     1.1.1.0 [115/20] via 13.1.1.1, 00:08:00, Ethernet0/1
i L1     2.2.2.0 [115/20] via 23.1.1.2, 00:00:19, Ethernet0/0
i L1     4.4.4.0 [115/10] via 23.1.1.2, 00:00:19, Ethernet0/0
                 [115/10] via 13.1.1.1, 00:00:19, Ethernet0/1
i L1     11.11.11.0 [115/10] via 23.1.1.2, 00:00:19, Ethernet0/0
                    [115/10] via 13.1.1.1, 00:00:19, Ethernet0/1
i L1     14.1.1.0 [115/10] via 23.1.1.2, 00:00:19, Ethernet0/0
                  [115/10] via 13.1.1.1, 00:00:19, Ethernet0/1
i L1     22.22.22.0 [115/10] via 23.1.1.2, 00:00:19, Ethernet0/0
                    [115/10] via 13.1.1.1, 00:00:19, Ethernet0/1
i L1     24.1.1.0 [115/10] via 23.1.1.2, 00:00:19, Ethernet0/0
                  [115/10] via 13.1.1.1, 00:00:19, Ethernet0/1
i L1     44.44.44.0 [115/10] via 23.1.1.2, 00:00:19, Ethernet0/0
                    [115/10] via 13.1.1.1, 00:00:19, Ethernet0/1
R3#
备注:可以看到R3上面出现了次优路径
③解决R3的次优路径:测试
备注:测试发现,ISIS在重分发的时候,调用route-map设置metric的数字,最终只是使metric在10的基数上加上设置数字的绝对值。
---R1重分发的时候用route-map设置不同的metric值
access-list 10 permit 11.11.11.0
access-list 10 permit 14.1.1.0
access-list 20 permit 22.22.22.0
access-list 20 permit 24.1.1.0
no route-map SetMetricISIS
route-map SetMetricISIS permit 10
    match ip address 10
    set metric 1
route-map SetMetricISIS permit 20
    match ip address 20
    set metric 2
route-map SetMetricISIS permit 30
router isis
redistribute ospf 1 level-1-2 route-map SetMetricISIS
--R2重分发的时候用route-map设置不同的metric值
access-list 50 permit 11.11.11.0
access-list 50 permit 14.1.1.0
access-list 60 permit 22.22.22.0
access-list 60 permit 24.1.1.0
no route-map SetMetricISIS
route-map SetMetricISIS permit 10
    match ip address 50
    set metric  -2
route-map SetMetricISIS permit 20
    match ip address 60
    set metric -1
route-map SetMetricISIS permit 30
router isis
redistribute ospf 1 level-1-2 route-map SetMetricISIS
--修改后的R3的路由表
R3#SHOW ip route | in 115
i L1     1.1.1.0 [115/20] via 13.1.1.1, 00:00:01, Ethernet0/1
i L1     2.2.2.0 [115/20] via 23.1.1.2, 00:04:51, Ethernet0/0
i L1     4.4.4.0 [115/10] via 23.1.1.2, 00:00:01, Ethernet0/0
                 [115/10] via 13.1.1.1, 00:00:01, Ethernet0/1
i L1     11.11.11.0 [115/11] via 13.1.1.1, 00:00:01, Ethernet0/1
i L1     14.1.1.0 [115/11] via 13.1.1.1, 00:00:01, Ethernet0/1
i L1     22.22.22.0 [115/11] via 23.1.1.2, 00:04:51, Ethernet0/0
i L1     24.1.1.0 [115/11] via 23.1.1.2, 00:04:51, Ethernet0/0
i L1     44.44.44.0 [115/10] via 23.1.1.2, 00:00:01, Ethernet0/0
                    [115/10] via 13.1.1.1, 00:00:01, Ethernet0/1
R3#
④解决R3的次优路径:最终
---R1重分发的时候用route-map设置不同的metric值
access-list 20 permit 22.22.22.0
access-list 20 permit 24.1.1.0
no route-map SetMetricISIS
route-map SetMetricISIS permit 20
    match ip address 20
    set metric 1
route-map SetMetricISIS permit 30
router isis
redistribute ospf 1 level-1-2 route-map SetMetricISIS
--R2重分发的时候用route-map设置不同的metric值
access-list 50 permit 11.11.11.0
access-list 50 permit 14.1.1.0
no route-map SetMetricISIS
route-map SetMetricISIS permit 10
    match ip address 50
    set metric  1
route-map SetMetricISIS permit 30
router isis
redistribute ospf 1 level-1-2 route-map SetMetricISIS
--修改后的R3的路由表
R3#SHOW ip route | in 115
i L1     1.1.1.0 [115/20] via 13.1.1.1, 00:00:08, Ethernet0/1
i L1     2.2.2.0 [115/20] via 23.1.1.2, 00:00:03, Ethernet0/0
i L1     4.4.4.0 [115/10] via 23.1.1.2, 00:00:03, Ethernet0/0
                 [115/10] via 13.1.1.1, 00:00:03, Ethernet0/1
i L1     11.11.11.0 [115/10] via 13.1.1.1, 00:00:08, Ethernet0/1
i L1     14.1.1.0 [115/10] via 13.1.1.1, 00:00:08, Ethernet0/1
i L1     22.22.22.0 [115/10] via 23.1.1.2, 00:00:03, Ethernet0/0
i L1     24.1.1.0 [115/10] via 23.1.1.2, 00:00:03, Ethernet0/0
i L1     44.44.44.0 [115/10] via 23.1.1.2, 00:00:03, Ethernet0/0
                    [115/10] via 13.1.1.1, 00:00:03, Ethernet0/1
R3#

本帖子中包含更多资源

您需要 思科 CCO 登录 才可以下载或查看,没有帐号?思科 CCO 注册   

x
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5
平均得分5 (3 评价)
发表于 2020-3-13 21:35:07 | 显示全部楼层
感谢楼主分享,谢谢~
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5
平均得分0 (0 评价)
发表于 2020-3-15 20:02:12 | 显示全部楼层
谢谢分享,学习了
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5
平均得分0 (0 评价)
发表于 2020-4-9 23:12:26 | 显示全部楼层
测试需要仔细。
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5
平均得分0 (0 评价)
您需要登录后才可以回帖 思科 CCO 登录 | 思科 CCO 注册   

本版积分规则

Archiver | 思科社区  

GMT+8, 2020-8-7 19:49 , Processed in 0.157319 second(s), 37 queries .

京ICP备11014401号-17

© 2020 思科系统.版权所有 重要声明 | 保密声明 | 隐私权政策 | 商标 |

快速回复 返回顶部 返回列表