BIRD: Filters and Functions example

BIRD contains a simple programming language. There are two objects in this language: filters and functions. Filters are interpreted by BIRD core when a route is being passed between protocols and routing tables. The filter language contains control structures such as if's and switches, but it allows no loops.
BIRD supports functions, so that you don't have to repeat the same blocks of code over and over. Functions can have zero or more parameters and they can have local variables. Recursion is not allowed.

In this post we will configure an inbound filter that will set MED to a specific value for a specific ASN and also set Local Preference attribute for a specific prefix from the specific upstream ISP.

Lets set MED 50 to all routes originated in Twitter ASN 13414. Also lets set local preffor prefix 4.0.0.0/9 received via Level3. The simple and non-elegant way to do that is define the following filter:

Read more

Bird Internet Routing Daemon Configuration and Administration

Show Commands:

bird> show symbols - list of symbols (filters, protocols, tables, etc...)
bird> show protocols [all] - list of protocols [including details]
birdc> show route for “prefix/ip” [all] - list route for given prefix/ip address [including details]
birdc> show route filter “filtr” [all] - list routes according given filter [including details]
birdc> show route where bgp_path ~ [= * 1234 * =] - list routes with given bgp path
birdc> show route where 127.0.0.5 ~ net - the same as “for prefix” (?)
birdc> show route filter { if 10.100.1.0 ~ net then accept; } - debug filter
birdc> show route where bgp_path.last = 15685 routes with origin 15685
birdc> show route tableT1 where bgp_path ~[ =* 701 *=] all count - list a number of routes that go via Verizon
birdc> show route table T1 all filter { if ( 701 ~ bgp_path ) then accept; reject } count - does the same thing as the previous command
birdc> show route table T1 where bgp_path_first = 2828 && bgp_path.len = 2 all count - list a number of routes originating in XO and have AS-PATH length 2
birdc> show route export EDGE_R1 -  equivalent of show route advertising-protocol bgp in junos. 'EDGE_R1' is a name of the bgp group in bird conf
birdc> show route table T1 primary count - show only best routes

Read more