Configure Segment Routing for OSPF Protocol

Open Shortest Path First (OSPF) is an Interior Gateway Protocol (IGP) developed by the OSPF working group of the Internet Engineering Task Force (IETF). Designed expressly for IP networks, OSPF supports IP subnetting and tagging of externally derived routing information. OSPF also allows packet authentication and uses IP multicast when sending and receiving packets.

This module provides the configuration information to enable segment routing for OSPF.

Enabling Segment Routing for OSPF Protocol

Segment routing on the OSPF control plane supports the following:

  • OSPFv2 control plane

  • Multi-area

  • IPv4 prefix SIDs for host prefixes on loopback interfaces

  • Adjacency SIDs for adjacencies

  • MPLS penultimate hop popping (PHP) and explicit-null signaling

This section describes how to enable segment routing MPLS and MPLS forwarding in OSPF. Segment routing can be configured at the instance, area, or interface level.

Before you begin

Your network must support the MPLS Cisco IOS XR software feature before you enable segment routing for OSPF on your router.


Note


You must enter the commands in the following task list on every OSPF router in the traffic-engineered portion of your network.


SUMMARY STEPS

  1. configure
  2. router ospf process-name
  3. segment-routing mpls
  4. segment-routing sr-prefer
  5. area 0
  6. segment-routing mpls
  7. exit
  8. Use the commit or end command.

DETAILED STEPS

  Command or Action Purpose

Step 1

configure

Example:


RP/0/RP0/CPU0:router# configure

Enters mode.

Step 2

router ospf process-name

Example:


RP/0/RP0/CPU0:router(config)# router ospf 1

Enables OSPF routing for the specified routing process and places the router in router configuration mode.

Step 3

segment-routing mpls

Example:

RP/0/RP0/CPU0:router(config-ospf)# segment-routing mpls

Enables segment routing using the MPLS data plane on the routing process and all areas and interfaces in the routing process.

Enables segment routing fowarding on all interfaces in the routing process and installs the SIDs received by OSPF in the forwarding table.

Step 4

segment-routing sr-prefer

Example:

RP/0/RP0/CPU0:router(config-ospf)# segment-routing sr-prefer

Sets the preference of segment routing (SR) labels over label distribution protocol (LDP) labels.

Step 5

area 0

Example:

RP/0/RP0/CPU0:router(config-ospf)# area 0

Enters area configuration mode.

Step 6

segment-routing mpls

Example:

RP/0/RP0/CPU0:router(config-ospf-ar)# segment-routing mpls

(Optional) Enables segment routing using the MPLS data plane on the area and all interfaces in the area. Enables segment routing fowarding on all interfaces in the area and installs the SIDs received by OSPF in the forwarding table.

Step 7

exit

Example:


RP/0/RP0/CPU0:router(config-ospf-ar)# exit
RP/0/RP0/CPU0:router(config-ospf)# exit

Step 8

Use the commit or end command.

commit —Saves the configuration changes and remains within the configuration session.

end —Prompts user to take one of these actions:
  • Yes — Saves configuration changes and exits the configuration session.

  • No —Exits the configuration session without committing the configuration changes.

  • Cancel —Remains in the configuration session, without committing the configuration changes.

What to do next

Configure the prefix SID.

Configuring a Prefix-SID on the OSPF-Enabled Loopback Interface

A prefix segment identifier (SID) is associated with an IP prefix. The prefix SID is manually configured from the segment routing global block (SRGB) range of labels. A prefix SID is configured under the loopback interface with the loopback address of the node as the prefix. The prefix segment steers the traffic along the shortest path to its destination.

A prefix SID can be a node SID or an Anycast SID. A node SID is a type of prefix SID that identifies a specific node. An Anycast SID is a type of prefix SID that identifies a set of nodes, and is configured with n-flag clear. The set of nodes (Anycast group) is configured to advertise a shared prefix address and prefix SID. Anycast routing enables the steering of traffic toward multiple advertising nodes. Packets addressed to an Anycast address are forwarded to the topologically nearest nodes.

The prefix SID is globally unique within the segment routing domain.

This task describes how to configure prefix segment identifier (SID) index or absolute value on the OSPF-enabled Loopback interface.

Before you begin

Ensure that segment routing is enabled on an instance, area, or interface.

SUMMARY STEPS

  1. configure
  2. router ospf process-name
  3. area value
  4. interface Loopback interface-instance
  5. prefix-sid {index SID-index | absolute SID-value } [n-flag-clear ] [explicit-null]
  6. Use the commit or end command.

DETAILED STEPS

  Command or Action Purpose

Step 1

configure

Example:


RP/0/RP0/CPU0:router# configure

Enters mode.

Step 2

router ospf process-name

Example:


RP/0/RP0/CPU0:router(config)# router ospf 1

Enables OSPF routing for the specified routing process, and places the router in router configuration mode.

Step 3

area value

Example:


RP/0/RP0/CPU0:router(config-ospf)# area 0

Enters area configuration mode.

Step 4

interface Loopback interface-instance

Example:


RP/0/RP0/CPU0:router(config-ospf-ar)# interface Loopback0 passive

Specifies the loopback interface and instance.

Step 5

prefix-sid {index SID-index | absolute SID-value } [n-flag-clear ] [explicit-null]

Example:


RP/0/RP0/CPU0:router(config-ospf-ar)# prefix-sid index 1001

RP/0/RP0/CPU0:router(config-ospf-ar)# prefix-sid absolute 17001

Configures the prefix-SID index or absolute value for the interface.

Specify index SID-index for each node to create a prefix SID based on the lower boundary of the SRGB + the index.

Specify absolute SID-value for each node to create a specific prefix SID within the SRGB.

By default, the n-flag is set on the prefix-SID, indicating that it is a node SID. For specific prefix-SID (for example, Anycast prefix-SID), enter the n-flag-clear keyword. OSPF does not set the N flag in the prefix-SID sub Type Length Value (TLV).

To disable penultimate-hop-popping (PHP) and add an explicit-Null label, enter the explicit-null keyword. OSPF sets the E flag in the prefix-SID sub TLV.

Step 6

Use the commit or end command.

commit —Saves the configuration changes and remains within the configuration session.

end —Prompts user to take one of these actions:
  • Yes — Saves configuration changes and exits the configuration session.

  • No —Exits the configuration session without committing the configuration changes.

  • Cancel —Remains in the configuration session, without committing the configuration changes.

Verify the prefix-SID configuration:

RP/0/RP0/CPU0:router# show ospf database opaque-area 7.0.0.1 self-originate
 OSPF Router with ID (10.0.0.1) (Process ID 1)
                Type-10 Opaque Link Area Link States (Area 0)
<...>
    Extended Prefix TLV: Length: 20
      Route-type: 1
      AF        : 0
      Flags     : 0x40
      Prefix    : 10.0.0.1/32

      SID sub-TLV: Length: 8
        Flags     : 0x0
        MTID      : 0
        Algo      : 0
        SID Index : 1001