OSPF 单区域基础实验

OSPF 单区域
1.1.1 实验介绍
1.1.1.1 学习目标
实现单区域 OSPF 的配置
实现 OSPF 区域认证的配置
描述 OSPF 在多路访问网络中邻居关系建立的过程
实现对 OSPF 接口代价值进行修改
阐明 OSPF Silent-interface 的配置方法
实现通过 display 命令查看 OSPF 各种状态
1.1.1.2 实验组网介绍
1-1 OSPF 单区域
R1 R2 R3 之间通过交换机 S1 相连,其接口、 IP 地址如图所示。 R1 R2 R3 上均创建
Loopback0 IP 地址为 10.0.x.x/24 ,其中 x 为设备编号。
R1 R2 R3 所有接口都属于区域 0 ,在互联接口、 Loopback0 接口上激活 OSPF HCIP-Datacom-Core Technology 实验手册
1.1.1.3 实验背景
你是公司的网络管理员。现在公司的网络中有三台 AR 路由器,通过以太网实现相互的连通。
在以太网这样的广播式多路访问网络上,可能存在安全隐患,所有你选择采用 OSPF 区域认证
的方法来避免恶意的路由攻击。
1.1.2 实验任务
1.1.2.1 任务思路
1. 设备 IP 地址配置。
2. R1 R2 R3 上配置 OSPF ,手动指定 Router ID ,并在互联接口、 Loopback0 接口上
激活 OSPF
3. 配置完成后,在 R1 R2 R3 上检查 OSPF 邻居关系状态、 OSPF 路由表,并检查 R1
R2 R3 环回口之间的连通性。
4. 手动关闭 R1 R2 R3 的互联接口,开启 debug 以观察 OSPF 邻居关系的建立过程,再
同时开启互联接口,观察设备的 debug 输出。
5. 手动修改 R2 Loopback0 接口的网络类型,观察 OSPF 路由的掩码长度变化。
6. 手动修改 OSPF 接口的 Cost 值。
7. 分别将互联接口、 Loopback0 接口配置为 OSPF Silent-Interface ,观察现象的区别。
1.1.2.2 任务步骤
步骤 1 互联接口、环回口 IP 地址配置
# 配置 R1 GE0/0/3 接口、环回口 IP 地址
<R1>system-view
Enter system view, return user view with Ctrl+Z.
[R1]interface GigabitEthernet 0/0/3
[R1-GigabitEthernet0/0/3] ip address 10.0.123.1 24
[R1-GigabitEthernet0/0/3] quit
[R1]interface LoopBack 0
[R1-LoopBack0] ip address 10.0.1.1 24
[R1-LoopBack0] quit
# 配置 R2 GE0/0/4 接口、环回口 IP 地址
<R2>system-view
[R2]interface GigabitEthernet 0/0/4
[R2-GigabitEthernet0/0/4] ip address 10.0.123.2 24
[R2-GigabitEthernet0/0/4] quit
[R2]interface LoopBack 0
[R2-LoopBack0] ip address 10.0.2.2 24
[R2-LoopBack0] quit
# 配置 R3 GE0/0/4 接口、环回口 IP 地址
<R3>system-view
Enter system view, return user view with Ctrl+Z.
[R3]interface GigabitEthernet 0/0/4
[R3-GigabitEthernet0/0/4] ip address 10.0.123.3 24
[R3-GigabitEthernet0/0/4] quit
[R3]interface LoopBack 0
[R3-LoopBack0] ip address 10.0.3.3 24
[R3-LoopBack0] quit
# R1 上验证连通性
<R1>ping -c 1 10.0.123.2
PING 10.0.123.2: 56 data bytes, press CTRL_C to break
Reply from 10.0.123.2: bytes=56 Sequence=1 ttl=255 time=2 ms
--- 10.0.123.2 ping statistics ---
1 packet(s) transmitted
1 packet(s) received
0.00% packet loss
round-trip min/avg/max = 2/2/2 ms
<R1>ping -c 1 10.0.123.3
PING 10.0.123.3: 56 data bytes, press CTRL_C to break
Reply from 10.0.123.3: bytes=56 Sequence=1 ttl=255 time=2 ms
--- 10.0.123.3 ping statistics ---
1 packet(s) transmitted
1 packet(s) received
0.00% packet loss
round-trip min/avg/max = 2/2/2 ms
步骤 2 配置单区域 OSPF
# 配置 R1 R2 R3 OSPF Router ID Loopback0 接口地址, OSPF 进程号为 1
[R1]ospf 1 router-id 10.0.1.1
[R2]ospf 1 router-id 10.0.2.2
[R3]ospf 1 router-id 10.0.3.3
# R1 R2 R3 的互联接口、 Loopback0 接口激活 OSPF
[R1]ospf 1
[R1-ospf-1]area 0 HCIP-Datacom-Core Technology 实验手册
[R1-ospf-1-area-0.0.0.0] network 10.0.123.1 0.0.0.0
[R1-ospf-1-area-0.0.0.0] network 10.0.1.1 0.0.0.0
[R2]ospf 1
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0] network 10.0.123.2 0.0.0.0
[R2-ospf-1-area-0.0.0.0] network 10.0.2.2 0.0.0.0
[R3]ospf 1
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0] network 10.0.123.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0] network 10.0.3.3 0.0.0.0
# 为保证安全性,配置 OSPF 的区域认证,使用明文方式,密码配置为 “huawei”
[R1]ospf 1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0] authentication-mode simple plain huawei
[R2]ospf 1
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0] authentication-mode simple plain huawei
[R3]ospf 1
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0] authentication-mode simple plain huawei
步骤 3 检查 OSPF 配置结果
# 检查 R1 R2 R3 上的 OSPF 邻居信息
<R1>display ospf peer
OSPF Process 1 with Router ID 10.0.1.1
Neighbors
Area 0.0.0.0 interface 10.0.123.1(GigabitEthernet0/0/3)'s neighbors
Router ID: 10.0.2.2 Address: 10.0.123.2
State: Full Mode:Nbr is Master Priority: 1
DR: 10.0.123.1 BDR: 10.0.123.2 MTU: 0
Dead timer due in 39 sec
Retrans timer interval: 5
Neighbor is up for 00:24:56
Authentication Sequence: [ 0 ]
Router ID: 10.0.3.3 Address: 10.0.123.3
State: Full Mode:Nbr is Slave Priority: 1
DR: 10.0.123.1 BDR: 10.0.123.2 MTU: 0
Dead timer due in 38 sec
Retrans timer interval: 5
Authentication Sequence: [ 0 ]
从输出结果可知 R1 R2 R3 之间已经成功建立 OSPF 邻居关系。
<R2>display ospf peer
OSPF Process 1 with Router ID 10.0.2.2
Neighbors
Area 0.0.0.0 interface 10.0.123.2(GigabitEthernet0/0/4)'s neighbors
Router ID: 10.0.1.1 Address: 10.0.123.1
State: Full Mode:Nbr is Slave Priority: 1
DR: 10.0.123.1 BDR: 10.0.123.2 MTU: 0
Dead timer due in 34 sec
Retrans timer interval: 0
Neighbor is up for 00:27:10
Authentication Sequence: [ 0 ]
Router ID: 10.0.3.3 Address: 10.0.123.3
State: Full Mode:Nbr is Slave Priority: 1
DR: 10.0.123.1 BDR: 10.0.123.2 MTU: 0
Dead timer due in 36 sec
Retrans timer interval: 5
Neighbor is up for 00:26:50
Authentication Sequence: [ 0 ]
从输出结果可知 R2 R1 R3 之间已经成功建立 OSPF 邻居关系。
<R3>display ospf peer
OSPF Process 1 with Router ID 10.0.3.3
Neighbors
Area 0.0.0.0 interface 10.0.123.3(GigabitEthernet0/0/4)'s neighbors
Router ID: 10.0.1.1 Address: 10.0.123.1
State: Full Mode:Nbr is Master Priority: 1
DR: 10.0.123.1 BDR: 10.0.123.2 MTU: 0
Dead timer due in 31 sec
Retrans timer interval: 0
Neighbor is up for 00:28:06
Authentication Sequence: [ 0 ]
Router ID: 10.0.2.2 Address: 10.0.123.2
State: Full Mode:Nbr is Master Priority: 1
DR: 10.0.123.1 BDR: 10.0.123.2 MTU: 0
Dead timer due in 34 sec
Retrans timer interval: 5
Neighbor is up for 00:28:09
Authentication Sequence: [ 0 ]
从输出结果可知 R3 R1 R2 之间已经成功建立 OSPF 邻居关系。
[R1]display ospf routing
OSPF Process 1 with Router ID 10.0.1.1
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
10.0.1.1/32 0 Stub 10.0.1.1 10.0.1.1 0.0.0.0
10.0.123.0/24 1 Transit 10.0.123.1 10.0.1.1 0.0.0.0
10.0.2.2/32 1 Stub 10.0.123.2 10.0.2.2 0.0.0.0
10.0.3.3/32 1 Stub 10.0.123.3 10.0.3.3 0.0.0.0
Total Nets: 4
Intra Area: 4 Inter Area: 0 ASE: 0 NSSA: 0
从输出结果可知 R1 已经成功学习到 R2 R3 Loopback0 接口路由。
[R2]display ospf routing
OSPF Process 1 with Router ID 10.0.2.2
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
10.0.2.2/32 0 Stub 10.0.2.2 10.0.2.2 0.0.0.0
10.0.123.0/24 1 Transit 10.0.123.2 10.0.2.2 0.0.0.0
10.0.1.1/32 1 Stub 10.0.123.1 10.0.1.1 0.0.0.0
10.0.3.3/32 1 Stub 10.0.123.3 10.0.3.3 0.0.0.0
Total Nets: 4
Intra Area: 4 Inter Area: 0 ASE: 0 NSSA: 0
从输出结果可知 R2 已经成功学习到 R1 R3 Loopback0 接口路由。
[R3]display ospf routing
OSPF Process 1 with Router ID 3.3.3.3
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
10.0.3.3/32 0 Stub 10.0.3.3 10.0.3.3 0.0.0.0
10.0.123.0/24 1 Transit 10.0.123.3 10.0.3.3 0.0.0.0
10.0.1.1/32 1 Stub 10.0.123.1 10.0.1.1 0.0.0.0
10.0.2.2/32 1 Stub 10.0.123.2 10.0.2.2 0.0.0.0
Total Nets: 4
Intra Area: 4 Inter Area: 0 ASE: 0 NSSA: 0
从输出结果可知 R3 已经成功学习到 R1 R2 Loopback0 接口路由。
PING 10.0.2.2: 56 data bytes, press CTRL_C to break
Reply from 10.0.2.2: bytes=56 Sequence=1 ttl=255 time=50 ms
--- 10.0.2.2 ping statistics ---
1 packet(s) transmitted
1 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/50/50 ms
<R1>ping -c 1 -a 10.0.1.1 10.0.3.3
PING 10.0.3.3: 56 data bytes, press CTRL_C to break
Reply from 10.0.3.3: bytes=56 Sequence=1 ttl=255 time=60 ms
--- 10.0.3.3 ping statistics ---
1 packet(s) transmitted
1 packet(s) received
0.00% packet loss
round-trip min/avg/max = 60/60/60 ms
R1 上以 Loopback0 接口地址为源测试与 R2 R3 Loopback0 接口之间的连通性。
# R1 上查看 OSPF LSDB
<R1>displayospflsdb
OSPFProcess 1 withRouter ID 10.0.1.1
LinkState Database
Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 10.0.3.3 10.0.3.3 468 48 80000005 0
Router 10.0.2.2 10.0.2.2 472 48 8000000B 0
Router 10.0.1.1 10.0.1.1 467 48 8000000D 0
Network 10.0.123.1 10.0.1.1 467 36 80000008 0
在这里一共可以看到 4 LSA ,前 3 条为 Type-1 LSA ,分别由 R1 R2 R3 产生,可以通过
AdvRouter 判断该 LSA 是由哪台路由器生成的。第四条为 Type-2 LSA ,是由一个网段的 DR
产生的。在这里, R1 10.0.123.0/24 这个网段的 DR ,所以该 Type-2 LSA AdvRouter
10.0.1.1
# 查看 R1 产生的 Type-1 LSA
[R1]display ospf lsdb router self-originate
OSPF Process 1 with Router ID 10.0.1.1
Area: 0.0.0.0
Link State Database
Type : Router
Ls id : 10.0.1.1
Adv rtr : 10.0.1.1
Ls age : 430
Len : 48
seq# : 80000009
chksum : 0x8188
Link count: 2
* Link ID: 10.0.1.1
Data : 255.255.255.255
Link Type: StubNet
Metric : 0
Priority : Medium
* Link ID : 10.0.123.1
Data : 10.0.123.1
Link Type: TransNet
Metric : 1
从输出中可以看到这条 LSA 一共描述了 2 Link ,第一个 Link 描述了 Loopback 接口所在网
段, Link Type StubNet Link ID Data 分别是该 Stub 网段的 IP 地址和掩码。第二个
Link 描述了三台路由器的互联网段, Link Type TransNet ,可以看到 Link ID DR 的接口
地址: 10.0.123.1 Data 为该网段上本地接口的 IP 地址: 10.0.123.1
# 查看 R1 产生的 Type-2 LSA
[R1]display ospf lsdb network self-originate
OSPF Process 1 with Router ID 10.0.1.1
Area: 0.0.0.0
Link State Database
Type : Network
Ls id : 10.0.123.1
Adv rtr : 10.0.1.1
Ls age : 1662
Len : 36
Options : E
seq# : 80000005
chksum : 0x3d58
Net mask : 255.255.255.0
Priority: Low
Attached Router 10.0.1.1
Attached Router 10.0.2.2
Attached Router 10.0.3.3
从输出信息可以看到 Type-2 LSA 中的 Attached Router 描述了 DR 所在网段的邻居信息。
步骤 4 观察 OSPF 邻居关系建立过程
之前查看 OSPF 邻居信息时可以看到 DR 10.0.123.1 ,这与根据 DR 选举原则进行预测的结
果并不一致。在 OSPF 中, DR 的选举为非抢占,即网络中存在 DR BDR 时,新进入网络的
路由器不能抢占 DR BDR 的角色。当在配置 OSPF 时对设备的配置顺序存在前后差距,就
可能导致选举出的 DR 为先启动的设备。
为此可以关闭 R1 R2 R3 的互联接口,并使用 debugging ospf 1 event 观察 OSPF 邻居关
系建立的具体过程,之后尽量同时重新打开 R1 R2 R3 的接口,通过 debug 输出信息查看
DR BDR 的选举过程。
# 关闭 R1 R2 R3 的互联接口
[R1] interface GigabitEthernet0/0/3
[R1-GigabitEthernet0/0/3] shutdown
[R2] interface GigabitEthernet0/0/4
[R2-GigabitEthernet0/0/4] shutdown
[R3] interface GigabitEthernet0/0/4
[R3-GigabitEthernet0/0/4] shutdown
# 打开 R1 R2 R3 debug 功能以及开启 debug ospf event
<R1>terminal debugging
Info: Current terminal debugging is on.
<R1>terminal monitor
<R1>debugging ospf 1 event
R2 R3 相同操作,不再重复。
# 重新打开 R1 R2 R3 的互联接口
[R1] interface GigabitEthernet0/0/3
[R1-GigabitEthernet0/0/3] undo shutdown
[R2] interface GigabitEthernet0/0/4
[R2-GigabitEthernet0/0/4] undo shutdown
[R2] interface GigabitEthernet0/0/4
[R2-GigabitEthernet0/0/4] undo shutdown
# R3 上观察 debug 输出信息
May 22 2020 14:32:25-08:00 R3 %%01PHY/1/PHY(l)[20]: GigabitEthernet0/0/4: change status to
up
May 22 2020 14:32:25-08:00 R3 %%01IFNET/4/LINK_STATE(l)[21]:The line protocol IP on the interface
GigabitEthernet0/0/4 has entered the UP state.
May 22 2020 14:32:25.650.5-08:00 R3 RM/6/RMDEBUG:
FileID: 0x7017802c Line: 1281 Level: 0x20
OSPF 1: Intf 10.0.123.3 Rcv InterfaceUp State Down -> Waiting.
May 22 2020 14:32:25.650.6-08:00 R3 RM/6/RMDEBUG:
FileID: 0x7017802c Line: 1395 Level: 0x20
OSPF 1 Send Hello Interface Up on 10.0.123.3
May 22 2020 14:32:29-08:00 R3 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1
configurations have been changed. The current change number is 20, the change loop count is 0, and
the maximum number of records is 4095.
May 22 2020 14:33:06-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[22]:Neighbor changes event: neighbor
status changed. (ProcessId=1, NeighborAddress=10.0.123.2, NeighborEvent=HelloReceived,
NeighborPreviousState=Down, NeighborCurrentState=Init)
May 22 2020 14:33:06.320.2-08:00 R3 RM/6/RMDEBUG:
FileID: 0x7017802d Line: 1119 Level: 0x20
OSPF 1: Nbr 10.0.123.2 Rcv HelloReceived State Down -> Init.
May 22 2020 14:33:08.390.1-08:00 R3 RM/6/RMDEBUG:
FileID: 0x7017802c Line: 2061 Level: 0x20
OSPF 1 Send Hello Interface State Changed on 10.0.123.3
May 22 2020 14:33:08.390.2-08:00 R3 RM/6/RMDEBUG:
FileID: 0x7017802c Line: 2072 Level: 0x20
OSPF 1: Intf 10.0.123.3 Rcv WaitTimer State Waiting -> DR.
May 22 2020 14:33:08-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[23]:Neighbor changes event: neighbor
status changed. (ProcessId=1, NeighborAddress=10.0.123.2, NeighborEvent=2WayReceived,
NeighborPreviousState=Init, NeighborCurrentState=ExStart)
May 22 2020 14:33:08-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[24]:Neighbor changes event: neighbor
status changed. (ProcessId=1, NeighborAddress=10.0.123.2, NeighborEvent=NegotiationDone,
NeighborPreviousState=ExStart, NeighborCurrentState=Exchange)
May 22 2020 14:33:08.480.1-08:00 R3 RM/6/RMDEBUG:
FileID: 0x7017802d Line: 1715 Level: 0x20
OSPF 1: Nbr 10.0.123.2 Rcv 2WayReceived State Init -> ExStart.
May 22 2020 14:33:08.530.1-08:00 R3 RM/6/RMDEBUG:
FileID: 0x7017802d Line: 1828 Level: 0x20
OSPF 1: Nbr 10.0.123.2 Rcv NegotiationDone State ExStart -> Exchange.
May 22 2020 14:33:08-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[25]:Neighbor changes event: neighbor
status changed. (ProcessId=1, NeighborAddress=10.0.123.2, NeighborEvent=ExchangeDone,
NeighborPreviousState=Exchange, NeighborCurrentState=Loading)
May 22 2020 14:33:08-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[26]:Neighbor changes event: neighbor
status changed. (ProcessId=1, NeighborAddress=10.0.123.2, NeighborEvent=LoadingDone,
NeighborPreviousState=Loading, NeighborCurrentState=Full)
May 22 2020 14:33:08.590.3-08:00 R3 RM/6/RMDEBUG:
FileID: 0x7017802d Line: 1940 Level: 0x20
OSPF 1: Nbr 10.0.123.2 Rcv ExchangeDone State Exchange -> Loading.
May 22 2020 14:33:08.590.4-08:00 R3 RM/6/RMDEBUG:
FileID: 0x7017802d Line: 2339 Level: 0x20
OSPF 1: Nbr 10.0.123.2 Rcv LoadingDone State Loading -> Full.
May 22 2020 14:33:10-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[27]:Neighbor changes event: neighbor
status changed. (ProcessId=1, NeighborAddress=10.0.123.1, NeighborEvent=HelloReceived,
NeighborPreviousState=Down, NeighborCurrentState=Init)
May 22 2020 14:33:10-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[28]:Neighbor changes event: neighbor
status changed. (ProcessId=1, NeighborAddress=10.0.123.1, NeighborEvent=2WayReceived,
NeighborPreviousState=Init, NeighborCurrentState=ExStart)
May 22 2020 14:33:10-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[29]:Neighbor changes event: neighbor
status changed. (ProcessId=1, NeighborAddress=10.0.123.1, NeighborEvent=NegotiationDone,
NeighborPreviousState=ExStart, NeighborCurrentState=Exchange)
May 22 2020 14:33:10.340.1-08:00 R3 RM/6/RMDEBUG:
FileID: 0x7017802d Line: 1119 Level: 0x20
OSPF 1: Nbr 10.0.123.1 Rcv HelloReceived State Down -> Init.
May 22 2020 14:33:10.340.2-08:00 R3 RM/6/RMDEBUG:
FileID: 0x7017802d Line: 1715 Level: 0x20
OSPF 1: Nbr 10.0.123.1 Rcv 2WayReceived State Init -> ExStart.
May 22 2020 14:33:10.420.1-08:00 R3 RM/6/RMDEBUG:
FileID: 0x7017802d Line: 1828 Level: 0x20
OSPF 1: Nbr 10.0.123.1 Rcv NegotiationDone State ExStart -> Exchange.
May 22 2020 14:33:10-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[30]:Neighbor changes event: neighbor
status changed. (ProcessId=1, NeighborAddress=10.0.123.1, NeighborEvent=ExchangeDone,
NeighborPreviousState=Exchange, NeighborCurrentState=Loading)
May 22 2020 14:33:10-08:00 R3 %%01OSPF/4/NBR_CHANGE_E(l)[31]:Neighbor changes event: neighbor
status changed. (ProcessId=1, NeighborAddress=10.0.123.1, NeighborEvent=LoadingDone,
NeighborPreviousState=Loading, NeighborCurrentState=Full)
May 22 2020 14:33:10.460.3-08:00 R3 RM/6/RMDEBUG:
FileID: 0x7017802d Line: 1940 Level: 0x20
OSPF 1: Nbr 10.0.123.1 Rcv ExchangeDone State Exchange -> Loading.
May 22 2020 14:33:10.460.4-08:00 R3 RM/6/RMDEBUG:
FileID: 0x7017802d Line: 2339 Level: 0x20
OSPF 1: Nbr 10.0.123.1 Rcv LoadingDone State Loading -> Full.
在几乎同时启动 OSPF 时,从输出信息中可以看到 R3 成为 DR
# 查看 R2 debug 输出信息
May 22 2020 14:32:29-08:00 R2 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1
configurations have been changed. The current change number is 15, the change loop count is 0, and
the maximum number of records is 4095.
May 22 2020 14:32:29-08:00 R2 %%01PHY/1/PHY(l)[18]: GigabitEthernet0/0/4: change status to up
May 22 2020 14:32:29-08:00 R2 %%01IFNET/4/LINK_STATE(l)[19]:The line protocol IP on the interface
GigabitEthernet0/0/4 has entered the UP state.
May 22 2020 14:32:29.760.5-08:00 R2 RM/6/RMDEBUG:
FileID: 0x7017802c Line: 1281 Level: 0x20
OSPF 1: Intf 10.0.123.2 Rcv InterfaceUp State Down -> Waiting.
May 22 2020 14:32:29.760.6-08:00 R2 RM/6/RMDEBUG:
FileID: 0x7017802c Line: 1395 Level: 0x20
OSPF 1 Send Hello Interface Up on 10.0.123.2
May 22 2020 14:33:06.310.1-08:00 R2 RM/6/RMDEBUG:
FileID: 0x7017802c Line: 2061 Level: 0x20
OSPF 1 Send Hello Interface State Changed on 10.0.123.2
May 22 2020 14:33:06.310.2-08:00 R2 RM/6/RMDEBUG:
FileID: 0x7017802c Line: 2072 Level: 0x20
OSPF 1: Intf 10.0.123.2 Rcv WaitTimer State Waiting -> DR.
May 22 2020 14:33:08-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[20]:Neighbor changes event: neighbor
status changed. (ProcessId=1, NeighborAddress=10.0.123.3, NeighborEvent=HelloReceived,
NeighborPreviousState=Down, NeighborCurrentState=Init)
May 22 2020 14:33:08-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[21]:Neighbor changes event: neighbor
status changed. (ProcessId=1, NeighborAddress=10.0.123.3, NeighborEvent=2WayReceived,
NeighborPreviousState=Init, NeighborCurrentState=ExStart)
May 22 2020 14:33:08-08:00 R2 %%01OSPF/4/NBR_CHANGE_E(l)[22]:Neighbor changes event: neighbor
status changed. (ProcessId=1, NeighborAddress=10.0.123.3, NeighborEvent=NegotiationDone,
NeighborPreviousState=ExStart, NeighborCurrentState=Exchange)
May 22 2020 14:33:08.420.1-08:00 R2 RM/6/RMDEBUG:
FileID: 0x7017802d Line: 1119 Level: 0x20
OSPF 1: Nbr 10.0.123.3 Rcv HelloReceived State Down -> Init.
May 22 2020 14:33:08.420.2-08:00 R2 RM/6/RMDEBUG:
FileID: 0x7017802d Line: 1715 Level: 0x20
OSPF 1: Nbr 10.0.123.3 Rcv 2WayReceived State Init -> ExStart.
May 22 2020 14:33:08.420.3-08:00 R2 RM/6/RMDEBUG:
FileID: 0x7017802c Line: 2501 Level: 0x20
OSPF 1: Intf 10.0.123.2 Rcv NeighborChange State DR -> BackupDR.
从输出信息中可以看到 R2 成为了 BDR
步骤 5 配置 OSPF 接口的网络类型
# R1 上查看 OSPF 路由表中的 R2 R3 Loopback0 接口路由
<R1>display ospf routing 10.0.2.2
OSPF Process 1 with Router ID 10.0.1.1
Destination : 10.0.2.2/32
AdverRouter : 10.0.2.2 Area : 0.0.0.0
Cost : 1 Type : Stub
NextHop : 10.0.123.2 Interface : GigabitEthernet0/0/3
Priority : Medium Age : 00h09m02s
<R1>display ospf routing 10.0.3.3
OSPF Process 1 with Router ID 10.0.1.1
Destination : 10.0.3.3/32
AdverRouter : 10.0.3.3 Area : 0.0.0.0
Cost : 1 Type : Stub
NextHop : 10.0.123.3 Interface : GigabitEthernet0/0/3
Priority : Medium Age : 00h09m13s
可以看到 Loopback0 接口路由的掩码为 32 位,而不是实际的 24 位。
# R2 为例查看 OSPF Type-1 LSA
<R2>display ospf lsdb router 10.0.2.2
OSPF Process 1 with Router ID 10.0.2.2
Area: 0.0.0.0
Link State Database
Type : Router
Ls id : 10.0.2.2
Adv rtr : 10.0.2.2
Ls age : 1528
Len : 48
Options : E
seq# : 80000020
chksum : 0x9653
Link count: 2
* Link ID: 10.0.2.2
Data : 255.255.255.255
Link Type: StubNet
Metric : 0
Priority : Medium
* Link ID: 10.0.123.3
Data : 10.0.123.2
Link Type: TransNet
Metric : 1
可以看到 R2 上关于 Loopback0 接口的 LSA 里已经将掩码设为 32 位, OSPF Loopback
口视为一个末梢网络,且该网络中只连接着一个节点,因此无论该接口实际配置的网络掩码是
多少位, OSPF Type-1 LSA 中描述这个接口时,都以主机( 32 位网络掩码)的形式进行通
告。
关于 OSPF Loopback 接口详细解释可以查阅 RFC 2328 Section 9.1
# 修改 R2 Loopback0 接口的网络类型
[R2]interface LoopBack 0
[R2-LoopBack0] ospf network-type broadcast
Loopback 接口的网络类型修改为 Broadcast OSPF 在发布这个接口的网络信息时,会使
用接口真实掩码(本例中 R2 Loopback0 接口真实掩码长度为 24 位)进行发布。
# R1 上再次查看 OSPF 路由表中 R2 Loopback0 接口路由
<R1>display ospf routing 10.0.2.2
OSPF Process 1 with Router ID 10.0.1.1
Destination : 10.0.2.0 /24
AdverRouter : 10.0.2.2 Area : 0.0.0.0
Cost : 1 Type : Stub
NextHop : 10.0.123.2 Interface : GigabitEthernet0/0/3
Priority : Low Age : 00h04m10s
从输出信息中可以看到路由的掩码已经变为 24 位。
步骤 6 修改 OSPF 接口的 Cost
# R1 上查看 OSPF 路由表中的 R3 Loopback0 接口路由
<R1>display ospf routing 10.0.3.3
OSPF Process 1 with Router ID 10.0.1.1
Destination : 10.0.3.3/32
AdverRouter : 10.0.3.3 Area : 0.0.0.0
Cost : 1 Type : Stub
NextHop : 10.0.123.3 Interface : GigabitEthernet0/0/3
Priority : Medium Age : 00h46m56s
从输出信息可以看到其 Cost 值为 1
# 修改 R1 GE0/0/3 接口 OSPF Cost 值为 20 ,修改 R3 GE0/0/4 接口 OSPF Cost 值为 10
[R1]interface GigabitEthernet0/0/3
[R1-GigabitEthernet0/0/3] ospf cost 20
[R3]interface GigabitEthernet0/0/4
[R3-GigabitEthernet0/0/4] ospf cost 10 HCIP-Datacom-Core Technology 实验手册
20
# R1 上重新查看 OSPF 路由表中的 R2 Loopback0 接口路由
<R1>display ospf routing 10.0.2.2
OSPF Process 1 with Router ID 10.0.1.1
Destination : 10.0.2.0/24
AdverRouter : 10.0.2.2 Area : 0.0.0.0
Cost : 20 Type : Stub
NextHop : 10.0.123.2 Interface : GigabitEthernet0/0/3
Priority : Low Age : 00h04m19s
从输出信息可以看到其 Cost 值为 20
# R3 上查看 OSPF 路由表中的 R1 Loopback0 接口路由
<R3>display ospf routing 10.0.1.1
OSPF Process 1 with Router ID 10.0.3.3
Destination : 10.0.1.1/32
AdverRouter : 10.0.1.1 Area : 0.0.0.0
Cost : 10 Type : Stub
NextHop : 10.0.123.1 Interface : GigabitEthernet0/0/4
Priority : Medium Age : 00h06m07s
从输出信息可以看到其 Cost 值为 10
步骤 7 配置 OSPF Silent-Interface
# R1 GE0/0/3 接口配置为 Silent-Iinterface
[R1]ospf 1
[R1-ospf-1] silent-interface GigabitEthernet 0/0/3
# 查看 R1 OSPF 邻居表
<R1>display ospf peer
OSPF Process 1 with Router ID 10.0.1.1
配置互联接口为 Silent-Interface 之后,不再从该接口发送、接收 hello 报文,已经建立关系
的邻居消失。
# 查看 R1 OSPF 接口 GE0/0/3 的信息
<R1>display ospf interface GigabitEthernet 0/0/3
OSPF Process 1 with Router ID 10.0.1.1
Interfaces
Interface: 10.0.123.1 (GigabitEthernet0/0/3)
Cost: 20 State: DR Type: Broadcast MTU: 1500
Priority: 1
Designated Router: 10.0.123.1
Backup Designated Router: 0.0.0.0
Timers: Hello 10 , Dead 40 , Poll 120 , Retransmit 5 , Transmit Delay 1
Silent interface, No hellos
从输出信息可以看到该接口被设置为 Silent-Interface ,不再存在 hello 报文。
# 删除 R1 Silent-Interface 配置
# R2 R3 Loopback0 配置为 Silent-Interface
[R2]ospf 1
[R2-ospf-1] silent-interface LoopBack 0
[R3]ospf 1
[R3-ospf-1] silent-interface LoopBack 0
# R1 上查看 OSPF 路由表
<R1>display ospf routing
OSPF Process 1 with Router ID 10.0.1.1
Routing Tables
Routing for Network
Destination Cost Type NextHop AdvRouter Area
10.0.1.1/32 0 Stub 10.0.1.1 10.0.1.1 0.0.0.0
10.0.123.0/24 20 Transit 10.0.123.1 10.0.1.1 0.0.0.0
10.0.2.0/24 20 Stub 10.0.123.2 10.0.2.2 0.0.0.0
10.0.3.3/32 20 Stub 10.0.123.3 10.0.3.3 0.0.0.0
Total Nets: 4
Intra Area: 4 Inter Area: 0 ASE: 0 NSSA: 0
可以看到 R2 R3 Loopback0 接口路由依旧存在。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值