测品娱乐
您的当前位置:首页华为路由器配置OSPF的Stub区域实例

华为路由器配置OSPF的Stub区域实例

来源:测品娱乐
*-

华为路由器配置OSPF的Stub区域

组网需求

如图1所示,所有的S-switch都运行OSPF,整个自治系统划分为3个区域。其中S-switch-A和S-switch-B作为ABR来转发区域之间的路由,S-switch-D作为ASBR引入了外部路由(静态路由)。

要求将Area1配置为Stub区域,减少通告到此区域内的LSA数量,但不影响路由的可达性。 图1 配置OSPF Stub区域组网图

S-switch S-switch-A S-switch-A S-switch-B S-switch-B S-switch-C S-switch-C S-switch-D S-switch-D 接口 GE 0/0/1 GE 0/0/2 GE 0/0/1 GE 0/0/2 GE 0/0/1 GE 0/0/2 GE 0/0/1 GE 0/0/2 对应的VLANIF VLANIF 10 VLANIF 20 VLANIF 10 VLANIF 30 VLANIF 20 VLANIF 40 VLANIF 30 VLANIF 50 IP地址 192.168.0.1/24 192.168.1.1/24 192.168.0.2/24 192.168.2.1/24 192.168.1.2/24 172.16.1.1/24 192.168.2.2/24 172.17.1.1/24 *-

S-switch-E S-switch-F GE 0/0/1 GE 0/0/1 VLANIF 40 VLANIF 50 172.16.1.2/24 172.17.1.2/24 配置思路

采用如下的思路配置OSPF的Stub区域: 1. 2. 3. 4.

在各S-switch上使能OSPF,配置OSPF基本功能。 在S-switch-D上配置静态路由,并在OSPF中引入。

配置Area1为Stub区域(需要在Area1内所有的S-switch上配置Stub命令)。 在S-switch-A上配置禁止向Stub区域通告Type3 LSA。

数据准备

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

各接口所属的VLAN ID,具体数据如图1所示。 各VLANIF接口的IP地址,具体数据如图1所示。

各S-switch设备的Router ID,OSPF进程号以及各接口所属的区域。 ▪

S-switch-A的Router ID 1.1.1.1,运行的OSPF进程号1,区域0的网段192.168.0.0/24,区域1的网段192.168.1.0/24。 ▪

S-switch-B的Router ID 2.2.2.2,运行的OSPF进程号1,区域0的网段192.168.0.0/24,区域2的网段192.168.2.0/24。 ▪

S-switch-C的Router ID 3.3.3.3,运行的OSPF进程号1,区域1的网段192.168.1.0/24,172.16.1.0/24。 ▪

S-switch-D的Router ID 4.4.4.4,运行的OSPF进程号1,区域2的网段192.168.2.0/24,172.17.1.0/24。 ▪ ▪

S-switch-E的Router ID 5.5.5.5,运行的OSPF进程号1,区域1的网段172.16.1.0/24。 S-switch-F的Router ID 6.6.6.6,运行的OSPF进程号1,区域2的网段172.17.1.0/24。

*-

配置步骤

1. 2.

配置OSPF基本功能(请参见举例配置OSPF基本功能) 配置S-switch-D引入静态路由 # 在S-switch-D引入静态路由,例如。

[S-switch-D] ip route-static 200.0.0.0 8 null 0 [S-switch-D] ospf

[S-switch-D-ospf-1] import-route static type 1 [S-switch-D-ospf-1] quit

# 查看S-switch-C的ABR/ASBR信息。 [S-switch-C] 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 # 查看S-switch-C的OSPF路由表。 [S-switch-C] 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.16.1.0/24 1 Transit 172.16.1.1 3.3.3.3 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.1.0/24 1 Transit 192.168.1.2 3.3.3.3 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

200.0.0.0/8 4 Type1 1 192.168.1.1 4.4.4.4

Total Nets: 6

Intra Area: 2 Inter Area: 3 ASE: 1 NSSA: 0

当S-switch-C所在区域为普通区域时,可以看到路由表中存在AS外部的路由。 3.

配置Area1为Stub区域 # 配置S-switch-A。 [S-switch-A] ospf

[S-switch-A-ospf-1] area 1

[S-switch-A-ospf-1-area-0.0.0.1] stub [S-switch-A-ospf-1-area-0.0.0.1] quit [S-switch-A-ospf-1] quit # 配置S-switch-C。 [S-switch-C] ospf

[S-switch-C-ospf-1] area 1

[S-switch-C-ospf-1-area-0.0.0.1] stub [S-switch-C-ospf-1-area-0.0.0.1] quit [S-switch-C-ospf-1] quit # 配置S-switch-E。 [S-switch-E] ospf

*-

[S-switch-E-ospf-1] area 1

[S-switch-E-ospf-1-area-0.0.0.1] stub [S-switch-E-ospf-1-area-0.0.0.1] quit [S-switch-E-ospf-1] quit # 查看S-switch-C的路由表。

[S-switch-C] 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.16.1.0/24 1 Transit 172.16.1.1 3.3.3.3 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.1.0/24 1 Transit 192.168.1.2 3.3.3.3 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: 6

Intra Area: 2 Inter Area: 4 ASE: 0 NSSA: 0

当把S-switch-C所在区域配置为Stub区域时,已经看不到AS外部的路由,取而代之的是一条通往区域外部的缺省路由。 # 配置禁止向Stub区域通告Type3 LSA。 [S-switch-A] ospf

[S-switch-A-ospf-1] area 1

[S-switch-A-ospf-1-area-0.0.0.1] stub no-summary

*-

[S-switch-A-ospf-1-area-0.0.0.1] quit [S-switch-A-ospf-1] quit 4.

验证配置结果

# 查看S-switch-C的OSPF路由表。 [S-switch-C] 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.16.1.0/24 1 Transit 172.16.1.1 3.3.3.3 0.0.0.1

192.168.1.0/24 1 Transit 192.168.1.2 3.3.3.3 0.0.0.1

Total Nets: 3

Intra Area: 2 Inter Area: 1 ASE: 0 NSSA: 0

禁止向Stub区域通告Summary-LSA后,Stub区域设备的路由表项进一步减少。路由表中已经看不到区域外部的路由,取而代之的是一条通往区域外部的缺省路由。

配置文件

S-switch-A的配置文件 #

sysname S-switch-A #

*-

router id 1.1.1.1 #

vlan batch 10 20 #

interface Vlanif10

ip address 192.168.0.1 255.255.255.0 #

interface Vlanif20

ip address 192.168.1.1 255.255.255.0 #

interface GigabitEthernet0/0/1 port trunk allow-pass vlan 10 #

interface GigabitEthernet0/0/2 port trunk allow-pass vlan 20 # 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 说明:

S-switch-B和S-switch-F的配置文件与前例相同,此处省略。 •

S-switch-C的配置文件 #

sysname S-switch-C

*-

#

router id 3.3.3.3 #

vlan batch 20 40 #

interface Vlanif20

ip address 192.168.1.2 255.255.255.0 #

interface Vlanif40

ip address 172.16.1.1 255.255.255.0 #

interface GigabitEthernet0/0/1 port trunk allow-pass vlan 20 #

interface GigabitEthernet0/0/2 port trunk allow-pass vlan 40 # 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 •

S-switch-D的配置文件 #

sysname S-switch-D #

vlan batch 30 50

*-

#

router id 4.4.4.4 #

interface Vlanif30

ip address 192.168.2.2 255.255.255.0 #

interface Vlanif50

ip address 172.17.1.1 255.255.255.0 #

interface GigabitEthernet0/0/1 port trunk allow-pass vlan 30 #

interface GigabitEthernet0/0/2 port trunk allow-pass vlan 50 # 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 200.0.0.0 255.0.0.0 NULL0 # return •

S-switch-E的配置文件 #

sysname S-switch-E #

router id 5.5.5.5

*-

#

vlan batch 40 #

interface Vlanif40

ip address 172.16.1.2 255.255.255.0 #

interface GigabitEthernet0/0/1 port trunk allow-pass vlan 40 # ospf 1 area 0.0.0.1

network 172.16.1.0 0.0.0.255 stub # return

因篇幅问题不能全部显示,请点此查看更多更全内容