问答 百科手机端

配置OSPF的NSSA区域示例

2023-05-19 11:42

举例介绍OSPF的NSSA区域的配置过程。

组网需求

某些网络由于引入大量外部路由导致路由表的规模过大,网络资源浪费,CPU占用率较高。为了解决这个问题,可以将位于自治系统边缘的非骨干区域配置成NSSA区域,减少传递的路由信息数量。配置区域为NSSA区域后,不传播来自OSPF网络其它区域的外部路由,但引入自治系统外部的路由,这样可以避免大量外部路由对路由器带宽和存储资源的消耗。

如下图所示,所有的路由器都运行OSPF,整个自治系统划分为两个区域。其中DeviceA和DeviceB作为ABR来转发区域间的路由,DeviceD作为ASBR引入了外部静态路由10.0.0.0/8。此时,在不影响路由可达的前提下,达到减少通告到Area1内的LSA数量,但引入自治系统外部路由的目的。需要将Area1配置为NSSA区域,并配置NSSA区域中的DeviceA为转换路由器。

图1 配置OSPF NSSA区域组网图

配置思路

采用如下的思路配置OSPF的NSSA区域:

1、在各路由器上使能OSPF,配置OSPF基本功能,实现OSPF协议互连。

2、配置Area1为NSSA区域。

3、在DeviceD上配置引入静态路由10.0.0.0/8。

4、配置NSSA区域中的DeviceA为转换路由器。

数据准备

为完成此配置例,需准备如下的数据:

1、DeviceA的Router ID 1.1.1.1,运行的OSPF进程号1,区域0的网段192.168.0.0/24,区域1的网段192.168.1.0/24、192.168.3.0/24

2、DeviceB的Router ID 2.2.2.2,运行的OSPF进程号1,区域0的网段192.168.2.0/24,区域1的网段192.168.1.0/24、192.168.4.0/24

3、DeviceC的Router ID 3.3.3.3,运行的OSPF进程号1,区域0的网段192.168.0.0/24、192.168.2.0/24

4、DeviceD的Router ID 4.4.4.4,运行的OSPF进程号1,区域1的网段192.168.3.0/24、192.168.4.0/24。

操作步骤

1、配置各接口的IP地址

设备名称 设备接口 IP地址
DeviceA GE0/0/1 192.168.0.1/24
GE0/0/2 192.168.3.1/24
GE0/0/3 192.168.1.1/24
DeviceB GE0/0/1 192.168.1.2/24
GE0/0/2 192.168.2.1/24
GE0/0/3 192.168.4.2/24
DeviceC GE0/0/1 192.168.0.2/24
GE0/0/2 192.168.2.2/24
DeviceD GE0/0/1 192.168.3.2/24
GE0/0/2 192.168.4.1/24

2、配置OSPF基本功能

#配置DeviceA设备的ospf

#
ospf 1
 area 0.0.0.0
  network 192.168.0.0 0.0.0.255
 area 0.0.0.1
  network 192.168.3.0 0.0.0.255
  network 192.168.1.0 0.0.0.255
#

#配置DeviceB设备的ospf  

#
ospf 1
 area 0.0.0.0
  network 192.168.2.0 0.0.0.255
 area 0.0.0.1
  network 192.168.4.0 0.0.0.255
  network 192.168.1.0 0.0.0.255
#

#配置DeviceC设备的ospf

#
ospf 1
 area 0.0.0.0
  network 192.168.0.0 0.0.0.255
  network 192.168.2.0 0.0.0.255
#

#配置DeviceD设备的ospf

#
ospf 1
 area 0.0.0.1
  network 192.168.3.0 0.0.0.255
  network 192.168.4.0 0.0.0.255
#

3、配置Area1区域为NSSA区域

# 配置DeviceA

[~DeviceA] ospf
[*DeviceA-ospf-1] area 1
[*DeviceA-ospf-1-area-0.0.0.1] nssa
[*DeviceA-ospf-1-area-0.0.0.1] commit
[~DeviceA-ospf-1-area-0.0.0.1] quit

# 配置DeviceB

[~DeviceB] ospf
[*DeviceB-ospf-1] area 1
[*DeviceB-ospf-1-area-0.0.0.1] nssa
[*DeviceB-ospf-1-area-0.0.0.1] commit
[~DeviceB-ospf-1-area-0.0.0.1] quit

# 配置DeviceD

[~DeviceD] ospf
[*DeviceD-ospf.
[*DeviceD-ospf-1-area-0.0.0.1] nssa [*DeviceD-ospf-1-area-0.0.0.1] commit [~DeviceD-ospf-1-area-0.0.0.1] quit

所有连接到NSSA区域的路由器必须使用nssa命令将该区域配置成NSSA属性。

4、配置DeviceD引入静态路由10.0.0.0/8

[*DeviceD] ip route-static 10.0.0.0 8 null 0
[*DeviceD] ospf
[*DeviceD-ospf-1] import-route static
[*DeviceD-ospf-1] commit
[~DeviceD-ospf-1] quit

# 查看DeviceC的OSPF路由表。

[~DeviceC] display ospf routing
          OSPF Process 1 with Router ID 3.3.3.3
                   Routing Tables

 Routing for Network
 Destination        Cost  Type       NextHop         AdvRouter       Area
 192.168.3.0/24     2     Inter-area 192.168.0.1     1.1.1.1       0.0.0.0
 192.168.4.0/24     2     Inter-area 192.168.2.1     2.2.2.2       0.0.0.0
 192.168.0.0/24     1     Stub       192.168.0.2     3.3.3.3       0.0.0.0
 192.168.1.0/24     2     Inter-area 192.168.0.1     1.1.1.1       0.0.0.0
 192.168.1.0/24     2     Inter-area 192.168.2.1     2.2.2.2       0.0.0.0
 192.168.2.0/24     1     Stub       192.168.2.2     3.3.3.3       0.0.0.0

 Routing for ASEs
 Destination      Cost      Type       Tag    NextHop         AdvRouter
 10.0.0.0/8       1         Type2      1      192.168.2.1     2.2.2.2

 Total Nets: 7
 Intra Area: 2  Inter Area: 4  ASE: 1  NSSA: 0

可以看到,NSSA区域引入AS外部路由的发布路由器的Router ID为2.2.2.2,即DeviceB为转换路由器。这是因为OSPF会选举Router ID较大的ABR作为转换路由器。

5、配置DeviceA为转换路由器

[~DeviceA] ospf
[*DeviceA-ospf-1] area 1
[*DeviceA-ospf-1-area-0.0.0.1] nssa default-route-advertise no-summary translator-always
[*DeviceA-ospf-1-area-0.0.0.1] commit
[~DeviceA-ospf-1-area-0.0.0.1] quit

6、查看配置结果

# 查看DeviceC的OSPF路由表

[~DeviceC] display ospf routing
          OSPF Process 1 with Router ID 3.3.3.3
                   Routing Tables

 Routing for Network
 Destination        Cost  Type       NextHop         AdvRouter       Area
 192.168.3.0/24     2     Inter-area 192.168.0.1     1.1.1.1       0.0.0.0
 192.168.4.0/24     2     Inter-area 192.168.2.1     2.2.2.2       0.0.0.0
 192.168.0.0/24     1     Stub       192.168.0.2     3.3.3.3       0.0.0.0
 192.168.1.0/24     2     Inter-area 192.168.2.1     2.2.2.2       0.0.0.0
 192.168.1.0/24     2     Inter-area 192.168.0.1     1.1.1.1       0.0.0.0
 192.168.2.0/24     1     Stub       192.168.2.2     3.3.3.3       0.0.0.0

 Routing for ASEs
 Destination      Cost      Type       Tag    NextHop         AdvRouter
 10.0.0.0/8       1         Type2      1      192.168.0.1     1.1.1.1

 Total Nets: 7
 Intra Area: 2  Inter Area: 4  ASE: 1  NSSA: 0

可以看到,DeviceC引入了一条AS外部的路由,并且,引入的外部路由的发布路由器的Router ID变为1.1.1.1,即DeviceA成为了转换路由器。

热门