Building a Scalable BGP Lab with Containerlab and FRRouting

In this guide we’ll build a mini ISP-style BGP lab that scales cleanly from a handful of routers to hundreds or thousands — without going insane managing configs by hand.

We’ll use:

  • Containerlab for wiring the topology
  • FRRouting (FRR) containers for control-plane
  • A small Python generator to spit out:
    • Per-node frr.conf
    • Per-node daemons
    • A lab.clab.yml topology file

The example here uses 5 core routers and 10 edge routers, but you can turn that into 1000+ edges by changing a single variable.

1. Prerequisites

You’ll need:

  • A Linux host (bare metal or VM)
  • Docker installed and running
  • Containerlab installed
  • Python 3.8+

Docker (if not installed)

curl -fsSL https://get.docker.com | sh

Containerlab

bash -c “$(curl -sL https://get.containerlab.dev)”

2. What We’re Building

Topology design:

  • Core routers: r1, r2, r3, r4, r5
  • Edges: edge001edge010 (easily scalable)
  • All cores run iBGP in AS 65000
  • Edges are eBGP neighbors with their assigned core:
    • Each edge gets a unique ASN: 65101+
  • r1 and r2 act as route reflectors
  • Each edge has:
    • A loopback (100.64.x.y/32)
    • A /30 link to its core (10.1.0.0/30, 10.1.0.4/30, etc.)

All configs + topology are generated automatically into a single directory: lab_bgp/.

3. Generate the lab file
https://github.com/usrfrann/Networking-Scripts/blob/master/lab_generator_script.py

4. Deploy the Lab with Containerlab

From inside lab_bgp/:

cd lab_bgp
containerlab deploy -t lab.clab.yml

Containerlab will:

  • Pull frrouting/frr:latest
  • Start all core + edge containers
  • Mount each node’s frr.conf + daemons
  • Wire the eth interfaces according to the links we generated

5. Verify BGP Is Running

Check a core router

docker exec -it clab-bgp-scale-lab-r1 vtysh

Inside vtysh:

r1# show bgp summary

You should NOT see bgpd is not running.

You should see:

  • Established iBGP sessions to other cores (via loopbacks)
  • Established eBGP sessions to the edges mapped to r1

Check an edge router

docker exec -it clab-bgp-scale-lab-edge001 vtysh

Then:

edge001# show bgp summary
edge001# show ip bgp

You should see:

  • eBGP session to its core
  • Its loopback route advertised
  • Reflected/learned prefixes from the rest of the “network”

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *