[HCIP] OSPF作业1:影响邻居关系建立的原因
一,网络拓扑
二,按图示配置IP,配置基础的OSPF
R1:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <Huawei>system-view Enter system view, return user view with Ctrl+Z. [Huawei]sysname R1 [R1] interface g0/0/0 [R1-GigabitEthernet0/0/0]ip address 10.1.12.1 24 Feb 13 2022 10:28:27-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state. [R1-GigabitEthernet0/0/0] interface g0/0/1 [R1-GigabitEthernet0/0/1]ip address 10.1.14.1 24 Feb 13 2022 10:28:39-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface GigabitEthernet0/0/1 has entered the UP state. [R1]ospf router-id 0.0.0.1 [R1-ospf-1]area 0 [R1-ospf-1-area-0.0.0.0] interface g0/0/0 [R1-GigabitEthernet0/0/0]ospf enable 1 area 0 [R1-GigabitEthernet0/0/0] interface g0/0/1 [R1-GigabitEthernet0/0/1]ospf enable 1 area 0 |
R2:
<Huawei>system-view Enter system view, return user view with Ctrl+Z. [Huawei]sysname R2 [R2]interface g0/0/0 [R2-GigabitEthernet0/0/0]ip address 10.1.12.2 24 Feb 13 2022 10:32:44-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state. [R2-GigabitEthernet0/0/0]interface g0/0/1 [R2-GigabitEthernet0/0/1]ip address 10.1.23.2 24 Feb 13 2022 10:32:55-08:00 R2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface GigabitEthernet0/0/1 has entered the UP state. [R2-GigabitEthernet0/0/1]ospf router-id 0.0.0.2 [R2-ospf-1]area 0 [R2-ospf-1-area-0.0.0.0]interface g0/0/0 [R2-GigabitEthernet0/0/0]ospf enable 1 area 0 [R2-GigabitEthernet0/0/0]interface g0/0/1 [R2-GigabitEthernet0/0/1]ospf enable 1 area 0
R3:
<Huawei>system-view Enter system view, return user view with Ctrl+Z. [Huawei]sysname R3 [R3]interface g0/0/0 [R3-GigabitEthernet0/0/0]ip address 10.1.23.3 24 Feb 13 2022 10:38:42-08:00 R3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state. [R3-GigabitEthernet0/0/0]interface g0/0/1 [R3-GigabitEthernet0/0/1]ip address 10.1.34.3 24 [R3-GigabitEthernet0/0/1]ospf router-id 0.0.0.3 Feb 13 2022 10:38:42-08:00 R3 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface GigabitEthernet0/0/1 has entered the UP state. [R3-GigabitEthernet0/0/1]ospf router-id 0.0.0.3 [R3-ospf-1]area 0 [R3-ospf-1-area-0.0.0.0]interface g0/0/0 [R3-GigabitEthernet0/0/0]ospf enable 1 area 0 [R3-GigabitEthernet0/0/0]interface g0/0/1 [R3-GigabitEthernet0/0/1]ospf enable 1 area 0
R4:
<Huawei>system-view Enter system view, return user view with Ctrl+Z. [Huawei]sysname R4 [R4]interface g0/0/0 [R4-GigabitEthernet0/0/0]ip address 10.1.14.4 24 Feb 13 2022 10:40:58-08:00 R4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state. inter [R4-GigabitEthernet0/0/0]face g0/0/1 [R4-GigabitEthernet0/0/1]ip address 10.1.34.4 24 Feb 13 2022 10:40:58-08:00 R4 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface GigabitEthernet0/0/1 has entered the UP state. [R4-GigabitEthernet0/0/1]ospf router-id 0.0.0.4 [R4-ospf-1]area 0 [R4-ospf-1-area-0.0.0.0]interface g0/0/0 [R4-GigabitEthernet0/0/0]ospf enable 1 area 0 [R4-GigabitEthernet0/0/0]interface g0/0/1 [R4-GigabitEthernet0/0/1]ospf enable 1 area 0
当出现:
Feb 12 2022 17:01:54-08:00 Core-2 %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=1, NeighborAddress=10.1.10.252, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init)
[R1]display ospf peer brief OSPF Process 1 with Router ID 0.0.0.1 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 0.0.0.2 Full 0.0.0.0 GigabitEthernet0/0/1 0.0.0.4 Full ---------------------------------------------------------------------------- [R3-GigabitEthernet0/0/1]display ospf peer brief OSPF Process 1 with Router ID 0.0.0.3 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 0.0.0.2 Full 0.0.0.0 GigabitEthernet0/0/1 0.0.0.4 Full ----------------------------------------------------------------------------
三,实验内容
根本原因 源自于报文(字段)
(1)相邻设备的RID冲突
①改变R1的RID为0.0.0.2
[R1]ospf 1 router-id 0.0.0.2 Info: The configuration succeeded. You need to restart the OSPF process to validate the new router ID. [R1-ospf-1]qu [R1]qu <R1> <R1>reset ospf process Warning: The OSPF process will be reset. Continue? [Y/N]:Y
②此时,R1和R2分别发出RID冲突的通告
<R1> Feb 13 2022 11:10:59-08:00 R1 %%01OSPF/4/CONFLICT_ROUTERID_INTF(l)[69]:OSPF Router id conflict is detected on interface. (ProcessId=256, RouterId=2.0.0.0, AreaId=0.0.0.0, InterfaceName=GigabitEthernet0/0/0, IpAddr=1.12.1.10, PacketSrcIp=2.12.1.10) <R2> Feb 13 2022 11:10:59-08:00 R2 %%01OSPF/4/CONFLICT_ROUTERID_INTF(l)[22]:OSPF Router id conflict is detected on interface. (ProcessId=256, RouterId=2.0.0.0, AreaId=0.0.0.0, InterfaceName=GigabitEthernet0/0/0, IpAddr=2.12.1.10, PacketSrcIp=1.12.1.10)
③同时邻居表建立不了邻居
<R1>display ospf peer brief OSPF Process 1 with Router ID 0.0.0.2 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/1 0.0.0.4 Full ---------------------------------------------------------------------------- <R2>display ospf peer brief OSPF Process 1 with Router ID 0.0.0.2 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/1 0.0.0.3 Full ----------------------------------------------------------------------------
④过了5分钟左右后,华为的路由器因为RID冲突会默认自动调整RID的机制,重新建立邻居关系,发出通告。(但是之前在做的时候有时候,只有一台更换了RID)
<R1> Feb 13 2022 11:16:07-08:00 R1 %%01OSPF/4/AUTO_CHG_RTRID(l)[79]:OSPF automatically changes the router ID when detecting router ID conflict in the area. (ProcessId=256, NewRouterId=1.14.1.10, OldRouterId=2.0.0.0, ConflictRtrIdNum=16777216)
<R1>display ospf peer brief OSPF Process 1 with Router ID 10.1.14.1 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 10.1.23.2 Full 0.0.0.0 GigabitEthernet0/0/1 0.0.0.4 Full ---------------------------------------------------------------------------- <R2>display ospf peer brief OSPF Process 1 with Router ID 10.1.23.2 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 10.1.14.1 Full 0.0.0.0 GigabitEthernet0/0/1 0.0.0.3 Full ----------------------------------------------------------------------------
(2)相邻设备的区域ID不同
①更改R1的g0/0/0和G0/0/1接口宣告在area 10
[R1]ospf 1 [R1-ospf-1]dis this [V200R003C00] # ospf 1 router-id 0.0.0.2 area 0.0.0.0 # return [R1-ospf-1]area 10 [R1-ospf-1-area-0.0.0.10]interface g0/0/1 [R1-GigabitEthernet0/0/1]undo ospf enable 1 area 0 [R1-GigabitEthernet0/0/1]ospf enable 1 area 10
[R1-GigabitEthernet0/0/1]interface g0/0/0
[R1-GigabitEthernet0/0/0]undo ospf enable 1 area 0
[R1-GigabitEthernet0/0/0]ospf enable 1 area 10
②邻居关系立即断开,并且无法再建立
[R1]display ospf peer brief OSPF Process 1 with Router ID 10.1.14.1 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State ----------------------------------------------------------------------------
(3)认证类型不匹配(0-不认证,1-明文认证,2-密文认证)
暂时无法实验认证
(4)认证数据不匹配(密码不匹配)
暂时无法实验认证
(5)广播网络中(比如现在的以太网络),掩码必须相同(点到点网络不关心)
①我们先查看AR2和AR3之间的链路类型为广播网络
[R2]display ospf interface OSPF Process 1 with Router ID 10.1.23.2 Interfaces Area: 0.0.0.0 (MPLS TE not enabled) IP Address Type State Cost Pri DR BDR 10.1.12.2 Broadcast DR 1 1 10.1.12.2 10.1.12.1 10.1.23.2 Broadcast BDR 1 1 10.1.23.3 10.1.23.2 <R3>display ospf interface OSPF Process 1 with Router ID 0.0.0.3 Interfaces Area: 0.0.0.0 (MPLS TE not enabled) IP Address Type State Cost Pri DR BDR 10.1.23.3 Broadcast DR 1 1 10.1.23.3 10.1.23.2 10.1.34.3 Broadcast BDR 1 1 10.1.34.4 10.1.34.3
②更改R2的G0/0/1接口下地址网段为10.1.23.0/28的10.1.23.2,该网段依然包括10.1.23.2和10.1.23.3
[R2]interface g0/0/1 [R2-GigabitEthernet0/0/1]display this [V200R003C00] # interface GigabitEthernet0/0/1 ip address 10.1.23.2 255.255.255.0 ospf enable 1 area 0.0.0.0 # return [R2-GigabitEthernet0/0/1]ip address 10.1.23.2 28
③此时,R2与R3的邻居关系状态改变为DOWN,但是可以互相ping通
[R2]display ospf peer brief OSPF Process 1 with Router ID 10.1.23.2 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 10.1.14.1 Full ---------------------------------------------------------------------------- [R2]ping 10.1.23.3 PING 10.1.23.3: 56 data bytes, press CTRL_C to break Reply from 10.1.23.3: bytes=56 Sequence=1 ttl=253 time=40 ms Reply from 10.1.23.3: bytes=56 Sequence=2 ttl=253 time=30 ms Reply from 10.1.23.3: bytes=56 Sequence=3 ttl=253 time=40 ms --- 10.1.23.3 ping statistics --- 3 packet(s) transmitted 3 packet(s) received 0.00% packet loss round-trip min/avg/max = 30/36/40 ms
④改变R2和R3之间链路的接口网络类型为点到点
[R2]interface g0/0/1 [R2-GigabitEthernet0/0/1]ospf network-type p2p [R3]interface g0/0/0 [R3-GigabitEthernet0/0/0]ospf network-type p2p
⑤邻居重新建立
[R2-GigabitEthernet0/0/1] Feb 13 2022 11:39:05-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=3.23.1.10, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full) [R2-GigabitEthernet0/0/1]display ospf peer brief OSPF Process 1 with Router ID 10.1.23.2 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 10.1.14.1 Full 0.0.0.0 GigabitEthernet0/0/1 0.0.0.3 Full ----------------------------------------------------------------------------
(6)比特位(功能位),比如是否可以接收外部路由(设置为stub区域之类)
①网络拓扑
SW1:
[SW1]vlan 10 [SW1-vlan10]quit [SW1]interface g0/0/2 [SW1-GigabitEthernet0/0/2]port link-type trunk [SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan all [SW1-GigabitEthernet0/0/2]interface vlanif 10 [SW1-Vlanif10]ip address 192.168.0.252 24 [SW1]ospf router-id 0.0.0.5 [SW1-ospf-1]area 10 [SW1-ospf-1-area-0.0.0.10]interface vlanif 10 [SW1-Vlanif10]ospf enable 1 area 10
SW2:
[SW2]vlan 10 [SW2-vlan10]quit [SW2]interface g0/0/1 [SW2-GigabitEthernet0/0/1]port link-type trunk [SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all [SW2]ospf 1 router-id 0.0.0.6 [SW2-ospf-1]area 10 [SW2]interface vlanif 10 [SW2-Vlanif10]ip address 192.168.0.253 24 [SW2-Vlanif10]ospf enable 1 area 10
②邻居建立后,抓包发现SW1,发送的hello报文中可以接收外部路由功能位置一
[SW2]dis ospf peer brief OSPF Process 1 with Router ID 0.0.0.6 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.10 Vlanif10 0.0.0.5 Full ----------------------------------------------------------------------------
③我们将SW1的OSPF进程area10中配置为stub区域
[SW1]ospf [SW1-ospf-1]area 10 [SW1-ospf-1-area-0.0.0.10]stub
④邻居立刻进入DOWN状态,并且抓包发现,源为192.168.0.252的SW1的Hello报文中,接收外部路由的功能位置零
[SW1-ospf-1-area-0.0.0.10]display ospf peer brief OSPF Process 1 with Router ID 0.0.0.5 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State ----------------------------------------------------------------------------
(7)Hello时间和死亡时间都相同
①更改R3的接口G0/0/1接口Hello时间为1s,死亡时间自动变为hello时间的四倍
[R3]interface g0/0/1 [R3-GigabitEthernet0/0/1]ospf timer hello 1
②同时发现,数据包发送速度变快,然后更改R4的接口G0/0/1Hello时间为1s,邻居重新建立
[R4]interface g0/0/1 [R4-GigabitEthernet0/0/1]ospf timer hello 1
[R4]display ospf peer brief OSPF Process 1 with Router ID 0.0.0.4 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 10.1.14.1 Full 0.0.0.0 GigabitEthernet0/0/1 0.0.0.3 Full ----------------------------------------------------------------------------
(8)网络类型有参数影响邻居关系建立(严格意义上来讲网络类型不影响邻居关系,只要Hello时间相同即可)
网络类型 | Hello时间 | 死亡时间 | 是否需要DR |
广播 | 10 | 40 | 是 |
点到点 | 10 | 40 | 否 |
NBMA | 30 | 120 | 是 |
P2MP | 30 | 120 | 否 |
①更改R4的g0/0/0接口为P2MP,R1的G0/0/1接口为P2P
[R1]interface g0/0/1 [R1-GigabitEthernet0/0/1]ospf network-type p2p [R4]interface g0/0/0 [R4-GigabitEthernet0/0/0]ospf network-type p2mp
②R1和R4邻居关系DOWN,更改R4的G0/0/0接口的hello时间与P2P一致
[R1-GigabitEthernet0/0/1]display ospf peer brief OSPF Process 1 with Router ID 10.1.14.1 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 10.1.23.2 Full ----------------------------------------------------------------------------
[R4]interface g0/0/0 [R4-GigabitEthernet0/0/0]ospf timer hello 10
③邻居重新建立,但网络类型不同
<R1>display ospf peer brief OSPF Process 1 with Router ID 10.1.14.1 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 10.1.23.2 Full 0.0.0.0 GigabitEthernet0/0/1 0.0.0.4 Full ---------------------------------------------------------------------------- <R1>display ospf interface OSPF Process 1 with Router ID 10.1.14.1 Interfaces Area: 0.0.0.0 (MPLS TE not enabled) IP Address Type State Cost Pri DR BDR 10.1.12.1 Broadcast BDR 1 1 10.1.12.2 10.1.12.1 10.1.14.1 P2P P-2-P 1 1 0.0.0.0 0.0.0.0
[R4-GigabitEthernet0/0/0]display ospf interface OSPF Process 1 with Router ID 0.0.0.4 Interfaces Area: 0.0.0.0 (MPLS TE not enabled) IP Address Type State Cost Pri DR BDR 10.1.14.4 P2MP P-2-P 1 1 0.0.0.0 0.0.0.0 10.1.34.4 Broadcast DR 1 1 10.1.34.4 10.1.34.3
④我们再把R1的接口网络类型更换为广播型
[R1-GigabitEthernet0/0/1]ospf network-type broadcast
⑤邻居短暂的断开,又重新建立
[R1-GigabitEthernet0/0/1]ospf network-type broadcast Feb 13 2022 12:35:02-08:00 R1 %%01OSPF/3/NBR_CHG_DOWN(l)[0]:Neighbor event:neighbor state changed to Down. (ProcessId=256, NeighborAddress=4.0.0.0, NeighborEvent=KillNbr, NeighborPreviousState=Full, NeighborCurrentState=Down) [R1-GigabitEthernet0/0/1] [R1-GigabitEthernet0/0/1] Feb 13 2022 12:35:02-08:00 R1 %%01OSPF/3/NBR_DOWN_REASON(l)[1]:Neighbor state leaves full or changed to Down. (ProcessId=256, NeighborRouterId=4.0.0.0, NeighborAreaId=0, NeighborInterface=GigabitEthernet0/0/1,NeighborDownImmediate reason=Neighbor Down Due to Kill Neighbor, NeighborDownPrimeReason=Interface Parameter Mismatch, NeighborChangeTime=2022-02-13 12:35:02-08:00) [R1-GigabitEthernet0/0/1] Feb 13 2022 12:35:08-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[2]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=4.14.1.10, NeighborEvent=HelloReceived, NeighborPreviousState=Down, NeighborCurrentState=Init) [R1-GigabitEthernet0/0/1] Feb 13 2022 12:35:08-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[3]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=4.14.1.10, NeighborEvent=2WayReceived, NeighborPreviousState=Init, NeighborCurrentState=2Way) [R1-GigabitEthernet0/0/1] Feb 13 2022 12:35:38-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[4]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=4.14.1.10, NeighborEvent=AdjOk?, NeighborPreviousState=2Way, NeighborCurrentState=ExStart) [R1-GigabitEthernet0/0/1] Feb 13 2022 12:35:38-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[5]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=4.14.1.10, NeighborEvent=NegotiationDone, NeighborPreviousState=ExStart, NeighborCurrentState=Exchange) [R1-GigabitEthernet0/0/1] Feb 13 2022 12:35:38-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[6]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=4.14.1.10, NeighborEvent=ExchangeDone, NeighborPreviousState=Exchange, NeighborCurrentState=Loading) [R1-GigabitEthernet0/0/1] Feb 13 2022 12:35:38-08:00 R1 %%01OSPF/4/NBR_CHANGE_E(l)[7]:Neighbor changes event: neighbor status changed. (ProcessId=256, NeighborAddress=4.14.1.10, NeighborEvent=LoadingDone, NeighborPreviousState=Loading, NeighborCurrentState=Full)
[R1-GigabitEthernet0/0/1]display ospf peer brief OSPF Process 1 with Router ID 10.1.14.1 Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/0 10.1.23.2 Full 0.0.0.0 GigabitEthernet0/0/1 0.0.0.4 Full ----------------------------------------------------------------------------
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构