OSPF

Feature History for OSPF

This table provides release and platform support information for the features explained in this module.

These features are available in all the releases subsequent to the one they were introduced in, unless noted otherwise.

Release

Feature Name and Description

Supported Platform

Cisco IOS XE 17.18.1

OSPF: Open Shortest Path First (OSPF) is a link-state routing protocol that is used in Internet Protocol (IP) networks and suitable to be deployed on single autonomous system (AS), such as an enterprise network.

Cisco C9350 Series Smart Switches

Cisco C9610 Series Smart Switches

OSPF

Open Shortest Path First (OSPF) is a link-state routing protocol

  • that is used in Internet Protocol (IP) networks,

  • is classified as an Interior Gateway Protocol (IGP), and

  • suitable to be deployed on single autonomous system (AS), such as an enterprise network.

OSPF versions

OSPF versions and their classifications are as follows:

OSPFv2

OSPF or OSPF Version 2 (OSPFv2) is designed exclusively for IPv4 networks. It exchanges and calculates routes for IPv4 addresses.

OSPFv3

OSPF Version 3 (OSPFv3) was designed exclusively for IPv6 networks and address-family independent routing. While its primary design was for IPv6, OSPFv3 now allows carrying IPv4 routing information along with address families. This means a single OSPFv3 instance can route both IPv4 and IPv6 information.

OSPF for routed access

OSPF for Routed Access refers to a network design in which OSPF is implemented at the access layer of a network using Layer 3 switches. In a routed access design, the Layer 2 functionality, such as VLANs and MAC learning remains active. Layer 3 routing capabilities are deployed on the access layer switches. As a result, Layer 3 switches are configured with IP addresses on their Switched Virtual Interfaces (SVIs) or routed ports and they participate in a routing protocol such as OSPF.

Key components of OSPF

The following are the key components of OSPF:

  • Router ID:

    A unique identifier assigned to each OSPF device in the network.

  • Areas:

    OSPF divides a large AS into smaller, manageable segments called areas. This limits the scope of LSA flooding so that changes in one area do not necessarily affect the entire AS.

    Each area has a unique Area ID, typically represented as a decimal number, for example 0, 1, 2 or an IP address, for example 1.1.1.1.

    Table lists the types of areas and their classification.

    Types of areas

    Classification

    Backbone Area (Area 0):

    This is the central and most critical area in an OSPF domain. All other non-backbone areas must connect directly to Area 0. This ensures a logical and physical path for inter-area communication.

    It also acts as the transit area for traffic moving between different non-backbone areas.

    Stub Areas

    A stub area is designed to reduce the size of routing tables and LSDBs within the area. Information about external routes (routes from outside the OSPF autonomous system) is not sent into a stub area. To allow devices in a stub area to reach external destinations, the ABR connected to the stub area automatically generates and advertises a default external route into that area.

    Not-So-Stubby Area (NSSA)

    A more flexible type of stub area. While it also aims to reduce LSA flooding, it allows for the injection of external routes. An NSSA does not flood all LSAs from the OSPF backbone (core) into the area. However, unlike a standard stub area, it can import external routes (AS external routes) into the area through redistribution.

  • Device roles:

    In OSPF, devices are assigned specific roles based on their deployment and function within the network hierarchy.

    Table lists the device roles and their classifications.

    Device roles

    Classification

    ABR

    An OSPF-enabled device is classified as an Area Border Router (ABR) if it has interfaces in more than one OSPF area and at least one interface in Area 0. They connect regular areas to the backbone. ABRs maintain separate LSDBs for each area they are connected to and are responsible for summarizing routing information between areas.

    ASBR

    A device is classified as an Autonomous System Boundary Router (ASBR) if it has one interface connected to an OSPF network and at least one interface connected to a non-OSPF network (or another OSPF domain if routes are being explicitly redistributed). This external network could be running a different routing protocol like BGP, EIGRP, or RIP or simply consist of static routes that are being injected into OSPF.

  • Link-State Advertisement (LSA):

    Packets containing information about a device's neighbors and the state of its links. Devices exchange LSAs to share network topology information.

  • Link-State Database (LSDB):

    A database that stores information about the network topology, built from the LSAs received from neighboring devices. Each device in an OSPF area maintains an identical LSDB.

  • OSPF tables:

    OSPF devices maintain several tables to store routing and topology information:

    • Neighbor Table (Adjacency Database): Stores information about OSPF neighbors.

    • Topology Table (Link-State Database): Stores the topology structure of a network.

    • Routing Table (Forwarding Database): Stores the best routes to each destination network.

  • Hello Packets:

    Used by OSPF devices to discover neighbors and establish neighbor relationships.

  • Shortest Path First (SPF) Algorithm (Dijkstra's Algorithm):

    Used by each OSPF device to calculate the best path to each destination based on cost, using the information in the LSDB.

  • Cost (Metric):

    A parameter used by OSPF to determine the best path, typically based on interface bandwidth.

To learn more about OSPF, refer the additional references section in this chapter.

How OSPF works

Workflow

Before OSPF is configured, the switch must have IP routing enabled to allow it to forward traffic like a router.

The following section details how OSPF is configured and works on access switches:

  1. Each VLAN on the access switch will have an SVI configured with an IP address, acting as the default gateway for that VLAN. OSPF is enabled on these SVIs. This means the access switch will advertise the networks (VLAN subnets) directly connected to it into the OSPF domain. If there are dedicated links between access switches or links to distribution switches configured as routed ports (Layer 3 ports), OSPF will also run on these physical interfaces.
  2. The access layer switches will form OSPF neighbor relationships with their upstream distribution layer switches (which are also running OSPF).
  3. The access switches will exchange LSAs (Link-State Advertisements) with the distribution switches, sharing information about their directly connected networks (VLANs). They will build an LSDB (Link-State Database) that reflects the topology of their area.
  4. Each access switch will run the SPF algorithm based on its LSDB and populate its IP routing table with the best paths to all known destinations, including routes learned from the distribution layer.
  5. The access switch can now perform inter-VLAN routing locally, directly routing traffic between VLANs that terminate on that switch, without needing to send the traffic up to the distribution layer. For traffic destined outside its local VLANs, the access switch will use the OSPF-learned routes to forward packets upstream to the distribution layer.

Enable OSPF and configure area ID

Perform this task to enable OSPF, specify the range of IP addresses to associate with the routing process, and assign area IDs to be associated with that range.

Procedure


Step 1

enable

Example:

Device> enable

Enables privileged EXEC mode.

Enter your password, if prompted.

Step 2

configure terminal

Example:

Device# configure terminal

Enters global configuration mode.

Step 3

router ospf process-id [vrf vrf-name]

Example:

Device(config)# router ospf 15

Enables OSPF routing and enters router configuration mode.

  • process-id : The process ID is an internally used identification parameter that is locally assigned. Each OSPF process has a unique process ID.

    Process ID can be a positive integer from 1 to 65535.

  • vrf: Indicates that the OSPF process is being configured for a specific VRF.

  • vrf-name : Specifies the name of the VRF for which this OSPF process is being created.

Step 4

network address wild-card-mask area area-id

Example:

Device(config-router)# network 10.1.1.1 255.240.0.0 area 20

Defines an interface on which OSPF runs and the area ID for that interface.

  • address wild-card-mask : Addresses of the networks that belong to a particular OSPF area. The wildcard-mask allows to use a single command to define one or more multiple interfaces to be associated with a specific OSPF area.

  • area-id : The area identifer. The area ID can be a decimal value or an IP address.

Step 5

end

Example:

Device(config-router)# end

Returns to privileged EXEC mode.

Step 6

show ip protocols

Example:

Device# show ip protocols

(Optional) Verifies your entries.

Step 7

copy running-config startup-config

Example:

Device# copy running-config startup-config

(Optional) Saves your entries in the configuration file.


Configure OSPF for IPv6

Before you begin

You can customize OSPF for IPv6 for your network. However, the current configuration defaults for OSPF in IPv6 are set to meet the requirements of most customers and features.

Follow these guidelines:

  • Be careful when changing the defaults for IPv6 commands. Changing the defaults might adversely affect OSPF for the IPv6 network.

  • Before you enable IPv6 OSPF on an interface, you must enable routing by using the ip routing command in global configuration mode, enable the forwarding of IPv6 packets by using the ipv6 unicast-routing command in global configuration mode, and enable IPv6 on Layer 3 interfaces on which you are enabling IPv6 OSPF.

For more information about configuring OSPF routing for IPv6, see the “Implementing OSPF for IPv6” chapter in the Cisco IOS IPv6 Configuration Library on Cisco.com.

To configure OSPF routing for IPv6, perform this procedure:

Procedure


Step 1

enable

Example:

Device> enable

Enables privileged EXEC mode.

Enter your password, if prompted.

Step 2

configure terminal

Example:

Device# configure terminal

Enters global configuration mode.

Step 3

Choose one of the following:

  • router ospfv3 process-id
  • ipv6 router ospf process-id

Example:


Device(config)# router ospfv3 15
OR
Device(config)# ipv6 router ospf 15

Enables OSPF routing and enters router configuration mode.

process-id : The process ID is an internally used identification parameter that is locally assigned. Each OSPF process has a unique process ID.

Process ID can be a positive integer from 1 to 65535.

Step 4

area area-id range {ipv6-prefix / prefix-length} [advertise | not-advertise] [cost cost]

Example:

Device(config-router)# area .3 range 2001:0DB8::/32 not-advertise

(Optional) Consolidates and summarizes routes at an area boundary.

  • area-id : Identifier of the area about which routes are to be summarized. It can be specified as either a decimal value or as an IPv6 prefix.

  • ipv6-prefix/prefix length : The destination IPv6 network and a decimal value that shows how many of the high-order contiguous bits of the address comprise the prefix (the network portion of the address). A slash mark (/) must precede the decimal value.

  • advertise : (Optional) Sets the address range status to advertise and generate a Type 3 summary link-state advertisement.

  • not-advertise : (Optional) Sets the address range status to DoNotAdvertise. The Type 3 summary LSA is suppressed, and component networks remain hidden from other networks.

  • cost cost : (Optional) Sets the metric or cost for this summary route, which is use during OSPF SPF calculation to determine the shortest paths to the destination.

    The value can be 0 to 16777215.

Step 5

maximum-paths number-paths

Example:

Device(config-router)# maximum paths 16

(Optional) Defines the maximum number of equal-cost routes to the same destination that IPv6 OSPF should enter in the routing table.

The range is from 1 to 32. The default is 16 paths.

Step 6

exit

Example:

Device(config-router)# exit

Returns to global configuration mode.

Step 7

interface interface-id

Example:

Device(config)# interface gigabitethernet 1/0/1

Enters interface configuration mode, and specifies the Layer 3 interface to configure.

Step 8

Choose one of the following:

  • router ospfv3 process-id area area-id [instance instance-id]
  • ipv6 ospf process-id area area-id [instance instance-id]

Example:


Device(config-if)# router ospfv3 21 area .3
OR
Device(config-if)# ipv6 ospf 21 area .3

Enables OSPF for IPv6 on the interface.

instance instance-id : (Optional) Instance identifier.

Step 9

end

Example:

Device(config-if)# end

Returns to privileged EXEC mode.

Step 10

show ipv6 ospf [process-id] [area-id interface [interface-id]

Example:

Device# show ipv6 ospf 21 interface gigabitethernet 2/0/1

(Optional) Displays information about OSPF interfaces.

Step 11

show ipv6 ospf [process-id] [area-id

Example:

Device# show ipv6 ospf 21

(Optional) Displays general information about OSPF routing processes.

Step 12

copy running-config startup-config

Example:

Device# copy running-config startup-config

(Optional) Saves your entries in the configuration file.


Configure OSPF interfaces

You can use the ip ospf interface configuration commands to modify interface-specific OSPF parameters. You are not required to modify any of these parameters, but some interface parameters (hello interval, dead interval, and authentication key) must be consistent across all devices in an attached network. If you modify these parameters, be sure all devices in the network have compatible values.


Note


The ip ospf interface configuration commands are all optional.


Procedure


Step 1

enable

Example:

Device> enable

Enables privileged EXEC mode.

Enter your password, if prompted.

Step 2

configure terminal

Example:

Device# configure terminal

Enters global configuration mode.

Step 3

interface interface-id

Example:

Device(config)# interface gigabitethernet 1/0/1

Enters interface configuration mode, and specifies the Layer 3 interface to configure.

Step 4

ip ospf cost cost

Example:

Device(config-if)# ip ospf cost 8

(Optional) Explicitly specifies the cost of sending a packet on the interface.

Step 5

ip ospf retransmit-interval seconds

Example:

Device(config-if)# ip ospf retransmit-interval 10

(Optional) Specifies the number of seconds between link state advertisement transmissions.

The range is 1 to 65535 seconds. The default is 5 seconds.

Step 6

ip ospf transmit-delay seconds

Example:

Device(config-if)# ip ospf transmit-delay 2

(Optional) Sets the estimated number of seconds to wait before sending a link state update packet.

The range is 1 to 65535 seconds. The default is 1 second.

Step 7

ip ospf priority number

Example:

Device(config-if)# ip ospf priority 5

(Optional) Sets priority to help find the OSPF designated device for a network.

The range is from 0 to 255. The default is 1.

Step 8

ip ospf hello-interval seconds

Example:

Device(config-if)# ip ospf hello-interval 12

(Optional) Sets the number of seconds between hello packets sent on an OSPF interface. The value must be the same for all nodes on a network.

The range is 1 to 65535 seconds. The default is 10 seconds.

Step 9

ip ospf dead-interval seconds

Example:

Device(config-if)# ip ospf dead-interval 8

(Optional) Sets the number of seconds after the last device hello packet was seen before its neighbors declare the OSPF device to be down. The value must be the same for all nodes on a network.

The range is 1 to 65535 seconds. The default is 4 times the hello interval.

Step 10

ip ospf authentication-key key

Example:

Device(config-if)# ip ospf authentication-key password

Optional) Assign a password to be used by neighboring OSPF devices. The password can be any string of keyboard-entered characters up to 8 bytes in length. All neighboring devices on the same network must have the same password to exchange OSPF information.

Step 11

ip ospf message digest-key keyid md5 key

Example:

Device(config-if)# ip ospf message digest-key 16 md5 your1pass

(Optional) Enables MD5 authentication.

  • keyid : An identifier from 1 to 255.

  • key : An alphanumeric password of up to 16 bytes.

Step 12

ip ospf database-filter all out

Example:

Device(config-if)# ip ospf database-filter all out

(Optional) Block flooding of OSPF LSA packets to the interface. By default, OSPF floods new LSAs over all interfaces in the same area, except the interface on which the LSA arrives.

Step 13

end

Example:

Device(config-if)# end

Returns to privileged EXEC mode.

Step 14

show ip ospf interface inteface-id

Example:

Device# show ip ospf interface gigabitethernet 1/0/1 

(Optional) Displays OSPF-related interface information.

Step 15

show ip ospf neighbor detail

Example:

Device# show ip ospf neighbor detail

(Optional) Displays NSF awareness status of neighbor switch. The output matches one of these examples:

  • Optionsis 0x52
    LLSOptions is 0x1 (LR)

    When both of these lines appear, the neighbor switch is NSF aware.

  • LLSOptions is 0x1 (LR)

    When both of these lines appear, the neighbor switch is NSF aware.

Step 16

copy running-config startup-config

Example:

Device# copy running-config startup-config

(Optional) Saves your entries in the configuration file.


Configure OSPF area parameters

Before you begin

The OSPF area parmeter configurations are all optional.

Perform this procedure to configure the OSPF area parameters.

Procedure


Step 1

enable

Example:

Device> enable

Enables privileged EXEC mode.

Enter your password, if prompted.

Step 2

configure terminal

Example:

Device# configure terminal

Enters global configuration mode.

Step 3

router ospf process-id [vrf vrf-name]

Example:

Device(config)# router ospf 15

Enables OSPF routing and enters router configuration mode.

  • process-id : The process ID is an internally used identification parameter that is locally assigned. Each OSPF process has a unique process ID.

    Process ID can be a positive integer from 1 to 65535.

  • vrf: Indicates that the OSPF process is being configured for a specific VRF.

  • vrf-name : Specifies the name of the VRF for which this OSPF process is being created.

Step 4

area area-id authentication

Example:

Device(config-router)# area 1 authentication

(Optional) Allow password-based protection against unauthorized access to the identified area.

The identifier can be either a decimal value or an IP address.

Step 5

area area-id authentication message-digest

Example:

Device(config-router)# area 1 authentication message-digest

(Optional) Enables MD5 authentication on the area.

Step 6

area area-id stub [no-summary]

Example:

Device(config-router)# area 1 stub

(Optional) Define an area as a stub area.

The no-summary keyword prevents an ABR from sending summary link advertisements into the stub area.

Step 7

area area-id nssa [no-redistribution] [default-information-originate] [no-summary]

Example:

Device(config-router)# area 1 nssa default-information originate

(Optional) Defines an area as a not-so-stubby-area. Every device within the same area must agree that the area is NSSA. Select one of these keywords:

  • no-redistribution : Select when the device is an NSSA ABR and you want the redistribute command to import routes into normal areas, but not into the NSSA.

  • default-information-originate : Select on an ABR to allow importing type 7 LSAs into the NSSA.

  • no-summary : Select to not send summary LSAs into the NSSA.

Step 8

area area-id range address-mask

Example:

Device(config-router)# area 1 range 255.240.0.0

Optional) Specifies an address range for which a single route is advertised. Use this command only with area border routers.

Step 9

end

Example:

Device(config-router)# end

Returns to privileged EXEC mode.

Step 10

show ip ospf process-id

Example:

Device# show ip ospf

(Optional) Displays information about the OSPF routing process in general or for a specific process ID to verify configuration.

Step 11

show ip ospf [process-id [area-id]] database

Example:

Device# show ip ospf database

(Optional) Displays lists of information related to the OSPF database for a specific device.

Step 12

copy running-config startup-config

Example:

Device# copy running-config startup-config

(Optional) Saves your entries in the configuration file.


Parameters that optimize OSPF

These OSPF features and parameters allow for fine-tuning and optimization of an OSPF network.

OSPF parameters

Features

Authentication

Provides password-based protection to prevent unauthorized access to an OSPF area. This secures the routing updates exchanged within that area.

Route summarization

Consolidates multiple advertised network addresses into a single, summary route. This reduces the number of entries in routing tables and the amount of routing information exchanged.

If network numbers are contiguous, an Area Border Router (ABR) can be configured using the area range router configuration command to advertise a single summary route that encompasses all networks within that range to other areas.

Route summarization (for redistributed routes)

Reduces the size of the OSPF LSDB and routing tables when external routes (from other protocols) are redistributed into OSPF. Instead of advertising each redistributed route individually as an external LSA (Type 5), the summary-address router configuration command allows you to consolidate multiple contiguous redistributed routes into a single summary route.

Virtual links

Maintains backbone continuity in OSPF when a non-backbone area separates a standard area from Area 0, or when Area 0 itself is segmented.

Use the area area-id virtual-link router-id command to configure a virtual link. This establishes a logical connection between two ABRs through a non-backbone (transit) area, effectively extending the backbone.

Domain Name Server (DNS) names in display

Enhances readability and ease of identification in OSPF show command outputs.

Allows OSPF displays to show router DNS names instead of just their Router IDs or Neighbor IDs, making it simpler for administrators to identify specific devices.

Default metrics (cost calculation)

Determines the "cost" of a link, which OSPF uses to calculate the shortest path.

OSPF calculates the cost of an interface based on its bandwidth using the formula:
cost = reference_bandwidth / interface_bandwidth
The default reference bandwidth is 100 Mbps.

For high-bandwidth links (e.g., Gigabit Ethernet), the reference bandwidth can be increased to allow OSPF to differentiate costs more accurately.

Administrative distance

Rates the trustworthiness of routing information learned from different sources.

An integer value between 0 and 255, where a lower value indicates higher trustworthiness. OSPF uses different default administrative distances for intra-area, inter-area, and external routes. These values can be changed by the administrator.

Passive interfaces

Prevents OSPF from sending Hello packets out of a specific interface, typically used on interfaces connected to end-user segments where no OSPF neighbors are expected.

Once an interface is configured as passive, OSPF stops forming adjacencies on that segment. However, the network connected to the interface can still be advertised by OSPF.

Route calculation timers

Controls the timing of OSPF's SPF algorithm calculations.

Allows configuration of a delay time between a topology change and the start of the SPF calculation, and a hold time between consecutive SPF calculations. This helps to prevent excessive CPU utilization during periods of network instability.

Log neighbor changes

Provides real-time visibility into OSPF neighbor state transitions.

Configure the OSPF-enabled switch to send a syslog message whenever an OSPF neighbor’s state changes, for example, from Down to Full, or Full to Down. This feature aids network monitoring and troubleshooting.

Configure OSPF parameters

Perform this task to configure a stub area, configure a virtual link, configure DNS look up and so on.

Procedure


Step 1

enable

Example:

Device> enable

Enables privileged EXEC mode.

Enter your password, if prompted.

Step 2

configure terminal

Example:

Device# configure terminal

Enters global configuration mode.

Step 3

router ospf process-id [vrf vrf-name]

Example:

Device(config)# router ospf 15

Enables OSPF routing and enters router configuration mode.

  • process-id : The process ID is an internally used identification parameter that is locally assigned. Each OSPF process has a unique process ID.

    Process ID can be a positive integer from 1 to 65535.

  • vrf: Indicates that the OSPF process is being configured for a specific VRF.

  • vrf-name : Specifies the name of the VRF for which this OSPF process is being created.

Step 4

summary-address address-mask

Example:

Device(config-router)# summary-address 10.1.1.1

(Optional) Specifies an address and IP subnet mask for redistributed routes so that only one summary route is advertised.

Step 5

area area-id virtual-link router-id [hello-interval-seconds] [retransmit-interval-seconds] [trans] [authentication-key key] | message-digest-key keyid md5 key]]

Example:

Device(config-router)# area 2 virtual-link 192.168.255.1 hello-interval 5

(Optional) Define an area as a stub area. The no-summary keyword prevents an ABR from sending summary link advertisements into the stub area.

Step 6

area area-id nssa [no-redistribution] [default-information-originate] [no-summary]

Example:

Device(config-router)# area 1 nssa default-information originate

(Optional) Establishes a virtual link and set its parameters.

Step 7

default-information originate [always] [metric metric-value] [metric-type type-value] [router-map map-name

Example:

Device(config-router)# default information originate metric 100 metric-type 1

(Optional) Forces the ASBR to generate a default route into the OSPF routing domain. Parameters are all optional.

Step 8

ip ospf name-lookup

Example:

Device(config-router)# ip ospf name-lookup

(Optional) Configures DNS name lookup. The default is disabled.

Step 9

auto-cost reference-bandwidth ref-bw

Example:

Device(config-router)# auto-cost reference-bandwidth ref-bw

(Optional) Specifies the reference bandwidth in Mbps, and is used to automatically calculate the OSPF interface cost. Auto-cost is calculated using ref-bw/interface-bw.

  • The default ref-bw is 100 Mbps. The range is from 1 to 4294967.

  • The interface-bw is based on the interface's operating speed, and is set using the bandwidth x command in interface configuration mode.

Step 10

distance ospf {[inter-area dist1] [inter-area dist2] [external dist3]}

Example:


Device(config)# distance ospf inter-area 150

(Optional) Changes the OSPF distance values. The default distance for each type of route is 110. The range is 1 to 255.

Step 11

passive-interface type number

Example:


Device(config)# passive-interface gigabitethernet 1/0/6

(Optional) Suppresses the sending of hello packets through the specified interface.

Step 12

timers throttle spf spf-delay spf-holdtime spf-wait

Example:


Device(config)# timers throttle spf 200 100 100

(Optional) Configures route calculation timers.

  • spf-delay —Delay between receiving a change to SPF calculation. The range is from 1 to 600000 miliseconds.

  • spf-holdtime —Delay between first and second SPF calculation. The range is from 1 to 600000 in milliseconds.

  • spf-wait —Maximum wait time in milliseconds for SPF calculations. The range is from 1 to 600000 in milliseconds.

Step 13

ospf log-adj-changes

Example:


Device(config)# ospf log-adj-changes

(Optional) Sends syslog message when a neighbor state changes.

Step 14

end

Example:


Device(config)# end

Returns to privileged EXEC mode.

Step 15

show ip ospf [process-id [area-id]] database

Example:


Device# show ip ospf database

Displays lists of information related to the OSPF database for a specific router.

Step 16

copy running-config startup-config

Example:

Device# copy running-config startup-config

(Optional) Saves your entries in the configuration file.