Lab Objective
Enable Segment Routing on an OSPF network, assign a unique Prefix-SID to each router's loopback address, verify segment IDs are advertised via OSPF extensions rather than a separate label distribution protocol, and confirm traffic forwards using SR labels end to end.
Lab Purpose
Traditional MPLS label distribution, not covered in depth in this series, typically requires a separate protocol like LDP running alongside the IGP purely to distribute labels. Segment Routing eliminates this entirely by piggybacking label information directly onto OSPF's own link-state advertisements, so no separate label distribution protocol is needed at all.
Lab Topology
R1 ---- R2 ---- R3
R1 Loopback0: 1.1.1.1/32
R2 Loopback0: 2.2.2.2/32
R3 Loopback0: 3.3.3.3/32
OSPF already running across all links,
area 0Task 1: Enable Segment Routing for OSPF
Enable the Segment Routing MPLS feature within the OSPF process on all three routers.
Task 2: Assign a Prefix-SID to Each Router's Loopback
Configure a unique, globally significant Prefix-SID index for each router's loopback interface.
Task 3: Verify SR Is Advertised via OSPF
Confirm the OSPF database now carries segment routing information without any LDP configuration present.
Task 4: Verify the SR Label Forwarding Table
Examine R1's MPLS forwarding table and confirm labels derived from the configured Prefix-SIDs are populated.
Task 5: Verify End-to-End Label-Switched Connectivity
Confirm traffic from R1 to R3's loopback is forwarded using MPLS labels rather than plain IP lookups.
Solution and Verification
R1(config)# router ospf 1
R1(config-router)# segment-routing mpls
R2(config)# router ospf 1
R2(config-router)# segment-routing mpls
R3(config)# router ospf 1
R3(config-router)# segment-routing mplsR1(config)# interface loopback0
R1(config-if)# ip address 1.1.1.1 255.255.255.255
R1(config-if)# ip ospf network point-to-point
R1(config)# segment-routing mpls
R1(config-sr-mpls)# connected-prefix-sid-map
R1(config-sr-mpls-conn)# address-family ipv4
R1(config-sr-mpls-conn-af)# 1.1.1.1/32 index 1
R2 configured similarly with index 2 for 2.2.2.2/32
R3 configured similarly with index 3 for 3.3.3.3/32R1# show ip ospf database opaque-area | include SR|Segment
...
Extended Prefix Opaque LSA
Prefix: 2.2.2.2/32, SID Index: 2
Prefix: 3.3.3.3/32, SID Index: 3
-- OSPF's own extended LSAs carry the SID
-- information -- confirmed with no LDP
-- process running anywhere in this topologyR1# show mpls forwarding-table
Local Outgoing Prefix Outgoing Next Hop
Label Label or Tunnel Id interface
16002 16002 2.2.2.2/32 Gi0/0 10.1.1.2
16003 16003 3.3.3.3/32 Gi0/0 10.1.1.2
-- Labels 16002 and 16003 derive directly
-- from the configured SID indices (16000
-- being the default SRGB base, plus the
-- index) -- no LDP session was ever needed
-- to populate this tableR1# traceroute mpls ipv4 3.3.3.3/32
Type escape sequence to abort.
Tracing MPLS Label Switched Path...
0 10.1.1.1 MRU 1500 [Labels: 16003 Exp: 0]
L 1 10.1.1.2 MRU 1500 [Labels: implicit-null Exp: 0] 8 ms
L 2 10.2.2.2 8 ms
-- Confirms the path from R1 to R3's
-- loopback is genuinely label-switched
-- across the entire topology, using
-- exactly the labels derived from the
-- Prefix-SID assignmentsKey Takeaway
Segment Routing's core simplification is architectural: rather than running a separate label distribution protocol (LDP) alongside the IGP, SR extends the IGP itself (OSPF or IS-IS) to carry label information directly within its existing link-state advertisements — eliminating an entire protocol and its associated adjacency/synchronization concerns while still achieving the same MPLS label-switched forwarding behavior end to end.