Running BGP on a Linux server with BIRD Routing Daemon

Running BGP on a Linux server with BIRD Routing Daemon

In this post I will be quickly running through the basic setup and configuration of BIRD, an open-source routing protocol daemon for Unix-like systems with an amusingly recursive acronym (BIRD Internet Routing Daemon).

While there a number of BGP implementations available to Linux users (an honorable mention to ExaBGP and Quagga), BIRD is full-featured, well-documented, and one of the most popular daemons available, and so I will be sticking with it for the time being.

Onward...


Installation & Setup

Ubuntu / Debian:

1. Add the BIRD repository:


sudo add-apt-repository ppa:cz.nic-labs/bird

2. Install BIRD:


apt-get install bird

RHEL / Centos:

1. Add the YUM repository by creating the file /etc/yum.repos.d/bird.repo


[bird]
name=Network.CZ Repository
baseurl=ftp://repo.network.cz/pub/bird/centos/7/x86_64/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-network.cz

2. Download the repository GPG key:


curl ftp://bird.network.cz/pub/bird/redhat/RPM-GPG-KEY-network.cz -o /etc/pki/rpm-gpg/RPM-GPG-KEY-network.cz

3. Install BIRD:


yum install bird

Configuration

Once installed, you will want to make some standard changes to the default configuration file (/etc/bird/bird.conf). The file is very well-commented, and all protocol configurations are commented out by default, to be used as references. Some typical changes you may wish to make could be:

1. Enable logging:


log syslog { debug, trace, info, remote, warning, error, auth, fatal, bug };
log stderr all;

2. Set Router ID:


router id x.x.x.x;

3. Configure kernel synchronization:


protocol kernel {
#       learn;                  # Learn all alien routes from the kernel
        persist;                # Don't remove routes on bird shutdown
        scan time 20;           # Scan kernel routing table every 20 seconds
#       import none;            # Default is import all
        export none;            # Default is export none
#       kernel table 5;         # Kernel table to synchronize with (default: main)
}

Ensure that the kernel export is set to none if you want to ensure that BIRD will not have any effect on the server's routing decisions

If you are exporting BGP routes back into the kernel's RIB, depending on your use-case you may also want to solidify your servers routing to ensure that BGP routes don't take preference. Add any critical routes as follows (where <INT> is your network interface device):


ip route add x.x.x.x/x dev <INT> metric 1

And to make it persistent, add to /etc/sysconfig/network-scripts/<INT>:


x.x.x.x/x dev <INT> metric 1

Building a BGP Neighborship

Like everything else so far, BGP is also configured in /etc/bird/bird.conf. Here is an example BGP neighbor configuration:


protocol bgp {
  description "BIRD BGP CONFIG";
  local as <AS>;
  neighbor <IP> as <AS>;
  multihop;
  rr client;
  graceful restart;
  import all;
  export all;
}

Restart Service

Once you are happy with your configuration file, save the file and restart / enable the service:


systemctl restart bird
systemctl enable bird


Using the BIRD CLI Client

BIRD comes with a very Cisco-esque terminal interface, which is extremely easy to pick up. You can enter the CLI client by running birdc as root:

From here, the interface supports tab-completion, classic "?" queries, and a "show" command style language:

Alternatively, you can prepend any BIRD commands with "birdc" and run them straight from bash, which is needed for scripting

You can verify your BGP session establishment from here:

As you can see here, we have a full-table BGP session to our neighbor, as configured earlier, and we can look through our BIRD RIB accordingly:


In 2020, I hope to be doing some more work with BIRD, but that's about as far into it I will be going right now.

Thanks for reading, and Happy New Year!

Related Article