Configuring OSPF in BIRD

In this article, I will give an example of configuring OSPF in BIRD.

Command to install BIRD in Ubuntu:

sudo -i
apt install bird

Let’s set up the logs as I described in the article:
Setting up BIRD logs

Open the configuration file in any text editor:

nano /etc/bird/bird.conf

Specify the router ID globally, usually this is the IP address that we look to other OSFP neighbors, if not specified globally, then a random IP address will be selected on the interface, in the protocol ospf, protocol bgp, etc. sections. if necessary, you can additionally specify individual router ids if there are many network interfaces with different IP addresses:

router id 192.168.31.201;

Set up a protocol that will track interface events, up/down (depending on the number of interfaces and CPU load at that moment, you can adjust the scan period in seconds, I specified 100, this is more than usual, since I take a server with accel-ipoe as an example with more than 10,000 network interfaces):

protocol device {
    scan time 100;
}

Set up a protocol that will generate routes to all specified interfaces:

protocol direct {
	interface "vlan*", "ipoe*";
}

Set up a protocol that will synchronize BIRD routes with kernel routes (by default, import all, export none):

protocol kernel {
	      import all;
	      export all;
}

If necessary, configure a protocol that allows you to manually add the specified static routes:

protocol static {
	route x.x.x.0/23 blackhole;
#	route 10.0.0.0/8 unreachable;
#	route 10.5.0.0/24 via "eth0";
}

When importing and exporting routes, it is advisable to use filters to avoid unforeseen situations and import and export only what you need, below are some examples of filters.

The first example is to export routes with a netmask of 32, for example for a server with accel-ppp:

filter export_OSPF {
        if net.len = 32 then {
#                print "net accepted:", net;
                accept;
        }
 else{
#  print "net rejected:", net;
         reject;
 }
}

Similar import filter:

filter import_OSPF {
        if net.len = 32 then {
#                print "net accepted:", net;
                accept;
        }
 else{
#  print "net rejected:", net;
         reject;
 }
}

Another example of a filter that accepts only specified networks:

filter ixnfo_com
prefix set localnet;
{
localnet = [ 10.5.0.0/24+, X.X.X.0/23+ ];
if net ~ localnet  then accept;
reject;
}

Now let’s configure the OSPF protocol, in which we specify filters, OSPF neighbors, a network interface towards neighbors, and other parameters:

protocol ospf {
#router id 192.168.x.x;
 export filter export_OSPF;
 import none;
 area 0.0.0.0 {
  interface "vlan777" {
   hello 10;
   retransmit 5;
   cost 10;
   transmit delay 1;
   dead count 4;
   wait 40;
   type broadcast;
   priority 1;
   authentication none;
   #authentication cryptographic; password "ixnfo.com";

   neighbors {
   #192.168.5.100 eligible;
   192.168.5.100;
                      };
  };
 };
}

Restart bird to apply configuration changes:

systemctl restart bird.service
systemctl status bird.service
service bird status

Let’s check if bird starts when the operating system starts up and activate autorun:

systemctl is-enabled bird.service
systemctl enable bird.service

Let’s connect to the bird console, see statistics and connection with OSPF neighbors:

birdc
show status
show protocols all
show route
show route all
show ospf
show ospf neighbors
show ospf topology
exit

DR (Designated Router) – the router with the highest priority, when the priorities are equal, then the one with the highest router-id is selected.
BDR (Backup Designated Router) is the next router with the highest priority after DR.

If there are a lot of routes, then we export the kernel routes to a text file and see them there and make sure that everything is fine:

ip route > ixnfo.com.txt

You can monitor the number of routes, for example, using Zabbix:

route -n | wc -l

You can run birdc commands directly from the Linux terminal, for example:

birdc show ospf interface
birdc show ospf interface | wc -l

See also my articles:
Configuring OSPF in Quagga
Configuring OSPF on Juniper MX
Installing and configuring BIRD (BGP)

Leave a comment

Leave a Reply