OSPF特殊区域之STUB

本文探讨了OSPF划分区域的优势,重点解析了Stub区域的特点,包括其不接受4、5类路由,不允许ASBR存在等。通过实验拓扑,展示了配置Stub区域并观察路由情况的过程,同时提及了如何将Stub区域转换为Totally Stub区域以避免外部路由的lsa3。此外,还提到了在有多个ABR时调整cost值以优化选路的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

OSPF划分区域优点:
减小LSDB(lsa泛洪),同时保证到达目标网络的可达性
减小路由震荡
stub(末节网络)区域特点
1. 一个区域配置为stub时,所有相关路由器都需要配置该属性
2. 如果stub区域边界有多个ABR时,注意选路(修改cost)
3. 该区域不接受4、5类路由
4. 不能出现ASBR
5. 不能为区域0
6. 虚连接不能出现在该区域
7. ABR会自动下发一条缺省路由
实验拓扑
拓扑
需求
1. A1配置为stub区域,查看到R5的路由情况(在R3的ospf进程中引入rip路由)
2. 查看各个区域都存在几类路由
3. R1、R2的loopback发布在0区,R3的loopback发布在2区,R5的loopback发布在rip中
完成ip网络基本配置,以及ospf邻居建立,查看邻居情况如下:

#R1
<R1>dis ospf peer brief 

         OSPF Process 1 with Router ID 1.1.1.1
                  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          Serial0/0/1                      2.2.2.2          Full        
 0.0.0.2          Serial0/0/0                      3.3.3.3          Full        
 ----------------------------------------------------------------------------
<R1>

#R2
<R2>dis ospf peer brief 

         OSPF Process 1 with Router ID 2.2.2.2
                  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          Serial0/0/0                      1.1.1.1          Full        
 0.0.0.1          Serial0/0/1                      4.4.4.4          Full        
 ----------------------------------------------------------------------------
<R2>

#R3
<R3>dis ospf peer brief 

         OSPF Process 1 with Router ID 3.3.3.3
                  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.2          Serial0/0/0                      1.1.1.1          Full        
 ----------------------------------------------------------------------------
<R3>

#R4
<R4>dis ospf peer brief 

         OSPF Process 1 with Router ID 4.4.4.4
                  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.1          Serial0/0/1                      2.2.2.2          Full        
 ----------------------------------------------------------------------------
<R4>
ospf邻居建立正常

#查看R3是否学到R5的loopback
<R3>dis ip routing-table  p rip 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : RIP
         Destinations : 1        Routes : 1        

RIP routing table status : <Active>
         Destinations : 1        Routes : 1

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       51.1.1.0/24  RIP     100  1           D   35.1.1.5        Serial0/0/1

RIP routing table status : <Inactive>
         Destinations : 0        Routes : 0

<R3>

R3已学到R5的loopback路由,直接到最左侧R4上查看路由情况
<R4>dis ospf lsdb 

         OSPF Process 1 with Router ID 4.4.4.4
                 Link State Database 

                         Area: 0.0.0.1
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    4.4.4.4         4.4.4.4            701  60    80000004    1562
 Router    2.2.2.2         2.2.2.2            702  48    80000003    1562
 Sum-Net   21.1.1.1        2.2.2.2            712  28    80000002       0
 Sum-Net   12.1.1.0        2.2.2.2            712  28    80000002    1562
 Sum-Net   11.1.1.1        2.2.2.2            712  28    80000002    1562
 Sum-Net   31.1.1.1        2.2.2.2            712  28    80000002    3124
 Sum-Net   13.1.1.0        2.2.2.2            712  28    80000002    3124
 Sum-Asbr  3.3.3.3         2.2.2.2            712  28    80000002    3124


                 AS External Database
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 External  51.1.1.0        3.3.3.3            698  36    80000002       1
 External  35.1.1.0        3.3.3.3            700  36    80000002       1

<R4>
可以看到已经学到R5的外部路由,R4上存在1345类lsa(lsa2存在于MA网络)
注意此处的External路由的cost,在R3的ospf上引入rip时需要注意type1、type2的区别
*type1,经过的路径会累加cost值,可以反映出路径的花销
*type2,经过的路径不会累加cost值
-----------------------华丽的分割线-----------------------
配置A1区域为stub区域
将R4的A1区域配置为stb后,此时邻居会中断(在hello中区域flag必须一致),将R2的A1区域也配置为stub后,此时邻居建立
[R4-ospf-1-area-0.0.0.1]stub 
[R4-ospf-1-area-0.0.0.1]
Aug 28 2015 00:08:04-08:00 R4 %%01OSPF/3/NBR_CHG_DOWN(l)[0]:Neighbor event:neighbor state changed to Down. (ProcessId=1, NeighborAddress=2.2.2.2, NeighborEvent=KillNbr, NeighborPreviousState=Full, NeighborCurrentState=Down)
Aug 28 2015 00:08:04-08:00 R4 %%01OSPF/3/NBR_DOWN_REASON(l)[1]:Neighbor state leaves full or changed to Down. (ProcessId=1, NeighborRouterId=2.2.2.2, NeighborAreaId=1, NeighborInterface=Serial0/0/1,NeighborDownImmediate reason=Neighbor Down Due to Kill Neighbor, NeighborDownPrimeReason=Area reset, NeighborChangeTime=2015-08-28 00:08:04-08:00)
[R4-ospf-1-area-0.0.0.1]
Aug 28 2015 00:08:13-08:00 R4 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 19, the change loop count is 0, and the maximum number of records is 4095.
Aug 28 2015 00:08:15-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=24.1.1.2, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)
Aug 28 2015 00:08:25-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=24.1.1.2, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=ExStart)
Aug 28 2015 00:08:25-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=24.1.1.2, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange)
Aug 28 2015 00:08:25-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=24.1.1.2, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading)
Aug 28 2015 00:08:25-08:00 R4 %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=24.1.1.2, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full)
[R4-ospf-1-area-0.0.0.1]

邻居建立后再次查看路由、lsa情况
[R4]dis ip routing-tabl p o
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 6        Routes : 6        

OSPF routing table status : <Active>
         Destinations : 6        Routes : 6

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   OSPF    10   1563        D   24.1.1.2        Serial0/0/1
       11.1.1.1/32  OSPF    10   3124        D   24.1.1.2        Serial0/0/1
       12.1.1.0/24  OSPF    10   3124        D   24.1.1.2        Serial0/0/1
       13.1.1.0/24  OSPF    10   4686        D   24.1.1.2        Serial0/0/1
       21.1.1.1/32  OSPF    10   1562        D   24.1.1.2        Serial0/0/1
       31.1.1.1/32  OSPF    10   4686        D   24.1.1.2        Serial0/0/1

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0

[R4]
已经不存在外部路由,同时会下发一条缺省路由

查看lsa
[R4]dis ospf lsdb 

         OSPF Process 1 with Router ID 4.4.4.4
                 Link State Database 

                         Area: 0.0.0.1
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    4.4.4.4         4.4.4.4            231  60    80000003    1562
 Router    2.2.2.2         2.2.2.2            232  48    80000003    1562
 Sum-Net   0.0.0.0         2.2.2.2            242  28    80000001       1
 Sum-Net   21.1.1.1        2.2.2.2            242  28    80000001       0
 Sum-Net   12.1.1.0        2.2.2.2            242  28    80000001    1562
 Sum-Net   11.1.1.1        2.2.2.2            242  28    80000001    1562
 Sum-Net   31.1.1.1        2.2.2.2            242  28    80000001    3124
 Sum-Net   13.1.1.0        2.2.2.2            242  28    80000001    3124

[R4]
此时只存在13类lsa

*既然已经存在了一条缺省的lsa3,那么到外部区域的其他lsa3就不需要存在了,此时可以将stub区域配置为totally stub区域
*当一个区域边界存在多个ABR时,注意修改cost值进行选路

### Cisco OSPF NSSA 和 Stub 区域配置及差异 #### 总体概述 在Cisco OSPF网络中,NSSA(Not-So-Stubby Area)和Stub区域都是用于减少区域内LSA泛洪数量的设计方案。两者都阻止第五类LSA进入该区域,从而减少了内存占用并提高了性能。 #### Stub 区域特性 创建一个完全存根区域会防止任何外部路由被引入到此区域内[^2]。这意味着,在这种类型的区域里不会传播来自其他自治系统的第5类链路状态通告(External LSA),并且默认情况下也不会有汇总LSA(Type 4)存在。为了使这些区域内的路由器能够到达AS之外的目的地,默认路由会被注入进来作为替代选项。 #### NSSA 特性 对于NSSA而言,虽然同样不允许常规形式下的Type 5 LSAs流入,但它允许一种特殊的第七类LSA——即N1/N2类型的存在于此类别之中;这类LSA仅限于本区内流通,并最终由ABR转换成标准的E1/E2型外部宣告再向骨干区扩散出去。值得注意的是,`default-route-advertise`命令是必需设置项之一以便让NSSA ABR能向外广播一条缺省路径给内部节点知晓如何抵达远端目标地址范围外的地方[^3]。 #### 默认路由发布机制对比 当涉及到自动分发默认路由时,两者的处理方式有所不同。在一个普通的Stub环境中,只要边界路由器具备相应权限,则无需额外指令即可完成这项工作流程。然而针对NSSA来说,除非特别指定了上述提到过的特定参数,否则无法实现相同效果。 ```shell # 配置Stub区域 router ospf 1 area 0 stub # 配置NSSA区域 router ospf 1 area 1 nssa no-summary ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值