# SR BGP Data Center (eBGP)

Load **sr.data.center.ebgp.init.cfg**

```
configure
load bootflash:sr.data.center.ebgp.init.cfg
commit replace
y
```

<figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FlkWOiA9XNcIiEbeaGvth%2Fimage.png?alt=media&#x26;token=5307bc1c-d5ad-4420-9910-8d712e41ef44" alt=""><figcaption></figcaption></figure>



A VRF is already setup on R1 and R2. Configure an underlay data center fabric using only eBGP with SR MPLS. Each router should belong to ASN 6500X, where X is the router number. Enable multipathing so R1 and R2 have ECMP paths between each other.











































## Answer <a href="#id-2be62428-ca22-4a6e-9527-2103caddb125" id="id-2be62428-ca22-4a6e-9527-2103caddb125"></a>

```
#All routers
segment-routing
 global-block 16000 23999
!
route-policy SET_PREFIX_SID($SID)
 set label-index $SID
end-policy
!
route-policy PASS
 pass
end-policy

#R1
router static add ipv4 unicast
 10.1.3.3/32 gi0/0/0/3
!
router bgp 65001
 bgp bestpath as-path multipath-relax
 add ipv4 uni
  maximum-paths ebgp 4
  allocate-label all
  network 1.1.1.1/32 route-policy SET_PREFIX_SID(1)
 !
 neighbor 10.1.3.3
  remote-as 65003
  add ipv4 labeled-unicast
   route-policy PASS in
   route-policy PASS out

#R2
router static add ipv4 unicast
 10.2.4.4/32 gi0/0/0/4
!
router bgp 65002
 bgp bestpath as-path multipath-relax
 add ipv4 uni
  maximum-paths ebgp 4
  allocate-label all
  network 2.2.2.1/32 route-policy SET_PREFIX_SID(2)
 !
 neighbor 10.2.4.4
  remote-as 65004
  add ipv4 labeled-unicast
   route-policy PASS in
   route-policy PASS out

#R3
router static add ipv4 unicast
 10.1.3.1/32 gi0/0/0/1
 10.3.5.5/32 gi0/0/0/5
 10.3.6.6/32 gi0/0/0/6
!
router bgp 65003
 bgp bestpath as-path multipath-relax
 add ipv4 uni
  maximum-paths ebgp 4
  allocate-label all
  network 3.3.3.1/32 route-policy SET_PREFIX_SID(3)
 !
 neighbor 10.1.3.1
  remote-as 65001
  add ipv4 labeled-unicast
   route-policy PASS in
   route-policy PASS out
 neighbor 10.3.5.5
  remote-as 65005
  add ipv4 labeled-unicast
   route-policy PASS in
   route-policy PASS out
 neighbor 10.3.6.6
  remote-as 65006
  add ipv4 labeled-unicast
   route-policy PASS in
   route-policy PASS out

#R4
router static add ipv4 unicast
 10.2.4.2/32 gi0/0/0/2
 10.4.5.5/32 gi0/0/0/5
 10.4.6.6/32 gi0/0/0/6
!
router bgp 65004
 bgp bestpath as-path multipath-relax
 add ipv4 uni
  maximum-paths ebgp 4
  allocate-label all
  network 4.4.4.1/32 route-policy SET_PREFIX_SID(4)
 !
 neighbor 10.2.4.2
  remote-as 65002
  add ipv4 labeled-unicast
   route-policy PASS in
   route-policy PASS out
 neighbor 10.4.5.5
  remote-as 65005
  add ipv4 labeled-unicast
   route-policy PASS in
   route-policy PASS out
 neighbor 10.4.6.6
  remote-as 65006
  add ipv4 labeled-unicast
   route-policy PASS in
   route-policy PASS out

#R5
router static add ipv4 unicast
 10.3.5.3/32 gi0/0/0/3
 10.4.5.4/32 gi0/0/0/4
!
router bgp 65005
 bgp bestpath as-path multipath-relax
 add ipv4 uni
  maximum-paths ebgp 4
  allocate-label all
  network 5.5.5.1/32 route-policy SET_PREFIX_SID(5)
 !
 neighbor 10.4.5.4
  remote-as 65004
  add ipv4 labeled-unicast
   route-policy PASS in
   route-policy PASS out
 neighbor 10.3.5.3
  remote-as 65003
  add ipv4 labeled-unicast
   route-policy PASS in
   route-policy PASS out

#R6
router static add ipv4 unicast
 10.3.6.3/32 gi0/0/0/3
 10.4.6.4/32 gi0/0/0/4
!
router bgp 65006
 bgp bestpath as-path multipath-relax
 add ipv4 uni
  maximum-paths ebgp 4
  allocate-label all
  network 6.6.6.1/32 route-policy SET_PREFIX_SID(6)
 !
 neighbor 10.4.6.4
  remote-as 65004
  add ipv4 labeled-unicast
   route-policy PASS in
   route-policy PASS out
 neighbor 10.3.6.3
  remote-as 65003
  add ipv4 labeled-unicast
   route-policy PASS in
   route-policy PASS out
```



## Explanation <a href="#e8ce0e10-3568-456c-a1c1-05f8d10ebd03" id="e8ce0e10-3568-456c-a1c1-05f8d10ebd03"></a>

While Clos fabrics will probably not be on the CCIE-SP, it is still good practice to get a feel for how BGP would work as an underlay protocol.



First, because we are using BGP SR, we must define the SRGB globally on each router. This allows the router to use the prefix SID attribute and locally allocate a corresponding label from the SRGB.

```
segment-routing
 global-block 16000 23999
```



Next, each router must define each peer as a /32 route in the RIB. This is needed internally in the router in order to resolve labeled nexthops.

```
router static add ipv4 unicast
 10.1.2.1/32 gi0/0/0/0
```



Each router must inject its loopback with a prefix-SID labeled index value. Strictly speaking, the spine layers don’t need to do this, but it is usually done in practice so that you can use SR policies to preform TE.

```
route-policy SET_PREFIX_SID($SID)
 set label-index $SID
end-policy
!
router bgp 65001
 add ipv4 uni
  allocate-label all
  network 1.1.1.1/32 route-policy SET_PREFIX_SID(1)
```



Next, each router peers with its directly connected neighbors over an eBGP session.

```
#R1
router bgp 65001
 neighbor 10.1.3.3
  remote-as 65003
  add ipv4 labeled-unicast
   route-policy PASS in
   route-policy PASS out
```



Finally, we enable eBGP multipath. Strictly speaking, only the spines R3 and R4 will have multiple paths. However, it doesn’t hurt to add this to all routers. In order to preform ECMP on paths for which the AS path content does not match exactly, we enable the **as-path multipath-relax** feature.

```
router bgp 65001
 bgp bestpath as-path multipath-relax
 add ipv4 uni
  maximum-paths ebgp 4
```



## Verification <a href="#id-12bf610c-bf21-49b8-a78e-744153c85866" id="id-12bf610c-bf21-49b8-a78e-744153c85866"></a>

Each router should see every other router’s loopback1 in the BGP IPv4/LU table. The nexthop for each route is always the peer’s address on the directly connected subnet since we are using eBGP.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FPvne3o97DcFO61wqqtTg%2Fimage.png?alt=media&#x26;token=7816c9a7-6b53-4fb7-aea8-a034339ed394" alt=""><figcaption></figcaption></figure></div>



Each prefix has a prefix SID index value associated with it. The attribute is optional transitive, so it is automatically carried across eBGP sessions. Note that this is _not_ an extcommunity, so you do not need to send-community with the eBGP neighbors. This is a path attribute.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F2hQdHcFW7RmuzVmZPZMA%2Fimage.png?alt=media&#x26;token=ed51deab-edd0-435f-9d89-5e8282c3ee87" alt=""><figcaption></figcaption></figure></div>



Since the SRGB is the same on all routers, each LFIB should have 1600X entries for all loopbacks:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FEgNgC46fYJcP6oOx1CQe%2Fimage.png?alt=media&#x26;token=8adc1e4b-72b5-4e0c-9fd1-3eed3d6830a1" alt=""><figcaption></figcaption></figure></div>



An end-to-end LSP is achieved between R1 and R2 using a global label:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FgcFDlq75oZDRU8SKZh7k%2Fimage.png?alt=media&#x26;token=7d1aa74e-1bcb-4572-95b4-5522881ad424" alt=""><figcaption></figcaption></figure></div>



Using a multipath OAM traceroute we can see that there are indeed multiple paths being used between R1 and R2:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F9KUTNMk328XTA1k9Vmcm%2Fimage.png?alt=media&#x26;token=0e2d82f4-672b-4bd1-bce0-64f0d6d3d6b1" alt=""><figcaption></figcaption></figure></div>



CE101 and CE102 can reach each other:

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FjtJdcxd18Ud1ZX59Qtdl%2Fimage.png?alt=media&#x26;token=1aed0d09-7779-46f5-83c5-08269afd7b1b" alt=""><figcaption></figcaption></figure></div>



### Summary <a href="#id-42787e6c-9da3-4524-b8c8-110c18e659b6" id="id-42787e6c-9da3-4524-b8c8-110c18e659b6"></a>

eBGP in the data center is a fairly simple design. eBGP somewhat takes the place of LDP as a hop-by-hop label signaling protocol.

* Each router has its own ASN
* eBGP default rules mean that all prefixes are advertised to all neighbors, and next-hop-self is automatically used
* You must create a static /32 entry so that the labels can be resolved in CEF
* ECMP requires the use of **as-path multipath-relax** since every node has a different ASN
* You may want to tune the advertisement-interval to 0 since it will be 30 seconds by default. Otherwise you may see significant convergence delays.
