# SR-TE with AS Primary/Secondary Paths

Load **basic.isis.sr.vpnv4.enabled.cfg**

```
configure
load bootflash:basic.isis.sr.vpnv4.enabled.cfg
commit replace
y
```

VPNv4 is fully setup and working with CEs 101, 102, 107, 108.

Configure two SR-TE policies on R1 with R7 as the endpoint:

* Color 20 uses an explicit path via R4
* Color 10 uses a dynamic path based on TE metric

Configure R7 so that all traffic destined towards CE107 prefixes uses color 20 primarily, and falls back to color 10 if a path using color 20 cannot be calculated.

## Answer <a href="#e7d1f3ed-8047-4ecd-817d-e945d26933a6" id="e7d1f3ed-8047-4ecd-817d-e945d26933a6"></a>

```
#R1
segment-routing
 traffic-eng
  segment-list R7_VIA_R4
   index 1 address ipv4 4.4.4.1
   index 2 address ipv4 7.7.7.1
  !
  policy R7_COLOR_10
   color 10 end-point ipv4 7.7.7.1
   candidate-paths preference 100 dynamic
  !
  policy R7_COLOR_20
   color 20 end-point ipv4 7.7.7.1
   candidate-paths
    preference 100
     explicit segment-list R7_VIA_R4
!
router isis 1
 distribute link-state

#R7
extcommunity-set opaque COLOR10
  10
end-set
!
extcommunity-set opaque COLOR20
  20
end-set
!
route-policy CE107_IN
  set extcommunity color COLOR10 additive
  set extcommunity color COLOR20 additive
end-policy
!
router bgp 100
 vrf BLUE
  neighbor 192.168.107.107
   address-family ipv4 unicast
    route-policy CE107_IN in
!
router isis 1
 add ipv4 uni
  mpls traffic-eng router-id lo1
  mpls traffic-eng level-2
!
mpls traffic-eng
```

## Explanation <a href="#id-9046d18c-122a-4d8e-b2b5-933d45572078" id="id-9046d18c-122a-4d8e-b2b5-933d45572078"></a>

When BGP serivce routes contain multiple colors, the valid path with the highest color is used. This allows for primary/backup SR-TE steering. R7 can set multiple colors, and the highest color will be used by default. But if a valid SR-TE policy for that color does not exist, the next color is tried. If no valid SR-TE policies exist for any of the attached colors, the IGP path is simply used.

To set multiple colors with an RPL, we seem to require the **additive** keyword on multiple **set** lines. It does not appear you can set multiple colors in a single line.

```
#R7
extcommunity-set opaque COLOR10
  10
end-set
!
extcommunity-set opaque COLOR20
  20
end-set
!
route-policy CE107_IN
  set extcommunity color COLOR10 additive
  set extcommunity color COLOR20 additive
end-policy
```

R1 will receive the BGP service routes with multiple colors attached. Notice that SR policy color 20 is used:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FuPPrlLTzbc8VPfYhDKfr%2Fimage.png?alt=media&#x26;token=aad38bcf-dc24-4461-afca-66fe7d696d94" alt=""><figcaption></figcaption></figure></div>

We can cause the color 20 policy to become invalid by removing R4’s prefix SID from its loopback. This will cause the first SID descriptor in the segment-list to fail to be resolved to a label (4.4.4.1).

```
#R4
router isis 1
 interface Loopback1
  address-family ipv4 unicast
   no prefix-sid index 4
```

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FSeIPPlbX4Ldwfv1VnFEK%2Fimage.png?alt=media&#x26;token=8ebd63b0-ac03-4d32-8b68-32294c4fc022" alt=""><figcaption></figcaption></figure></div>

The BGP service route now uses the color 10 policy:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FZNGVnHtA9o0DT1psCTeT%2Fimage.png?alt=media&#x26;token=95b8bbaa-13c9-4600-8bbc-8ad38c003ef6" alt=""><figcaption></figcaption></figure></div>
