From 47eed50e300fcc630468b74a71a325ef8a856879 Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Sun, 4 May 2025 10:49:55 +0200 Subject: [PATCH] Add bird2 + skeleton config --- Dockerfile.bookworm | 3 ++- files/etc/bird/bird-local.conf | 1 + files/etc/bird/bird.conf | 26 ++++++++++++++++++++++++++ files/init-container.sh | 10 ++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 files/etc/bird/bird-local.conf create mode 100644 files/etc/bird/bird.conf diff --git a/Dockerfile.bookworm b/Dockerfile.bookworm index 3ce6e5d..d8f3132 100644 --- a/Dockerfile.bookworm +++ b/Dockerfile.bookworm @@ -4,7 +4,7 @@ ARG VPP_INSTALL_SKIP_SYSCTL=true ARG REPO=release EXPOSE 22/tcp RUN apt-get update && apt-get -y install curl procps tcpdump iproute2 iptables \ - iputils-ping net-tools git python3 python3-pip vim-tiny openssh-server && apt-get clean + iputils-ping net-tools git python3 python3-pip vim-tiny openssh-server bird2 && apt-get clean # Install VPP RUN mkdir -p /var/log/vpp /root/.ssh/ @@ -18,6 +18,7 @@ RUN git clone https://github.com/pimvanpelt/vppcfg.git && cd vppcfg && python3 - # Config files COPY files/etc/vpp/* /etc/vpp/ +COPY files/etc/bird/* /etc/bird/ COPY files/init-container.sh /sbin/ RUN chmod 755 /sbin/init-container.sh CMD ["/sbin/init-container.sh"] diff --git a/files/etc/bird/bird-local.conf b/files/etc/bird/bird-local.conf new file mode 100644 index 0000000..6adffc2 --- /dev/null +++ b/files/etc/bird/bird-local.conf @@ -0,0 +1 @@ +# Containerlab user overrides go in this file. diff --git a/files/etc/bird/bird.conf b/files/etc/bird/bird.conf new file mode 100644 index 0000000..46838ef --- /dev/null +++ b/files/etc/bird/bird.conf @@ -0,0 +1,26 @@ +# Bird2 configuration for VPP Containerlab + +# router id 192.0.2.0; + +timeformat base iso long; +timeformat log iso long; +timeformat protocol iso long; +timeformat route iso long; + +log "/var/log/bird/bird.log" { debug, trace, info, remote, warning, error, auth, fatal, bug }; + +protocol device { scan time 30; } + +protocol direct { ipv4; ipv6; check link yes; } + +protocol kernel kernel4 { + ipv4 { import none; export where source != RTS_DEVICE; }; + learn off; scan time 300; +} + +protocol kernel kernel6 { + ipv6 { import none; export where source != RTS_DEVICE; }; + learn off; scan time 300; +} + +include "bird-local.conf"; diff --git a/files/init-container.sh b/files/init-container.sh index ffd5c79..662f976 100755 --- a/files/init-container.sh +++ b/files/init-container.sh @@ -3,6 +3,7 @@ STARTUP_CONFIG=${STARTUP_CONFIG:="/etc/vpp/startup.conf"} CLAB_VPP_FILE=${CLAB_VPP_FILE:=/etc/vpp/clab.vpp} NETNS=${NETNS:="dataplane"} +BIRD_ENABLED=${BIRD_ENABLED:="true"} echo "Creating dataplane namespace" /usr/bin/mkdir -p /etc/netns/$NETNS @@ -14,6 +15,15 @@ sed -i -e 's,^#PermitRootLogin prohibit-password,PermitRootLogin yes,' /etc/ssh/ sed -i -e 's,^root:.*,root:$y$j9T$kG8pyZEVmwLXEtXekQCRK.$9iJxq/bEx5buni1hrC8VmvkDHRy7ZMsw9wYvwrzexID:20211::::::,' /etc/shadow /etc/init.d/ssh start +if [ "$BIRD_ENABLED" == "true" ]; then + echo "Starting Bird in $NETNS" + mkdir -p /run/bird /var/log/bird + chown bird:bird /var/log/bird + ROUTERID=$(ip -br a show eth0 | awk '{ print $3 }' | cut -f1 -d/) + sed -i -e "s,.*router id .*,router id $ROUTERID; # Set by container-init.sh," /etc/bird/bird.conf + /usr/bin/nsenter --net=/var/run/netns/$NETNS /usr/sbin/bird -u bird -g bird +fi + echo "Generating $CLAB_VPP_FILE" : > $CLAB_VPP_FILE MTU=9216