HCIA-Datacom Lab Guide
2 Creating an Interconnected IP Network
2.1 Lab 1: IPv4 Addressing and Routing
2.1.1 Introduction
[Link] About This Lab
Internet Protocol version 4 (IPv4) is a core protocol of the TCP/IP protocol suite
and works at the Internet layer in the TCP/IP model or the network layer in the
Open System Interconnection (OSI) model. The network layer provides
connectionless data transmission. Each IP datagram is transmitted independently,
removing the need to establish a connection before IP datagrams are sent.
Routing is the basic element of data communication networks. It is the process of
selecting paths on a network along which packets are sent from a source to a
destination.
In this lab activity, you will configure IPv4 addresses and static IPv4 routes, and
understand basic routing principles in the process.
[Link] Objectives
Upon completion of this task, you will be able to:
● Learn how to configure an IPv4 address on an interface
● Understand the functions and meanings of loopback interfaces
● Understand how direct routes are generated
● Learn how to configure static routes and understand the conditions for the
static routes to take effect
● Learn how to test the connectivity of the network layer by using the ping tool
● Learn how to configure static routes and understand their application
scenarios
[Link] Networking Topology
R1, R2, and R3 are gateways of their networks. You need to configure these
gateways to connect these networks.
Huawei confidential. Page 20 of 186
HCIA-Datacom Lab Guide
Figure 2-1 Lab topology for IPv4 addressing and routing
2.1.2 Lab Configuration
[Link] Configuration Roadmap
1. Configure IP addresses for the interfaces on the routers.
2. Configure static routes to interconnect the routers.
[Link] Configuration Procedure
Step 1 Complete basic device configuration.
# Name the devices.
The details are not provided here.
Step 2 Display the IP address of the current interface and the routing table of the router.
# Display the interface status on the router (R1 in this example).
[R1]display ip interface brief
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
(E): E-Trunk down
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 5
The number of interface that is UP in Protocol is 1
The number of interface that is DOWN in Protocol is 10
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/1 unassigned up down
GigabitEthernet0/0/2 unassigned up down
GigabitEthernet0/0/3 unassigned up down
Huawei confidential. Page 21 of 186
HCIA-Datacom Lab Guide
The display ip interface brief command displays the brief information about
interface IP addresses, including the IP addresses, subnet masks, physical status,
link-layer protocol status, and number of interfaces in different states.
GigabitEthernet0/0/1 and GigabitEthernet0/0/3 on R1 are not configured with IP
addresses. Therefore, the IP Address/Mask field is in the unassigned state, the
Protocol field is in the down state, and the Physical field is in the up state.
# Display the routing table on the router (R1 in this example).
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 4 Routes : 4
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/8 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
InLoopBack0 is a default loopback interface.
InLoopBack0 uses the fixed loopback address [Link]/8 to receive data packets
destined for the host where InLoopBack0 resides. The IP address of the
InLoopBack0 interface cannot be changed or advertised using a routing protocol.
Step 3 Configure IP addresses for physical interfaces.
# Configure IP addresses for physical interfaces based on the following table.
Table 2-1 IP addresses of physical interfaces
Router Interface IP Address/Mask
R1 GigabitEthernet0/0/1 [Link]/24
GigabitEthernet0/0/3 [Link]/24
R2 GigabitEthernet0/0/3 [Link]/24
GigabitEthernet0/0/4 [Link]/24
R3 GigabitEthernet0/0/1 [Link]/24
GigabitEthernet0/0/3 [Link]/24
<R1>system-view
[R1]interface GigabitEthernet0/0/1
[R1-GigabitEthernet0/0/1]ip address [Link] 24
[R1-GigabitEthernet0/0/1]quit
[R1]interface GigabitEthernet0/0/3
Huawei confidential. Page 22 of 186
HCIA-Datacom Lab Guide
[R1-GigabitEthernet0/0/3]ip address [Link] 24
[R1-GigabitEthernet0/0/3]quit
<R2>system-view
[R2]interface GigabitEthernet0/0/3
[R2-GigabitEthernet0/0/3]ip address [Link] 24
[R2-GigabitEthernet0/0/3]quit
[R2]interface GigabitEthernet0/0/4
[R2-GigabitEthernet0/0/4]ip address [Link] 24
[R2-GigabitEthernet0/0/4]quit
<R3>system-view
[R3]interface GigabitEthernet0/0/1
[R3-GigabitEthernet0/0/1]ip address [Link] 24
[R3-GigabitEthernet0/0/1]quit
[R3]interface GigabitEthernet0/0/3
[R3-GigabitEthernet0/0/3]ip address [Link] 24
[R3-GigabitEthernet0/0/3]quit
# Use the ping tool to test the connectivity.
[R1]ping [Link]
PING [Link]: 56 data bytes, press CTRL_C to break
Reply from [Link]: bytes=56 Sequence=1 ttl=255 time=70 ms
Reply from [Link]: bytes=56 Sequence=2 ttl=255 time=50 ms
Reply from [Link]: bytes=56 Sequence=3 ttl=255 time=40 ms
Reply from [Link]: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from [Link]: bytes=56 Sequence=5 ttl=255 time=50 ms
--- [Link] ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/48/70 ms
[R1]ping [Link]
PING [Link]: 56 data bytes, press CTRL_C to break
Reply from [Link]: bytes=56 Sequence=1 ttl=255 time=50 ms
Reply from [Link]: bytes=56 Sequence=2 ttl=255 time=60 ms
Reply from [Link]: bytes=56 Sequence=3 ttl=255 time=50 ms
Reply from [Link]: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from [Link]: bytes=56 Sequence=5 ttl=255 time=30 ms
--- [Link] ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/44/60 ms
# Display the routing table of R1.
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Huawei confidential. Page 23 of 186
HCIA-Datacom Lab Guide
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/8 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
The preceding command output shows that three direct routes are automatically
generated for each interface after the IP addresses of the interfaces are
configured, which are
1. A route to the network where the interface resides
2. The host route to the interface
3. The host route to the broadcast address of the network where the interface
resides
A host route is a route with a 32-bit mask.
Step 4 Create a loopback interface.
# Configure the loopback interface according to the following table.
Table 2-2 IP addresses of loopback interfaces
Router Interface IP Address/Mask
R1 LoopBack0 [Link]/32
R2 LoopBack0 [Link]/32
R3 LoopBack0 [Link]/32
Loopback interfaces are logical interfaces manually configured and do not exist
physically. Logical interfaces can be used to exchange data. A loopback interface is
always Up at the physical layer and link layer unless it is manually shut down.
Generally, a loopback interface uses a 32-bit mask. Loopback interfaces are used
for the following purposes:
1. Used as the address for identifying and managing the router
2. Used as the router ID in OSPF
3. Used for improving network reliability
Huawei confidential. Page 24 of 186
HCIA-Datacom Lab Guide
In this lab activity, the loopback interfaces are used to simulate clients.
[R1]interface LoopBack0
[R1-LoopBack0]ip address [Link] 32
[R2]interface LoopBack0
[R2-LoopBack0]ip address [Link] 32
[R3]interface LoopBack0
[R3-LoopBack0]ip address [Link] 32
# Display the routing table on the router (R1 in this example).
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 11 Routes : 11
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/32 Direct 0 0 D [Link] LoopBack0
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/8 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
Direct routes have been generated.
# Test the connectivity between the loopback interfaces.
[R1]ping -a [Link] [Link]
PING [Link]: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- [Link] ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
Using the ping –a source-ip-address destination-ip-address command to specify
the source and destination IP addresses of ping packets. At this point, the router
does not have a route to the destination IP address. Therefore, the ping operation
fails.
Step 5 Configure static routes.
# On R1, configure a route to the loopback0 interfaces of R2 and R3.
[R1]ip route-static [Link] 32 [Link]
Huawei confidential. Page 25 of 186
HCIA-Datacom Lab Guide
[R1]ip route-static [Link] 32 [Link]
# Display the routing table of R1.
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 13 Routes : 13
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/32 Direct 0 0 D [Link] LoopBack0
[Link]/32 Static 60 0 RD [Link] GigabitEthernet0/0/3
[Link]/32 Static 60 0 RD [Link] GigabitEthernet0/0/1
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/8 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
The configured static routes are added to the IP routing table.
# Test connectivity.
[R1]ping -a [Link] [Link]
PING [Link]: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- [Link] ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
The loopback0 interface of R2 still cannot be pinged because R2 does not have a route to the loopback0
interface of R1.
# On R2, add a route to LoopBack0 of R1.
[R2]ip route-static [Link] 32 [Link]
# Test connectivity.
<R1>ping -a [Link] [Link]
PING [Link]: 56 data bytes, press CTRL_C to break
Reply from [Link]: bytes=56 Sequence=1 ttl=255 time=60 ms
Reply from [Link]: bytes=56 Sequence=2 ttl=255 time=30 ms
Reply from [Link]: bytes=56 Sequence=3 ttl=255 time=10 ms
Reply from [Link]: bytes=56 Sequence=4 ttl=255 time=50 ms
Reply from [Link]: bytes=56 Sequence=5 ttl=255 time=30 ms
Huawei confidential. Page 26 of 186
HCIA-Datacom Lab Guide
--- [Link] ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/36/60 ms
Loopback0 on R1 can communicate with loopback0 on R2.
# Configure other necessary routes.
[R2]ip route-static [Link] 32 [Link]
[R3]ip route-static [Link] 32 [Link]
[R3]ip route-static [Link] 32 [Link]
# Test the connectivity between the loopback0 interfaces of the routers by
referring to the proceeding description.
Step 6 Configure a path from R1 to R2 via R3 as the backup path from LoopBack0 of R1
to LoopBack0 of R2.
# Configure static routes on R1 and R2.
[R1]ip route-static [Link] 32 [Link] preference 100
[R2]ip route-static [Link] 32 [Link] preference 100
# Display the routing tables of R1 and R2.
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 13 Routes : 13
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/32 Direct 0 0 D [Link] LoopBack0
[Link]/32 Static 60 0 RD [Link] GigabitEthernet0/0/3
[Link]/32 Static 60 0 RD [Link] GigabitEthernet0/0/1
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/8 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[R2]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Huawei confidential. Page 27 of 186
HCIA-Datacom Lab Guide
Destinations : 13 Routes : 13
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/32 Static 60 0 RD [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] LoopBack0
[Link]/32 Static 60 0 RD [Link] GigabitEthernet0/0/4
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/4
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/4
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/4
[Link]/8 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
The static route with a preference value of 100 is not added to the routing table.
# Shut down GigabitEthernet0/0/3 interface on R1 and R2 to invalidate the route
with the highest priority.
[R1]interface GigabitEthernet0/0/3
[R1-GigabitEthernet0/0/3]shutdown
# Display the routing table on R1 and R2. The command output shows that the
routes with a lower priority are activated when the routes with a higher priority
are invalidated.
[R1]display IP routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/32 Direct 0 0 D [Link] LoopBack0
[Link]/32 Static 100 0 RD [Link] GigabitEthernet0/0/1
[Link]/32 Static 60 0 RD [Link] GigabitEthernet0/0/1
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/8 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[R2]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 10 Routes : 10
Huawei confidential. Page 28 of 186
HCIA-Datacom Lab Guide
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/32 Static 100 0 RD [Link] GigabitEthernet0/0/4
[Link]/32 Direct 0 0 D [Link] LoopBack0
[Link]/32 Static 60 0 RD [Link] GigabitEthernet0/0/4
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/4
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/4
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/4
[Link]/8 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
In this case, the original static route becomes invalid and the static route with a
lower priority is activated.
# Test connectivity.
[R1]ping -a [Link] [Link]
PING [Link]: 56 data bytes, press CTRL_C to break
Reply from [Link]: bytes=56 Sequence=1 ttl=254 time=80 ms
Reply from [Link]: bytes=56 Sequence=2 ttl=254 time=60 ms
Reply from [Link]: bytes=56 Sequence=3 ttl=254 time=60 ms
Reply from [Link]: bytes=56 Sequence=4 ttl=254 time=110 ms
Reply from [Link]: bytes=56 Sequence=5 ttl=254 time=80 ms
--- [Link] ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 60/78/110 ms
# Trace the path of the data packets.
[R1]tracert -a [Link] [Link]
traceroute to [Link]([Link]), max hops: 30 ,packet length: 40,press CTRL_C to break
1 [Link] 40 ms 30 ms 50 ms
2 [Link] 80 ms 80 ms 60 ms
The tracert command displays the path of packets from the source to the
destination.
The command output shows that the data packets pass through
GigabitEthernet0/0/1 and GigabitEthernet0/0/3 of R3 and are then forwarded to
GigabitEthernet0/0/4 of R2.
In some lab environments, the devices may not respond to ICMP packets for security
reasons. Therefore, the results may vary. You can press Ctrl+C to end the tracert operation.
Step 7 Configure default routes to connect the LoopBack0 interface of R1 and the
LoopBack0 interface of R2.
Huawei confidential. Page 29 of 186
HCIA-Datacom Lab Guide
# Restore the interfaces and delete the configured routes.
[R1]interface GigabitEthernet0/0/3
[R1-GigabitEthernet0/0/3]undo shutdown
[R1-GigabitEthernet0/0/3]quit
[R1]undo ip route-static [Link] [Link] [Link]
[R1]undo ip route-static [Link] [Link] [Link] preference 100
# Display 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
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/32 Direct 0 0 D [Link] LoopBack0
[Link]/32 Static 60 0 RD [Link] GigabitEthernet0/0/1
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/8 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
R1 does not have a route to LoopBack0 ([Link]/32) of R2.
# Configure a default route on R1.
[R1]ip route-static [Link] 0 [Link]
# Display the routing table of R1.
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 13 Routes : 13
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/0 Static 60 0 RD [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] LoopBack0
[Link]/32 Static 60 0 RD [Link] GigabitEthernet0/0/1
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/8 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
Huawei confidential. Page 30 of 186
HCIA-Datacom Lab Guide
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
The default route has been activated.
# Test the connectivity between LoopBack0 of R1 and LoopBack0 of R2.
[R1]ping -a [Link] [Link]
PING [Link]: 56 data bytes, press CTRL_C to break
Reply from [Link]: bytes=56 Sequence=1 ttl=255 time=50 ms
Reply from [Link]: bytes=56 Sequence=2 ttl=255 time=30 ms
Reply from [Link]: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from [Link]: bytes=56 Sequence=4 ttl=255 time=40 ms
Reply from [Link]: bytes=56 Sequence=5 ttl=255 time=20 ms
--- [Link] ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/32/50 ms
LoopBack0 of R1 can communicate with LoopBack0 of R2.
----End
2.1.3 Verification
You can run the ping and tracert commands to test the connectivity between
loopback0 interfaces on different devices.
2.1.4 Configuration Reference
Configuration on R1
#
sysname R1
#
interface GigabitEthernet0/0/1
ip address [Link] [Link]
#
interface GigabitEthernet0/0/3
ip address [Link] [Link]
#
interface LoopBack0
ip address [Link] [Link]
#
ip route-static [Link] [Link] [Link]
ip route-static [Link] [Link] [Link]
#
return
Configuration on R2
#
sysname R2
#
interface GigabitEthernet0/0/3
Huawei confidential. Page 31 of 186
HCIA-Datacom Lab Guide
ip address [Link] [Link]
#
interface GigabitEthernet0/0/4
ip address [Link] [Link]
#
interface LoopBack0
ip address [Link] [Link]
#
ip route-static [Link] [Link] [Link]
ip route-static [Link] [Link] [Link] preference 100
ip route-static [Link] [Link] [Link]
#
return
Configuration on R3
#
sysname R3
#
interface GigabitEthernet0/0/1
ip address [Link] [Link]
#
interface GigabitEthernet00/3
ip address [Link] [Link]
#
interface LoopBack0
ip address [Link] [Link]
#
ip route-static [Link] [Link] [Link]
ip route-static [Link] [Link] [Link]
#
return
2.1.5 Quiz
1. In what situations will the configured static route be added to the IP routing
table? Can a route be added to the IP routing table if the configured next hop
is unreachable?
2. In step 3, if the -a argument is not specified during the connectivity test
between loopback interfaces, what is the source IP address of ICMP packets?
Why?
Huawei confidential. Page 32 of 186
HCIA-Datacom Lab Guide
2.2 Lab 2: OSPF Routing
2.2.1 Introduction
[Link] About This Lab
The Open Shortest Path First (OSPF) protocol is a link-state Interior Gateway
Protocol (IGP) developed by the Internet Engineering Task Force (IETF). Currently,
OSPF Version 2 (RFC2328) is used for IPv4. As a link-state protocol, OSPF has the
following advantages:
● Multicast packet transmission to reduce load on the switches that are not
running OSPF
● Classless Inter-Domain Routing (CIDR)
● Load balancing among equal-cost routes
● Packet authentication
With the preceding advantages, OSPF is widely accepted and used as an IGP.
In the lab activity, you will understand basic OSPF configurations and principles by
configuring single-area OSPF.
[Link] Objectives
Upon completion of this task, you will be able to:
● Learn the basic commands of OSPF
● Learn how to check the OSPF running status
● Learn how to control OSPF route selection using costs
● Understand the advertisement of default routes in OSPF
● Learn how to configure OSPF authentication
[Link] Networking Topology
R1, R2, and R3 are gateways of their networks. You need to configure OSPF to
enable connectivity between the networks.
Figure 2-2 Lab topology for configuring OSPF
Huawei confidential. Page 33 of 186
HCIA-Datacom Lab Guide
2.2.2 Lab Configuration
[Link] Configuration Roadmap
1. Create OSPF processes on the devices and enable OSPF on the interfaces.
2. Configure OSPF authentication.
3. Configure OSPF to advertise default routes.
4. Control OSPF route selection using costs.
[Link] Configuration Procedure
Step 1 Complete basic device configuration.
# Follow steps 1, 2, 3, and 4 in lab 1 to name the routers and configure the IP
addresses of the physical and loopback interfaces.
# Display the routing table on the router (R1 in this example).
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 11 Routes : 11
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/32 Direct 0 0 D [Link] LoopBack0
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/8 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
At this point, only direct routes exist on the device.
Step 2 Complete the basic OSPF configuration.
# Create an OSPF process.
[R1]ospf 1
You can set OSPF parameters only after creating an OSPF process. OSPF supports
multiple independent processes on one device. Route exchange between different
OSPF processes is similar to that between different routing protocols. You can
specify a process ID when creating an OSPF process. If no process ID is specified,
the default process ID 1 is used.
# Create an OSPF area and specify the interfaces on which OSPF is to be enabled.
Huawei confidential. Page 34 of 186
HCIA-Datacom Lab Guide
[R1-ospf-1]area 0
The area command creates an OSPF area and displays the OSPF area view.
[R1-ospf-1-area-[Link]]network [Link] [Link]
[R1-ospf-1-area-[Link]]network [Link] [Link]
[R1-ospf-1-area-[Link]]network [Link] [Link]
The network network-address wildcard-mask command specifies the interfaces
on which OSPF is to be enabled. OSPF can run on an interface only when the
following two conditions are met:
1. The mask length of the interface's IP address is not shorter than that specified
in the network command. OSPF uses reverse mask. For example [Link]
indicates that the mask length is 24 bits.
2. The address of the interface must be within the network range specified in
the network command.
In this example, OSPF can be enabled on the three interfaces, and they are all
added to area 0.
[R2]ospf
[R2-ospf-1]area 0
[R2-ospf-1-area-[Link]]network [Link] [Link]
[R2-ospf-1-area-[Link]]network [Link] [Link]
[R2-ospf-1-area-[Link]]network [Link] [Link]
If the wildcard mask in the network command is all 0s and the IP address of the
interface is the same as the IP address specified in the network-address
command, the interface also runs OSPF.
[R3]ospf
[R3-ospf-1]area 0
[R3-ospf-1-area-[Link]]network [Link] [Link]
[R3-ospf-1-area-[Link]]network [Link] [Link]
[R3-ospf-1-area-[Link]]network [Link] [Link]
Step 3 Display the OSPF status.
# Displays the OSPF neighbor information.
[R1]display ospf peer
OSPF Process 1 with Router ID [Link]
Neighbors
Area [Link] interface [Link](GigabitEthernet0/0/1)'s neighbors
Router ID: [Link] Address: [Link]
State: Full Mode:Nbr is Master Priority: 1
DR: [Link] BDR: [Link] MTU: 0
Dead timer due in 36 sec
Retrans timer interval: 0
Neighbor is up for [Link]
Authentication Sequence: [ 0 ]
Neighbors
Huawei confidential. Page 35 of 186
HCIA-Datacom Lab Guide
Area [Link] interface [Link](GigabitEthernet0/0/3)'s neighbors
Router ID: [Link] Address: [Link]
State: Full Mode:Nbr is Master Priority: 1
DR: [Link] BDR: [Link] MTU: 0
Dead timer due in 39 sec
Retrans timer interval: 4
Neighbor is up for [Link]
Authentication Sequence: [ 0 ]
The display ospf peer command displays information about neighbors in each
OSPF area. The information includes the area to which the neighbor belongs,
router ID of the neighbor, neighbor status, DR, and BDR.
# Display the routes learned from OSPF.
[R1]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 3 Routes : 4
OSPF routing table status : <Active>
Destinations : 3 Routes : 4
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/32 OSPF 10 1 D [Link] GigabitEthernet0/0/3
[Link]/32 OSPF 10 1 D [Link] GigabitEthernet0/0/1
[Link]/24 OSPF 10 2 D [Link] GigabitEthernet0/0/1
OSPF 10 2 D [Link] GigabitEthernet0/0/3
OSPF routing table status : <Inactive>
Destinations : 0 Routes : 0
Step 4 Configure OSPF authentication.
# Configure interface authentication on R1.
[R1]interface GigabitEthernet0/0/1
[R1- GigabitEthernet0/0/1]ospf authentication-mode md5 1 cipher HCIA-Datacom
[R1]interface GigabitEthernet0/0/3
[R1- GigabitEthernet0/0/3]ospf authentication-mode md5 1 cipher HCIA-Datacom
[R1- GigabitEthernet0/0/3]display this
#
interface GigabitEthernet0/0/3
ip address [Link] [Link]
ospf authentication-mode md5 1 cipher foCQTYsq-4.A\^38y!DVwQ0#
#
The password is displayed in cipher text when you view the configuration because
cipher means cipher-text.
# Display OSPF neighbors.
[R1]display ospf peer brief
Huawei confidential. Page 36 of 186
HCIA-Datacom Lab Guide
OSPF Process 1 with Router ID [Link]
Peer Statistic Information
------------------------------------------------------------------------------------------------------------------------------
Area Id Interface Neighbor id State
------------------------------------------------------------------------------------------------------------------------------
Total Peer(s): 0
Authentication is not configured on other routers. Therefore, the authentication fails and no neighbor is
available.
# Configuring interface authentication on R2.
[R2]interface GigabitEthernet0/0/3
[R2- GigabitEthernet0/0/3]ospf authentication-mode md5 1 cipher HCIA-Datacom
[R2]interface GigabitEthernet0/0/4
[R2- GigabitEthernet0/0/4]ospf authentication-mode md5 1 cipher HCIA-Datacom
# Display OSPF neighbors on R2.
[R2]display ospf peer brief
OSPF Process 1 with Router ID [Link]
Peer Statistic Information
------------------------------------------------------------------------------------------------------------------------------
Area Id Interface Neighbor id State
[Link] GigabitEthernet0/0/3 [Link] Full
------------------------------------------------------------------------------------------------------------------------------
Total Peer(s): 1
R2 has established a neighbor relationship with R1.
# Configure area authentication on R3.
[R3]ospf
[R3-ospf-1]area 0
[R3-ospf-1-area-[Link]]authentication-mode md5 1 cipher HCIA-Datacom
# Display OSPF neighbors on R3.
[R3]display ospf peer brief
OSPF Process 1 with Router ID [Link]
Peer Statistic Information
--------------------------------------------------------------------------------------------------------------------------------
Area Id Interface Neighbor id State
[Link] GigabitEthernet0/0/1 [Link] Full
[Link] GigabitEthernet0/0/3 [Link] Full
--------------------------------------------------------------------------------------------------------------------------------
Total Peer(s): 2
R3 has established a neighbor relationship with R1 and R2. Note: OSPF interface authentication and area
authentication implement OSPF packet authentication on OSPF interfaces.
Step 5 Assume that R1 is the egress of all networks. Therefore, R1 advertises the default
route to OSPF.
# Advertise the default route on R1.
[R1]ospf
[R1-ospf-1]default-route-advertise always
Huawei confidential. Page 37 of 186
HCIA-Datacom Lab Guide
The default-route-advertise command advertises the default route to a common
OSPF area. If the always argument is not specified, the default route is advertised
to other routers only when there are active non-OSPF default routes in the
routing table of the local router. In this example, no default route exists in the
local routing table. Therefore, the always argument needs to be used.
# Display the IP routing tables of R2 and R3.
[R2]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 15 Routes : 16
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/0 O_ASE 150 1 D [Link] GigabitEthernet0/0/3
[Link]/32 OSPF 10 1 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] LoopBack0
[Link]/32 OSPF 10 1 D [Link] GigabitEthernet0/0/4
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/24 OSPF 10 2 D [Link] GigabitEthernet0/0/3
OSPF 10 2 D [Link] GigabitEthernet0/0/4
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/4
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/4
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/4
[Link]/8 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[R3]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 15 Routes : 16
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/0 O_ASE 150 1 D [Link] GigabitEthernet0/0/1
[Link]/32 OSPF 10 1 D [Link] GigabitEthernet0/0/1
[Link]/32 OSPF 10 1 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] LoopBack0
[Link]/24 OSPF 10 2 D [Link] GigabitEthernet0/0/3
OSPF 10 2 D [Link] GigabitEthernet0/0/1
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
Huawei confidential. Page 38 of 186
HCIA-Datacom Lab Guide
[Link]/8 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
R2 and R3 have learned the default route.
Step 6 Change the cost values of interfaces on R1 so that LoopBack0 on R1 can reach
LoopBack0 on R2 via R3.
# According to the routing table of R1, the cost of the route from R1 to
LoopBack0 of R2 is 1, and the cost of the route from R1 to R2 via R3 is 2.
Therefore, you only need to change the cost of the route from R1 to LoopBack0 of
R2 to ensure that the value is greater than 2.
[R1]interface GigabitEthernet0/0/3
[R1- GigabitEthernet0/0/3]ospf cost 10
# Display the routing table of R1.
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
--------------------------------------------------------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 14 Routes : 14
Destination/Mask Proto Pre Cost Flags NextHop Interface
[Link]/32 Direct 0 0 D [Link] LoopBack0
[Link]/32 OSPF 10 2 D [Link] GigabitEthernet0/0/1
[Link]/32 OSPF 10 1 D [Link] GigabitEthernet0/0/1
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/3
[Link]/24 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/32 Direct 0 0 D [Link] GigabitEthernet0/0/1
[Link]/24 OSPF 10 2 D [Link] GigabitEthernet0/0/1
[Link]/8 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
[Link]/32 Direct 0 0 D [Link] InLoopBack0
In this case, the next hop of the route from R1 to LoopBack0 on R2 is GigabitEthernet0/0/1 on R3.
# Verify the result by issuing Tracert commands.
[R1]tracert –a [Link] [Link]
traceroute to [Link]([Link]), max hops: 30 ,packet length: 40,press CTRL_C to break
1 [Link] 40 ms 50 ms 50 ms
2 [Link] 60 ms 110 ms 70 ms
----End
Huawei confidential. Page 39 of 186
HCIA-Datacom Lab Guide
2.2.3 Verification
1. Test the connectivity between interfaces on different devices using Ping.
2. Shut down interfaces to simulate link faults and check the changes in routing
tables.
2.2.4 Configuration Reference
Configuration on R1
#
sysname R1
#
interface GigabitEthernet0/0/1
ip address [Link] [Link]
ospf authentication-mode md5 1 cipher %^%#`f*R'6q/RMq(+5*g(sP~SB8oQ49;%7WE:07P7X:W%^%#
#
interface GigabitEthernet0/0/3
ip address [Link] [Link]
ospf cost 10
ospf authentication-mode md5 1 cipher %^%#]e)pBf~[Link]~U;bRAVgE$U>%X;>T\M\tLlYRj2%^%#
#
interface LoopBack0
ip address [Link] [Link]
#
ospf 1
default-route-advertise always
area [Link]
network [Link] [Link]
network [Link] [Link]
network [Link] [Link]
#
return
Configuration on R2
#
sysname R2
#
interface GigabitEthernet0/0/3
ip address [Link] [Link]
ospf authentication-mode md5 1 cipher %^%#z+72ZaTk2+v/g7E~AmR"NFYAKC>LZ8~Y`[**Gh=&%^%#
#
interface GigabitEthernet0/0/4
ip address [Link] [Link]
ospf authentication-mode md5 1 cipher %^%#=@2jEBu!{&UYoB*(RDVLc5t~<1B_a-PwC$WH%jQ3%^%#
#
interface LoopBack0
ip address [Link] [Link]
#
ospf 1
area [Link]
network [Link] [Link]
network [Link] [Link]
Huawei confidential. Page 40 of 186
HCIA-Datacom Lab Guide
network [Link] [Link]
#
return
Configuration on R3
#
sysname R3
#
interface GigabitEthernet0/0/1
ip address [Link] [Link]
#
interface GigabitEthernet0/0/3
ip address [Link] [Link]
#
interface LoopBack0
ip address [Link] [Link]
#
ospf 1
area [Link]
authentication-mode md5 1 cipher %^%#Rl<:SVln1M>[Gk"v/OeSEW|:0:4*h;b|-d:N"s{>%^%#
network [Link] [Link]
network [Link] [Link]
network [Link] [Link]
#
return
2.2.5 Quiz
1. In step 6, what is the path for R2 to return ICMP packets to R1? Try to explain
the reason.
Huawei confidential. Page 41 of 186