# SRv6 uSID w/ EVPN-VPWS and BGP IPv4/IPv6

Load **top1.vpnv4v6.srv6.configured.cfg**

```
#IOS-XR
configure
load top1.vpnv4v6.srv6.usid.services.init.cfg
commit replace
y

#IOS-XE
config replace flash:top1.vpnv4v6.srv6.usid.services.init.cfg
```

SRv6 uSID is already preconfigured in the core.

Configure an EVPN-VPWS service between CSR1 and CSR3 using SRv6 as the underlay.

* CSR1 is configured for 10.0.0.1/24 on Gi2.3311
* CSR3 is configured for 10.0.0.3/24 on Gi2.3333
* This will not work in the data plane on XRd

Configure BGP IPv4/IPv6 in the global table between CSR2 and CSR4 also using SRv6 as the underlay.

* The BGP peerings are already setup in the global table

## Answer <a href="#id-5761a4b3-a9eb-4376-884c-c6565dac0dca" id="id-5761a4b3-a9eb-4376-884c-c6565dac0dca"></a>

```
#XR5
evpn
 segment-routing srv6
  locator CCIE
!
l2vpn
 xconnect group VPWS
  p2p CUSTOMER
   interface GigabitEthernet0/0/0/0.3311
   neighbor evpn evi 100 service 100 segment-routing srv6
 
#XR7
evpn
 segment-routing srv6
  locator CCIE
!
l2vpn
 xconnect group VPWS
  p2p CUSTOMER
   interface GigabitEthernet0/0/0/0.3333
   neighbor evpn evi 100 service 100 segment-routing srv6

#XR6, XR8
router bgp 100
 segment-routing srv6
  locator CCIE
 !
 address-family ipv4 unicast
  segment-routing srv6
   alloc mode per-vrf
 !
 address-family ipv6 unicast
  segment-routing srv6
   alloc mode per-vrf
 !
 neighbor-group RR
  address-family ipv4 unicast
   next-hop-self
   encapsulation-type srv6
  !
  address-family ipv6 unicast
   next-hop-self
   encapsulation-type srv6
```

## Explanation <a href="#id-58cac120-853f-412b-9c5e-c917b9c15684" id="id-58cac120-853f-412b-9c5e-c917b9c15684"></a>

SRv6 can be used as the data plane for EVPN-VPWS and global IPv4/IPv6 unicast. It does not appear to be supported for bridged EVPN. But bridge-domains are not configurable on XRv9K anyways.

For EVPN-VPWS, we must do two things. First, we configure the locator that EVPN will use:

```
evpn
 segment-routing srv6
  locator CCIE
```

Next, we configure the encapsulation as SRv6 on the xconnect:

```
l2vpn
 xconnect group VPWS
  p2p CUSTOMER
   neighbor evpn evi 100 service 100 segment-routing srv6
```

Alternatively, we can specify the locator on the individual p2p xconnect. However, we still must activate SRv6 under EVPN:

```
evpn
 segment-routing srv6
!
l2vpn
 xconnect group VPWS
  p2p CUSTOMER
   neighbor evpn evi 100 service 100 segment-routing srv6 locator CCIE
```

The SID advertisement works the same as we have seen with L3VPN. The SID is advertised within a Prefix SID Sub TLV. The label field contains the function bits.

<div align="left"><figure><img src="/files/lDkwilKFirWlsnn0qp77" alt=""><figcaption></figcaption></figure></div>

The PE installs this ::/64 SID into the FIB with a uDX2 instruction, which means to decapsulate and cross-connect for a layer 2 service.

<div align="left"><figure><img src="/files/AksLsIeuM2qYzRklsgvg" alt=""><figcaption></figcaption></figure></div>

Note that on XRv9K, this L2 service works in the data plane. However, on XRd, it seems that the node cannot do vlan rewrite operations, so this is not working in the data plane.

Next, we configure BGP IPv4/IPv6 unicast in the global VRF for SRv6. This is just like 6PE, in which global IPv6 unicast is tunneled across an MPLS core by advertising a service label with the ipv6/unicast prefix. To configure this, we first need to fix an issue. The PEs are not setting next-hop-self on the routes. This causes the RRs to not select these prefixes as best because the nexthop is inaccessible. When these were VRF routes, the PE automatically sets next-hop-self for the VPNv4/v6 route, as the PE is technically the router originating the VPN route.

<div align="left"><figure><img src="/files/IvjVdEbL2q9PDTzNvdG9" alt=""><figcaption></figcaption></figure></div>

We fix this by setting next-hop-self:

```
#XR6, XR8
router bgp 100
 neighbor-group RR
  address-family ipv4 unicast
   next-hop-self
  !
  address-family ipv6 unicast
   next-hop-self
```

Next, we enable SRv6 for BGP the same as we did for L3VPN. We can also configure the locator to be used by default:

```
#XR6, XR8
router bgp 100
 segment-routing srv6
  locator CCIE
```

We must do two other things. We must set the SRv6 alloc mode under the global AFIs, and we must set the encapsulation type as SRv6 under the iBGP neighbor statements.

```
#XR6, XR8
router bgp 100
 address-family ipv4 unicast
  segment-routing srv6
   alloc mode per-vrf
 !
 address-family ipv6 unicast
  segment-routing srv6
   alloc mode per-vrf
 !
 neighbor-group RR
  address-family ipv4 unicast
   encapsulation-type srv6
  !
  address-family ipv6 unicast
   encapsulation-type srv6
```

Now the global prefixes have a SID associated with them. The difference with global IPv4/IPv6 unicast is that BGP-LU is not used, so there is no label field to place the function bits inside. This is just an optimization to better pack BGP updates, so it is not a major drawback.

<div align="left"><figure><img src="/files/kF1PNcjPm39ZnmW99fUT" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="/files/WGJLPs1faqJQQIhTOd42" alt=""><figcaption></figcaption></figure></div>

Traffic between the two pairs of CEs should now be working:

<div align="left"><figure><img src="/files/qOFKojZSoC0NRr5BpPQc" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="/files/yCArOdTeKtqUVYcMFWdT" alt=""><figcaption></figcaption></figure></div>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ccie-sp.gitbook.io/ccie-spv5.1-labs/labs/srv6/srv6-usid-w-evpn-vpws-and-bgp-ipv4-ipv6.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
