Fundamentals 23 min read

Hands‑On OSPF Lab: Configuring Huawei, Cisco, and Juniper Networks

This article provides step‑by‑step OSPF lab exercises for Huawei, Cisco, and Juniper devices, covering basic OSPF concepts, configuration guidelines, verification commands, and troubleshooting tips, enabling readers to build and test a multi‑vendor OSPF network topology.

Open Source Linux
Open Source Linux
Open Source Linux
Hands‑On OSPF Lab: Configuring Huawei, Cisco, and Juniper Networks

Today we present the experimental practice part, introducing three vendors: Huawei, Cisco, and Zhanbo Network.

OSPF Simple Introduction

OSPF (Open Shortest Path First) is an IETF‑developed link‑state interior gateway protocol. For IPv4 it uses OSPF Version 2 (RFC2328). OSPF offers wide applicability, fast convergence, loop‑free operation, area division, equal‑cost routing, authentication, and multicast support, making it the dominant IGP in enterprises, carriers, governments, finance, education, and healthcare.

OSPF Configuration Considerations

Each OSPF process must have a unique Router ID within the OSPF domain.

OSPF divides an autonomous system into areas ; Area 0 is the backbone. All non‑backbone areas must stay connected to the backbone.

Typically the network type of the two ends of a link must match; a broadcast‑type link can still form adjacency with a point‑to‑point link, but routing information will not be exchanged.

The subnet mask of OSPF interfaces on both ends must be identical.

For broadcast and NBMA networks, at least one OSPF interface on the link must have a DR priority greater than 0 to elect a Designated Router.

Huawei OSPF Lab

Network Requirements

The topology contains three switches that need to communicate and be extensible via SwitchA and SwitchB as core devices.

Configuration Idea

Configure basic OSPF functionality:

Assign IP addresses to VLANIF interfaces on each switch to achieve intra‑VLAN connectivity.

Enable OSPF on each switch, using SwitchA as an ABR to split the OSPF domain into Area0 and Area1, allowing future expansion.

Operation Steps

Configure VLANs on interfaces

<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] vlan batch 10 20
[SwitchA] interface gigabitethernet 1/0/1
[SwitchA-GigabitEthernet1/0/1] port link-type trunk
[SwitchA-GigabitEthernet1/0/1] port trunk allow-pass vlan 10
[SwitchA-GigabitEthernet1/0/1] quit
[SwitchA] interface gigabitethernet 1/0/2
[SwitchA-GigabitEthernet1/0/2] port link-type trunk
[SwitchA-GigabitEthernet1/0/2] port trunk allow-pass vlan 20
[SwitchA-GigabitEthernet1/0/2] quit

Configure VLANIF IP addresses

[SwitchA] interface vlanif 10
[SwitchA-Vlanif10] ip address 192.168.0.1 24
[SwitchA-Vlanif10] quit
[SwitchA] interface vlanif 20
[SwitchA-Vlanif20] ip address 192.168.1.1 24
[SwitchA-Vlanif20] quit

Configure OSPF basic function

[SwitchA] ospf 1 router-id 10.1.1.1   // create process 1 with Router ID 10.1.1.1
[SwitchA-ospf-1] area 0   // create backbone area
[SwitchA-ospf-1-area-0.0.0.0] network 192.168.0.0 0.0.0.255   // area 0 network
[SwitchA-ospf-1-area-0.0.0.0] quit
[SwitchA-ospf-1] area 1   // create area 1
[SwitchA-ospf-1-area-0.0.0.1] network 192.168.1.0 0.0.0.255   // area 1 network
[SwitchA-ospf-1-area-0.0.0.1] return

Configure SwitchB and SwitchC similarly (see configuration files below).

Verification

Check OSPF neighbors on SwitchA: <SwitchA> display ospf peer Check OSPF routing tables on SwitchC and SwitchB:

<SwitchC> display ospf routing
<SwitchB> display ospf routing

Ping test between SwitchB and SwitchC:

<SwitchB> ping 192.168.1.2

Configuration Files

SwitchA configuration:

#
sysname SwitchA
#
vlan batch 10 20
#
interface Vlanif10
 ip address 192.168.0.1 255.255.255.0
#
interface Vlanif20
 ip address 192.168.1.1 255.255.255.0
#
interface GigabitEthernet1/0/1
 port link-type trunk
 port trunk allow-pass vlan 10
#
interface GigabitEthernet1/0/2
 port link-type trunk
 port trunk allow-pass vlan 20
#
ospf 1 router-id 10.1.1.1
 area 0.0.0.0
  network 192.168.0.0 0.0.0.255
 area 0.0.0.1
  network 192.168.1.0 0.0.0.255
return

SwitchB configuration:

#
sysname SwitchB
#
vlan batch 10
#
interface Vlanif10
 ip address 192.168.0.2 255.255.255.0
#
interface GigabitEthernet1/0/1
 port link-type trunk
 port trunk allow-pass vlan 10
#
ospf 1 router-id 10.2.2.2
 area 0.0.0.0
  network 192.168.0.0 0.0.0.255
return

SwitchC configuration:

#
sysname SwitchC
#
vlan batch 20
#
interface Vlanif20
 ip address 192.168.1.2 255.255.255.0
#
interface GigabitEthernet1/0/1
 port link-type trunk
 port trunk allow-pass vlan 20
#
ospf 1 router-id 10.3.3.3
 area 0.0.0.1
  network 192.168.1.0 0.0.0.255
return

Cisco OSPF Lab

Lab Topology

Basic Configuration

R1(config)#interface fastEthernet 0/0
R1(config-if)#ip address 172.16.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#interface s2/0
R1(config-if)#ip add 192.168.1.5 255.255.255.252
R1(config-if)#clock rate 64000
R1(config-if)#no shutdown

R2(config)#interface s3/0
R2(config-if)#ip add 192.168.1.6 255.255.255.252
R2(config-if)#no shutdown
R2(config)#interface fa1/0
R2(config-if)#ip add 10.10.10.1 255.255.255.0
R2(config-if)#no shutdown

OSPF Protocol Configuration

R1(config)#router ospf 1

Declare networks:

R1(config-router)#network 172.16.1.0 0.0.0.255 area 0
R1(config-router)#network 192.168.1.4 0.0.0.3 area 0
R2(config)#router ospf 1
R2(config-router)#network 192.168.1.4 0.0.0.3 area 0
R2(config-router)#network 10.10.10.0 0.0.0.255 area 0

Verification Commands

show ip route
show ip protocols
show ip ospf neighbor
show ip ospf neighbor detail
show ip ospf database
show ip ospf interface
show ip ospf interface s2/0
show interfaces s2/0

Changing Interface Cost

Modify bandwidth to affect OSPF cost:

R1(config)#interface s2/0
R1(config-if)#bandwidth 64

Or set cost directly:

R1(config)#interface s2/0
R1(config-if)#ip ospf cost 200

Monitoring and Debugging OSPF

debug ip ospf events
undebug all
debug ip ospf packet

Zhanbo Network OSPF Lab

Lab Topology

Configuration

IP address configuration:

# R1
set interfaces ge-0/0/0 unit 0 family inet address 1.1.1.1/30
set interfaces ge-0/0/1 unit 0 family inet address 10.1.1.1/2

# R2
set interfaces ge-0/0/0 unit 0 family inet address 1.1.1.2/30
set interfaces ge-0/0/2 unit 0 family inet address 2.2.2.1/30

# R3
set interfaces ge-0/0/2 unit 0 family inet address 2.2.2.2/30
set interfaces ge-0/0/3 unit 0 family inet address 172.16.0.1/30

# PC
PC-A: 10.1.1.10/24
PC-B: 172.16.0.10/24

Enable OSPF on interfaces and assign to area 0:

# R1
set protocols ospf area 0.0.0.0 interface ge-0/0/0.0
set protocols ospf area 0.0.0.0 interface ge-0/0/1.0

# R2
set protocols ospf area 0.0.0.0 interface ge-0/0/0.0
set protocols ospf area 0.0.0.0 interface ge-0/0/2.0

# R3
set protocols ospf area 0.0.0.0 interface ge-0/0/2.0
set protocols ospf area 0.0.0.0 interface ge-0/0/3.0

Verification

Show OSPF neighbors:

root@R1> show ospf neighbor
Address Interface State ID Pri Dead
1.1.1.2 ge-0/0/0.0 Full 1.1.1.2 128 39

Show OSPF interfaces:

root@R1> show ospf interface
Interface State Area DR ID BDR ID Nbrs
g e-0/0/0.0 DR 0.0.0.0 1.1.1.1 1.1.1.2 1
g e-0/0/1.0 DR 0.0.0.0 1.1.1.1 0.0.0.0 0

Show routing table:

root@R1> show route
inet.0: 7 destinations, 7 routes (7 active)
1.1.1.0/30   *[Direct/0] via ge-0/0/0.0
1.1.1.1/32   *[Local/0] via ge-0/0/0.0
2.2.2.0/30   *[OSPF/10] via ge-0/0/0.0
10.1.1.0/24  *[Direct/0] via ge-0/0/1.0
10.1.1.1/32  *[Local/0] via ge-0/0/1.0
172.16.0.0/24*[OSPF/10] via ge-0/0/0.0
224.0.0.5/32*[OSPF/10] MultiRecv

Ping test between PCs:

PC-A> ping 172.16.0.10
Reply from 172.16.0.10: bytes=32 time=4ms TTL=64
... (4 replies, 0% loss, avg 3ms)

Summary

This article introduced OSPF lab configurations for Huawei, Cisco, and Zhanbo Network devices, providing step‑by‑step commands, verification methods, and troubleshooting tips.

HuaweiCisconetwork routingOSPFJuniperLab Tutorial
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.