配置OSPF 基本功能
文档版本04 (2007-04-05) 华为技术有限公司4-43
配置OSPF 基本功能
如图4-21 所示,所有的路由器都运行OSPF,并将整个自治系统划分为3 个区域,其
中RouterA 和RouterB 作为ABR 来转发区域之间的路由。
配置完成后,每台路由器都应学到AS 内的到所有网段的路由。
图4-21 OSPF 基本配置组网图
RouterA RouterB
RouterD
POS1/0/0
192.168.0.1/24
POS1/0/0
192.168.0.2/24
POS2/0/0
192.168.2.1/24
POS1/0/0
192.168.2.2/24
Area0
POS2/0/0
192.168.1.1/24
GE2/0/0
172.17.1.1/24 RouterC
POS1/0/0
192.168.1.2/24
Area1
GE2/0/0
172.16.1.1/24
Area2
GE2/0/0
172.16.1.2/24
GE2/0/0
172.17.1.2/24
RouterE RouterF
采用如下的思路配置OSPF 基本功能:
1. 在各路由器上使能OSPF,指定不同区域内的网段。
2. 查看路由表及数据库信息。
为完成此配置例,需准备如下的数据:
4 OSPF 配置
Quidway NetEngine5000E
操作手册IP 路由分册
4-44 华为技术有限公司文档版本04 (2007-04-05)
RouterA 的router id 1.1.1.1,运行的OSPF 进程号1,在区域0 的网段
192.168.0.0,在区域1 的网段192.168.1.0。
RouterB 的router id 2.2.2.2,运行的OSPF 进程号1,在区域0 的网段
192.168.0.0,在区域2 的网段192.168.2.0。
RouterC 的router id 3.3.3.3,运行的OSPF 进程号1,在区域1 的网段
192.168.1.0,172.16.1.0。
RouterD 的router id 4.4.4.4,运行的OSPF 进程号1,在区域2 的网段
192.168.2.0,172.17.1.0。
RouterE 的router id 5.5.5.5,运行的OSPF 进程号1,在区域1 的网段172.16.1.0。
RouterF 的router id 6.6.6.6,运行的OSPF 进程号1,在区域2 的网段172.17.1.0。
配置步骤
步骤1 配置各接口的IP 地址(略)
步骤2 配置OSPF 基本功能
# 配置RouterA。
[RouterA] router id 1.1.1.1
[RouterA] ospf
[RouterA-ospf-1] area 0
[RouterA-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255
[RouterA-ospf-1-area-0.0.0.0] quit
[RouterA-ospf-1] area 1
[RouterA-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255
[RouterA-ospf-1-area-0.0.0.1] quit
# 配置RouterB。
[RouterB] router id 2.2.2.2
[RouterB] ospf
[RouterB-ospf-1] area 0
[RouterB-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255
[RouterB-ospf-1-area-0.0.0.0] quit
[RouterB-ospf-1] area 2
[RouterB-ospf-1-area-0.0.0.2] network 192.168.2.0 0.0.0.255
[RouterB-ospf-1-area-0.0.0.2] quit
# 配置RouterC。
[RouterC] router id 3.3.3.3
[RouterC] ospf
[RouterC-ospf-1] area 1
[RouterC-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255
[RouterC-ospf-1-area-0.0.0.1] network 172.16.1.0 0.0.0.255
[RouterC-ospf-1-area-0.0.0.1] quit
# 配置RouterD。
[RouterD] router id 4.4.4.4
[RouterD] ospf
[RouterD-ospf-1] area 2
[RouterD-ospf-1-area-0.0.0.2] network 192.168.2.0 0.0.0.255
Quidway NetEngine5000E
操作手册IP 路由分册4 OSPF 配置
文档版本04 (2007-04-05) 华为技术有限公司4-45
[RouterD-ospf-1-area-0.0.0.2] network 172.17.1.0 0.0.0.255
[RouterD-ospf-1-area-0.0.0.2] quit
# 配置RouterE。
[RouterE] router id 5.5.5.5
[RouterE] ospf
[RouterE-ospf-1] area 1
[RouterE-ospf-1-area-0.0.0.1] network 172.16.1.0 0.0.0.255
[RouterE-ospf-1-area-0.0.0.1] quit
# 配置RouterF。
[RouterF] router id 6.6.6.6
[RouterF] ospf
[RouterF-ospf-1] area 2
[RouterF-ospf-1-area-0.0.0.2] network 172.17.1.0 0.0.0.255
[RouterF-ospf-1-area-0.0.0.2] quit
步骤3 检验配置结果
# 查看RouterA 的OSPF 邻居。
[RouterA] display ospf peer
OSPF Process 1 with Router ID 1.1.1.1
Neighbors
Area 0.0.0.0 interface 192.168.0.1(Pos1/0/0)'s neighbors
Router ID: 2.2.2.2 Address: 192.168.0.2 GR State: Normal
State: Full Mode:Nbr is Master Priority: 1
DR: None BDR: None MTU: 0
Dead timer due in 36 sec
Neighbor is up for 00:15:04
Authentication Sequence: [ 0 ]
Neighbors
Area 0.0.0.1 interface 192.168.1.1(Pos2/0/0)'s neighbors
Router ID: 3.3.3.3 Address: 192.168.1.2 GR State: Normal
State: Full Mode:Nbr is Master Priority: 1
DR: None BDR: None MTU: 0
Dead timer due in 39 sec
Neighbor is up for 00:07:32
Authentication Sequence: [ 0 ]
# 显示RouterA 的OSPF 路由信息。
[RouterA] display ospf routing
OSPF Process 1 with Router ID 1.1.1.1
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
172.16.1.0/24 2 Transit 192.168.1.2 3.3.3.3 0.0.0.1
172.17.1.0/24 3 Inter-area 192.168.0.2 2.2.2.2 0.0.0.0
4 OSPF 配置
Quidway NetEngine5000E
操作手册IP 路由分册
4-46 华为技术有限公司文档版本04 (2007-04-05)
192.168.0.0/24 1 Stub 192.168.0.1 1.1.1.1 0.0.0.0
192.168.1.0/24 1 Stub 192.168.1.1 1.1.1.1 0.0.0.1
192.168.2.0/24 2 Inter-area 192.168.0.2 2.2.2.2 0.0.0.0
Total Nets: 5
Intra Area: 3 Inter Area: 2 ASE: 0 NSSA: 0
# 显示RouterA 的LSDB。
[RouterA] display ospf lsdb
OSPF Process 1 with Router ID 1.1.1.1
Link State Database
Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 2.2.2.2 2.2.2.2 317 48 80000003 1
Router 1.1.1.1 1.1.1.1 316 48 80000002 1
Sum-Net 172.16.1.0 1.1.1.1 250 28 80000001 2
Sum-Net 172.17.1.0 2.2.2.2 203 28 80000001 2
Sum-Net 192.168.2.0 2.2.2.2 237 28 80000002 1
Sum-Net 192.168.1.0 1.1.1.1 295 28 80000002 1
Area: 0.0.0.1
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 5.5.5.5 5.5.5.5 214 36 80000004 1
Router 3.3.3.3 3.3.3.3 217 60 80000008 1
Router 1.1.1.1 1.1.1.1 289 48 80000002 1
Sum-Net 172.17.1.0 1.1.1.1 202 28 80000002 3
Network 172.16.1.1 3.3.3.3 670 32 80000001 0
Sum-Net 172.17.1.0 1.1.1.1 202 28 80000001 3
Sum-Net 192.168.2.0 1.1.1.1 242 28 80000001 2
Sum-Net 192.168.0.0 1.1.1.1 300 28 80000001 1
# 查看RouterD 的路由表,并使用Ping 进行测试连通性。
[RouterD] display ospf routing
OSPF Process 1 with Router ID 4.4.4.4
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
172.16.1.0/24 4 Inter-area 192.168.2.1 2.2.2.2 0.0.0.2
172.17.1.0/24 1 Transit 172.17.1.1 4.4.4.4 0.0.0.2
192.168.0.0/24 2 Inter-area 192.168.2.1 2.2.2.2 0.0.0.2
192.168.1.0/24 3 Inter-area 192.168.2.1 2.2.2.2 0.0.0.2
192.168.2.0/24 1 Stub 192.168.2.2 4.4.4.4 0.0.0.2
Total Nets: 5
Intra Area: 2 Inter Area: 3 ASE: 0 NSSA: 0
[RouterD] ping 172.16.1.1
PING 172.16.1.1: 56 data bytes, press CTRL_C to break
Reply from 172.16.1.1: bytes=56 Sequence=1 ttl=253 time=62 ms
Reply from 172.16.1.1: bytes=56 Sequence=2 ttl=253 time=16 ms
Reply from 172.16.1.1: bytes=56 Sequence=3 ttl=253 time=62 ms
Reply from 172.16.1.1: bytes=56 Sequence=4 ttl=253 time=94 ms
Quidway NetEngine5000E
操作手册IP 路由分册4 OSPF 配置
文档版本04 (2007-04-05) 华为技术有限公司4-47
Reply from 172.16.1.1: bytes=56 Sequence=5 ttl=253 time=63 ms
--- 172.16.1.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 16/59/94 ms
----结束
配置文件
RouterA 的配置文件
#
sysname RouterA
#
router id 1.1.1.1
#
interface Pos1/0/0
link-protocol ppp
ip address 192.168.0.1 255.255.255.0
#
interface Pos2/0/0
link-protocol ppp
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
#
return
RouterB 的配置文件
#
sysname RouterB
#
router id 2.2.2.2
#
interface Pos1/0/0
link-protocol ppp
ip address 192.168.0.2 255.255.255.0
#
interface Pos2/0/0
link-protocol ppp
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
4 OSPF 配置
Quidway NetEngine5000E
操作手册IP 路由分册
4-48 华为技术有限公司文档版本04 (2007-04-05)
RouterC 的配置文件
#
sysname RouterC
#
router id 3.3.3.3
#
interface GigabitEthernet2/0/0
ip address 172.16.1.1 255.255.255.0
#
interface Pos1/0/0
link-protocol ppp
ip address 192.168.1.2 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
#
return
RouterD 的配置文件
#
sysname RouterD
#
router id 4.4.4.4
#
interface GigabitEthernet2/0/0
ip address 172.17.1.1 255.255.255.0
#
interface Pos1/0/0
link-protocol ppp
ip address 192.168.2.2 255.255.255.0
#
ospf 1
area 0.0.0.2
network 192.168.2.0 0.0.0.255
network 172.17.1.0 0.0.0.255
#
return
RouterE 的配置文件
#
sysname RouterE
#
router id 5.5.5.5
#
interface GigabitEthernet2/0/0
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
#
return
RouterF 的配置文件
Quidway NetEngine5000E
操作手册IP 路由分册4 OSPF 配置
#
sysname RouterF
#
router id 6.6.6.6
#
interface GigabitEthernet2/0/0
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
4.8.2
组网需求