使用多区域邻接配置OSPF

简介

本文档介绍如何为多区域邻接配置开放最短路径优先 (OSPF) 链路状态路由协议。

先决条件

要求

Cisco 建议您了解以下主题:

  • OSPF
  • 多区域邻接

思科还建议在尝试本文档中描述的配置之前先满足以下要求:

  • 必须在网络中预先配置 OSPF 链路状态路由协议。
  • 只有两个 OSPF 发言者使用在其间 OSPF 多区域功能可正常工作的接口。多区域 OSPF 仅适用于点对点网络类型。

使用的组件

本文档中的信息基于多区域 OSPF。

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

背景信息

OSPF 链路状态路由协议使用区域的概念,区域是 OSPF 域内的子域。区域内的路由器保留该区域的完整拓扑信息。默认情况下,接口只能属于一个 OSPF 区域。这不仅会导致网络中的次优路由问题,而且在网络设计不正确时还会导致其他问题。

在接口上配置多区域邻接时,OSPF 发言者会在该链路上建立多个邻接关系 (ADJ)。多区域接口是一种用于形成 ADJ 的点对点逻辑接口。本文档介绍使用多区域OSPF ADJ解决问题并满足网络要求的场景。

配置

网络图

此网络图中使用了网络/OSPF 域。系统要求从路由器 5 (R5) 到 R1 (10.1.1.1) 的流量始终通过 R3。假设R3是网络中的防火墙,所有流量均可通过该防火墙路由,或者R3和R4之间的链路的带宽比R2和R4之间的链路的带宽多。在这两种情况下,系统都要求流量从 R5 传递到 R1(10.1.1.1/32 前缀)时必须流经 R3。

初始路由器配置

本部分介绍 R1 到 R5 的初始配置。

配置R1
interface Ethernet0/0
 ip address 192.168.12.1 255.255.255.0
!
interface Loopback0
 ip address 10.1.1.1 255.255.255.255
!
ip route 0.0.0.0 0.0.0.0 192.168.12.2
配置R2
interface Ethernet0/0
 ip address 192.168.12.2 255.255.255.0
!
interface Ethernet0/1
 ip address 192.168.23.2 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 0
!
interface Ethernet0/2
 ip address 192.168.24.2 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 99
!
interface Loopback0
 ip address 10.2.2.2 255.255.255.255
!
ip route 10.1.1.1 255.255.255.255 192.168.12.1
!
router ospf 1
 router-id 0.0.0.2
 redistribute static metric-type 1 subnets
配置R3
interface Ethernet0/0
 ip address 192.168.34.3 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 99
!
interface Ethernet0/1
 ip address 192.168.23.3 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 0
!
interface Loopback0
 ip address 10.3.3.3 255.255.255.255
!
router ospf 1
 router-id 0.0.0.3
配置R4
interface Ethernet0/0
 ip address 192.168.34.4 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 99
!
interface Ethernet0/1
 ip address 192.168.45.4 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 99
!
interface Ethernet0/2
 ip address 192.168.24.4 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 99
!
interface Loopback0
 ip address 10.4.4.4 255.255.255.255
!
router ospf 1
 router-id 0.0.0.4
配置R5
interface Ethernet0/1
 ip address 192.168.45.5 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 99
!
interface Loopback0
 ip address 10.5.5.5 255.255.255.255
!
router ospf 1
 router-id 0.0.0.5

默认行为

本部分介绍在完成上文配置时路由器的默认行为。

以下是从 R5 到 10.1.1.1 的跟踪结果。请注意,流量通过 R2,而不是 R3:

R5#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 192.168.45.4 6 msec 6 msec 6 msec       <<< R4
2 192.168.24.2 6 msec 6 msec 8 msec       <<< R2
3 192.168.12.1 8 msec * 3 msec            <<< R1

在此网络中,路由器R4必须做出决定,而且可以根据系统要求将流量路由到R3,而不是直接路由到R2。

以下是 R4 上的路由表示例:

R4#show ip route 10.1.1.1
Routing entry for 10.1.1.1/32
Known via "ospf 1", distance 110, metric 30, type extern 1
Last update from 192.168.24.2 on Ethernet0/2, 00:14:33 ago
Routing Descriptor Blocks:
* 192.168.24.2, from 0.0.0.2, 00:14:33 ago, via Ethernet0/2 <<< Towards R2
  Route metric is 30, traffic share count is 1

度量值 30 与此路由(前缀为 10.1.1.1/32)关联。这是因为自治系统边界路由器 (ASBR) (R2) 使用的默认度量值为 20,而 R4 上的接口 Eth0/2 的开销值为 10。

从 R4 经由 R3 到 10.1.1.1/32 前缀的路径更长。此处,R4上接口Ethernet 0/2(通向R2的路径)的开销被更改,以验证它是否更改了行为:

interface Ethernet0/2
 ip address 192.168.24.4 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 99
 ip ospf cost 100
 end

以下是 R5 的跟踪结果以及 R4 中的 show ip route 命令输出:

R5#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 192.168.45.4 4 msec 9 msec 8 msec       <<< R4
2 192.168.24.2 8 msec 9 msec 10 msec      <<< R2
3 192.168.12.1 10 msec * 5 msec           <<< R1
R4#show ip route 10.1.1.1
Routing entry for 10.1.1.1/32
Known via "ospf 1", distance 110, metric 120, type extern 1
Last update from 192.168.24.2 on Ethernet0/2, 00:01:50 ago
Routing Descriptor Blocks:
* 192.168.24.2, from 0.0.0.2, 00:01:50 ago, via Ethernet0/2
  Route metric is 120, traffic share count is 1

正如跟踪结果所示,来自 R5 的流量采用相同的路径,并且流量不会流经 R3。此外,如 R4 上的 show ip route 10.1.1.1 命令输出中所示,在 R4(接口 Ethernet0/2)上添加的开销值 100 将生效,路由到前缀的开销值为 120(与 30 相对)。但是,该路径仍未更改,并且尚未满足流量经过 R3 的要求。

要确定此行为的原因,可参见R4 show ip ospf border-routers命令输出(R4接口Ethernet 0/2上的开销仍设置为100):

R4#show ip ospf border-routers
            OSPF Router with ID (0.0.0.4) (Process ID 1)
                Base Topology (MTID 0)
 Internal Router Routing Table
Codes: i - Intra-area route, I - Inter-area route

i 0.0.0.2 [100] via 192.168.24.2, Ethernet0/2, ABR/ASBR, Area 99, SPF 3
i 0.0.0.3 [10] via 192.168.34.3, Ethernet0/0, ABR, Area 99, SPF 3

在 R4 上,可以看到,有两个区域边界路由器 (ABR)(R2:0.0.0.2;R3:0.0.0.3),并且 R2 为 ASBR。此输出还显示了 ASBR 的区域内 (i) 信息。

现在,R4上的接口Ethernet 0/2已关闭,以确定流量是否流经R3,并查看show ip ospf border-routers命令输出如何显示:

interface Ethernet0/2
 ip address 192.168.24.4 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 99
 ip ospf cost 100
 shutdown 
 end

以下是 R5 的跟踪结果以及 R4 中的 show ip route 命令输出:

R5#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 192.168.45.4 7 msec 7 msec 8 msec       <<< R4
2 192.168.34.3 9 msec 8 msec 8 msec       <<< R3
3 192.168.23.2 9 msec 9 msec 7 msec       <<< R2
4 192.168.12.1 8 msec * 4 msec            <<< R1
R4#show ip route 10.1.1.1
Routing entry for 10.1.1.1/32
Known via "ospf 1", distance 110, metric 40, type extern 1      <<< Metric 40
Last update from 192.168.34.3 on Ethernet0/0, 00:01:46 ago      <<< Traffic to R2
Routing Descriptor Blocks:
* 192.168.34.3, from 0.0.0.2, 00:01:46 ago, via Ethernet0/0
  Route metric is 40, traffic share count is 1

如上所示,关闭 R4 上的接口 Ethernet0/2 时,流量通过 R3。此外,与通向 R3 的路由相关的开销值仅为 40,而经由 R2 到 10.1.1.1/32 的开销值为 120。OSPF 协议仍偏向于通过 R2 而不是 R3 来路由流量,即使通过 R3 到达 10.1.1.1/32 的开销值较低也是如此。

以下是在 R4 上再次执行 show ip ospf border-routers 命令的输出:

R4#show ip ospf border-routers
           OSPF Router with ID (0.0.0.4) (Process ID 1)
               Base Topology (MTID 0)
Internal Router Routing Table
Codes: i - Intra-area route, I - Inter-area route

I 0.0.0.2 [20] via 192.168.34.3, Ethernet0/0, ASBR, Area 99, SPF 4
i 0.0.0.3 [10] via 192.168.34.3, Ethernet0/0, ABR, Area 99, SPF 4

到达ASBR所需的信息是区域间信息。但是,详细说明如何到达 ASBR 的区域内信息要比区域间信息更可取,而不管与这两条路径关联的 OSPF 开销值如何。

因此,通过 R3 的路径不是首选路径,即使通过 R3 的路径开销值更低也是如此。

以下是在 R4 上重新打开接口 Ethernet0/2:

interface Ethernet0/2
 no shutdown
 end

来自 R5 的跟踪结果指明路由操作恢复到以前观察到的结果(即流量不流经 R3):

R5#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 192.168.45.4 6 msec 7 msec 7 msec        <<< R4
2 192.168.24.2 7 msec 8 msec 7 msec        <<< R2
3 192.168.12.1 8 msec * 12 msec            <<< R1

可以使用多种方法来解决此问题(以下列出的方法并不详尽):

  • 将R2和R3之间的区域更改为99,然后修改开销。
  • 在 R2 与 R3 之间另外添加一个链路,并将其配置为位于区域 99 中。
  • 使用多区域 ADJ。

请参阅下一节,了解多区域OSPF ADJ的工作方式及其如何解决当前此问题。

多区域邻接配置

如前所述,多区域ADJ可用于在单个链路上形成多个点对点逻辑邻接。具体要求是,链路上必须只有两个 OSPF 发言者,而且在广播网络中,必须手动将 OSPF 网络类型更改为链路上的点对点。

借助此功能,多个区域可以共享一个物理链路,并且可以在共享链路的每个区域中创建一个区域内路径。

为满足此要求,您必须通过链路Ethernet 0/1在R2和R3之间配置OSPF多区域ADJ,该链路当前仅位于区域0

以下是 R2 的配置:

interface Ethernet0/1
 ip address 192.168.23.2 255.255.255.0
 ip ospf network point-to-point
 ip ospf multi-area 99
 ip ospf 1 area 0
 end

以下是 R3 的配置:

interface Ethernet0/1
 ip address 192.168.23.3 255.255.255.0
 ip ospf network point-to-point
 ip ospf multi-area 99
 ip ospf 1 area 0
 end

OSPF ADJ 出现在虚拟链路上:

%OSPF-5-ADJCHG: Process 1, Nbr 0.0.0.2 on OSPF_MA0 from LOADING to FULL, Loading Done

%OSPF-5-ADJCHG: Process 1, Nbr 0.0.0.3 on OSPF_MA0 from LOADING to FULL, Loading Done

以下是新形成的 ADJ:

R2#show ip ospf neighbor 0.0.0.3
<Snip>
Neighbor 0.0.0.3, interface address 192.168.23.3
   In the area 99 via interface OSPF_MA0
   Neighbor priority is 0, State is FULL, 6 state changes
   DR is 0.0.0.0 BDR is 0.0.0.0
   Options is 0x12 in Hello (E-bit, L-bit)
   Options is 0x52 in DBD (E-bit, L-bit, O-bit)
   LLS Options is 0x1 (LR)
   Dead timer due in 00:00:39
   Neighbor is up for 00:03:01
   Index 2/3, retransmission queue length 0, number of retransmission 0
   First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0)
   Last retransmission scan length is 0, maximum is 0
   Last retransmission scan time is 0 msec, maximum is 0 msec
R3#show ip ospf neighbor 0.0.0.2
<Snip>
Neighbor 0.0.0.2, interface address 192.168.23.2
   In the area 99 via interface OSPF_MA0
   Neighbor priority is 0, State is FULL, 6 state changes
   DR is 0.0.0.0 BDR is 0.0.0.0
   Options is 0x12 in Hello (E-bit, L-bit)
   Options is 0x52 in DBD (E-bit, L-bit, O-bit)
   LLS Options is 0x1 (LR)
   Dead timer due in 00:00:39
   Neighbor is up for 00:01:41
   Index 2/3, retransmission queue length 0, number of retransmission 0
   First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0
   Last retransmission scan length is 0, maximum is 0
   Last retransmission scan time is 0 msec, maximum is 0 msec

验证

要验证配置是否正常工作,请在R4上输入show ip ospf border-routers命令:

R4#show ip ospf border-routers
           OSPF Router with ID (0.0.0.4) (Process ID 1)
                Base Topology (MTID 0)
Internal Router Routing Table
Codes: i - Intra-area route, I - Inter-area route

i 0.0.0.3 [10] via 192.168.34.3, Ethernet0/0, ABR, Area 99, SPF 10
i 0.0.0.2 [20] via 192.168.34.3, Ethernet0/0, ABR/ASBR, Area 99, SPF 10

如图所示,用于将流量路由到R2(0.0.0.2)/ASBR的区域内信息通过R3。这可以解决前面提到的问题。

以下是 R5 的跟踪结果:

R5#traceroute 10.1.1.1
Type escape sequence to abort.
Tracing the route to 10.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 192.168.45.4 8 msec 9 msec 8 msec       <<< R4
2 192.168.34.3 8 msec 8 msec 8 msec       <<< R3
3 192.168.23.2 7 msec 8 msec 8 msec       <<< R2
4 192.168.12.1 8 msec * 4 msec            <<< R1

如上所示,从 R5 到 10.1.1.1 的流量正常流经 R3,并且满足系统要求。

在R2、R3和R4上输入show ip ospf neighbor命令以验证是否已建立ADJ:

R2#show ip ospf neighbor
Neighbor ID Pri  State    Dead Time  Address        Interface
0.0.0.3       0  FULL/ -  00:00:39   192.168.23.3   Ethernet0/1
0.0.0.4       0  FULL/ -  00:00:37   192.168.24.4   Ethernet0/2
0.0.0.3       0  FULL/ -  00:00:33   192.168.23.3   OSPF_MA0
R3#show ip ospf neighbor
Neighbor ID Pri  State    Dead Time  Address        Interface
0.0.0.2       0  FULL/ -  00:00:34   192.168.23.2   Ethernet0/1
0.0.0.2       0  FULL/ -  00:00:35   192.168.23.2   OSPF_MA0
0.0.0.4       0  FULL/ -  00:00:39   192.168.34.4   Ethernet0/0
R4#show ip ospf neighbor
Neighbor ID Pri  State    Dead Time  Address        Interface
0.0.0.2       0  FULL/ -  00:00:32   192.168.24.2   Ethernet0/2  
0.0.0.5       0  FULL/ -  00:00:32   192.168.45.5   Ethernet0/1
0.0.0.3       0  FULL/ -  00:00:35   192.168.34.3   Ethernet0/0

:在这些输出中,Ethernet0/1接口条目表示区域0上的ADJ,OSPF_MA0接口条目表示区域99上的多区域ADJ。

R4 接口 Ethernet0/2 的开销值仍为 100,通过 R3 的路径是 R4 上的首选路径。如果去除此开销值,则 R4 会像以前一样将流量直接路由到 R2。

以下是在 R4 接口 Ethernet0/2 上将 IP OSPF 开销值仍配置为 100 时 R4 上的配置和 show ip route 命令输出:

interface Ethernet0/2
 ip address 192.168.24.4 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 99
ip ospf cost 100
R4#show ip route 10.1.1.1
Routing entry for 10.1.1.1/32
Known via "ospf 1", distance 110, metric 40, type extern 1
Last update from 192.168.34.3 on Ethernet0/0, 00:28:45 ago
Routing Descriptor Blocks:
* 192.168.34.3, from 0.0.0.2, 00:28:45 ago, via Ethernet0/0
  Route metric is 40, traffic share count is 1

以下是去除开销值时 R4 上的配置和 show ip route 命令输出:

interface Ethernet0/2
 ip address 192.168.24.4 255.255.255.0
 ip ospf network point-to-point
 ip ospf 1 area 99
 end
R4#show ip route 10.1.1.1
Routing entry for 10.1.1.1/32
Known via "ospf 1", distance 110, metric 30, type extern 1
Last update from 192.168.24.2 on Ethernet0/2, 00:00:13 ago
Routing Descriptor Blocks:
* 192.168.24.2, from 0.0.0.2, 00:00:13 ago, via Ethernet0/2     <<< Route changed back to R2
     Route metric is 30, traffic share count is 1

故障排除

当前没有故障排除此配置的特定可用资料。

修订历史记录

版本发布日期备注

2.0

02-Aug-2022

内容已更新以确保准确性。 更新的标题、机器翻译、德语等

1.0

31-Mar-2015

初始版本

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值