BIRD¶
We will use the BIRD Internet Routing Daemon to implement BGP routing and participate the DFZ.
Installation¶
We need to install the bird package and enable the service to be started on system boot:
rtr-pod0-1:~# apk add bird
(1/3) Installing libssh (0.11.3-r0)
(2/3) Installing bird (3.1.5-r0)
Executing bird-3.1.5-r0.pre-install
(3/3) Installing bird-openrc (3.1.5-r0)
Executing busybox-1.37.0-r30.trigger
OK: 67.8 MiB in 122 packages
rtr-pod0-1:~# rc-update add bird
* service bird added to runlevel default
Base Config¶
The BIRD configuration file is located in /etc/bird.conf. Please use the following config template for the initial configuration. At least, you need to update the values of:
- the
router id - the blackhole routes in the
pi4andpi6protocols - the loopback addresses in the
kernel4andkernel6protocols - the
local asvalue in the BGP template
Do not use for production!
This minimalistic base config must not be used in a production environment! It lacks safety and security settings for didactic reasons.
# Set router ID. It is a unique identification of your router, usually one of
# IPv4 addresses of the router. It is recommended to configure it explicitly.
router id 212.111.xxx.yyy;
# The Device protocol is not a real routing protocol. It does not generate any
# routes and it only serves as a module for getting information about network
# interfaces from the kernel. It is necessary in almost any configuration.
protocol device {
}
# These static protocols inject null routes for prefix assigned to your pod. This
# is required so that BGP sees a route that can announce to your peers.
protocol static pi4 {
ipv4 { };
# blackhole our IPv4 PI
route 212.111.xxx.yyy/26 blackhole;
}
protocol static pi6 {
ipv6 { };
# blackhole our IPv6 PI
route 2001:xxxx:yyyy::/48 blackhole;
}
# The kernel protocols will import routes from and to the kernel RIB.
protocol kernel kernel4 {
ipv4 {
import all; # import all routes
export filter {
# set preferred source IP to loopback address
krt_prefsrc = 212.111.xxx.yyy;
# export all routes
accept;
};
};
merge paths yes; # enable multipath for BGP
learn yes; # do learn (import) foreign routes
persist yes; # do not remove routes on bird shutdown
graceful restart; # deferred synchronization in case of recovery
}
protocol kernel kernel6 {
ipv6 {
import all; # Import all routes
export filter {
# set preferred source IP to loopback address
krt_prefsrc = 2001:xxxx:yyyy::0;
# export all routes
accept;
};
};
merge paths yes; # enable multipath for BGP
learn yes; # do learn (import) foreign routes
persist yes; # do not remove routes on bird shutdown
graceful restart; # deferred synchronization in case of recovery
}
# BGP filter function for the local PI networks
function net_local() -> bool {
return proto = "pi4" || proto = "pi6";
}
# BGP filter checking for BGP routes
function from_bgp() -> bool {
return source = RTS_BGP;
}
# BGP base template
template bgp tpl_bgp {
# the ASN of our pod
local as NNN;
# enable some BGP capabilities
advertise hostname yes;
enable extended messages yes;
}
Console¶
With this basic configuration BIRD can now be started:
rtr-pod0-1:~# /etc/init.d/bird start
* Starting bird ...
[ ok ]
The birdc command can be used to inspect and control the state of the BIRD routing daemon:
rtr-pod0-1:~# birdc
BIRD 3.1.5 ready.
bird> show interfaces
lo up (index=1)
MultiAccess AdminUp LinkUp Loopback Ignored MTU=65536
127.0.0.1/8 (Preferred, scope host)
::1/128 (Preferred, scope host)
eth0 down (index=2)
MultiAccess Broadcast Multicast AdminDown LinkDown MTU=1500
bird> show protocols
Name Proto Table State Since Info
kernel4 Kernel master4 up 09:52:40.337
kernel6 Kernel master6 up 09:52:40.337
device1 Device --- up 09:52:40.337
pi4 Static master4 up 09:52:40.337
pi6 Static master6 up 09:52:40.337
bird> show route
Table master4:
212.111.251.128/26 blackhole [pi4 09:52:40.337] * (200)
Table master6:
2001:67c:2fb0::/48 blackhole [pi6 09:52:40.337] * (200)
bird>
You can use the all parameter on most of the show commands to get more details. Later on, this will help to see which routes have been received and inspect routing protocol specific details:
bird> show route ?
show route [<prefix>|for <prefix>|for <ip>|in <prefix>] [table <t>] [(import|export) table <p>.<c>] [filter <f>|where <cond>] [all] [primary] [filtered] [(export|preexport|noexport) <p>] [protocol <p>] [stats|count] Show routing table
bird> show route all
Table master4:
212.111.1.0/26 blackhole [pi4 09:52:40.337] * (200)
preference: 200
source: static
Internal route handling values: 0L 4G 0S id 1
Table master6:
2001:1:2::/48 blackhole [pi6 09:52:40.337] * (200)
preference: 200
source: static
Internal route handling values: 0L 5G 0S id 1