Lab 1-1 Single-Area OSPF
Lab 1-1 Single-Area OSPF
Learning Objectives
The objectives of this lab are to learn and understand how to perform the
following operations:
How to configure single-area OSPF
How to configure OSPF authentication
How to establish neighbor relationships on multi-access networks
How to use OSPF to advertise the subnet mask of the network to
which the loopback interface connects
How to change cost values for OSPF interfaces
How to configure an interface as a silent interface
How to view OSPF status using the display command
How to view OSPF neighbor relationships and troubleshoot faults
using the debug command
Topology
Tasks
Step 1 Perform basic configurations and configure IP
addresses.
Configure IP addresses and masks for R1, R2, and R3. Set a 24-bit mask for
loopback interfaces to simulate an independent network segment.
<R1>system-view
Enter system view, return user view with Ctrl+Z.
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 10.0.123.1 24
[R1-GigabitEthernet0/0/0]quit
[R1]interface LoopBack 0
[R1-LoopBack0]ip address 10.0.1.1 24
[R1-LoopBack0]quit
<R2>system-view
Enter system view, return user view with Ctrl+Z.
[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip address 10.0.123.2 24
[R2-GigabitEthernet0/0/0]quit
[R2]interface LoopBack 0
[R2-LoopBack0]ip address 10.0.2.2 24
[R2-LoopBack0]quit
<R3>system-view
Enter system view, return user view with Ctrl+Z.
[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip address 10.0.123.3 24
[R3-GigabitEthernet0/0/0]quit
[R3]interface LoopBack 0
[R3-LoopBack0]ip address 10.0.3.3 24
[R3-LoopBack0]quit
Verify the connectivity between routers.
[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
[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
[R2]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
View the routing tables and test the connectivity of the entire network.
View the routing table of R1.
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
----------------------------------------------------------------------------
Routing Tables: Public
Destinations : 12 Routes : 12
The command output shows that R1 learns two routes from OSPF:
10.0.2.2/32 and 10.0.3.3/32. The next hops of the two routes are 10.0.123.2
and 10.0.123.3 respectively.
Verify the connectivity from R1 to loopback interface addresses of R2 and
R3.
[R1]ping -c 1 10.0.2.2
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=3 ms
[R1]ping -c 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=2 ms
Run the display ospf brief command to view basic OSPF information on R1.
[R1]display ospf brief
The preceding command output shows that R1 has two neighbors in Area
0.0.0.0, their router IDs are 10.0.2.2 and 10.0.3.3 respectively, and their
OSPF neighbor relationships are in Full state.
Run the display ospf lsdb command on R1 to check OSPF LSDB
information.
[R1]display ospf lsdb
Area: 0.0.0.0
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 10.0.3.3 10.0.3.3 1569 48 80000005 0
Router 10.0.2.2 10.0.2.2 1568 48 80000006 0
Router 10.0.1.1 10.0.1.1 1567 48 80000008 0
Network 10.0.123.110.0.1.1 1567 36 80000004 0
The preceding command output shows that the LSDB contains four LSAs, the
first three of which are Type 1 LSAs generated by R1, R2, and R3
respectively. You can check the AdvRouter field to determine which router
generates an LSA. The fourth LSA is a Type 2 LSA, which is generated by a
DR of a network segment. Because R1 is the DR of the network segment
10.0.123.0/24, you can see that the AdvRouter field of this LSA is 10.0.1.1.
[R1]display ospf lsdb router self-originate
Type : Router
Ls id : 10.0.1.1
Adv rtr : 10.0.1.1
Ls age : 430
Len : 48
Options : E
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
The preceding command output shows detailed information about the Router
LSA generated by R1. This LSA describes two networks. The first network is
the network segment where the loopback interface resides. The Link Type
field displays StubNet, and Link ID and Data fields indicate the IP address
and mask of this stub network segment. The second network is the network
segment that connects the three routers. The Link Type displays TransNet,
the Link ID field displays 10.0.123.1, which is the interface address of the
DR, and the Data field displays 10.0.123.1, which is the local interface
address on the network segment.
[R1]display ospf lsdb network self-originate
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
After the OSPF process of R1 is reset, the BDR 10.0.123.2 becomes the new
DR, and the DR other 10.0.123.3 becomes the new BDR.
Shut down G0/0/0 of R1, R2, and R3 and run the debugging ospf 1 event
command to check the OSPF neighbor relationship establishment process.
Undoshutdown G0/0/0 of R1, R2, and R3 simultaneously, and observe
neighbor status change and DR and BDR election on the broadcast multi-
access network.
<R1>debugging ospf 1 event
<R1>terminal debugging
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]shut
[R1-GigabitEthernet0/0/0]undo shut
When G0/0/0 is just enabled, the interface state changes from Down to
Waiting. Then routers start exchanging Hello packets. After 40 seconds, the
status of G0/0/0 on R3 changes from Waiting to DR.
Step 4 Set the network type for loopback interfaces.
Check the IP routing table of R1 and focus on the two routes 10.0.2.2/32 and
10.0.3.3/32.
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
----------------------------------------------------------------------------
Routing Tables: Public
Destinations : 12 Routes : 12
OSPF knows that the network segment where Loopback0 resides can have
only one IP address. Therefore the subnet mask of the advertised route is 32
bits.
Change the network type of Loopback0 on R2 to broadcast. When OSPF
advertises network information of this interface, it will use a 24-bit mask.
[R2]interface LoopBack 0
[R2-LoopBack0]ospf network-type broadcast
You can see that the subnet mask of the route to Loopback0 address
advertised by R2 is 24 bits.
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
----------------------------------------------------------------------------
Routing Tables: Public
Destinations : 12 Routes : 12
Check the cost of the route from R1 to Loopback0 of R3 again. You can see
that the cost of the route to 10.0.3.3/32 is 20.
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
----------------------------------------------------------------------------
Routing Tables: Public
Destinations : 12 Routes : 12
On R3, check the cost of the route to 10.0.1.1/32. You can see that the cost
is 10.
[R3]display ip routing-table
Route Flags: R - relay, D - download to fib
----------------------------------------------------------------------------
Routing Tables: Public
Destinations : 12 Routes : 12
Destination/Mask Proto Pre Cost Flags NextHop Interface
Check the neighbor list of R1. You can see that OSPF neighbor relationships
between R1 and R2 and between R1 and R3 disapear. After a RIP interface is
configured as a silent interface, this interface does not send RIP updates. In
OSPF, routers can exchange routing information only after they establish an
OSPF neighbor relationship. After an OSPF interface is configured as a silent
interface, this interface does not receive or send Hello packets. As a result,
this interface cannot establish OSPF neighbor relationships with interfaces of
other routers.
[R1]display ospf interface GigabitEthernet 0/0/0
[R2]ospf 1
[R2-ospf-1]silent-interface LoopBack 0
[R1-ospf-1]quit
[R3]ospf 1
[R3-ospf-1]silent-interface LoopBack 0
[R1-ospf-1]quit
Check the IP routing table of R1. The command output shows that
configuring Loopback0 as a silent interface does not affect its route
advertisement.
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
----------------------------------------------------------------------------
Routing Tables: Public
Destinations : 12 Routes : 12
----End
Device Configurations
<R1>display current-configuration
[V200R007C00SPC600]
#
sysname R1
#
interface GigabitEthernet0/0/0
ip address 10.0.123.1 255.255.255.0
ospf cost 20
#
interface LoopBack0
ip address 10.0.1.1 255.255.255.0
#
ospf 1 router-id 10.0.1.1
silent-interface LoopBack0
area 0.0.0.0
authentication-mode simple plain huawei
network 10.0.1.1 0.0.0.0
network 10.0.123.1 0.0.0.0
#
return
<R2>display current-configuration
[V200R007C00SPC600]
#
sysname R2
#
interface GigabitEthernet0/0/0
ip address 10.0.123.2 255.255.255.0
#
interface LoopBack0
ip address 10.0.2.2 255.255.255.0
ospf network-type broadcast
#
ospf 1 router-id 10.0.2.2
silent-interface LoopBack0
area 0.0.0.0
authentication-mode simple plain huawei
network 10.0.2.2 0.0.0.0
network 10.0.123.2 0.0.0.0
#
return
<R3>display current-configuration
[V200R007C00SPC600]
#
sysname R3
#
interface GigabitEthernet0/0/0
ip address 10.0.123.3 255.255.255.0
ospf cost 10
#
interface LoopBack0
ip address 10.0.3.3 255.255.255.0
#
ospf 1 router-id 10.0.3.3
silent-interface LoopBack0
area 0.0.0.0
authentication-mode simple plain huawei
network 10.0.3.3 0.0.0.0
network 10.0.123.3 0.0.0.0
#
return