Thursday, May 14, 2026

Complete Cisco IOS XR Segment Routing MPLS Configuration Guide Using OSPF and BGP Labeled Unicast

Complete Cisco IOS XR Segment Routing MPLS with OSPF and BGP Labeled Unicast Configuration Guide

Complete Cisco IOS XR Segment Routing MPLS with OSPF and BGP Labeled Unicast Configuration Guide

Segment Routing is one of the most important modern networking technologies used in enterprise backbones, service provider networks, cloud infrastructure, and large-scale MPLS deployments.

In this complete educational lab guide, we will configure:

  • OSPF Segment Routing MPLS
  • Prefix SID allocation
  • SRGB configuration
  • BGP labeled-unicast
  • Inter-AS Segment Routing
  • Redistribution between BGP and OSPF
  • Static routes for label forwarding
  • Route policies for SID allocation
  • End-to-end labeled connectivity

๐ŸŽฏ What You Will Learn

  • What Segment Routing MPLS is
  • How SR-MPLS works
  • What Prefix SID means
  • How SRGB operates
  • OSPF Segment Routing concepts
  • BGP labeled-unicast configuration
  • Inter-AS MPLS forwarding
  • IOS XR route policies
  • MPLS label mathematics
  • Verification and troubleshooting

1. Introduction to Segment Routing

Segment Routing simplifies MPLS deployments by removing the dependency on protocols such as:

  • LDP
  • RSVP-TE

Instead of dynamically distributing labels using LDP, Segment Routing uses globally known Segment Identifiers called SIDs.

Every router receives a unique SID.

Traffic forwarding happens based on MPLS labels directly associated with prefixes.

Segment Routing Formula

$$ Path = SID_1 + SID_2 + SID_3 $$

Where:

  • \(SID_1\) = First segment
  • \(SID_2\) = Intermediate segment
  • \(SID_3\) = Final destination

2. Understanding SR-MPLS

SR-MPLS stands for Segment Routing Multiprotocol Label Switching.

Instead of signaling labels dynamically, SR-MPLS uses:

  • OSPF
  • IS-IS
  • BGP

to advertise SIDs.

Each Prefix SID becomes an MPLS label.

Label Calculation Formula

$$ MPLS\\ Label = SRGB\\ Base + PrefixSID $$

Example:

$$ 16000 + 1 = 16001 $$

Thus:

$$ Loopback\\ SID = 16001 $$

3. Understanding SRGB

SRGB stands for Segment Routing Global Block.

This defines the MPLS label range used for Segment Routing.

Configured SRGB

segment-routing global-block 16000 23999

This means:

  • First label = 16000
  • Last label = 23999

SRGB Size Formula

$$ SRGB\\ Size = Last\\ Label - First\\ Label + 1 $$

Therefore:

$$ 23999 - 16000 + 1 = 8000 $$

4. Prefix SID Explained

Prefix SID identifies a router prefix uniquely.

Each loopback receives a Prefix SID index.

Example:

prefix-sid index 1

Combined with SRGB:

$$ 16000 + 1 = 16001 $$

Thus Loopback0 of XR1 receives MPLS label 16001.

Router SID Index Resulting Label
XR1 1 16001
XR2 2 16002
XR3 3 16003
XR4 4 16004
XR5 5 16005

5. Network Topology


         AS 100                    AS 200

   XR1 -------- XR2 ---------- XR3 -------- XR4 -------- XR5

XR2 and XR3 operate as ASBRs between AS 100 and AS 200.

Segment Routing labels are exchanged using BGP labeled-unicast.

6. XR1 and XR2 Configuration

XR1 Configuration

XR1 operates as the ingress Segment Routing router inside AS 100.

Code Example

segment-routing global-block 16000 23999

XR1

hostname XR1

interface gig0/0/0/0
 ip address 192.1.12.1 255.255.255.0
 no shut
!

interface loopback0
 ip address 10.1.1.1 255.255.255.255
!

segment-routing global-block 16000 23999
!

router ospf 1
 router-id 10.1.1.1
 segment-routing mpls

 area 0

  interface gig0/0/0/0
  exit

  interface loopback0
   prefix-sid index 1
  exit

 exit
exit

commit

Detailed XR1 Explanation

The command:

segment-routing mpls

enables SR-MPLS inside OSPF.

The loopback interface receives:

prefix-sid index 1

This allocates SID label:

$$ 16000 + 1 = 16001 $$

XR2 Configuration


XR2

hostname XR2

Interface gig0/0/0/0
 ip address 192.1.12.2 255.255.255.0
 no shut
!

Interface gig0/0/0/1
 ip address 192.1.23.2 255.255.255.0
 no shut
!

Interface loopback0
 ip address 10.1.1.2 255.255.255.255
!

segment-routing global-block 16000 23999
!

router ospf 1
 router-id 10.1.1.2
 segment-routing mpls

 area 0

  interface gig0/0/0/0
  exit

  interface gig0/0/0/1
  exit

  interface loopback0
   prefix-sid index 2
  exit

 exit
exit

commit

XR2 Prefix SID Mathematics

$$ 16000 + 2 = 16002 $$

Thus:

$$ Loopback\\ Label = 16002 $$

7. XR3 XR4 XR5 Configuration

XR3 Configuration


XR3

hostname XR3

Interface gig0/0/0/1
 ip address 192.1.34.3 255.255.255.0
 no shut
!

Interface loopback0
 ip address 10.1.1.3 255.255.255.255
!

segment-routing global-block 16000 23999
!

router ospf 1
 router-id 10.1.1.3
 segment-routing mpls

 area 0

  interface gig0/0/0/1
  exit

  interface loopback0
   prefix-sid index 3
  exit

 exit
exit

commit

XR4 Configuration


XR4

hostname XR4

Interface gig0/0/0/0
 ip address 192.1.34.4 255.255.255.0
 no shut
!

Interface gig0/0/0/1
 ip address 192.1.45.4 255.255.255.0
 no shut
!

Interface loopback0
 ip address 10.1.1.4 255.255.255.255
!

segment-routing global-block 16000 23999
!

router ospf 1
 router-id 10.1.1.4
 segment-routing mpls

 area 0

  interface gig0/0/0/0
  exit

  interface gig0/0/0/1
  exit

  interface loopback0
   prefix-sid index 4
  exit

 exit
exit

commit

XR5 Configuration


XR5

hostname XR5

Interface gig0/0/0/0
 ip address 192.1.45.5 255.255.255.0
 no shut
!

Interface loopback0
 ip address 10.1.1.5 255.255.255.255
!

segment-routing global-block 16000 23999
!

router ospf 1
 router-id 10.1.1.5
 segment-routing mpls

 area 0

  interface gig0/0/0/0
  exit

  interface loopback0
   prefix-sid index 5
  exit

 exit
exit

commit

8. Configure External Link Between XR2 and XR3

XR2 and XR3 operate as ASBRs between:

  • AS 100
  • AS 200

XR2

Interface gig0/0/0/1
 ip address 192.1.23.2 255.255.255.0
 no shut
!

commit

XR3

Interface gig0/0/0/0
 ip address 192.1.23.3 255.255.255.0
 no shut
!

commit

Why This Link Matters

This inter-AS link transports:

  • BGP labeled routes
  • MPLS labels
  • Segment Routing information

9. Route Policy Configuration

Route policies define:

  • Label allocation
  • BGP route handling
  • Prefix SID assignment

XR2 Route Policies


XR2

route-policy PASSALL
 pass
end-policy

commit

route-policy SID($SID)
 set label-index $SID
 pass
end-policy

commit

Understanding Label Index

$$ Label = SRGB + LabelIndex $$

Example:

$$ 16000 + 2 = 16002 $$

10. Static Route Configuration

Static routes are required between ASBRs for labeled forwarding.


XR2

router static
 address-family ipv4 unicast
  192.1.23.3/32 gig0/0/0/1
 exit
!

commit

XR3

router static
 address-family ipv4 unicast
  192.1.23.2/32 gig0/0/0/0
 exit
!

commit

Why Static Routes Are Needed

Labeled-unicast requires next-hop reachability.

These static routes ensure:

  • MPLS forwarding works
  • Labels are exchanged correctly
  • BGP LU sessions remain operational

11. Configure BGP Labeled Unicast

XR2 BGP Configuration


XR2

router bgp 100

 address-family ipv4 unicast

  network 10.1.1.1/32 route-policy SID(1)
  network 10.1.1.2/32 route-policy SID(2)

  allocate-label all

 exit

 neighbor 192.1.23.3

  remote-as 200

  address-family ipv4 labeled-unicast

   route-policy PASSALL out
   route-policy PASSALL in

  exit

 exit
exit

commit

XR3 BGP Configuration


XR3

router bgp 200

 address-family ipv4 unicast

  network 10.1.1.3/32 route-policy SID(3)
  network 10.1.1.4/32 route-policy SID(4)
  network 10.1.1.5/32 route-policy SID(5)

  allocate-label all

 exit

 neighbor 192.1.23.2

  remote-as 100

  address-family ipv4 labeled-unicast

   route-policy PASSALL out
   route-policy PASSALL in

  exit

 exit
exit

commit

Label Allocation Formula

$$ Allocated\\ Label = SRGB + PrefixSID $$

For XR5:

$$ 16000 + 5 = 16005 $$

12. Redistribute BGP into OSPF

XR2 Redistribution


router ospf 1
 redistribute bgp 100
exit

commit

XR3 Redistribution


router ospf 1
 redistribute bgp 200
exit

commit

Redistribution ensures:

  • Inter-AS reachability
  • Loopback propagation
  • Label advertisement continuity

13. Verification Commands

Verify OSPF Neighbors

show ospf neighbor

Verify Segment Routing Labels

show segment-routing mpls forwarding

Verify MPLS Forwarding Table

show mpls forwarding

Verify BGP Labeled Unicast

show bgp ipv4 labeled-unicast summary

Verify Connectivity

ping 10.1.1.5 source loopback0
Expected Output Example

XR1#show mpls forwarding

Local Label  Outgoing Label  Prefix
16005        Pop Label       10.1.1.5/32

14. Troubleshooting Segment Routing MPLS

Problem Cause Solution
No MPLS labels Segment routing disabled Enable SR MPLS
BGP labeled-unicast down Neighbor issue Verify BGP adjacency
No Prefix SID SID not configured Add prefix-sid index
No inter-AS reachability Missing static route Add interface static route
OSPF routes missing Redistribution absent Redistribute BGP into OSPF

๐Ÿ’ก Important Verification Note

In Eve-NG environments, XR2 and XR3 may require reload after configuration.

This initializes BGP Segment Routing labels correctly.

15. Segment Routing Mathematics and Deep Theory

Label Stack Formula

$$ Label\\ Stack = SID_1 + SID_2 + SID_3 + ... + SID_n $$

Path Computation Formula

$$ Shortest\\ Path = Minimum\\ Cost\\ SPF $$

OSPF calculates shortest paths using Dijkstra SPF algorithm.

MPLS Forwarding Function

$$ Forward(Packet)=Swap(Label)+Transmit $$

Traffic Engineering Logic

$$ Traffic\\ Engineering = Bandwidth + Latency + Path\\ Optimization $$

Segment Routing Scale Formula

$$ Total\\ Labels = Number\\ of\\ Prefix\\ SIDs $$

If:

$$ Routers = 500 $$

Then:

$$ Labels = 500 $$

Final Conclusion

This complete Cisco IOS XR Segment Routing MPLS tutorial demonstrated how to configure:

  • OSPF Segment Routing
  • Prefix SID allocation
  • SRGB
  • BGP labeled-unicast
  • Inter-AS label exchange
  • Static routing for labeled forwarding
  • Redistribution between BGP and OSPF

Segment Routing is rapidly replacing traditional MPLS signaling protocols because it provides:

  • Scalability
  • Simplified architecture
  • Better traffic engineering
  • Cloud-ready networking
  • Efficient MPLS operations

Mastering SR-MPLS and BGP labeled-unicast is essential for modern service provider and enterprise backbone engineers.

No comments:

Post a Comment

Featured Post

How HMT Watches Lost the Time: A Deep Dive into Disruptive Innovation Blindness in Indian Manufacturing

The Rise and Fall of HMT Watches: A Story of Brand Dominance and Disruptive Innovation Blindness The Rise and Fal...

Popular Posts