Cisco device configuration tutorials and networking fundamentals
Cisco configuration tutorials
Jump to section:
Segment Routing (SR) is a source-based routing method that uses extensions to OSPF and IS-IS to advertise Segment IDs (SID). An SID uniquely identifies a router or a link in an SR domain. An SID can be a Prefix SID which is unique in an SR domain, or it can be an Adjacency SID which is locally significant to a router. Segment Routing is an MPLS control plane technology that can replace LDP and RSVP to signal prefix-to-label bindings.
The benefit of SR is that it can connect two PE routers within an MPLS core network without the complexity and periodic keepalive messages required by LDP and RSVP. SR does not change the data plane operation of the MPLS core network. This means, MPLS label switching, the label push, pop and swap operations, and the logic of the Label Forwarding Information Base (LFIB) are the same with SR, LDP and RSVP.
SR changes the way MPLS labels are assigned to IP prefixes, and how these labels (Segment IDs) are communicated between devices in the MPLS core network. A Prefix SID is configured on an MPLS-enabled router and advertised using the IGP. An ingress PE receives the Prefix SID value and the loopback IP of the egress PE. The Prefix SID indicates the MPLS label that should be assigned to an outgoing packet.
SR uses a specific label range for its operation. The label range is called the Segment Routing Global Block (SRGB), and it is independent from the one used by LDP or RSVP. On Cisco devices the default SRGB is between 16000 and 23999. When tracing a route from an ingress PE router to an egress PE router, the following example output can be seen.
R1#trace 6.6.6.6 pr 1 Type escape sequence to abort. Tracing the route to 6.6.6.6 VRF info: (vrf in name/id, vrf out name/id) 1 10.1.0.1 [MPLS: Label 16006 Exp 0] 4 msec 2 10.2.0.2 [MPLS: Label 16006 Exp 0] 5 msec 3 10.3.0.2 [MPLS: Label 16006 Exp 0] 4 msec 4 10.4.0.2 [MPLS: Label 16006 Exp 0] 4 msec 5 10.5.0.2 4 msec
This indicates that the egress PE advertised the Prefix SID value 6. The value 6 is an offset value. Each router in the SR domain uses the same SRGB (labels between 16000 - 23999). The offset value 6 is calculated from the starting point of 16000. Thus, when the ingress PE R1 receives the IP 6.6.6.6 with the Prefix SID value 6, it will calculate and assign the MPLS label 16000 + 6 (16006) to reach IP 6.6.6.6. Each router in the SR domain comes to the same conclusion, and for this reason the same MPLS label is visible in the above traceroute.
In the following example scenario, SR is enabled for the OSPF area 0 on all routers. Each router has its own Node SID, which uniquely represents that device in the SR domain. The Node SID is configured as an Index value on each router. The Index value works together with the SRGB. There is a default SRGB range starting at 16000. Index 1 means the MPLS label 16001 is assigned. Index 2 is 16002. Thus, the Index value represents an offset to the start of the SRGB.
Configuration:
R1#show run int Gi1 | sec int interface GigabitEthernet1 description ** to R2 ** ip address 10.1.0.2 255.255.255.252 ip ospf network point-to-point negotiation auto no mop enabled no mop sysid R1#show run int Lo10 | sec int interface Loopback10 ip address 1.1.1.1 255.255.255.255 R1#show run | sec ^segment segment-routing mpls ! connected-prefix-sid-map address-family ipv4 1.1.1.1/32 index 1 range 1 exit-address-family ! R1#show run | sec ^router router ospf 10 router-id 1.1.1.1 segment-routing area 0 mpls segment-routing mpls network 1.1.1.1 0.0.0.0 area 0 network 10.1.0.0 0.0.0.3 area 0
R2#show run int Gi1 | sec int interface GigabitEthernet1 description ** to R1 ** ip address 10.1.0.1 255.255.255.252 ip ospf network point-to-point negotiation auto no mop enabled no mop sysid R2#show run int Gi2 | sec int interface GigabitEthernet2 description ** to R3 ** ip address 10.2.0.1 255.255.255.252 ip ospf network point-to-point negotiation auto no mop enabled no mop sysid R2#show run int Lo10 | sec int interface Loopback10 ip address 2.2.2.2 255.255.255.255 R2#show run | sec ^segment segment-routing mpls ! connected-prefix-sid-map address-family ipv4 2.2.2.2/32 index 2 range 1 exit-address-family ! R2#show run | sec ^router router ospf 10 router-id 2.2.2.2 segment-routing area 0 mpls segment-routing mpls network 2.2.2.2 0.0.0.0 area 0 network 10.1.0.0 0.0.0.3 area 0 network 10.2.0.0 0.0.0.3 area 0
R3#show run int Gi1 | sec int interface GigabitEthernet1 description ** to R2 ** ip address 10.2.0.2 255.255.255.252 ip ospf network point-to-point negotiation auto no mop enabled no mop sysid R3#show run int Gi2 | sec int interface GigabitEthernet2 description ** to R4 ** ip address 10.3.0.1 255.255.255.252 ip ospf network point-to-point negotiation auto no mop enabled no mop sysid R3#show run int Lo10 | sec int interface Loopback10 ip address 3.3.3.3 255.255.255.255 R3#show run | sec ^segment segment-routing mpls ! connected-prefix-sid-map address-family ipv4 3.3.3.3/32 index 3 range 1 exit-address-family ! R3#show run | sec ^router router ospf 10 router-id 3.3.3.3 segment-routing area 0 mpls segment-routing mpls network 3.3.3.3 0.0.0.0 area 0 network 10.2.0.0 0.0.0.3 area 0 network 10.3.0.0 0.0.0.3 area 0
R1#show mpls forwarding-table Local Outgoing Prefix Bytes Label Outgoing Next Hop Label Label or Tunnel Id Switched interface 16 Pop Label 10.1.0.1-A 0 Gi1 10.1.0.1 16002 Pop Label 2.2.2.2/32 0 Gi1 10.1.0.1 16003 16003 3.3.3.3/32 0 Gi1 10.1.0.1 16004 16004 4.4.4.4/32 0 Gi1 10.1.0.1 16005 16005 5.5.5.5/32 0 Gi1 10.1.0.1 16006 16006 6.6.6.6/32 0 Gi1 10.1.0.1 « Labels are assigned based on received Prefix SID index value A - Adjacency SID R1#show segment-routing mpls connected-prefix-sid-map ipv4 PREFIX_SID_CONN_MAP ALGO_0 Prefix/masklen SID Type Range Flags SRGB 1.1.1.1/32 1 Indx 1 Y PREFIX_SID_PROTOCOL_ADV_MAP ALGO_0 Prefix/masklen SID Type Range Flags SRGB Source 1.1.1.1/32 1 Indx 1 Y OSPF Area 0 1.1.1.1 2.2.2.2/32 2 Indx 1 Y OSPF Area 0 2.2.2.2 3.3.3.3/32 3 Indx 1 Y OSPF Area 0 3.3.3.3 4.4.4.4/32 4 Indx 1 Y OSPF Area 0 4.4.4.4 5.5.5.5/32 5 Indx 1 Y OSPF Area 0 5.5.5.5 6.6.6.6/32 6 Indx 1 Y OSPF Area 0 6.6.6.6 « Index 6 means that the label is 16006 R1#show ip ospf database opaque-area prefix 6.6.6.6/32 OSPF Router with ID (1.1.1.1) (Process ID 10) Type-10 Opaque Area Link States (Area 0) LS age: 1382 Options: (No TOS-capability, DC) LS Type: Opaque Area Link Link State ID: 7.0.0.0 Opaque Type: 7 (Extended Prefix) « Opaque LSA type-7 carrying Prefix SID Opaque ID: 0 Advertising Router: 6.6.6.6 « R6 is the advertising router, this is the OSPF router ID LS Seq Number: 80000002 Checksum: 0xD494 Length: 44 TLV Type: Extended Prefix Length: 20 Prefix : 6.6.6.6/32 « The prefix is 6.6.6.6/32 AF : 0 Route-type: Intra Flags : N-bit Sub-TLV Type: Prefix SID Length: 8 Flags : None MTID : 0 Algo : SPF SID : 6 « The prefix SID is index 6, which is MPLS label 16006 R1#show ip route ospf | beg Ga Gateway of last resort is not set 2.0.0.0/32 is subnetted, 1 subnets O 2.2.2.2 [110/2] via 10.1.0.1, 00:55:56, GigabitEthernet1 3.0.0.0/32 is subnetted, 1 subnets O 3.3.3.3 [110/3] via 10.1.0.1, 00:55:56, GigabitEthernet1 4.0.0.0/32 is subnetted, 1 subnets O 4.4.4.4 [110/4] via 10.1.0.1, 00:55:56, GigabitEthernet1 5.0.0.0/32 is subnetted, 1 subnets O 5.5.5.5 [110/5] via 10.1.0.1, 00:55:01, GigabitEthernet1 6.0.0.0/32 is subnetted, 1 subnets O 6.6.6.6 [110/6] via 10.1.0.1, 00:55:56, GigabitEthernet1 10.0.0.0/8 is variably subnetted, 6 subnets, 2 masks O 10.2.0.0/30 [110/2] via 10.1.0.1, 00:55:56, GigabitEthernet1 O 10.3.0.0/30 [110/3] via 10.1.0.1, 00:55:56, GigabitEthernet1 O 10.4.0.0/30 [110/4] via 10.1.0.1, 00:55:56, GigabitEthernet1 O 10.5.0.0/30 [110/5] via 10.1.0.1, 00:55:56, GigabitEthernet1 R1#show ip route 6.6.6.6 Routing entry for 6.6.6.6/32 Known via "ospf 10", distance 110, metric 6, type intra area Last update from 10.1.0.1 on GigabitEthernet1, 00:56:15 ago SR Incoming Label: 16006 « Segment Routing label also shows in RIB Routing Descriptor Blocks: * 10.1.0.1, from 6.6.6.6, 00:56:15 ago, via GigabitEthernet1, prefer-non-rib-labels, merge-labels Route metric is 6, traffic share count is 1 MPLS label: 16006 MPLS Flags: NSF R1#trace 6.6.6.6 pr 1 Type escape sequence to abort. Tracing the route to 6.6.6.6 VRF info: (vrf in name/id, vrf out name/id) 1 10.1.0.1 [MPLS: Label 16006 Exp 0] 4 msec « The label is assigned at each hop 2 10.2.0.2 [MPLS: Label 16006 Exp 0] 4 msec 3 10.3.0.2 [MPLS: Label 16006 Exp 0] 3 msec 4 10.4.0.2 [MPLS: Label 16006 Exp 0] 2 msec 5 10.5.0.2 4 msec
As visible in the above outputs, R6 has the Prefix SID Index 6 configured. This translates to MPLS label 16006 on all routers, because the SRGB range starts with 16000. All other routers in the OSPF area install the label that is advertised by R6. As a result, the same label is visible throughout the entire traceroute.
In this example scenario, each router has the same SRGB by default, which is the range 16000 - 23999. So when a router receives an index of 6, they locally do the translation to 16000 + 6, and install the MPLS label 16006. The default SRGB range values can change between routers, for example different vendors may have a different default SRGB range.
In this example topology, SR is configured with OSPF using IOS-XR. Each router is assigned a Node SID based on its Loopback IP address. The Node SID is advertised through the OSPF SR extension with the LSA type-7. Thus, each router can assign an MPLS label to all other routers in the network.
Configuration:
RP/0/0/CPU0:R1#show run | beg hostname
Tue Jan 9 15:44:36.384 UTC
Building configuration...
hostname R1
domain lookup disable
line console
escape-character 0x51
!
interface Loopback10
ipv4 address 1.1.1.1 255.255.255.255
!
interface MgmtEth0/0/CPU0/0
shutdown
!
interface GigabitEthernet0/0/0/0
description ** to R2 **
ipv4 address 10.1.0.2 255.255.255.252
!
interface GigabitEthernet0/0/0/1
shutdown
!
interface GigabitEthernet0/0/0/2
shutdown
!
router ospf 10
router-id 1.1.1.1
address-family ipv4 unicast
area 0
segment-routing forwarding mpls
segment-routing mpls
interface Loopback10
prefix-sid index 1
loopback stub-network enable
!
interface GigabitEthernet0/0/0/0
network point-to-point
!
!
!
end
RP/0/0/CPU0:R2#show run | beg hostname
Tue Jan 9 15:46:51.433 UTC
Building configuration...
hostname R2
domain lookup disable
line console
escape-character 0x51
!
interface Loopback10
ipv4 address 2.2.2.2 255.255.255.255
!
interface MgmtEth0/0/CPU0/0
shutdown
!
interface GigabitEthernet0/0/0/0
description ** to R3 **
ipv4 address 10.2.0.1 255.255.255.252
!
interface GigabitEthernet0/0/0/1
description ** to R1 **
ipv4 address 10.1.0.1 255.255.255.252
!
interface GigabitEthernet0/0/0/2
shutdown
!
router ospf 10
router-id 2.2.2.2
address-family ipv4 unicast
area 0
segment-routing forwarding mpls
segment-routing mpls
interface Loopback10
prefix-sid index 2
loopback stub-network enable
!
interface GigabitEthernet0/0/0/0
network point-to-point
!
interface GigabitEthernet0/0/0/1
network point-to-point
!
!
!
end
RP/0/0/CPU0:R3#show run | beg hostname
Tue Jan 9 15:47:15.601 UTC
Building configuration...
hostname R3
domain lookup disable
line console
escape-character 0x51
!
interface Loopback10
ipv4 address 3.3.3.3 255.255.255.255
!
interface MgmtEth0/0/CPU0/0
shutdown
!
interface GigabitEthernet0/0/0/0
description ** to R2 **
ipv4 address 10.2.0.2 255.255.255.252
!
interface GigabitEthernet0/0/0/1
description ** to R4 **
ipv4 address 10.3.0.1 255.255.255.252
!
interface GigabitEthernet0/0/0/2
shutdown
!
router ospf 10
router-id 3.3.3.3
address-family ipv4 unicast
area 0
segment-routing forwarding mpls
segment-routing mpls
interface Loopback10
prefix-sid index 3
loopback stub-network enable
!
interface GigabitEthernet0/0/0/0
network point-to-point
!
interface GigabitEthernet0/0/0/1
network point-to-point
!
!
!
end
RP/0/0/CPU0:R1#show mpls forwarding Tue Jan 9 15:52:59.060 UTC Local Outgoing Prefix Outgoing Next Hop Bytes Label Label or ID Interface Switched ------ ----------- ------------------ ------------ --------------- ------------ 16002 Pop SR Pfx (idx 2) Gi0/0/0/0 10.1.0.1 0 16003 16003 SR Pfx (idx 3) Gi0/0/0/0 10.1.0.1 544 16004 16004 SR Pfx (idx 4) Gi0/0/0/0 10.1.0.1 0 16005 16005 SR Pfx (idx 5) Gi0/0/0/0 10.1.0.1 0 16006 16006 SR Pfx (idx 6) Gi0/0/0/0 10.1.0.1 31040 « MPLS forwarding table contains Segment Routing labels 24000 Pop SR Adj (idx 0) Gi0/0/0/0 10.1.0.1 0 RP/0/0/CPU0:R1#show ospF database opaque-area 6.6.6.6/32 Tue Jan 9 15:55:00.972 UTC OSPF Router with ID (1.1.1.1) (Process ID 10) Type-10 Opaque Link Area Link States (Area 0) LS age: 1778 Options: (No TOS-capability, DC) LS Type: Opaque Area Link Link State ID: 7.0.0.1 Opaque Type: 7 « OSPF Opaque LSA type-7 advertises Prefix SID Opaque ID: 1 Advertising Router: 6.6.6.6 LS Seq Number: 80000001 Checksum: 0xcc9c Length: 44 Extended Prefix TLV: Length: 20 Route-type: 1 AF : 0 Flags : 0x40 Prefix : 6.6.6.6/32 « /32 Node Prefix SID is advertised by R6 SID sub-TLV: Length: 8 Flags : 0x0 MTID : 0 Algo : 0 SID Index : 6 « An index value 6 is added to the SRGB RP/0/0/CPU0:R1#show ip route 6.6.6.6 Wed Jan 10 13:16:27.937 UTC Routing entry for 6.6.6.6/32 Known via "ospf 10", distance 110, metric 6, labeled SR, type intra area « Information about SR included in RIB Installed Jan 10 13:16:08.709 for 00:00:19 Routing Descriptor Blocks 10.1.0.1, from 6.6.6.6, via GigabitEthernet0/0/0/0 Route metric is 6 No advertising protos. RP/0/0/CPU0:R1#trace 6.6.6.6 pr 1 Tue Jan 9 15:55:20.590 UTC Type escape sequence to abort. Tracing the route to 6.6.6.6 1 10.1.0.1 [MPLS: Label 16006 Exp 0] 9 msec « Traffic is sent label switched with SR label 2 10.2.0.2 [MPLS: Label 16006 Exp 0] 0 msec 3 10.3.0.2 [MPLS: Label 16006 Exp 0] 0 msec 4 10.4.0.2 [MPLS: Label 16006 Exp 0] 0 msec 5 10.5.0.2 19 msec
In IOS XR the following configurations achieve the same result. This is due to configuration inheritance. Namely, if the configuration is applied at the OSPF instance level, then the OSPF area 0 inherits that configuration. However, the same configuration can also be applied to the OSPF area only, then it takes effect only in that single area.
At the OSPF instance level | At the OSPF area level |
---|---|
RP/0/0/CPU0:R1#show run router ospf Tue Jan 9 16:08:22.107 UTC router ospf 10 router-id 1.1.1.1 segment-routing mpls segment-routing forwarding mpls address-family ipv4 unicast area 0 interface Loopback10 prefix-sid index 1 loopback stub-network enable ! interface GigabitEthernet0/0/0/0 network point-to-point ! ! ! |
RP/0/0/CPU0:R1#show run router ospf Tue Jan 9 16:06:14.056 UTC router ospf 10 router-id 1.1.1.1 address-family ipv4 unicast area 0 segment-routing forwarding mpls segment-routing mpls interface Loopback10 prefix-sid index 1 loopback stub-network enable ! interface GigabitEthernet0/0/0/0 network point-to-point ! ! ! |
The Segment Routing Global Block (SRGB) can be changed on each router, however it is best to have an identical SRGB throughout a network. In the following example the SRGB is changed on IOS XR, and this has an effect on the assigned MPLS label values.
RP/0/0/CPU0:R1#show run | begin ospf Tue Jan 9 16:17:58.347 UTC Building configuration... router ospf 10 router-id 1.1.1.1 address-family ipv4 unicast area 0 segment-routing forwarding mpls segment-routing mpls interface Loopback10 prefix-sid index 1 loopback stub-network enable ! interface GigabitEthernet0/0/0/0 network point-to-point ! ! ! segment-routing global-block 20000 20010 ! end
Now that the SRGB block is changed on every router, the index value offset is counted from 20000 upwards, as seen in the following output. The MPLS labels start from 20000. Index 0 would be 20000.
RP/0/0/CPU0:R1#show mpls forwarding
Tue Jan 9 16:20:21.468 UTC
Local Outgoing Prefix Outgoing Next Hop Bytes
Label Label or ID Interface Switched
------ ----------- ------------------ ------------ --------------- ------------
20002 Pop SR Pfx (idx 2) Gi0/0/0/0 10.1.0.1 0
20003 20003 SR Pfx (idx 3) Gi0/0/0/0 10.1.0.1 0
20004 20004 SR Pfx (idx 4) Gi0/0/0/0 10.1.0.1 0
20005 20005 SR Pfx (idx 5) Gi0/0/0/0 10.1.0.1 0
20006 20006 SR Pfx (idx 6) Gi0/0/0/0 10.1.0.1 0
24000 Pop SR Adj (idx 0) Gi0/0/0/0 10.1.0.1 0
Instead of using an index value to specify the offset from the SRGB, an absolute value can also be used to provide an exact number for the Prefix SID. The following table shows how to configure absolute SIDs in IOS XE and XR.
IOS XE | IOS XR |
---|---|
R1#show run | section ^segment segment-routing mpls ! connected-prefix-sid-map address-family ipv4 1.1.1.1/32 absolute 16010 range 1 exit-address-family ! |
RP/0/0/CPU0:R1#show run router ospf Tue Jan 9 16:32:37.337 UTC router ospf 10 router-id 1.1.1.1 address-family ipv4 unicast area 0 segment-routing forwarding mpls segment-routing mpls interface Loopback10 prefix-sid absolute 16010 loopback stub-network enable ! interface GigabitEthernet0/0/0/0 network point-to-point ! ! ! |
An Adjacency SID is a locally significant value which is automatically assigned by a router. The Adjacency SID has a role in Fast Reroute (TI-LFA), traffic engineering and load balancing. The following command can be used to view the Adjacency SID on a router.
R2#show ip ospf segment-routing adjacency-sid
OSPF Router with ID (2.2.2.2) (Process ID 10)
Flags: S - Static, D - Dynamic, P - Protected, U - Unprotected, G - Group, L - Adjacency Lost
Adj-Sid Neighbor ID Interface Neighbor Addr Flags Backup Nexthop Backup Interface
-------- --------------- ------------------ --------------- ------- --------------- ------------------
16 3.3.3.3 Gi1 10.2.0.2 D U
17 1.1.1.1 Gi2 10.1.0.2 D U
OSPF uses extensions to the routing protocol to encapsulate Segment Routing information. There are special types of Link State Update (LSU) messages advertised between OSPF neighbors to communicate details related to SR, such as the Prefix SID or Adjacency SID. The Prefix SID is encoded in the OSPF LSA type-7 as shown in the following packet capture.
The Adjacency SID is encoded in the OSPF LSA type-8, which is displayed below. The Adjacency SID is locally significant only, and is used in Segment Routing Topology Independent Loop Free Alternate (TI-LFA), which is a SR Fast Reroute mechanism.
Disclaimer: You download and use files from networkstudysite.com at your own risk.
Lab YAML file:
Packet capture:
Text files with configurations:
How to use these files:
With YAML files you can easily recreate the example labs on networkstudysite.com. Learn more in this short guide.
Explore 313 packet captures
You can find more information at the following external links:
By clicking on the links below, you are leaving the networkstudysite.com website.
Cisco - Chapter: Segment Routing With OSPFv2 Node SID
Cisco Learning Network - Introduction to Segment Routing
Cisco Community - ASR9000/XR Introduction to Segment Routing
RFC 8402 - Segment Routing Architecture
RFC 8665 - OSPF Extensions for Segment Routing
Disclaimer:
Use at your own risk: networkstudysite.com makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information found on this website. Full disclaimer on the About page.
Privacy Policy:
networkstudysite.com does not install browser cookies to collect or store your data.
Thank you for your interest in this blog post!
Looking for something else? View infographics, explore the archives or read the recommended posts below: