实验:单区域OSPF配置详解

操作工具:ensp

1.实验目的

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

2.实验拓扑

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

                          图1-2 配置单区域OSPF

更多实验拓扑资料,可领取

实验拓扑(部分示意)

关注+点赞后,文章底部找我领取

3.实验步骤

  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 32

[R3-LoopBack0]quit

  1. 运行OSPF

R1的配置

[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]are

[R3-ospf-1]area 0

[R3-ospf-1-area-0.0.0.0]net

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

[R3-ospf-1-area-0.0.0.0]net

[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】进程ID

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

【技术要点2Router ID

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

4.实验调试

  1. 在R1上查看当前设备所有激活OSPF的接口信息

<R1>display ospf interface all

    OSPF Process 1 with Router ID 1.1.1.1  //OSPF的进程为1,router-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

//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]

[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]

[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]

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=NegotiationDone,NeighborPreviousState=ExStart,NeighborCurrentState=Exchange)  //交互DD报文并发送LSR、LSU进入到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状态

更多实验拓扑资料,可领取

实验拓扑(部分示意)

关注+点赞后,文章底部找我领取

想要更多实验拓扑,↓可关注+点赞后通过底部方式获取↓(备注csdn)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

卓应米老师

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值