配置OSPF的Stub区域示例
介绍了将引入了静态路由的普通区域配置成Stub区域的过程,可以在不影响路由可达性的前提下减少通告到此区域内的LSA数量。
组网需求
如图5-9所示,所有的路由器都运行OSPF,整个自治系统划分为3个区域。其中DeviceA和DeviceB作为ABR来发布区域之间的路由,DeviceD作为ASBR引入了外部路由(静态路由)。
要求将Area1配置为Stub区域,减少通告到此区域内的LSA数量,但不影响路由的可达性。
配置思路
采用如下的思路配置OSPF的Stub区域:
在各路由器上配置OSPF基本功能,实现互连。
在DeviceD上配置静态路由,并在OSPF中引入。
配置Area1为Stub区域(需要在Area1内所有的路由器上配置stub命令),在DeviceC上查看OSPF路由信息。
在DeviceA上配置禁止向Stub区域通告Type3 LSA,在DeviceC上查看OSPF路由信息。
数据准备
为完成此配置例,需准备如下的数据:
设备 |
Router ID |
Process ID |
IP地址 |
DeviceA |
1.1.1.1 |
1 |
区域0:192.168.0.0/24 区域1:192.168.1.0/24 |
DeviceB |
2.2.2.2 |
1 |
区域0:192.168.0.0/24 区域2:192.168.2.0/24 |
DeviceC |
3.3.3.3 |
1 |
区域1:192.168.1.0/24、172.16.1.0/24 |
DeviceD |
4.4.4.4 |
1 |
区域2:192.168.2.0/24、172.17.1.0/24 |
DeviceE |
5.5.5.5 |
1 |
区域1:172.16.1.0/24 |
DeviceF |
6.6.6.6 |
1 |
区域2:172.17.1.0/24 |
操作步骤
- 配置接口的IP地址(略)
- 配置OSPF基本功能(请参见配置OSPF基本功能示例)
- 配置DeviceD引入静态路由
[*DeviceD] ip route-static 10.0.0.0 8 null 0
[*DeviceD] ospf 1
[*DeviceD-ospf-1] import-route static type 1
[*DeviceD-ospf-1] commit
[~DeviceD-ospf-1] quit
# 查看DeviceC的ABR和ASBR信息。
[~DeviceC] display ospf abr-asbr
OSPF Process 1 with Router ID 3.3.3.3
Routing Table to ABR and ASBR
Type Destination Area Cost NextHop RtType
Intra-area 1.1.1.1 0.0.0.1 1 192.168.1.1 ABR
Inter-area 4.4.4.4 0.0.0.1 3 192.168.1.1 ASBR
# 查看DeviceC的OSPF路由表。
当DeviceC所在区域为普通区域时,可以看到路由表中存在AS外部的路由。
[~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 172.17.1.0/24 4 Inter-area 192.168.1.1 1.1.1.1 0.0.0.1 192.168.0.0/24 2 Inter-area 192.168.1.1 1.1.1.1 0.0.0.1 192.168.2.0/24 3 Inter-area 192.168.1.1 1.1.1.1 0.0.0.1 Routing for ASEs Destination Cost Type Tag NextHop AdvRouter 10.0.0.0/8 4 Type1 1 192.168.1.1 4.4.4.4 Total Nets: 4 Intra Area: 0 Inter Area: 3 ASE: 1 NSSA: 0
- 配置Area1为Stub区域
# 配置DeviceA。
[*DeviceA] ospf 1
[*DeviceA-ospf-1] area 1
[*DeviceA-ospf-1-area-0.0.0.1] stub
[*DeviceA-ospf-1-area-0.0.0.1] commit
[~DeviceA-ospf-1-area-0.0.0.1] quit
# 配置DeviceC。
[*DeviceC] ospf 1
[*DeviceC-ospf-1] area 1
[*DeviceC-ospf-1-area-0.0.0.1] stub
[*DeviceC-ospf-1-area-0.0.0.1] commit
[~DeviceC-ospf-1-area-0.0.0.1] quit
# 配置DeviceE。
[*DeviceE] ospf 1
[*DeviceE-ospf-1] area 1
[*DeviceE-ospf-1-area-0.0.0.1] stub
[*DeviceE-ospf-1-area-0.0.0.1] commit
[~DeviceE-ospf-1-area-0.0.0.1] quit
# 显示DeviceC的路由表。
当把DeviceC所在区域配置为Stub区域时,已经看不到AS外部的路由,取而代之的是一条缺省路由。
[~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 0.0.0.0/0 2 Inter-area 192.168.1.1 1.1.1.1 0.0.0.1 172.17.1.0/24 4 Inter-area 192.168.1.1 1.1.1.1 0.0.0.1 192.168.0.0/24 2 Inter-area 192.168.1.1 1.1.1.1 0.0.0.1 192.168.2.0/24 3 Inter-area 192.168.1.1 1.1.1.1 0.0.0.1 Total Nets: 4 Intra Area: 0 Inter Area: 4 ASE: 0 NSSA: 0
- # 配置禁止向Stub区域通告Type3 LSA。
[*DeviceA] ospf
[*DeviceA-ospf-1] area 1
[*DeviceA-ospf-1-area-0.0.0.1] stub no-summary
[*DeviceA-ospf-1-area-0.0.0.1] commit
[~DeviceA-ospf-1-area-0.0.0.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 0.0.0.0/0 2 Inter-area 192.168.1.1 1.1.1.1 0.0.0.1 Total Nets: 1 Intra Area: 0 Inter Area: 1 ASE: 0 NSSA: 0
禁止向Stub区域通告Summary LSA后,Stub路由器的路由表项进一步减少,只保留了一条通往区域外部的缺省路由。
配置文件
DeviceA的配置文件
#
sysname DeviceA
#
router id 1.1.1.1
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 192.168.0.1 255.255.255.0
#
interface GigabitEthernet0/2/0
undo shutdown
ip address 192.168.1.1 255.255.255.0
#
ospf 1
area 0.0.0.0
network 192.168.0.0 0.0.0.255
area 0.0.0.1
network 192.168.1.0 0.0.0.255
stub no-summary
#
return
DeviceB的配置文件
#
sysname DeviceB
#
router id 2.2.2.2
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 192.168.0.2 255.255.255.0
#
interface GigabitEthernet0/2/0
undo shutdown
ip address 192.168.2.1 255.255.255.0
#
ospf 1
area 0.0.0.0
network 192.168.0.0 0.0.0.255
area 0.0.0.2
network 192.168.2.0 0.0.0.255
#
return
DeviceC的配置文件
#
sysname DeviceC
#
router id 3.3.3.3
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 192.168.1.2 255.255.255.0
#
interface GigabitEthernet0/2/0
undo shutdown
ip address 172.16.1.1 255.255.255.0
#
ospf 1
area 0.0.0.1
network 192.168.1.0 0.0.0.255
network 172.16.1.0 0.0.0.255
stub
#
return
DeviceD的配置文件
#
sysname DeviceD
#
router id 4.4.4.4
#
interface GigabitEthernet0/1/0
undo shutdown
ip address 192.168.2.2 255.255.255.0
#
interface GigabitEthernet0/2/0
undo shutdown
ip address 172.17.1.1 255.255.255.0
#
ospf 1
import-route static type 1
area 0.0.0.2
network 192.168.2.0 0.0.0.255
network 172.17.1.0 0.0.0.255
#
ip route-static 10.0.0.0 255.0.0.0 NULL0
#
return
DeviceE的配置文件
#
sysname DeviceE
#
router id 5.5.5.5
#
interface GigabitEthernet0/2/0
undo shutdown
ip address 172.16.1.2 255.255.255.0
#
ospf 1
area 0.0.0.1
network 172.16.1.0 0.0.0.255
stub
#
return
DeviceF的配置文件
#
sysname DeviceF
#
router id 6.6.6.6
#
interface GigabitEthernet0/2/0
undo shutdown
ip address 172.17.1.2 255.255.255.0
#
ospf 1
area 0.0.0.2
network 172.17.1.0 0.0.0.255
#
return