0% found this document useful (0 votes)
59 views47 pages

03 OSPF Basics

Uploaded by

Billups
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views47 pages

03 OSPF Basics

Uploaded by

Billups
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 47

OSPF Basics

Page 1 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Foreword
• Routers forward data packets based on routing tables. Routing entries can be manually configured or generated using
dynamic routing protocols.

• Compared with dynamic routes, static routes use less bandwidth and do not utilize CPU resources for route
calculation and update analysis. Static routes alone can implement interworking for simple networks. If a network
fault occurs or the topology changes, static routes cannot be automatically updated and must be manually
reconfigured to adapt to the network change.

• Compared with static routes, dynamic routing protocols have higher scalability and better adaptability.

• The Open Shortest Path First (OSPF), as an Interior Gateway Protocol (IGP), is widely used because it features high
scalability and fast convergence.

• This course describes basic OSPF concepts, OSPF adjacency establishment, and basic OSPF configurations.

Page 2 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Objectives
• On completion of this course, you will be able to:
▫ Describe the overall process of OSPF route calculation.

▫ Clarify functions of the DR and BDR.

▫ Describe OSPF packets and their functions.

▫ Configure basic OSPF functions.

▫ Distinguish the OSPF neighbor relationship and adjacency.

Page 3 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Introduction to Dynamic Routing Protocols
2. Overview of OSPF
3. OSPF Working Mechanism
4. Basic OSPF Configurations

Page 4 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Classification of Dynamic Routing Protocols
By ASs

Interior Gateway Protocols (IGPs) Exterior Gateway Protocols (EGPs)

RIP OSPF IS-IS BGP

By working mechanisms and


algorithms
Distance Vector Routing Protocols Link-State Routing Protocols

RIP OSPF IS-IS

Page 5 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Distance-Vector Routing Protocol
• A router running a distance-vector routing protocol periodically floods its routing table. Through route exchange,
each router learns routes from neighboring routers, loads the routes to its routing table, and then advertises the routes
to other neighboring routers.

• All routers on a network do not know the network topology. They only know the direction to a destination network
segment and the cost.

Routing Routing Routing


Table Table Table

10.0.3.3

R1 R2 R3
To reach the device at 10.0.3.3,
pass through R2.

Page 6 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Link State Routing Protocol: LSA Flooding
• A link-state routing protocol advertises the link state but not routing information.

• Routers running link-state routing protocols establish neighbor relationships and then exchange Link State
Advertisements (LSAs).

• Advertise LSAs to describe link status


LSA LSA
information.
R2 1.54 • An LSA describes the status of a router
4M
1 00M interface, such as the cost of the interface
and the connected object.

R1 1 00 M R3
M 0
100

LSA LSA

R4
OSPF
Page 7 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Link State Routing Protocol: LSDB Maintenance
Each router generates LSAs and adds the received LSAs to its own link state database (LSDB). Routers parse the LSAs
stored in their LSDBs to obtain the network topology.

LSDB
• Routers use LSDBs to store LSAs.
• An LSDB usually stores various types of
LSA LSA LSAs, and each type of LSA describes
LSD R2 1.54 LSD different information.
4M
B 1 00M B

R1 1 00 M R3
M 0
100
LSDB
LSA LSA

R4
OSPF
Page 8 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Link State Routing Protocol: SPF Calculation
Each router uses the Shortest Path First (SPF) algorithm to calculate routes based on the LSDB. Each router calculates a
loop-free tree with itself as the root and the shortest path. With the tree, the router knows the optimal paths to all network
segments.
LSDB
Each router calculates a loop-free tree with itself
as the root and the shortest path.
LSD R2 1.54 LSD
4M
B 1 00M B

2
R1 1 00 M R3
M 0
100
LSDB
3 1

R4 4

OSPF
Page 9 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Link State Routing Protocol: Routing Table
Generation
A router installs the calculated optimal path to its routing table.

Routing Based on the SPF calculation result, each router


LSDB installs routes to the routing table.
table

LSD Routing R2 1.54 LSD Routing


M 4M Routing
table Table
B table 1 00 B

R1 1 00 M R3
M 0
100

R4
Routing
LSDB table OSPF
Page 10 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Summary of Link State Routing Protocols
Establish a neighbor LSDB Exchange link state LSDB
relationship information
R1 R2 R1 R2

e
Ex

n t
Es

io ta
r

at k s
ta c

p o
h

hi hb
bl
i n an g

rm i n
ish

ns i g

fo e l
re fo e l

tio ne
la

i n an g
tio a ne rm i n

la a
at k s

ch
re l i s h
ns ig io ta

Ex
hi hb

b
p or n te

ta
Es
R3 R3
1 2 LSDB

Calculate the Calculate the


3 4 Routing table
path path Generate routing Routing table
entries
R1 R2 R1 R2

1 2

Calculate the Routing table


R3 R3
path 3

Page 11 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Introduction to Dynamic Routing Protocols
2. Overview of OSPF
3. OSPF Working Mechanism
4. Basic OSPF Configurations

Page 12 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Overview of OSPF
• OSPF, defined by the Internet Engineering Task Force (IETF), is an IGP based on the link state. OSPF
version 2 (OSPFv2), defined in RFC 2328, is intended for IPv4, and OSPF version 3 (OSPFv3)), defined
in RFC 2740, is intended for IPv6.

• OSPF has the following advantages:


▫ Uses the accumulated link cost as the reference value for route selection based on the SPF algorithm.

▫ Transmits and receives some protocol packets in multicast mode.

▫ Supports area partition

▫ Supports load balancing among equal-cost routes.

▫ Supports packet authentication.

Page 13 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
OSPF Application Scenarios

OSPF is usually deployed on large-scale enterprise


networks to ensure reachable routes between

Core layer
buildings.
Area 0
▫ The core and aggregation layers are deployed in the
OSPF backbone area.
Aggregation layer
▫ The access and aggregation layers are deployed in

Area 1 Area N the OSPF non-backbone area.

Access layer …

Page 14 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Router ID Area Metric

Basic OSPF Concepts: Router ID


• A router ID is a 32-bit integer that uniquely identifies an OSPF router in an AS.

• The rules for selecting a router ID are as follows:


▫ The router ID of an OSPF router is manually configured (recommended).

▫ If the router ID is not manually configured, a router uses the largest IP address of a loopback interface as the router ID.

▫ If no loopback interface is configured, the router uses the largest IP address of a physical interface as the router ID.

Router ID 10.0.1.1 Router ID 10.0.2.2

R1 Area 0 R2

I'm 10.0.1.1

Router ID 10.0.3.3 R3

Page 15 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Router ID Area Metric

Basic OSPF Concepts: Area


• Each OSPF area is regarded as a logical group and identified by an area ID.

• An OSPF area ID is a 32-bit non-negative integer in dotted decimal notation (the format is the same as that of an IPv4
address), for example, area 0.0.0.1. For simplicity, an OSPF area ID is also expressed in decimal notation.

R1 Area 0 R2

R3

Page 16 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Router ID Area Metric

Basic OSPF Concepts: Metric


• OSPF uses the cost as the route metric. Each OSPF-enabled interface maintains an interface cost. The default
interface cost is 100 Mbit/s divided by interface bandwidth. The value 100 Mbit/s is the default reference value
specified by OSPF and is configurable.

• OSPF uses the accumulated cost, that is, the total cost of the outbound interfaces of all routers that the traffic passes
from the source network to the destination network.
Cost of the OSPF Interface Accumulated Cost of the OSPF Path

Serial interface (1.544 Mbit/s) Default 10.0.1.1/32


cost = 64

FE interface GE interface
Default cost = 1 Default cost = 1 Cost = 1 Cost = 64

R1 R2 R3
Different OSPF interfaces have different costs because of their In the routing table of R3, the cost of the OSPF route to network segment
different bandwidths. 10.0.1.1/32 is 1 plus 64, that is, 65.

Page 17 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Router ID Area Metric

Basic OSPF Concepts: Example for Changing the


Metric
Area 0 Area 0
10.0.1.1/32 10.0.1.1/32

R1 Default cost of GE 0/0/0 R2 R1 GE 0/0/0 Cost 100 R2


Aggregation
layer

Default cost of GE 0/0/1 Default cost of GE 0/0/1 GE 0/0/1 Cost 10 GE 0/0/1 Cost 10
Area 1 Area 1

Default cost of GE 0/0/0 GE 0/0/0 Cost 10


Access layer R3 R4 R3 R4
Aggregation layer
[R4]display ip routing-table 10.0.1.1 [R4]display ip routing-table 10.0.1.1
Summary Count : 2 Summary Count : 1
Destination/Mask Proto Cost NextHop Interface
Destination/Mask Proto Cost NextHop Interface
10.0.1.1/32 OSPF 2 10.0.34.3 GigabitEthernet0/0/1
10.0.1.1/32 OSPF 20 10.0.34.3 GigabitEthernet0/0/0
OSPF 2 10.0.24.2 GigabitEthernet0/0/0

By default, there are two paths from R4 to network segment 10.0.1.1/32, In the figure, the cost of the device interface is changed to ensure that traffic
and the data forwarding path is uncontrollable. does not need to pass through R2 when the access router accesses R1.

Page 18 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
OSPF Neighbor Table LSDB OSPF Routing Table

Three OSPF Tables: OSPF Neighbor Table


OSPF has three important tables: OSPF neighbor table, LSDB, and OSPF routing table. Pay attention to the following
information about the OSPF neighbor table:
▫ Before OSPF transmits link state information, OSPF neighbor relationships must be established.

▫ OSPF neighbor relationships are established by exchanging Hello packets.

▫ The OSPF neighbor table displays the status of the neighbor relationship between OSPF routers. You can run the display ospf
peer command to view the status.
<R1> display ospf peer
OSPF Process 1 with Router ID 10.0.1.1
[R1]display ospf peer Neighbors
Area 0.0.0.0 interface 10.0.12.1(GigabitEthernet1/0/0)'s neighbors
Router ID: 10.0.2.2 Address: 10.0.12.2 GR State: Normal
Router ID:10.0.1.1 Router ID:10.0.2.2 State: Full Mode:Nbr is Master Priority: 1
DR: 10.0.12.1 BDR: 10.0.12.2 MTU: 0
GE1/0/0 GE1/0/0 Dead timer due in 35 sec
R1 10.0.12.1/30 10.0.12.2/30 R2 Retrans timer interval: 5
Neighbor is up for 00:00:05
Authentication Sequence: [ 0 ]

Page 19 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
OSPF Neighbor Table LSDB OSPF Routing Table

Three OSPF Tables: LSDB


Pay attention to the following information about the LSDB:
▫ The LSDB stores the LSAs generated by R1 and received from its neighbors. In this example, the LSDB of R1 contains three
LSAs.

▫ Type indicates the LSA type, and AdvRouter indicates the router that sends the LSA.

▫ You can run the display ospf lsdb command to check the LSDB.

<R1> display ospf lsdb


[R1]display ospf lsdb OSPF Process 1 with Router ID 10.0.1.1
Link State Database
Router ID:10.0.1.1 Router ID:10.0.2.2
Type LinkStateIDArea: 0.0.0.0
AdvRouter Age Len Sequence Metric

GE1/0/0 GE1/0/0 Router 10.0.2.2 10.0.2.2 98 36 8000000B 1

R1 10.0.12.1/30 10.0.12.2/30 R2 Router 10.0.1.1 10.0.1.1 92 36 80000005 1

Network 10.0.12.2 10.0.2.2 98 32 80000004 0

Page 20 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
OSPF Neighbor Table LSDB OSPF Routing Table

Three OSPF Tables: OSPF Routing Table


Pay attention to the following information about the OSPF routing table:
▫ The OSPF routing table and the router routing table are different. In this example, the OSPF routing table contains three routes.

▫ An OSPF routing table contains information that guides packet forwarding, for example, destination, cost, and next hop.

▫ You can run the display ip routing-table command to check the OSPF routing table.

[R1]display ospf routing <R1> display ospf routing


OSPF Process 1 with Router ID 10.0.1.1
Routing Tables
Router ID:10.0.1.1 Router ID:10.0.2.2 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
GE1/0/0 GE1/0/0
10.1.12.0/20 1 Transit 10.0.12.1 10.0.1.1 0.0.0.0
R1 10.0.12.1/30 10.0.12.2/30 R2
10.0.2.2/32 1 stub 10.0.12.2 10.0.2.2 0.0.0.0

Total Nets: 3
Intra Area: 3 Inter Area: 0 ASE: 0 NSSA: 0

Page 21 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
OSPF Packet Format and Type
• OSPF defines five types of packets. Different types of OSPF packets have the same header format.

• OSPF packets are encapsulated in IP packets. The protocol number in the IP header of OSPF packets is 89.

Protocol number
89

IP Packet header OSPF Packet header OSPF Packet data


Type Packet Name Function
Discovers and maintains neighbor
1 Hello
relationships.
Exchanges brief LSDB Version Type Packet Length
2 Database Description
information.
Router ID
Requests specific link state
3 Link State Request
information. Area ID
Sends detailed link state
4 Link State Update Checksum Auth Type
information.
5 Link State Ack Acknowledges LSAs. Authentication

Page 22 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Introduction to Dynamic Routing Protocols
2. Overview of OSPF
3. OSPF Working Mechanism
▪ Neighbor Relationship Establishment
▫ Adjacency Establishment

▫ Functions of the DR and BDR

4. Basic OSPF Configurations

Page 23 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Summary of OSPF Working Mechanism

R1 R2

Discover neighbors on a direct link Neighbor


1 through Hello packets relationship

2 Negotiate master/slave roles

Describe LSDBs (summary


3 information)

4 Update LSAs and synchronize Adjacency


LSDBs of both ends
5 Calculate Calculate
route route
Steps 1 to 4 are performed through interaction between the two parties, and
step 5 is performed independently.
Page 24 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Neighbor Relationship Establishment
• OSPF uses Hello packets to discover and establish neighbor relationships.

• On an Ethernet link, by default, OSPF sends Hello packets in multicast mode (destination address: 224.0.0.5).

• An OSPF Hello packet contains information such as the router ID and neighbor list of a router.

R2 R1
10.0.2.2 10.0.1.1
Neighbor status
of R1 Down: Initial state of a neighbor, which indicates that no
Hello (Router ID: 10.0.1.1 neighbor: null) packets are received from the neighbor.
1 Down
Init: The router has received a Hello packet from its
Hello (Router ID: 10.0.2.2 neighbor: null)
1 Init neighbor, but its router ID is not in the neighbor list of the
received Hello packet.
Hello (Router ID: 10.0.2.2 neighbor: 10.0.1.1)
2 2-way 2-way: The router finds that its router ID exists in the
neighbor list of the received Hello packet.

Page 25 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Hello Packet
• Hello packets are used in the following scenarios: • Key fields

▫ Network Mask: indicates the network mask of the interface that sends Hello packets.
▫ Neighbor discovery: Hello packets are used to automatically
▫ HelloInterval: indicates the interval at which Hello packets are sent. The value is 10s
discover neighboring routers. typically.

▫ Neighbor relationship establishment: The two ends negotiate ▫ RouterDeadInterval: indicates the expiration time of a neighbor relationship. If a device
does not receive any Hello packets from its neighbors within a specified Dead interval, the
parameters in Hello packets and establish a neighbor relationship.
neighbors are considered to be Down. The value is 40s typically.
▫ Neighbor relationship holding: A router periodically sends and ▫ Neighbor: indicates the router ID of a neighbor.

receives Hello packets to detect the operating status of neighbors. • Description of other fields

▫ Options:
▪ E: indicates whether external routes are supported.
Network Mask ▪ MC: indicates whether to support forwarding of multicast data packets.
Hello Interval Options Router Priority ▪ N/P: indicates whether the area is an NSSA.
RouterDeadInterval ▫ Router Priority: indicates the DR priority. The default value is 1. If it is set to 0, the
Designated Router router cannot participate in DR or BDR election.
Backup Designated Router ▫ Designated Router: indicates the interface address of a DR.

Neighbor ▫ Backup Designated Router: indicates the interface address of a BDR.

Page 26 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Introduction to Dynamic Routing Protocols
2. Overview of OSPF
3. OSPF Working Mechanism
▫ Neighbor Relationship Establishment

▪ Adjacency Establishment
▫ Functions of the DR and BDR

4. Basic OSPF Configurations

Page 27 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Adjacency Establishment (1)
R2 R1
10.0.2.2 10.0.1.1Neighbor status Fields in DD packets
of R1 ▫ I: If the DD packet is the first among multiple consecutive
DD packets sent by a device, this field is set to 1.
2-way Otherwise, this field is set to 0.
ExStart: The router starts to send DD ▫ M (More): If the DD packet is the last among multiple
DD(Seq=X, I=1, M=1, MS=1) packets to its neighbor. The DD
consecutive DD packets sent by a device, this field is set to
ExStart packets sent in this state do not
0. Otherwise, this field is set to 1.
contain the link state description.
▫ MS (Master/Slave): When two OSPF routers exchange
DD(Seq=Y, I=1, M=1, MS=1)
DD packets, they need to determine the master/slave
relationship. The router with a larger router ID becomes
DD (Seq=Y, LSDB summary) the master router. The value 1 indicates that the sender is
Exchange: A router and its neighbor
Exchange the master.
exchange DD packets that contain
DD (Seq = Y + 1, LSDB summary, MS link state summaries. ▫ DD sequence number: indicates the sequence number of
= 1) a DD packet. The master and slave devices use sequence
numbers to ensure the reliability and integrity of DD
Loading: A router and its neighbor packet transmission.
DD(Seq=Y+1)
Loading send LSR packets, LSU packets, and
LSAck packets to each other.

Page 28 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
DD Packet
A DD packet contains the LSA header information, including the LS type, LS ID, Advertising Router, LS Sequence
Number, and LS Checksum.

Description of other fields


Interface MTU Options 0 0 0 0 0 I M MS ▫ Interface MTU: indicates the maximum size of an IP packet that an
interface can send without fragmenting the packet. The DD packets
DD sequence number sent by two neighbors contain the MTU. If the MTU in the received
DD packet is different from the local MTU, the DD packet is discarded.
LSA Header By default, MTU check is disabled on a Huawei device.
▫ Options: The field is the same as that in a Hello packet.

Page 29 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Adjacency Establishment (2)

R2 R1
• R1 starts to send LSR packets to R2 to request the link state
Neighbor status
information that is discovered through DD packets in Exchange state
of R1
LSR and does not exist in the local LSDB.
Loading • R2 sends an LSU packet to R1. The LSU packet contains detailed
information about the requested link state. After R1 receives the LSU
LSU
Full packet and does not have other LSAs to be requested, R1 changes the
neighbor status from Loading to Full.
LSAck
• R1 sends an LSAck packet to R2 to acknowledge the LSU packet.
Full: The router has synchronized
the LSDB with the neighbor.

Question: If multiple routers are located on the same broadcast network, what are the problems in establishing adjacencies using the
preceding method?

Page 30 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Introduction to Dynamic Routing Protocols
2. Overview of OSPF
3. OSPF Working Mechanism
▫ Neighbor Relationship Establishment

▫ Adjacency Establishment

▪ Functions of the DR and BDR

4. Basic OSPF Configurations

Page 31 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Functions of the DR and BDR
Problems on the MA Network DR election on an MA network:
• A DR establishes and maintains adjacencies on an MA network and synchronizes
▫ n x (n-1)/2 adjacencies complicate management.
LSAs.
▫ Repeated LSA flooding wastes resources. Solution
• The DR establishes adjacencies with all other routers and exchanges link state
information with them. Other routers do not directly exchange link state information.

• To prevent single points of failures (SPOFs), a BDR is elected to quickly take over
services of the DR when the DR fails.

R1 R2 R1 R2

DR BDR DR BDR

Adjacency
R3 R4 R5 R3 R4 R5

Page 32 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
DR and BDR Election Rules
• DR or BDR election is in non-preemption mode.
R1 (DR) R2 (DRother)
• DR or BDR election is based on interfaces. 10.0.1.1 10.0.2.2

▫ The greater the DR priority of an interface, the higher the


Not participating in
priority. 100 10.0.1.1 0 the election

▫ If the DR priorities of interfaces are the same, the interface


R4 is a new device and
with a larger router ID is preferred. 95 200
cannot become a DR or
BDR.
R3 (BDR) New router - R4
10.0.3.3 (DRother)
10.0.4.4

• Question:
▫ If the priorities of the four routers in the preceding figure are all set to 0, can OSPF work normally?
▫ Which types of links form an MA network by default?

Page 33 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
DR and BDR Election on Different Types of
Networks
OSPF Network Common Data Link Whether to Elect Whether to Establish an
Type Layer Protocol a DR Adjacency with the Neighbor
Point-to-point PPP and HDLC No Yes

The DR establishes adjacencies with


Broadcast Ethernet
the BDR and DRothers.
The BDR establishes adjacencies with
Yes
the DR and DRothers.
NBMA FR The DRothers establish a neighbor
relationship.

P2MP Manually specified protocol No Yes

Page 34 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Adjusting the OSPF Network Type of Device
Interfaces as Needed
• The OSPF network type is automatically set based on the data link
layer encapsulation of the interface.

• Routers in the figure are interconnected through Ethernet interfaces,


CO-R1 CO-R2
so the network type of these interfaces is broadcast by default.

• Each link is a point-to-point (P2P) link, so it is unnecessary to elect


OSPF
the DR and BDR on a link.
AS-R1 AS-R2
Ethernet link • To improve OSPF efficiency and speed up the establishment of
neighbor relationships, you can change the network type of these
interconnected interfaces to P2P.

In the interface view, run the ospf network { p2p | p2mp | broadcast | nbma } command to change the network type of
the interface.

Page 35 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Contents
1. Introduction to Dynamic Routing Protocols
2. Overview of OSPF
3. OSPF Working Mechanism
4. Basic OSPF Configurations

Page 36 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Configuration Commands (1)
1. Create an OSPF process and enter the OSPF view.

[Huawei] ospf [ process-id | Router ID Router ID ]

The router supports OSPF multi-process, and the process ID is configured locally. Two devices that use different OSPF process IDs can also establish an adjacency.

2. Create an OSPF area and enter the OSPF area view.

[Huawei-ospf-1] area area-id

3. Enable OSPF in the OSPF area.

[Huawei-ospf-1-area-0.0.0.0] network network-address wildcard-mask

Run the following command to configure the network segment included in the area. The mask length of the interface IP address is larger than or equal to the mask length

specified by the network command, and the primary IP address of the interface must be on the network segment specified by the network command. In this case, OSPF

can be activated in the corresponding area on the interface.

4. Enable OSPF in the interface view.

[Huawei-GigabitEthernet1/0/0] ospf enable process-id area area-id

The ospf enable command takes precedence over the network command.

Page 37 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Configuration Commands (2)
5. Set a priority for an interface that participates in the DR election in the interface view.

[Huawei-GigabitEthernet1/0/0] ospf dr-priority priority

By default, the priority is 1.

6. Set the interval for sending Hello packets on an interface.

[Huawei-GigabitEthernet1/0/0] ospf timer Hello interval

By default, for a P2P or broadcast interface, the interval for sending Hello packets is 10 seconds; the dead interval after which an interface considers its OSPF neighbor

invalid is four times the interval for sending Hello packets.

7. Set a network type for an OSPF interface.

[Huawei-GigabitEthernet1/0/0] ospf network-type { broadcast | nbma | p2mp | p2p }

By default, the network type of an interface is determined by the physical interface. The network type of an Ethernet interface is broadcast, and the network type of a serial

interface or a POS interface (PPP or HDLC is used) is P2P.

Page 38 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
OSPF Configuration Examples
• Basic information: The router ID of each device is 10.0.x.x, where x is
R1 R2 the router number. For example, the router ID of R5 is 10.0.5.5. The IP
GE0/0/0 GE0/0/0
address for interconnection between devices is 10.0.xyz.x(y)/24, where
xyz indicate the router numbers. The router numbers are in ascending

Se
/1
Se1/0/0

1/ 0
0/
GE
order. For example, the IP address of GE0/0/1 on R2 is 10.0.235.2/24.

/1
/1

Se
0
0/

1/ 0
• Topology: Five routers work in area 0.
GE

/1
SW1 R4
/2

GE

/1
0

1/ 0
0/

The configuration on R2 is used as an example.


/0
GE
Se1/0/0

Se
/3

0 /
/0

1/0

[R2]ospf 1 router-id 10.0.2.2


GE
0
0/

Se
0
GE

/0
/0

[R2-ospf-1]area 0.0.0.0
[R2-ospf-1-area-0.0.0.0] network 10.0.12.0 0.0.0.255
R3 R5 [R2-ospf-1-area-0.0.0.0] network 10.0.24.2 0.0.0.0
Ethernet link [R2-ospf-1-area-0.0.0.0] network 10.0.235.2 0.0.0.0
Serial link

Page 39 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
OSPF Configuration Verification (1)
Run the display ospf interface all command to check information about all OSPF
interfaces on the device.
R1 R2
GE0/0/0 • Time parameters, such as the interval for sending Hello packets and dead interval

• Link type and MTU of the interface

• Interface IP address of the DR and the priority of the DR for an Ethernet link

/1

Se
0
0/

1/ 0
GE
[R2]display ospf interface all

/1
OSPF Process 1 with Router ID 10.0.2.2
Area: 0.0.0.0
Interface: 10.0.12.2 (GigabitEthernet0/0/0)
SW1 Cost: 1 State: DR Type: Broadcast MTU: 1500 Priority: 1
R4 Designated Router: 10.0.12.2
Backup Designated Router: 10.0.12.1
Timers: HELLO 10 , Dead 40 , Poll 120 , Retransmit 5 , Transmit Delay 1

Interface: 10.0.235.2 (GigabitEthernet0/0/1)


Cost: 1 State: DROther Type: Broadcast MTU: 1500 Priority: 1
Designated Router: 10.0.235.5
Backup Designated Router: 10.0.235.3
R3 R5 Timers: HELLO 10 , Dead 40 , Poll 120 , Retransmit 5 , Transmit Delay 1

OSPF interface Interface: 10.0.24.2 (Serial1/0/1) --> 10.0.24.4


Cost: 48 State: P-2-P Type: P2P MTU: 1500
Timers: HELLO 10 , Dead 40 , Poll 120 , Retransmit 5 , Transmit Delay 1

Page 40 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
OSPF Configuration Verification (2)
Run the display ospf peer command to check the neighbor status of the device.
• Router ID of the neighboring router
R1 R2
• Neighbor status, such as FULL, TWO-WAY, and DOWN

<R2>display ospf peer


OSPF Process 1 with Router ID 10.0.2.2
Area 0.0.0.0 interface 10.0.12.2(GigabitEthernet0/0/0)'s neighbors
Router ID: 10.0.1.1 Address: 10.0.12.1
State: Full Mode:Nbr is Slave Priority: 1
SW1 DR: 10.0.12.2 BDR: 10.0.12.1 MTU: 0
Dead timer due in 28 sec
R4 Retrans timer interval: 5
Neighbor is up for 00:01:31
Authentication Sequence: [ 0 ]

Area 0.0.0.0 interface 10.0.235.2(GigabitEthernet0/0/1)'s neighbors


Router ID: 10.0.3.3 Address: 10.0.235.3
State: Full Mode:Nbr is Master Priority: 1
DR: 10.0.235.5 BDR: 10.0.235.3 MTU: 0
R3 R5
Dead timer due in 30 sec
Retrans timer interval: 5
Neighbor is up for 00:01:31
Authentication Sequence: [ 0 ]

Page 41 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
OSPF Configuration Verification (3)
On a P2P network, DR or BDR election is not required. Therefore, when checking
the OSPF neighbor table of R2, you can find that the DR/BDR field of Serial1/0/1
R1 R2
in the command output is None.

<R2>display ospf peer


OSPF Process 1 with Router ID 10.0.2.2
Area 0.0.0.0 interface 10.0.235.2(GigabitEthernet0/0/1)'s neighbors
Router ID: 10.0.5.5 Address: 10.0.235.5
State: Full Mode:Nbr is Master Priority: 1
DR: 10.0.235.5 BDR: 10.0.235.3 MTU: 0
Dead timer due in 40 sec
SW1 Retrans timer interval: 0
R4 Neighbor is up for 00:01:27
Authentication Sequence: [ 0 ]

Area 0.0.0.0 interface 10.0.24.2(Serial1/0/1)'s neighbors


Router ID: 10.0.4.4 Address: 10.0.24.4
State: Full Mode:Nbr is Master Priority: 1
DR: None BDR: None MTU: 0
Dead timer due in 35 sec
R3 R5 Retrans timer interval: 5
Neighbor is up for 00:01:56
Authentication Sequence: [ 0 ]

Page 42 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
OSPF Configuration Verification (4)
Run the display ospf lsdb command to check the LSDB of the device.
• An LSDB consists of multiple types of LSAs. All LSAs have the same packet header format,
R1 R2
in which key fields such as Type, LinkState ID, and AdvRouter are included. The next course
will focus on LSA details.

<R2>display ospf lsdb

OSPF Process 1 with Router ID 10.0.2.2


Link State Database

Area: 0.0.0.0
SW1
R4 Type LinkState ID AdvRouter Age Len Sequence Metric
Router 10.0.4.4 10.0.4.4 662 72 80000006 48
Router 10.0.2.2 10.0.2.2 625 72 8000000C 1
Router 10.0.1.1 10.0.1.1 638 60 80000007 1
Router 10.0.5.5 10.0.5.5 634 60 8000000B 1
Router 10.0.3.3 10.0.3.3 639 60 80000009 1
R3 R5 Network 10.0.235.5 10.0.5.5 634 36 80000005 0
Network 10.0.12.2 10.0.2.2 629 32 80000003 0

Are LSDBs on other devices the same?

Page 43 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
OSPF Configuration Verification (5)
Run the display ospf routing command to check the OSPF routing table of the
device.
R1 R2
• The OSPF routing table of R2 shows that R2 has learned the routes to the entire network

through OSPF.

<R2>display ospf routing

OSPF Process 1 with Router ID 10.0.2.2


Routing Tables
SW1
Destination Cost Type NextHop AdvRouter Area
R4
10.0.12.0/24 1 Transit 10.0.12.2 10.0.2.2 0.0.0.0
10.0.24.0/24 48 Stub 10.0.24.2 10.0.2.2 0.0.0.0
10.0.235.0/24 1 Transit 10.0.235.2 10.0.2.2 0.0.0.0
10.0.13.0/24 49 Stub 10.0.12.1 10.0.1.1 0.0.0.0
10.0.13.0/24 49 Stub 10.0.235.3 10.0.3.3 0.0.0.0
R3 R5
10.0.45.0/24 49 Stub 10.0.235.5 10.0.5.5 0.0.0.0

Page 44 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Quiz
1. (Single) Which of the following packets is used by OSPF to maintain neighbor relationships? ( )
A. Hello

B. Database Description

C. LSR

D. LSU

2. (Multiple) Which of the following network types are supported by OSPF? ( )


A. P2P network

B. P2MP network

C. Broadcast network

D. NBMA network

Page 45 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
Summary
• This course describes basic OSPF concepts, including the router ID, area, and cost. Routers
running OSPF send link state information to each other to calculate the topology and routes.
• This course describes the process of establishing OSPF neighbor relationships and adjacencies.
On an MA network, the DR and BDR need to be elected. There are five types of OSPF packets.
All packets have the same packet header format. An OSPF router periodically sends Hello
packets to discover and maintain neighbor relationships, and uses DD, LSR, LSU, and LSAck
packets to synchronize LSDBs. Finally, this course introduces the simple configuration of a
single OSPF area.

Page 46 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.
谢谢
Thank You
www.huawei.com

Page 47 Copyright © 2020 Huawei Technologies Co., Ltd. All rights reserved.

You might also like