Sending BGP routes using ExaBGP
Hey all,
Recently i came across a problem statement where i wanted to send some good amount of routes via BGP.
While hunting, i came across ExaBGP.
ExaBGP is an open-source software project designed to enable the integration of BGP (Border Gateway Protocol) into various applications and systems.
so, in this post i will try to explain how i am using it.
Topology
If you have gone through my last post on segment routing with Arista, i used a 3 router topology, here i integrated ExaBGP container in the same topology. ExaBGP is spawned in container-lab as an container.
ExaBGP(eth1)---(eth5) R1----R2-----R3
ExaBGP has a docker container format, which u can pull from docker registry, but for me when i was trying to integrate with container-lab it was not working, hence i looked how i can make a container myself which can be used in container-lab.
ExaBGP container :
Create folder named exa-image.
create a file named Dockerfile inside it,with below content
run the docker build command to create the docker image.
dshaw@dshaw-pc:~/exa-image$ ls -lrt
total 4
-rw-rw-r-- 1 dshaw dshaw 203 Feb 14 18:15 Dockerfile
dshaw@dshaw-pc:~/exa-image$ cat Dockerfile
FROM ubuntu:20.04
# Install dependencies
RUN apt update
RUN apt install python3-pip net-tools wget mrtparse vim nano -y && \
rm -rf /var/lib/apt/lists/* && apt clean
RUN pip install exabgp==4.2.17
verify the docker image here.
dshaw@dshaw-pc:~/exa-image$ docker images | grep exa
exa_new latest 1b3aec26feef 4 weeks ago 486MB
Container-lab topology :
dshaw@dshaw-pc:~/arsta-seg$ cat topo.yaml
name: arsta-seg
topology:
nodes:
R1:
kind: ceos
image: ceos:4.31.2F
R2:
kind: ceos
image: ceos:4.31.2F
R3:
kind: ceos
image: ceos:4.31.2F
exa1:
kind: linux
image: exa_new:latest
binds:
- exa1:/home
links:
- endpoints: ["R1:eth1", "R2:eth1"]
- endpoints: ["R2:eth2", "R3:eth2"]
- endpoints: ["R1:eth3", "R3:eth3"]
- endpoints: ["R1:eth5", "exa1:eth1"]
the bind command here is basically mounting the content of exa1 folder into the docker, in /home directory. Below are the content of the Exa1 directory.
dshaw@dshaw-pc:~/arsta-seg/exa1$ ls -lrt
-rwxrwxr-x 1 dshaw dshaw 46 Feb 14 23:19 deploy.sh
-rw-rw-r-- 1 dshaw dshaw 370 Feb 15 00:06 ebgp-code.conf
-rw-rw-r-- 1 dshaw dshaw 220 Feb 15 00:10 route_gen.py
File1: deploy.sh
its optional, i am using it to configure the interface connected to R1. You can simply run the ifconfig command within the ExaBGP container after spinning up the topology
dshaw@dshaw-pc:~/arsta-seg/exa1$ cat deploy.sh
ifconfig eth1 191.0.0.2 netmask 255.255.255.0
File2 : route_gen.py
its a python program that basically controls route generation, you can change the program to generate more routes. I used range 1 to 20, which will generate 19 routes. 10.0.0.1,10.0.0.2 .... like this.
领英推荐
dshaw@dshaw-pc:~/arsta-seg/exa1$ cat route_gen.py
#!/usr/bin/env python
import sys
import time
for item in range(1,20):
sys.stdout.write(f'announce route 10.0.0.{item}/32 next-hop 191.0.0.2\n')
sys.stdout.flush()
time.sleep(.01)
while True:
time.sleep(1)
File3 : ebgp-code.conf
This file defines the BGP part, and calls the above python program for route generation.
dshaw@dshaw-pc:~/arsta-seg/exa1$ cat ebgp-code.conf
process gen_routes {
run ./usr/bin/python3 /home/route_gen.py;
encoder text;
}
template {
neighbor leaf1 {
local-as 101;
peer-as 100;
router-id 191.0.0.2;
local-address 191.0.0.2;
api {
processes [ gen_routes ];
}
}
}
neighbor 191.0.0.1 {
inherit leaf1;
}
R1 configuration :
here on R1, i am configuring eth5 looking towards ExaBGP container & the required BGP config. I have some left over config from my last lab, hence marked the required ExaBGP things with --->> ExaBGP<<--- marker.
R1#show run int eth5
interface Ethernet5 --->> ExaBGP<<---
no switchport --->> ExaBGP<<---
ip address 191.0.0.1/24 --->> ExaBGP<<---
R1#show run sec bgp
router bgp 100
router-id 1.1.1.1
neighbor R3 peer group
neighbor R3 remote-as 100
neighbor R3 next-hop-self
neighbor R3 update-source Loopback0
neighbor exa peer group --->> ExaBGP<<---
neighbor exa remote-as 101 --->> ExaBGP<<---
neighbor v6 peer group
neighbor v6 remote-as 100
neighbor v6 update-source Loopback0
neighbor 3.3.3.3 peer group R3
neighbor 191.0.0.2 peer group exa --->> ExaBGP<<---
neighbor 9000::3 peer group v6
!
address-family ipv4
neighbor 3.3.3.3 activate
neighbor 191.0.0.2 activate --->> ExaBGP<<---
network 5.10.0.0/24
!
address-family ipv6
neighbor 9000::3 activate
network 5001::/64
Starting ExaBGP program:
command1 is to go into the docker container.
command2 and 3 are showing whats mounted.
Command4 starts ExaBGP program.
dshaw@dshaw-pc:~/arsta-seg/exa1$ docker exec -it clab-arsta-seg-exa1 bash
root@exa1:/# cd home/
root@exa1:/home# ls -lrt
-rwxrwxr-x 1 1000 1000 46 Feb 14 17:49 deploy.sh
-rw-rw-r-- 1 1000 1000 370 Feb 14 18:36 ebgp-code.conf
-rw-rw-r-- 1 1000 1000 220 Feb 14 18:40 route_gen.py
root@exa1:/home# exabgp ebgp-code.conf
if things are fine, then BGP will come up.
18:37:25 | 60 | reactor | connected to peer-1 with outgoing-10 191.0.0.2-191.0.0.1
Validation on R1
R1#show ip bgp summary
BGP summary information for VRF default
Router identifier 1.1.1.1, local AS number 100
Neighbor Status Codes: m - Under maintenance
Neighbor V AS MsgRcvd MsgSent InQ OutQ Up/Down State PfxRcd PfxAcc
3.3.3.3 4 100 255 263 0 0 00:44:58 Estab 1 1
191.0.0.2 4 101 45 53 0 0 00:41:34 Estab 19 19
R1#show ip route bgp interface ethernet 5
B E 10.0.0.1/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.2/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.3/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.4/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.5/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.6/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.7/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.8/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.9/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.10/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.11/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.12/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.13/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.14/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.15/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.16/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.17/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.18/32 [200/0]
via 191.0.0.2, Ethernet5
B E 10.0.0.19/32 [200/0]
via 191.0.0.2, Ethernet5
so we are receiving the routes from ExaBGP container.
lets go to R3, to see if we are receiving them
R3#show ip route 10.0.0.19/32
B I 10.0.0.19/32 [200/0]
via 1.1.1.1/32, IS-IS SR tunnel index 3
via 1.23.1.2, Ethernet2, label 900041
Yes, i am receiving them on R3.
thanks for reading , hope it helps.
While trying to make the ExaBGP container, i faced some issue, but this blog from Julio helped a lot
Solutions Architect at Cisco ? Innovator ? CCIE#49883 R&S/Enterprise & SP ? DevNet500 ? SDWAN ? ACI
11 个月Additionally, you can use BIRD, which supports IPv6 as well as more features
On mission to deliver affordable DDoS protection
11 个月Can recommended playing with GoBGP instead. Way more pleasant experience