BGP minilab
This is a small lab environment to run the configuration examples from
my book:
Installing the minilab
Install the minilab on your own computer as follows:
Network topology used in the examples
Running the minilab
- Start Docker
- Start the command line:
- terminal (Mac)
- shell or xterm (Linux)
- Powershell (Windows)
- make the minilab folder/directory your current directory
You can then use the following scripts:
-
./start.sh or .\start.ps1:
starts the virtual routers and loads the configurations to run a lab
Arguments:
-
lab (mandatory): name of the lab you want to run
-
lab number (optional): if the lab has several variations, specify a number
(or name)
-
detach (optional): don't connect to the default router after the lab is started
-
keeprunning (optional): after logging out of the default router, the lab keeps running
-
connectrouter.sh or connectrouter.ps1:
connects to an already running virtual router
Arguments:
-
router (optional): the router to connect to.
If not supplied, a list of running routers will be shown.
-
router command: run the OS-level command on the specified router
-
router command arguments: run the FRR command with the supplied arguments on the specified router
-
stoprouters.sh or stoprouters.ps1:
stops all running virtual routers
Examples, Mac/Linux:
./start.sh noconverge
./start.sh example 1
./start.sh example keeprunning 1
./start.sh example 1 detach
./connectrouter.sh Router82
./connectrouter.sh 82 bash
./connectrouter.sh 82 show ip bgp summary
./stoprouters.sh
Examples, Windows:
.\start.ps1 noconverge
.\start.ps1 example 1
.\start.ps1 example keeprunning 1
.\start.ps1 example 1 detach
.\connectrouter.ps1 Router82
.\connectrouter.ps1 82 bash
.\connectrouter.ps1 82 show ip bgp summary
.\stoprouters.ps1
The "noconverge" lab is a BGP setup with four routers with
policies such that BGP never converges. Type
show ip bgp
every two seconds or so and you see how the BGP table keeps changing.
Creating labs
To create your own labs, do the following:
-
Create a directory, for instance "lab".
-
In that directory, create a file "settings.txt". In addition to extra settings
explained below, this file needs to have a line starting with "default routers"
and then the names/numbers of the routers that are part of the lab.
-
In the lab directory, create subdirectories for all the routers that are part
of the lab, where the subdirectory name matches the names in the settings file.
-
Copy all the configuration files for each router to its subdirectory. Don't
forget the "daemons" file and edit it to start the required routing daemons.
-
Copy the vlans.sh file to each router directory and edit it to create the
VLANs you need for that router.
The routers will have VLAN subinterfaces so they can communicate
with each other if they have a VLAN in common.
-
If you want the virtual routers to be able to connect to the real internet
outside their container, remove the last line of the vlans.sh file, which
removes the default route upon startup.
This is an example of a settings.txt file with all of the
settings that are supported.
# default settings (need to go on top!)
#
# routers to start as part of the lab
default routers 10 20 30 40 83 82
#
# which router to connect to on startup
# empty means the lab runs in detached mode
default attach 82
#
# text displayed on lab startup
default txt Hi!
#
# Below are the Docker image settings. These overrule
# the same settings in the start script, so they are
# normally not required.
#
# docker image to use
default dockerimage frrouting/frr:v8.3.1
#
# location of configs in Docker image
default configdir /etc/frr
#
# extra commands to run in the container at startup
default startup
(Note that comments are only possible at the beginnen of a line!)
Variations
If you want to have variations of the same lab, create a directory "0"
inside the main lab directory and move everything to that 0 directory.
You can now make a copy of the 0 directory, perhaps naming it "1".
Then, run the "1" variant of the lab as follows:
./start.sh lab 1
If you save your configurations, those go inside sub-lab 1. You can then
make a copy of 1 and make further changes to the copy and so on.
If a variation needs settings that are different from the default settings,
add them to the settings.txt file:
# variant 1
1 routers 10 20 30 40 83 90 95 96 82
1 attach 90
1 txt This is lab 1.
If some routers have the same configuration in all or most variants of the
lab, you can remove the directories of those routers from the variant
directory, and the version in the "0" directory will be used instead.
This is indicated by (router) at startup.
This way you can change the configuration in 0 and all the variants will
inherit that change.
An advantage of using the 0 configurations is that if you start a new variant
of the lab while another is already running, only routers actually present in
that variant will be restarted.
This is indicated by {router} at startup.
See the "example" lab for how all of this works.
Run them with:
.\start.ps1 example 1
...
./start.sh example 5
HyperV won't start under Windows on a Mac
This is a misleading error message.
See here
for the solution.
Version: 1.0 2022-11-09