当前位置: 首页 > news >正文

配置单区域 OSPF

  1. 实验目的
  1. 实现单区域 OSPF 的配置。
  2. 描述 OSPF 在多路访问网络中邻居关系建立的过程。
  1. 实验拓扑

配置单区域 OSPF 的实验拓扑如图 1-2 所示。

1

1-2 配置单区域 OSPF

  1. 实验步骤
  1. 配置 IP 地址。

R1 的配置:

<Huawei>system-view

[Huawei]undo info-center enable [Huawei]sysname R1 [R1]interface g0/0/0

[R1-GigabitEthernet0/0/0]ip address 12.1.1.1 24 [R1-GigabitEthernet0/0/0]quit

[R1]interface LoopBack 0


[R1-LoopBack0]ip address 1.1.1.1 24 [R1-LoopBack0]quit

R2 的配置:

<Huawei>system-view [Huawei]undo info-center enable [Huawei]sysname R2 [R2]interface g0/0/1

[R2-GigabitEthernet0/0/1]ip address 12.1.1.2 24 [R2-GigabitEthernet0/0/1]quit

[R2]interface g0/0/0

[R2-GigabitEthernet0/0/0]ip address 23.1.1.2 24 [R2-GigabitEthernet0/0/0]quit

[R2]interface LoopBack 0


[R2-LoopBack0]ip address 2.2.2.2 24 [R2-LoopBack0]quit

R3 的配置:

<Huawei>system-view [Huawei]undo info-center enable [Huawei]sysname R3 [R3]interface g0/0/1

[R3-GigabitEthernet0/0/1]ip address 23.1.1.3 24 [R3-GigabitEthernet0/0/1]quit

[R3]interface LoopBack 0


[R3-LoopBack0]ip address 3.3.3.3 24


[R3-LoopBack0]quit

  1. 运行 OSPFR1 的配置:

[R1]ospf router-id 1.1.1.1         // 启用 OSPF,设置它的 Router ID 1.1.1.1 [R1-ospf-1]area 0 // 区域 0

[R1-ospf-1-area-0.0.0.0]network 12.1.1.0 0.0.0.255// 宣告网络 12.1.1.0

[R1-ospf-1-area-0.0.0.0]network 1.1.1.0 0.0.0.255 // 宣告网络 1.1.1.0


[R1-ospf-1-area-0.0.0.0]quit

R2 的配置:

[R2]ospf router-id 2.2.2.2

[R2-ospf-1]area 0

[R2-ospf-1-area-0.0.0.0]network 12.1.1.0 0.0.0.255

[R2-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.255


[R2-ospf-1-area-0.0.0.0]network 2.2.2.0 0.0.0.255 [R2-ospf-1-area-0.0.0.0]quit

R3 的配置:

[R3]ospf router-id 3.3.3.3

[R3-ospf-1]area 0

[R3-ospf-1-area-0.0.0.0]network 23.1.1.0 0.0.0.255

【技术要点】

OSPF的进程ID编号范围为1~65535,只在本地有效,不同路由器的进程ID可以不同。

【技术要点】

  1. Router ID用于在自治系统中唯一地标识一台运行OSPF的路由器,它是一个32位的无符号整数。
  2. Router ID选举规则如下。
  1. 手动配置OSPF路由器的Router ID(建议手动配置)。
  2. 如果没有手动配置Router ID,则路由器使用LoopBack接口中最大的IP地址作为Router ID
  3. 如果没有配置LoopBack接口,则路由器使用物理接口中最大的IP地址作为Router ID

[R3-ospf-1-area-0.0.0.0]network 3.3.3.0 0.0.0.255 [R3-ospf-1-area-0.0.0.0]quit

  1. 实验调试
  1. R1 上查看当前设备所有激活的 OSPF 的接口信息。

<R1>display ospf interface all

OSPF Process 1 with Router ID 1.1.1.1 //OSPF 的进程为 1Router ID 1.1.1.1 Interfaces

Area: 0.0.0.0   (MPLS TE not enabled)    //OSPF 的区域为 0


Interface: 12.1.1.1 (GigabitEthernet0/0/0)

Cost: 1       State: DR              Type: Broadcast     MTU: 1500 Priority: 1

1

//G0/0/0 的开销1,它DR,网络类型为广播MTU 1500,优先级1 Designated Router: 12.1.1.1 //DR 12.1.1.1

Backup Designated Router: 12.1.1.2                     //BDR 12.1.1.2

Timers: Hello 10, Dead 40, Poll 120, Retransmit 5, Transmit Delay 1

Interface: 1.1.1.1 (LoopBack0)

Cost: 0       State: P-2-P             Type: P2P              MTU: 1500


Timers: Hello 10, Dead 40, Poll 120, Retransmit 5, Transmit Delay 1

  1. R1 上查看当前设备的邻居状态。

<R1>display ospf peer

OSPF Process 1 with Router ID 1.1.1.1 Neighbors

Area 0.0.0.0 interface 12.1.1.1(GigabitEthernet0/0/0)'s neighbors Router ID: 2.2.2.2 Address: 12.1.1.2

State: Full Mode:Nbr is Master Priority: 1 // 邻居状态为Full,邻居为Master

DR: 12.1.1.1 BDR: 12.1.1.2 MTU: 0


Dead timer due in 34 sec Retrans timer interval: 5 Neighbor is up for 00:29:56 Authentication Sequence: [ 0 ]

  1. R1 上查看当前设备的 LSDB

<R1>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

109

60

8000000A

1

Router

1.1.1.1

1.1.1.1

169

48

80000007

1

Router

3.3.3.3

3.3.3.3

114

48

80000005

1

Network

23.1.1.2

2.2.2.2

109

32

80000003

0

Network

12.1.1.1

1.1.1.1

169

32

80000003

0

  1. R1 上查看当前设备的 OSPF 路由表。

<R1>display ospf routing

OSPF Process 1 with Router ID 1.1.1.1 Routing Tables

Routing for Network

Destination

Cost

Type

NextHop

AdvRouter

Area

1.1.1.1/32

0

Stub

1.1.1.1

1.1.1.1

0.0.0.0

12.1.1.0/24

1

Transit

12.1.1.1

1.1.1.1

0.0.0.0

2.2.2.2/32

1

Stub

12.1.1.2

2.2.2.2

0.0.0.0

3.3.3.3/32

2

Stub

12.1.1.2

3.3.3.3

0.0.0.0

23.1.1.0/24

2

Transit

12.1.1.2

2.2.2.2

0.0.0.0

Total Nets: 5


Intra Area: 5 Inter Area: 0 ASE: 0 NSSA: 0

  1. R1 上开启以下命令,观察 OSPF 的状态机。

<R1>terminal debugging                         // 使能终端显示 Debug 信息功能

<R1>terminal monitor                         // 使能终端显示信息中心发送信息的功能

<R1>debugging ospf event                         // 用来查看 OSPF 协议工作过程中的所有事件

<R1>debugging ospf packet                         // 用来查看 OSPF 协议工作过程中的所有报文

<R1>system-view [R1]interface g0/0/0

[R1-GigabitEthernet0/0/0]shutdown [R1-GigabitEthernet0/0/0]quit [R1]interface g0/0/0

[R1-GigabitEthernet0/0/0]undo shutdown [R1-GigabitEthernet0/0/0]quit [R1]info-center enable

调试信息如下 :

Sep 2 2022 15:13:00-08:00 R1 %%01IFPDT/4/IF_STATE(l)

[0]:Interface GigabitEthernet0/0/0 has turned into UP state. [R1]

Sep 2 2022 15:13:00-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.

[R1]

Sep 2 2022 15:13:00.191.7-08:00 R1 RM/6/RMDEBUG:

FileID: 0xd017802c Line: 1295 Level: 0x20

OSPF 1: Intf 12.1.1.1 Rcv InterfaceUp State Down -> Waiting.

// 接入 UP 后,OSPF Down 状态进入 Waiting 状态

[R1]

Sep 2 2022 15:13:00.191.8-08:00 R1 RM/6/RMDEBUG:

FileID: 0xd0178025 Line: 559 Level: 0x20

OSPF 1: SEND Packet. Interface: GigabitEthernet0/0/0 [R1]

Sep 2 2022 15:13:00.191.9-08:00 R1 RM/6/RMDEBUG: Source Address: 12.1.1.1 [R1]

Sep 2 2022 15:13:00.191.10-08:00 R1 RM/6/RMDEBUG: Destination Address: 224.0.0.5 [R1]

Sep 2 2022 15:13:00.191.11-08:00 R1 RM/6/RMDEBUG: Ver# 2, Type: 1 (Hello) [R1]

Sep 2 2022 15:13:00.191.12-08:00 R1 RM/6/RMDEBUG: Length: 44, Router: 1.1.1.1 [R1]

Sep 2 2022 15:13:00.191.13-08:00 R1 RM/6/RMDEBUG: Area: 0.0.0.0, Chksum: fa9c [R1]

Sep 2 2022 15:13:00.191.14-08:00 R1 RM/6/RMDEBUG: AuType: 00 [R1]

Sep 2 2022 15:13:00.191.15-08:00 R1 RM/6/RMDEBUG: Key(ascii): * * * * * * * * [R1]


Sep 2 2022 15:13:00.191.16-08:00 R1 RM/6/RMDEBUG: Net Mask: 255.255.255.0

[R1]

1

Sep 2 2022 15:13:00.191.17-08:00 R1 RM/6/RMDEBUG: Hello Int: 10, Option: _E_ [R1]

Sep 2 2022 15:13:00.191.18-08:00 R1 RM/6/RMDEBUG: Rtr Priority: 1, Dead Int: 40 [R1]

Sep 2 2022 15:13:00.191.19-08:00 R1 RM/6/RMDEBUG: DR: 0.0.0.0 [R1]

Sep 2 2022 15:13:00.191.20-08:00 R1 RM/6/RMDEBUG: BDR: 0.0.0.0 [R1]

Sep 2 2022 15:13:00.191.21-08:00 R1 RM/6/RMDEBUG: # Attached Neighbors: 0 [R1]

Sep 2 2022 15:13:00.191.22-08:00 R1 RM/6/RMDEBUG:

[R1]

Sep 2 2022 15:13:00.191.23-08:00 R1 RM/6/RMDEBUG:

FileID: 0xd017802c Line: 1409 Level: 0x20

OSPF 1 Send Hello Interface Up on 12.1.1.1                   //R1 在接口上发送 Hello

[R1]

Sep 2 2022 15:13:00.641.1-08:00 R1 RM/6/RMDEBUG:

FileID: 0xd0178024 Line: 2236 Level: 0x20

OSPF 1: RECV Packet. Interface: GigabitEthernet0/0/0 [R1]

Sep 2 2022 15:13:00.641.2-08:00 R1 RM/6/RMDEBUG: Source Address: 12.1.1.2 [R1]

Sep 2 2022 15:13:00.641.3-08:00 R1 RM/6/RMDEBUG: Destination Address: 224.0.0.5 [R1]

Sep 2 2022 15:13:00-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.1.1.12, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)

// 邻居收到 Hello 包,状态从 Down 进入 Init

[R1]

Sep 2 2022 15:13:00.641.5-08:00 R1 RM/6/RMDEBUG: Ver# 2, Type: 1 (Hello) [R1]

Sep 2 2022 15:13:00.641.6-08:00 R1 RM/6/RMDEBUG: Length: 44, Router: 2.2.2.2 [R1]

Sep 2 2022 15:13:00.641.7-08:00 R1 RM/6/RMDEBUG: Area: 0.0.0.0, Chksum: f89a [R1]

Sep 2 2022 15:13:00.641.8-08:00 R1 RM/6/RMDEBUG: AuType: 00 [R1]

Sep 2 2022 15:13:00.641.9-08:00 R1 RM/6/RMDEBUG: Key(ascii): * * * * * * * * [R1]

Sep 2 2022 15:13:00.641.10-08:00 R1 RM/6/RMDEBUG: Net Mask: 255.255.255.0 [R1]

Sep 2 2022 15:13:00.641.11-08:00 R1 RM/6/RMDEBUG: Hello Int: 10, Option: _E_ [R1]

Sep 2 2022 15:13:00.641.12-08:00 R1 RM/6/RMDEBUG: Rtr Priority: 1, Dead Int: 40 [R1]

Sep 2 2022 15:13:00.641.13-08:00 R1 RM/6/RMDEBUG: DR: 0.0.0.0 [R1]

Sep 2 2022 15:13:00.641.14-08:00 R1 RM/6/RMDEBUG: BDR: 0.0.0.0 [R1]

Sep 2 2022 15:13:00.641.15-08:00 R1 RM/6/RMDEBUG: # Attached Neighbors: 0 [R1]

Sep 2 2022 15:13:00.641.16-08:00 R1 RM/6/RMDEBUG:

[R1]

Sep 2 2022 15:13:00.641.17-08:00 R1 RM/6/RMDEBUG:

FileID: 0xd017802d Line: 1136 Level: 0x20

OSPF 1: Nbr 12.1.1.2 Rcv HelloReceived State Down -> Init. [R1]

Sep 2 2022 15:13:10-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.1.1.12, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way)

// 邻居收到 Hello 包,并在 Hello 包中看到自己的 Router ID,状态从 Init 进入 2Way

[R1]

Sep 2 2022 15:13:39-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.1.1.12, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart)

// 发送 DD 报文,进入 ExStart 状态

[R1]

Sep 2 2022 15:13:44-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.1.1.12, NeighborEvent=N egotiationDone,NeighborPreviousState=ExStart,NeighborCurrentState=Exchange)

// 交互 DD 报文并发送 LSRLSU 进入 Exchange 状态

[R1]

Sep 2 2022 15:13:44-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.1.1.12, NeighborEvent= ExchangeDone,NeighborPreviousState=Exchange,NeighborCurrentState=Loading)

// 交互完毕进入 Loading 状态

[R1]

Sep 2 2022 15:13:44-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[7]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=2.1.1.12, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full)


//LSA 同步完成进入 Full 状态

本文出自作者的《华为HCIP-Datacom认证实验指导》

http://www.xdnf.cn/news/1364797.html

相关文章:

  • 基于SpringBoot的招聘管理系统【2026最新】
  • Redis类型之List
  • 【慕伏白】CTFHub 技能树学习笔记 -- Web 之信息泄露
  • vue3+typescript:为表格生成唯一的Key/No
  • 集群与集群概念
  • 如何在 Jenkins 中安装 Master 和 Slave 节点以优化 CI/CD 流程
  • 【数据可视化-98】2025年上半年地方财政收入Top 20城市可视化分析:Python + Pyecharts打造炫酷暗黑主题大屏
  • 【数据可视化-100】使用 Pyecharts 绘制人口迁徙图:步骤与数据组织形式
  • Linux下的软件编程——网络编程(http)
  • 基于git的场景解决
  • DeepSeek 14B模型本地部署与预训练实现方案
  • 从零开始学习单片机15
  • MySQL常见报错分析及解决方案总结(1)---Can‘t connect to MySQL server on ‘localhost‘(10061)
  • 什么是事件循环(Event Loop)?浏览器和 Node.js 中的事件循环有什么区别?
  • 维度建模 —— 雪花模型 和 星型模型的优缺点
  • 冯·诺依曼架构:现代计算机的基石与瓶颈
  • Linux驱动开发笔记(七)——并发与竞争(下)——自旋锁信号量互斥体
  • k8s笔记03-常用操作命令
  • vite 项目创建、插件配置
  • JBL音响代理——河北正娱科技的声学精品工程
  • 智慧城市SaaS平台/交通设施运行监测系统之桥梁运行监测、城市道路塌陷风险运行监测系统架构内容
  • 网络编程--TCP/UDP Socket套接字
  • 验证码流程
  • 【AI解读源码系列】ant design mobile——Space间距
  • 京东API分类接口实战指南:获取各类商品信息
  • 【大模型本地运行与部署框架】Ollama的API交互
  • Spring拦截器中@Resource注入为null的问题
  • PAT乙级_1120 买地攻略_Python_AC解法_含疑难点
  • 6.3Element UI 的表单
  • 【python断言插件responses_validator使用】