IP : 开放最短路径优先 (OSPF)

在 OSPF 进程之间再分配时的次理想路由

2016 年 10 月 24 日 - 机器翻译
其他版本: PDFpdf | 英语 (2015 年 8 月 22 日) | 反馈


目录


简介

当在开放最短路径优先(OSPF)之间的重新分发处理并且提供解决方案时,本文展示不最理想的路由问题。

先决条件

要求

本文档没有任何特定的要求。

使用的组件

本文档不限于特定的软件和硬件版本。

本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您使用的是真实网络,请确保您已经了解所有命令的潜在影响。

规则

有关文档规则的详细信息,请参阅 Cisco 技术提示规则

问题

当重新分配在多点的区别OSPF进程之间在网络时,进入subobtimal路由的情况甚至更坏,路由环路是可能的。

在下面拓扑里我们有进程OSPF1,并且OSPF 2.路由器1 (R1)和路由器2 (R2)从OSPF1再分布到OSPF2。

/image/gif/paws/28025/2ospf-redis-1.jpg

路由器的R1R2配置如下所示。

R1
hostname r1  
!  
ip subnet-zero  
!  
interface Loopback0  
 ip address 10.255.255.1 255.255.255.255  
!  
interface Loopback1  
 ip address 192.168.255.1 255.255.255.255  
!  
interface Ethernet0/0  
 ip address 10.0.0.1 255.255.255.0  
!  
interface Ethernet1/0  
 ip address 192.168.0.1 255.255.255.0  
!  
router ospf 1  
 router-id 10.255.255.1  
 log-adjacency-changes  
 passive-interface Loopback0  
network 10.0.0.0 0.0.0.255 area 0
 network 10.255.255.1 0.0.0.0 area 0 
!  
router ospf 2  
 router-id 192.168.255.1  
 log-adjacency-changes  
 redistribute ospf 1 subnets match internal
 
!--- Redistributing OSPF 1 into OSPF 2.
 
 passive-interface Loopback1  
 network 192.168.0.0 0.0.0.255 area 0  
 network 192.168.255.1 0.0.0.0 area 0  
!  
ip classless  
!  
end

R2
hostname r2  
!  
ip subnet-zero  
!  
 
interface Loopback0  
 ip address 10.255.255.2 255.255.255.255  
!  
interface Loopback1  
 ip address 192.168.255.2 255.255.255.255  
!  
interface Ethernet0/0  
 ip address 10.0.0.2 255.255.255.0  
!  
interface Ethernet1/0  
 ip address 192.168.0.2 255.255.255.0  
!  
router ospf 1  
 router-id 10.255.255.2  
 log-adjacency-changes  
 passive-interface Loopback0  
network 10.0.0.0 0.0.0.255 area 0 
 network 10.255.255.2 0.0.0.0 area 0  
!  
router ospf 2  
 router-id 192.168.255.2  
 log-adjacency-changes  
 redistribute ospf 1 subnets match internal

!--- Redistributing OSPF 1 into OSPF 2. 

 passive-interface Loopback1  
 network 192.168.0.0 0.0.0.255 area 0  
 network 192.168.255.2 0.0.0.0 area 0  
!  
ip classless  
 
end

上述拓扑, R4's E1/0在区域1,并且E0/0在Area 0。所以, R4是通告网络10.0.1.0/24的区域边界路由器(ABR)作为域间(IA)路由对R1和R2。R1和R2重新分配此信息到OSPF2。重新分配配置命令在R1R2的上述配置里突出显示。所以, R1和R2学习大约10.0.1.0/24作为IA通过OSPF1和作为外部类型2 (E2)通过OSPF2,因为外部链路状态通告(LSA)被传播在OSPF2域中。

因为IA路由在E1或E2路由总是被偏好,所需的是看到,在R1和R2里路由表, 10.0.1.0/24是有next-hop R4的一个IA路由。然而,当查看他们的路由表,不同的事被看到时-在R1, 10.0.1.0/24是有next-hop R4的一个IA路由,但是在R2, 10.0.1.0/24是有下一条R1的一个E2路由。

这是命令输出show ip route命令R1的。

r1#show ip route 
 
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP 
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP 
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area 
       * - candidate default, U - per-user static route, o - ODR 
       P - periodic downloaded static route 
 

!--- The gateway of the last resort is not set.
 
 
     10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks 
O E2    10.255.255.2/32 [110/1] via 192.168.0.2, 00:24:21, Ethernet1/0 
C       10.0.0.0/24 is directly connected, Ethernet0/0 
O IA    10.0.1.0/24 [110/20] via 10.0.0.4, 00:23:49, Ethernet0/0 
C       10.255.255.1/32 is directly connected, Loopback0 
O IA    10.255.255.4/32 [110/11] via 10.0.0.4, 00:23:49, Ethernet0/0 
     192.168.255.0/32 is subnetted, 3 subnets 
O       192.168.255.3 [110/11] via 192.168.0.3, 00:26:09, Ethernet1/0 
O       192.168.255.2 [110/11] via 192.168.0.2, 00:26:09, Ethernet1/0 
C       192.168.255.1 is directly connected, Loopback1 
C    192.168.0.0/24 is directly connected, Ethernet1/0 
O    192.168.1.0/24 [110/20] via 192.168.0.3, 00:26:09, Ethernet1/0 

这是命令输出show ip route命令R2的。

r2#show ip route 
 
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP 
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP 
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area 
       * - candidate default, U - per-user static route, o - ODR 
       P - periodic downloaded static route 
 

!--- The gateway of last resort is not set. 

 
     10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks 
C       10.255.255.2/32 is directly connected, Loopback0 
C       10.0.0.0/24 is directly connected, Ethernet0/0 
O E2    10.0.1.0/24 [110/20] via 192.168.0.1, 00:25:34, Ethernet1/0 
O E2    10.255.255.1/32 [110/1] via 192.168.0.1, 00:25:34, Ethernet1/0 
O E2    10.255.255.4/32 [110/11] via 192.168.0.1, 00:25:34, Ethernet1/0 
     192.168.255.0/32 is subnetted, 3 subnets 
O       192.168.255.3 [110/11] via 192.168.0.3, 00:26:45, Ethernet1/0 
C       192.168.255.2 is directly connected, Loopback1 
O       192.168.255.1 [110/11] via 192.168.0.1, 00:26:45, Ethernet1/0 
C    192.168.0.0/24 is directly connected, Ethernet1/0 
O    192.168.1.0/24 [110/20] via 192.168.0.3, 00:26:45, Ethernet1/0 

为什么发生此问题?

当启用在一个路由器的多个OSPF进程,从软件中的时,进程独立。OSPF协议,在一OSPF程序里面,总是偏好在外部路由的内部路由。然而, OSPF不执行在进程之间的任何OSPF路由选择(例如, OSPF度量和路由类型没有被考虑到,当决定进程应该安装到路由表)的路由时。

没有不同的OSPF进程之间的交互作用,并且同分决赛是管理距离。因此,因为两个OSPF进程有默认管理距离110,尝试第一的进程安装路由做它成路由表。所以,必须配置路由的管理距离从不同的OSPF进程,因此某些OSPF进程路由在另一进程路由被偏好由人的目的,和不作为机会问题。

关于管理距离的更多信息,参考什么是管理距离。关于在路由表里发送安置的Cisco路由器如何的更多信息选择,参考在Cisco路由器的路由选择

解决方案

解决方案 1

因为我们知道上述情况,路由器选择根据管理距离的最佳路由,逻辑方法防止此行为将增加外部路由的管理距离在OSPF2的。这样,获知的路由通过OSPF1在从OSPF1再分布的外部路由永远将更喜欢到OSPF2。这执行使用sub-router configuration命令距离ospf外部<value>如下面配置所显示。

R1
hostname r1  
!  
ip subnet-zero  
!  
interface Loopback0  
 ip address 10.255.255.1 255.255.255.255  
!  
interface Loopback1  
 ip address 192.168.255.1 255.255.255.255  
!  
interface Ethernet0/0  
 ip address 10.0.0.1 255.255.255.0  
!  
interface Ethernet1/0  
 ip address 192.168.0.1 255.255.255.0  
!  
router ospf 1  
 router-id 10.255.255.1  
 log-adjacency-changes  
 passive-interface Loopback0  
 network 10.0.0.0 0.0.0.255 area 0  
 network 10.255.255.1 0.0.0.0 area 0  
!  
router ospf 2  
 router-id 192.168.255.1  
 log-adjacency-changes  
 redistribute ospf 1 subnets match internal  
 passive-interface Loopback1  
 network 192.168.0.0 0.0.0.255 area 0  
 network 192.168.255.1 0.0.0.0 area 0  
 distance ospf external 115  

!--- Increases the administrative distance of external 
!--- routes to 115. 

!  
ip classless  
!  
end 

R2
hostname r2  
!  
ip subnet-zero  
!  
interface Loopback0  
 ip address 10.255.255.2 255.255.255.255  
!  
interface Loopback1  
 ip address 192.168.255.2 255.255.255.255  
!  
interface Ethernet0/0  
 ip address 10.0.0.2 255.255.255.0  
!  
interface Ethernet1/0  
 ip address 192.168.0.2 255.255.255.0  
!  
router ospf 1  
 router-id 10.255.255.2  
 log-adjacency-changes  
 passive-interface Loopback0  
 network 10.0.0.0 0.0.0.255 area 0  
 network 10.255.255.2 0.0.0.0 area 0  
!  
router ospf 2  
 router-id 192.168.255.2  
 log-adjacency-changes  
 redistribute ospf 1 subnets match internal  
 passive-interface Loopback1  
 network 192.168.0.0 0.0.0.255 area 0  
 network 192.168.255.2 0.0.0.0 area 0  
 distance ospf external 115  

!--- Increases the administrative distance of 
!--- external routes to 115. 

!  
ip classless  
!  
end 

发生的路由表,当更改外部路由的管理距离在OSPF2的如下所示时。

这是命令输出show ip route命令R1的。

r1#show ip route 
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP 
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP 
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area 
       * - candidate default, U - per-user static route, o - ODR 
       P - periodic downloaded static route 
 

!--- The gateway of the last resort is not set.

 
     10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks 
O       10.255.255.2/32 [110/11] via 10.0.0.2, 00:00:35, Ethernet0/0 
C       10.0.0.0/24 is directly connected, Ethernet0/0 
O IA    10.0.1.0/24 [110/20] via 10.0.0.4, 00:00:35, Ethernet0/0 
C       10.255.255.1/32 is directly connected, Loopback0 
O       10.255.255.4/32 [110/11] via 10.0.0.4, 00:00:35, Ethernet0/0 
     192.168.255.0/32 is subnetted, 3 subnets 
O       192.168.255.3 [110/11] via 192.168.0.3, 00:00:35, Ethernet1/0 
O       192.168.255.2 [110/11] via 192.168.0.2, 00:00:35, Ethernet1/0 
C       192.168.255.1 is directly connected, Loopback1 
C    192.168.0.0/24 is directly connected, Ethernet1/0 
O    192.168.1.0/24 [110/20] via 192.168.0.3, 00:00:35, Ethernet1/0 

这是命令输出show ip route命令R2的。

r2#show ip route 
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP 
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP 
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area 
       * - candidate default, U - per-user static route, o - ODR 
       P - periodic downloaded static route 
 

!--- The gateway of the last resort is not set. 

 
     10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks 
C       10.255.255.2/32 is directly connected, Loopback0 
C       10.0.0.0/24 is directly connected, Ethernet0/0 
O       10.255.255.1/32 [110/11] via 10.0.0.1, 00:01:28, Ethernet0/0 
O IA    10.0.1.0/24 [110/20] via 10.0.0.4, 00:01:28, Ethernet0/0 
O       10.255.255.4/32 [110/11] via 10.0.0.4, 00:01:28, Ethernet0/0 
     192.168.255.0/32 is subnetted, 3 subnets 
O       192.168.255.3 [110/11] via 192.168.0.3, 00:01:28, Ethernet1/0 
C       192.168.255.2 is directly connected, Loopback1 
O       192.168.255.1 [110/11] via 192.168.0.1, 00:01:28, Ethernet1/0 
C    192.168.0.0/24 is directly connected, Ethernet1/0 
O    192.168.1.0/24 [110/20] via 192.168.0.3, 00:01:28, Ethernet1/0 

请注意在某些情况下,当也有从OSPF2的再分配到OSPF1时,并且有重新分配到OSPF2 (路由信息协议[RIP],增强的内部网关路由选择协议(EIGRP)静态的其他路由协议,等等),这可能导致在OSPF2的subobtimal路由那些外部路由的。

解决方案 2

如果最终原因实现两个不同的OSPF进程是过滤某些路由,有允许您执行在ABR的路由过滤在Cisco IOSï ¿  ½软件版本12.2(4)T呼叫的SPF ABR类型3 LSA过滤的一新特性。

而不是配置秒钟OSPF程序,是OSPF2的一部分,在以上示例的链路,可能配置作为另一个区域在OSPF1里面。然后,您能实现在R1和R2的需要的路由过滤与此新特性。关于此功能的更多信息,参考SPF ABR类型3 LSA过滤


相关信息


Document ID: 28025