Nothing Special   »   [go: up one dir, main page]

Bird

Download as pdf or txt
Download as pdf or txt
You are on page 1of 43

BIRD Users Guide

Ondrej Filip <feela@network.cz>, Pavel Machek <pavel@ucw.cz>, Martin Mares <mj@ucw.cz>, Ondrej Zajicek <santiago@crfreenet.org> This document contains user documentation for the BIRD Internet Routing Daemon project.

Contents
1 Introduction 1.1 What is BIRD 1.2 Installing BIRD 1.3 Running BIRD 1.4 Privileges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3 4 4 4 5 6 6 6 8 11 14 14 15 17 17 18 19 20 20 25 26 26 28 35 37 40 41

2 About routing tables 3 Conguration 3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Global options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.3 Protocol options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Remote control 5 Filters 5.1 Introduction . . . . 5.2 Data types . . . . 5.3 Operators . . . . . 5.4 Control structures 5.5 Route attributes . 5.6 Other statements . 6 Protocols 6.1 BGP . 6.2 Device 6.3 Direct 6.4 Kernel 6.5 OSPF 6.6 Pipe . 6.7 RAdv 6.8 RIP . 6.9 Static

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

. . . . . . . . .

7 Conclusions 43 7.1 Future work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 7.2 Getting more help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Chapter 1: Introduction
1.1 What is BIRD

The name BIRD is actually an acronym standing for BIRD Internet Routing Daemon. Lets take a closer look at the meaning of the name: BIRD : Well, we think we have already explained that. Its an acronym standing for BIRD Internet Routing Daemon, you remember, dont you? :-) Internet Routing : Its a program (well, a daemon, as you are going to discover in a moment) which works as a dynamic router in an Internet type network (that is, in a network running either the IPv4 or the IPv6 protocol). Routers are devices which forward packets between interconnected networks in order to allow hosts not connected directly to the same local area network to communicate with each other. They also communicate with the other routers in the Internet to discover the topology of the network which allows them to nd optimal (in terms of some metric) rules for forwarding of packets (which are called routing tables) and to adapt themselves to the changing conditions such as outages of network links, building of new connections and so on. Most of these routers are costly dedicated devices running obscure rmware which is hard to congure and not open to any changes (on the other hand, their special hardware design allows them to keep up with lots of high-speed network interfaces, better than general-purpose computer does). Fortunately, most operating systems of the UNIX family allow an ordinary computer to act as a router and forward packets belonging to the other hosts, but only according to a statically congured table. A Routing Daemon is in UNIX terminology a non-interactive program running on background which does the dynamic part of Internet routing, that is it communicates with the other routers, calculates routing tables and sends them to the OS kernel which does the actual packet forwarding. There already exist other such routing daemons: routed (RIP only), GateD (non-free), Zebra and MRTD, but their capabilities are limited and they are relatively hard to congure and maintain. BIRD is an Internet Routing Daemon designed to avoid all of these shortcomings, to support all the routing technology used in the todays Internet or planned to be used in near future and to have a clean extensible architecture allowing new routing protocols to be incorporated easily. Among other features, BIRD supports: both IPv4 and IPv6 protocols multiple routing tables the Border Gateway Protocol (BGPv4) the Routing Information Protocol (RIPv2) the Open Shortest Path First protocol (OSPFv2, OSPFv3) the Router Advertisements for IPv6 hosts a virtual protocol for exchange of routes between dierent routing tables on a single host a command-line interface allowing on-line control and inspection of status of the daemon soft reconguration (no need to use complex online commands to change the conguration, just edit the conguration le and notify BIRD to re-read it and it will smoothly switch itself to the new conguration, not disturbing routing protocols unless they are aected by the conguration changes) a powerful language for route ltering BIRD has been developed at the Faculty of Math and Physics, Charles University, Prague, Czech Republic as a student project. It can be freely distributed under the terms of the GNU General Public License. BIRD has been designed to work on all UNIX-like systems. It has been developed and tested under Linux 2.0 to 2.6, and then ported to FreeBSD, NetBSD and OpenBSD, porting to other systems (even non-UNIX ones) should be relatively easy due to its highly modular architecture. BIRD supports either IPv4 or IPv6 protocol, but have to be compiled separately for each one. Therefore, a dualstack router would run two instances of BIRD (one for IPv4 and one for IPv6), with completely separate setups (conguration les, tools ...). 3

Chapter 1. Introduction

1.2

Installing BIRD

On a recent UNIX system with GNU development tools (GCC, binutils, m4, make) and Perl, installing BIRD should be as easy as: ./configure make make install vi /usr/local/etc/bird.conf bird You can use ./configure --help to get a list of congure options. The most important ones are: --enable-ipv6 which enables building of an IPv6 version of BIRD, --with-protocols= to produce a slightly smaller BIRD executable by conguring out routing protocols you dont use, and --prefix= to install BIRD to a place dierent from. /usr/local.

1.3

Running BIRD

You can pass several command-line options to bird: -c cong name use given conguration le instead of prex /etc/bird.conf. -d enable debug messages and run bird in foreground. -D lename of debug log log debugging information to given le instead of stderr. -p just parse the cong le and exit. Return value is zero if the cong le is valid, nonzero if there are some errors. -s name of communication socket use given lename for a socket for communications with the client, default is prex /var/run/bird.ctl. -u user drop privileges and use that user ID, see the next section for details. -g group use that group ID, see the next section for details. BIRD writes messages about its work to log les or syslog (according to cong).

1.4

Privileges

BIRD, as a routing daemon, uses several privileged operations (like setting routing table and using raw sockets). Traditionally, BIRD is executed and runs with root privileges, which may be prone to security problems. The recommended way is to use a privilege restriction (options -u, -g). In that case BIRD is executed with root privileges, but it changes its user and group ID to an unprivileged ones, while using Linux capabilities to retain just required privileges (capabilities CAP NET *). Note that the control socket is created before the privileges are dropped, but the cong le is read after that. The privilege restriction is not implemented in BSD port of BIRD. A nonprivileged user (as an argument to -u options) may be the user nobody, but it is suggested to use a new dedicated user account (like bird). The similar considerations apply for the group option, but there is one more condition the users in the same group can use birdc to control BIRD. Finally, there is a possibility to use external tools to run BIRD in an environment with restricted privileges. This may need some conguration, but it is generally easy BIRD needs just the standard library, privileges to read the cong le and create the control socket and the CAP NET * capabilities.

Chapter 2: About routing tables


BIRD has one or more routing tables which may or may not be synchronized with OS kernel and which may or may not be synchronized with each other (see the Pipe protocol). Each routing table contains a list of known routes. Each route consists of: network prex this route is for (network address and prex length the number of bits forming the network part of the address; also known as a netmask) preference of this route IP address of router which told us about this route IP address of router we should forward the packets to using this route other attributes common to all routes dynamic attributes dened by protocols which may or may not be present (typically protocol metrics) Routing table maintains multiple entries for a network, but at most one entry for one network and one protocol. The entry with the highest preference is used for routing (we will call such an entry the selected route ). If there are more entries with the same preference and they are from the same protocol, the protocol decides (typically according to metrics). If they arent, an internal ordering is used to break the tie. You can get the list of route attributes in the Route attributes section. Each protocol is connected to a routing table through two lters which can accept, reject and modify the routes. An export lter checks routes passed from the routing table to the protocol, an import lter checks routes in the opposite direction. When the routing table gets a route from a protocol, it recalculates the selected route and broadcasts it to all protocols connected to the table. The protocols typically send the update to other routers in the network. Note that although most protocols are interested in receiving just selected routes, some protocols (e.g. the Pipe protocol) receive and process all entries in routing tables (accepted by lters). Usually, a routing table just chooses a selected route from a list of entries for one network. But if the sorted option is activated, these lists of entries are kept completely sorted (according to preference or some protocol-dependent metric). This is needed for some features of some protocols (e.g. secondary option of BGP protocol, which allows to accept not just a selected route, but the rst route (in the sorted list) that is accepted by lters), but it is incompatible with some other features (e.g. deterministic med option of BGP protocol, which activates a way of choosing selected route that cannot be described using comparison and ordering). Minor advantage is that routes are shown sorted in show route, minor disadvantage is that it is slightly more computationally expensive.

Chapter 3: Conguration
3.1 Introduction

BIRD is congured using a text conguration le. Upon startup, BIRD reads prex /etc/bird.conf (unless the -c command line option is given). Conguration may be changed at users request: if you modify the cong le and then signal BIRD with SIGHUP, it will adjust to the new cong. Then theres the client which allows you to talk with BIRD in an extensive way. In the cong, everything on a line after # or inside /* */ is a comment, whitespace characters are treated as a single space. If theres a variable number of options, they are grouped using the { } brackets. Each option is terminated by a ;. Conguration is case sensitive. Here is an example of a simple cong le. It enables synchronization of routing tables with OS kernel, scans for new network interfaces every 10 seconds and runs RIP on all network interfaces found. protocol kernel { persist; scan time 20; export all; } protocol device { scan time 10; } protocol rip { export all; import all; interface "*"; } # Dont remove routes on BIRD shutdown # Scan kernel routing table every 20 seconds # Default is export none

# Scan interfaces every 10 seconds

3.2

Global options

include "lename " This statement causes inclusion of a new le. The maximal depth is set to 5. log "lename "|syslog [name name ]|stderr all|{ list of classes } Set logging of messages having the given class (either all or { error, trace } etc.) into selected destination (a le specied as a lename string, syslog with optional name argument, or the stderr output). Classes are: info, warning, error and fatal for messages about local problems, debug for debugging messages, trace when you want to know what happens in the network, remote for messages about misbehavior of remote machines, auth about authentication failures, bug for internal BIRD bugs. You may specify more than one log line to establish logging to multiple destinations. Default: log everything to the system log. debug protocols all|off|{ states, routes, filters, interfaces, events, packets } Set global defaults of protocol debugging options. See debug in the following section. Default: o. debug commands number Control logging of client connections (0 for no logging, 1 for logging of connects and disconnects, 2 and higher for logging of all client commands). Default: 0. mrtdump "lename " Set MRTdump le name. This option must be specied to allow MRTdump feature. Default: no dump le. mrtdump protocols all|off|{ states, messages } Set global defaults of MRTdump options. See mrtdump in the following section. Default: o. 6

3.2. Global options filter name local variables { commands } Dene a lter. You can learn more about lters in the following chapter. function name (parameters ) local variables { commands } Dene a function. You can learn more about functions in the following chapter.

protocol rip|ospf|bgp|... [name [from name2 ]] { protocol options } Dene a protocol instance called name (or with a name like rip5 generated automatically if you dont specify any name ). You can learn more about conguring protocols in their own chapters. When from name2 expression is used, initial protocol options are taken from protocol or template name2 You can run more than one instance of most protocols (like RIP or BGP). By default, no instances are congured. template rip|bgp|... [name [from name2 ]] { protocol options } Dene a protocol template instance called name (or with a name like bgp1 generated automatically if you dont specify any name ). Protocol templates can be used to group common options when many similarly congured protocol instances are to be dened. Protocol instances (and other templates) can use templates by using from expression and the name of the template. At the moment templates (and from expression) are not implemented for OSPF protocol. define constant = expression Dene a constant. You can use it later in every place you could use a value of the same type. Besides, there are some predened numeric constants based on /etc/iproute2/rt * les. A list of dened constants can be seen (together with other symbols) using show symbols command. router id IPv4 address Set BIRDs router ID. Its a world-wide unique identication of your router, usually one of routers IPv4 addresses. Default: in IPv4 version, the lowest IP address of a non-loopback interface. In IPv6 version, this option is mandatory. router id from [-] [ "mask " ] [ prex ] [, ...] Set BIRDs router ID based on an IP address of an interface specied by an interface pattern. The option is applicable for IPv4 version only. See 3.3 (interface) section for detailed description of interface patterns. listen bgp [address address ] [port port ] [dual] This option allows to specify address and port where BGP protocol should listen. It is global option as listening socket is common to all BGP instances. Default is to listen on all addresses (0.0.0.0) and port 179. In IPv6 mode, option dual can be used to specify that BGP socket should accept both IPv4 and IPv6 connections (but even in that case, BIRD would accept IPv6 routes only). Such behavior was default in older versions of BIRD. timeformat route|protocol|base|log "format1 " [limit "format2 "] This option allows to specify a format of date/time used by BIRD. The rst argument species for which purpose such format is used. route is a format used in show route command output, protocol is used in show protocols command output, base is used for other commands and log is used in a log le. format1 is a format string using strftime(3) notation (see man strftime for details). limit> and format2 allow to specify the second format string for times in past deeper than limit seconds. There are two shorthands: iso long is a ISO 8601 date time format (YYYY-MM-DD hh:mm:ss) that can be also specied using "%F %T". iso short is a variant of ISO 8601 that uses just the time format (hh:mm:ss) for near times (up to 20 hours in the past) and the date format (YYYY-MM-DD) for far times. This is a shorthand for "%T" 72000 "%F". By default, BIRD uses an short, ad-hoc format for route and protocol times, and a iso long similar format (DD-MM-YYYY hh:mm:ss) for base and log. These defaults are here for a compatibility with older versions and might change in the future. table name [sorted] Create a new routing table. The default routing table is created implicitly, other routing tables have to be added by this command. Option sorted can be used to enable sorting of routes, see 2 (sorted table) description for details.

Chapter 3. Conguration

roa table name [ { roa table options ... } ] Create a new ROA (Route Origin Authorization) table. ROA tables can be used to validate route origination of BGP routes. A ROA table contains ROA entries, each consist of a network prex, a max prex length and an AS number. A ROA entry species prexes which could be originated by that AS number. ROA tables could be lled with data from RPKI (RFC 6480) or from public databases like Whois. ROA tables are examined by roa check() operator in lters. Currently, there is just one option, roa prex max num as num , which can be used to populate the ROA table with static ROA entries. The option may be used multiple times. Other entries can be added dynamically by add roa command. eval expr Evaluates given lter expression. It is used by us for testing of lters.

3.3

Protocol options

For each protocol instance, you can congure a bunch of options. Some of them (those described in this section) are generic, some are specic to the protocol (see sections talking about the protocols). Several options use a switch argument. It can be either on, yes or a numeric expression with a non-zero value for the option to be enabled or off, no or a numeric expression evaluating to zero to disable it. An empty switch is equivalent to on (silence means agreement). preference expr Sets the preference of routes generated by this protocol. Default: protocol dependent. disabled switch Disables the protocol. You can change the disable/enable status from the command line interface without needing to touch the conguration. Disabled protocols are not activated. Default: protocol is enabled. debug all|off|{ states, routes, filters, interfaces, events, packets } Set protocol debugging options. If asked, each protocol is capable of writing trace messages about its work to the log (with category trace). You can either request printing of all trace messages or only of the types selected: states for protocol state changes (protocol going up, down, starting, stopping etc.), routes for routes exchanged with the routing table, filters for details on route ltering, interfaces for interface change events sent to the protocol, events for events internal to the protocol and packets for packets sent and received by the protocol. Default: o. mrtdump all|off|{ states, messages } Set protocol MRTdump ags. MRTdump is a standard binary format for logging information from routing protocols and daemons. These ags control what kind of information is logged from the protocol to the MRTdump le (which must be specied by global mrtdump option, see the previous section). Although these ags are similar to ags of debug option, their meaning is dierent and protocol-specic. For BGP protocol, states logs BGP state changes and messages logs received BGP messages. Other protocols does not support MRTdump yet. router id IPv4 address This option can be used to override global router id for a given protocol. Default: uses global router id. import all | none | filter name | filter { lter commands } | where lter expression Specify a lter to be used for ltering routes coming from the protocol to the routing table. all is shorthand for where true and none is shorthand for where false. Default: all. export lter This is similar to the import keyword, except that it works in the direction from the routing table to the protocol. Default: none. import keep filtered switch Usually, if an import lter rejects a route, the route is forgotten. When this option is active, these

3.3. Protocol options

routes are kept in the routing table, but they are hidden and not propagated to other protocols. But it is possible to show them using show route filtered. Note that this option does not work for the pipe protocol. Default: o. import limit [number | off ] [action warn | block | restart | disable] Specify an import route limit (a maximum number of routes imported from the protocol) and optionally the action to be taken when the limit is hit. Warn action just prints warning log message. Block action discards new routes coming from the protocol. Restart and disable actions shut the protocol down like appropriate commands. Disable is the default action if an action is not explicitly specied. Note that limits are reset during protocol recongure, reload or restart. Default: off. receive limit [number | off ] [action warn | block | restart | disable] Specify an receive route limit (a maximum number of routes received from the protocol and remembered). It works almost identically to import limit option, the only dierence is that if import keep filtered option is active, ltered routes are counted towards the limit and blocked routes are forgotten, as the main purpose of the receive limit is to protect routing tables from overow. Import limit, on the contrary, counts accepted routes only and routes blocked by the limit are handled like ltered routes. Default: off. export limit [ number | off ] [action warn | block | restart | disable] Specify an export route limit, works similarly to the import limit option, but for the routes exported to the protocol. This option is experimental, there are some problems in details of its behavior the number of exported routes can temporarily exceed the limit without triggering it during protocol reload, exported routes counter ignores route blocking and block action also blocks route updates of already accepted routes and these details will probably change in the future. Default: off. description "text " This is an optional description of the protocol. It is displayed as a part of the output of show route all command. table name Connect this protocol to a non-default routing table. There are several options that give sense only with certain protocols: interface [-] [ "mask " ] [ prex ] [, ...] [ { option ; [...] } ] Species a set of interfaces on which the protocol is activated with given interface-specic options. A set of interfaces specied by one interface option is described using an interface pattern. The interface pattern consists of a sequence of clauses (separated by commas), each clause may contain a mask, a prex, or both of them. An interface matches the clause if its name matches the mask (if specied) and its address matches the prex (if specied). Mask is specied as shell-like pattern. For IPv6, the prex part of a clause is generally ignored and interfaces are matched just by their name. An interface matches the pattern if it matches any of its clauses. If the clause begins with -, matching interfaces are excluded. Patterns are parsed left-to-right, thus interface "eth0", -"eth*", "*"; means eth0 and all non-ethernets. An interface option can be used more times with dierent interfaces-specic options, in that case for given interface the rst matching interface option is used. This option is allowed in Direct, OSPF, RIP and RAdv protocols, but in OSPF protocol it is used in area subsection. Default: none. Examples: interface "*" { type broadcast; }; - start the protocol on all interfaces with type broadcast option. interface "eth1", "eth4", "eth5" { type ptp; }; - start the protocol on enumerated interfaces with type ptp option. interface -192.168.1.0/24, 192.168.0.0/16; - start the protocol on all interfaces that have address from 192.168.0.0/16, but not from 192.168.1.0/24.

10

Chapter 3. Conguration interface -192.168.1.0/24, 192.168.0.0/16; - start the protocol on all interfaces that have address from 192.168.0.0/16, but not from 192.168.1.0/24. interface "eth*" 192.168.1.0/24; - start the protocol on all ethernet interfaces that have address from 192.168.1.0/24.

tx class|dscp num This option species the value of ToS/DS/Class eld in IP headers of the outgoing protocol packets. This may aect how the protocol packets are processed by the network relative to the other network trac. With class keyword, the value (0-255) is used for the whole ToS/Class octet (but two bits reserved for ECN are ignored). With dscp keyword, the value (0-63) is used just for the DS eld in the octet. Default value is 0xc0 (DSCP 0x30 - CS6). tx priority num This option species the local packet priority. This may aect how the protocol packets are processed in the local TX queues. This option is Linux specic. Default value is 7 (highest priority, privileged trac). password "password " [ { id num ; generate from time ; generate to time ; accept from time ; accept to time ; } Species a password that can be used by the protocol. Password option can be used more times to specify more passwords. If more passwords are specied, it is a protocol-dependent decision which one is really used. Specifying passwords does not mean that authentication is enabled, authentication can be enabled by separate, protocol-dependent authentication option. This option is allowed in OSPF and RIP protocols. BGP has also password option, but it is slightly dierent and described separately. Default: none. Password option can contain section with some (not necessary all) password sub-options: id num ID of the password, (0-255). If its not used, BIRD will choose ID based on an order of the password item in the interface. For example, second password item in one interface will have default ID 2. ID is used by some routing protocols to identify which password was used to authenticate protocol packets. generate from "time " The start time of the usage of the password for packet signing. The format of time is dd-mm-yyyy HH:MM:SS. generate to "time " The last time of the usage of the password for packet signing. accept from "time " The start time of the usage of the password for packet verication. accept to "time " The last time of the usage of the password for packet verication.

Chapter 4: Remote control


You can use the command-line client birdc to talk with a running BIRD. Communication is done using a bird.ctl UNIX domain socket (unless changed with the -s option given to both the server and the client). The commands can perform simple actions such as enabling/disabling of protocols, telling BIRD to show various information, telling it to show routing table ltered by lter, or asking BIRD to recongure. Press ? at any time to get online help. Option -r can be used to enable a restricted mode of BIRD client, which allows just read-only commands (show ...). Option -v can be passed to the client, to make it dump numeric return codes along with the messages. You do not necessarily need to use birdc to talk to BIRD, your own applications could do that, too the format of communication between BIRD and birdc is stable (see the programmers documentation). There is also lightweight variant of BIRD client called birdcl, which does not support command line editing and history and has minimal dependencies. This is useful for running BIRD in resource constrained environments, where Readline library (required for regular BIRD client) is not available. Many commands have the name of the protocol instance as an argument. This argument can be omitted if there exists only a single instance. Here is a brief list of supported functions: show status Show router status, that is BIRD version, uptime and time from last reconguration. show protocols [all] Show list of protocol instances along with tables they are connected to and protocol status, possibly giving verbose information, if all is specied. show ospf interface [name ] ["interface "] Show detailed information about OSPF interfaces. show ospf neighbors [name ] ["interface "] Show a list of OSPF neighbors and a state of adjacency to them. show ospf state [all] [name ] Show detailed information about OSPF areas based on a content of the link-state database. It shows network topology, stub networks, aggregated networks and routers from other areas and external routes. The command shows information about reachable network nodes, use option all to show information about all network nodes in the link-state database. show ospf topology [all] [name ] Show a topology of OSPF areas based on a content of the link-state database. It is just a stripped-down version of show ospf state. show ospf lsadb [global | area id | link] [type num ] [lsid id ] [self | router id ] [name ] Show contents of an OSPF LSA database. Options could be used to lter entries. show static [name ] Show detailed information about static routes. show interfaces [summary] Show the list of interfaces. For each interface, print its type, state, MTU and addresses assigned. show symbols [table|filter|function|protocol|template|roa|symbol ] Show the list of symbols dened in the conguration (names of protocols, routing tables etc.).

show route [[for] prex |IP ] [table sym ] [filter f |where c ] [(export|preexport) p ] [protocol p ] [opti Show contents of a routing table (by default of the main one or the table attached to a respective protocol), that is routes, their metrics and (in case the all switch is given) all their attributes. 11

12

Chapter 4. Remote control You can specify a prex if you want to print routes for a specic network. If you use for prex or IP , youll get the entry which will be used for forwarding of packets to the given destination. By default, all routes for each network are printed with the selected one at the top, unless primary is given in which case only the selected route is shown. You can also ask for printing only routes processed and accepted by a given lter (filter name or filter { lter } or matching a given condition (where condition ). The export and preexport switches ask for printing of entries that are exported to the specied protocol. With preexport, the export lter of the protocol is skipped. You can also select just routes added by a specic protocol. protocol p . If BIRD is congured to keep ltered routes (see import keep filtered option), you can show them instead of routes by using filtered switch. The stats switch requests showing of route statistics (the number of networks, number of routes before and after ltering). If you use count instead, only the statistics will be printed.

show roa [prex | in prex | for prex ] [as num ] [table t >] Show contents of a ROA table (by default of the rst one). You can specify a prex to print ROA entries for a specic network. If you use for prex , youll get all entries relevant for route validation of the network prex; i.e., ROA entries whose prexes cover the network prex. Or you can use in prex to get ROA entries covered by the network prex. You could also use as option to show just entries for given AS. add roa prex max num ] as num [table t >] Add a new ROA entry to a ROA table. Such entry is called dynamic compared to static entries specied in the cong le. These dynamic entries survive reconguration. delete roa prex max num ] as num [table t >] Delete the specied ROA entry from a ROA table. Only dynamic ROA entries (i.e., the ones added by add roa command) can be deleted. flush roa [table t >] Remove all dynamic ROA entries from a ROA table. configure [soft] ["cong le "] [timeout [num ]] Reload conguration from a given le. BIRD will smoothly switch itself to the new conguration, protocols are recongured if possible, restarted otherwise. Changes in lters usually lead to restart of aected protocols. If soft option is used, changes in lters does not cause BIRD to restart aected protocols, therefore already accepted routes (according to old lters) would be still propagated, but new routes would be processed according to the new lters. If timeout option is used, cong timer is activated. The new conguration could be either conrmed using configure confirm command, or it will be reverted to the old one when the cong timer expires. This is useful for cases when reconguration breaks current routing and a router becames inaccessible for an administrator. The cong timeout expiration is equivalent to configure undo command. The timeout duration could be specied, default is 300 s. configure confirm Deactivate the cong undo timer and therefore conrm the current conguration. configure undo Undo the last conguration change and smoothly switch back to the previous (stored) conguration. If the last conguration change was soft, the undo change is also soft. There is only one level of undo, but in some specic cases when several reconguration requests are given immediately in a row and the intermediate ones are skipped then the undo also skips them back. configure check ["cong le "] Read and parse given cong le, but do not use it. useful for checking syntactic and some semantic validity of an cong le.

13 enable|disable|restart name |"pattern "|all Enable, disable or restart a given protocol instance, instances matching the pattern or all instances. reload [in|out] name |"pattern "|all Reload a given protocol instance, that means re-import routes from the protocol instance and reexport preferred routes to the instance. If in or out options are used, the command is restricted to one direction (re-import or re-export). This command is useful if appropriate lters have changed but the protocol instance was not restarted (or reloaded), therefore it still propagates the old set of routes. For example when configure soft command was used to change lters. Re-export always succeeds, but re-import is protocol-dependent and might fail (for example, if BGP neighbor does not support route-refresh extension). In that case, re-export is also skipped. Note that for the pipe protocol, both directions are always reloaded together (in or out options are ignored in that case). down Shut BIRD down. debug protocol |pattern |all all|off|{ states | routes | filters | events | packets } Control protocol debugging. dump resources|sockets|interfaces|neighbors|attributes|routes|protocols Dump contents of internal data structures to the debugging output. echo all|off|{ list of log classes } [ buer-size ] Control echoing of log messages to the command-line output. See 3.2 (log option) for a list of log classes. eval expr Evaluate given expression.

Chapter 5: Filters
5.1 Introduction

BIRD contains a simple programming language. (No, it cant yet read mail :-). There are two objects in this language: lters and functions. Filters are interpreted by BIRD core when a route is being passed between protocols and routing tables. The lter language contains control structures such as ifs and switches, but it allows no loops. An example of a lter using many features can be found in filter/test.conf. Filter gets the route, looks at its attributes and modies some of them if it wishes. At the end, it decides whether to pass the changed route through (using accept) or whether to reject it. A simple lter looks like this: filter not_too_far int var; { if defined( rip_metric ) then var = rip_metric; else { var = 1; rip_metric = 1; } if rip_metric > 10 then reject "RIP metric is too big"; else accept "ok"; } As you can see, a lter has a header, a list of local variables, and a body. The header consists of the filter keyword followed by a (unique) name of lter. The list of local variables consists of type name ; pairs where each pair denes one local variable. The body consists of { statements }. Each statement is terminated by a ;. You can group several statements to a single compound statement by using braces ({ statements }) which is useful if you want to make a bigger block of code conditional. BIRD supports functions, so that you dont 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. Function denitions look like this: function name () int local_variable; { local_variable = 5; } function with_parameters (int parameter) { print parameter; } Unlike in C, variables are declared after the function line, but before the rst {. You cant declare variables in nested blocks. Functions are called like in C: name(); with parameters(5);. Function may return values using the return [expr] command. Returning a value exits from current function (this is similar to C). Filters are declared in a way similar to functions except they cant have explicit parameters. They get a route table entry as an implicit parameter, it is also passed automatically to any functions called. The lter must terminate with either accept or reject statement. If theres a runtime error in lter, the route is rejected. A nice trick to debug lters is to use show route filter name from the command line client. An example session might look like: 14

5.2. Data types pavel@bug:~/bird$ ./birdc -s bird.ctl BIRD 0.0.0 ready. bird> show route 10.0.0.0/8 dev eth0 [direct1 23:21] (240) 195.113.30.2/32 dev tunl1 [direct1 23:21] (240) 127.0.0.0/8 dev lo [direct1 23:21] (240) bird> show route ? show route [<prefix>] [table <t>] [filter <f>] [all] [primary]... bird> show route filter { if 127.0.0.5 ~ net then accept; } 127.0.0.0/8 dev lo [direct1 23:21] (240) bird>

15

5.2

Data types

Each variable and each value has certain type. Booleans, integers and enums are incompatible with each other (that is to prevent you from shooting in the foot). bool This is a boolean type, it can have only two values, true and false. Boolean is the only type you can use in if statements. int This is a general integer type, you can expect it to store signed values from -2000000000 to +2000000000. Overows are not checked. You can use 0x1234 syntax to write hexadecimal values. pair This is a pair of two short integers. Each component can have values from 0 to 65535. Literals of this type are written as (1234,5678). The same syntax can also be used to construct a pair from two arbitrary integer expressions (for example (1+2,a)). quad This is a dotted quad of numbers used to represent router IDs (and others). Each component can have a value from 0 to 255. Literals of this type are written like IPv4 addresses. string This is a string of characters. There are no ways to modify strings in lters. You can pass them between functions, assign them to variables of type string, print such variables, but you cant concatenate two strings. String literals are written as "This is a string constant". ip This type can hold a single IP address. Depending on the compile-time conguration of BIRD you are using, it is either an IPv4 or IPv6 address. IP addresses are written in the standard notation (10.20.30.40 or fec0:3:4::1). You can apply special operator .mask(num ) on values of type ip. It masks out all but rst num bits from the IP address. So 1.2.3.4.mask(8) = 1.0.0.0 is true. prefix This type can hold a network prex consisting of IP address and prex length. Prex literals are written as ipaddress /pxlen , or ipaddress /netmask . There are two special operators on prexes: .ip which extracts the IP address from the pair, and .len, which separates prex length from the pair. So 1.2.0.0/16.pxlen = 16 is true. ec This is a specialized type used to represent BGP extended community values. It is essentially a 64bit value, literals of this type are usually written as (kind , key , value ), where kind is a kind of extended community (e.g. rt / ro for a route target / route origin communities), the format and possible values of key and value are usually integers, but it depends on the used kind. Similarly to pairs, ECs can be constructed using expressions for key and value parts, (e.g. (ro, myas, 3*10), where myas is an integer variable).

16

Chapter 5. Filters

int|pair|quad|ip|prefix|ec|enum set Filters recognize four types of sets. Sets are similar to strings: you can pass them around but you cant modify them. Literals of type int set look like [ 1, 2, 5..7 ]. As you can see, both simple values and ranges are permitted in sets. For pair sets, expressions like (123,*) can be used to denote ranges (in that case (123,0)..(123,65535)). You can also use (123,5..100) for range (123,5)..(123,100). You can also use * and a..b expressions in the rst part of a pair, note that such expressions are translated to a set of intervals, which may be memory intensive. E.g. (*,4..20) is translated to (0,4..20), (1,4..20), (2,4..20), ... (65535, 4..20). EC sets use similar expressions like pair sets, e.g. (rt, 123, 10..20) or (ro, 123, *). Expressions requiring the translation (like (rt, *, 3)) are not allowed (as they usually have 4B range for ASNs). You can also use expressions for int, pair and EC set values. However it must be possible to evaluate these expressions before daemon boots. So you can use only constants inside them. E.g. define define myas=64500; int set odds; pair set ps; ec set es; odds = [ one, 2+1, 6-one, 2*2*2-1, 9, 11 ]; ps = [ (1,one+one), (3,4)..(4,8), (5,*), (6,3..6), (7..9,*) ]; es = [ (rt, myas, 3*10), (rt, myas+one, 0..16*16*16-1), (ro, myas+2, *) ];

Sets of prexes are special: their literals does not allow ranges, but allows prex patterns that are written as ipaddress /pxlen {low ,high }. Prex ip1 /len1 matches prex pattern ip2 /len2 {l ,h } if the rst min(len1, len2) bits of ip1 and ip2 are identical and len1 <= ip1 <= len2. A valid prex pattern has to satisfy low <= high, but pxlen is not constrained by low or high. Obviously, a prex matches a prex set literal if it matches any prex pattern in the prex set literal. There are also two shorthands for prex patterns: address /len + is a shorthand for address /len {len ,maxlen } (where maxlen is 32 for IPv4 and 128 for IPv6), that means network prex address /len and all its subnets. address /len - is a shorthand for address /len {0,len }, that means network prex address /len and all its supernets (network prexes that contain it). For example, [ 1.0.0.0/8, 2.0.0.0/8+, 3.0.0.0/8-, 4.0.0.0/8{16,24} ] matches prex 1.0.0.0/8, all subprexes of 2.0.0.0/8, all superprexes of 3.0.0.0/8 and prexes 4.X.X.X whose prex length is 16 to 24. [ 0.0.0.0/0{20,24} ] matches all prexes (regardless of IP address) whose prex length is 20 to 24, [ 1.2.3.4/32- ] matches any prex that contains IP address 1.2.3.4. 1.2.0.0/16 ~ [ 1.0.0.0/8{15,17} ] is true, but 1.0.0.0/16 ~ [ 1.0.0.0/8- ] is false. Cisco-style patterns like 10.0.0.0/8 ge 16 le 24 can be expressed in BIRD as 10.0.0.0/8{16,24}, 192.168.0.0/16 le 24 as 192.168.0.0/16{16,24} and 192.168.0.0/16 ge 24 as 192.168.0.0/16{24,32}. enum Enumeration types are xed sets of possibilities. You cant dene your own variables of such type, but some route attributes are of enumeration type. Enumeration types are incompatible with each other. bgppath BGP path is a list of autonomous system numbers. You cant write literals of this type. There are several special operators on bgppaths: P .first returns the rst ASN (the neighbor ASN) in path P . P .last returns the last ASN (the source ASN) in path P . Both first and last return zero if there is no appropriate ASN, for example if the path contains an AS set element as the rst (or the last) part. P .len returns the length of path P .

5.3. Operators

17

prepend(P ,A) prepends ASN A to path P and returns the result. Statement P = prepend(P , A); can be shortened to P .prepend(A); if P is appropriate route attribute (for example bgp path). bgpmask BGP masks are patterns used for BGP path matching (using path ~ [= 2 3 5 * =] syntax). The masks resemble wildcard patterns as used by UNIX shells. Autonomous system numbers match themselves, * matches any (even empty) sequence of arbitrary AS numbers and ? matches one arbitrary AS number. For example, if bgp path is 4 3 2 1, then: bgp path ~ [= * 4 3 * =] is true, but bgp path ~ [= * 4 5 * =] is false. BGP mask expressions can also contain integer expressions enclosed in parenthesis and integer variables, for example [= * 4 (1+2) a =]. There is also old syntax that uses / .. / instead of [= .. =] and ? instead of *. clist Clist is similar to a set, except that unlike other sets, it can be modied. The type is used for community list (a set of pairs) and for cluster list (a set of quads). There exist no literals of this type. There are three special operators on clists: add(C ,P ) adds pair (or quad) P to clist C and returns the result. If item P is already in clist C , it does nothing. P may also be a clist, in that case all its members are added; i.e., it works as clist union. delete(C ,P ) deletes pair (or quad) P from clist C and returns the result. If clist C does not contain item P , it does nothing. P may also be a pair (or quad) set, in that case the operator deletes all items from clist C that are also members of set P . Moreover, P may also be a clist, which works analogously; i.e., it works as clist dierence. filter(C ,P ) deletes all items from clist C that are not members of pair (or quad) set P . I.e., filter do the same as delete with inverted set P . P may also be a clist, which works analogously; i.e., it works as clist intersection. Statement C = add(C , P ); can be shortened to C .add(P ); if C is appropriate route attribute (for example bgp community). Similarly for delete and filter. eclist Eclist is a data type used for BGP extended community lists. Eclists are very similar to clists, but they are sets of ECs instead of pairs. The same operations (like add, delete, or ~ membership operator) can be used to modify or test eclists, with ECs instead of pairs as arguments.

5.3

Operators

The lter language supports common integer operators (+,-,*,/), parentheses (a*(b+c)), comparison (a=b, a!=b, a<b, a>=b). Logical operations include unary not (!), and (&&) and or (||). Special operators include ~ for is element of a set operation - it can be used on element and set of elements of the same type (returning true if element is contained in the given set), or on two strings (returning true if rst string matches a shell-like pattern stored in second string) or on IP and prex (returning true if IP is within the range dened by that prex), or on prex and prex (returning true if rst prex is more specic than second one) or on bgppath and bgpmask (returning true if the path matches the mask) or on number and bgppath (returning true if the number is in the path) or on bgppath and int (number) set (returning true if any ASN from the path is in the set) or on pair/quad and clist (returning true if the pair/quad is element of the clist) or on clist and pair/quad set (returning true if there is an element of the clist that is also a member of the pair/quad set). There is one operator related to ROA infrastructure - roa check(). It examines a ROA table and does RFC 6483 route origin validation for a given network prex. The basic usage is roa check(table ), which checks current route (which should be from BGP to have AS PATH argument) in the specied ROA table and returns ROA UNKNOWN if there is no relevant ROA, ROA VALID if there is a matching ROA, or ROA INVALID if there are some relevant ROAs but none of them match. There is also an extended variant roa check(table , prex , asn ), which allows to specify a prex and an ASN as arguments.

5.4

Control structures

Filters support two control structures: conditions and case switches.

18

Chapter 5. Filters

Syntax of a condition is: if boolean expression then command1 ; else command2 ; and you can use { command 1 ; command 2 ; ... } instead of either command. The else clause may be omitted. If the boolean expression is true, command1 is executed, otherwise command2 is executed. The case is similar to case from Pascal. Syntax is case expr { else: | num or prex [ .. num or prex] : statement ; [ ... ] }. The expression after case can be of any type which can be on the left side of the operator and anything that could be a member of a set is allowed before :. Multiple commands are allowed without {} grouping. If expr matches one of the : clauses, statements between it and next : statement are executed. If expr matches neither of the : clauses, the statements after else: are executed. Here is example that uses if and case structures: case arg1 { 2: print "two"; print "I can do more commands without {}"; 3 .. 5: print "three to five"; else: print "something else"; } if 1234 = i then printn "."; else { print "not 1234"; print "You need {} around multiple commands"; }

5.5

Route attributes

A lter is implicitly passed a route, and it can access its attributes just like it accesses variables. Attempts to access undened attribute result in a runtime error; you can check if an attribute is dened by using the defined( attribute ) operator. One notable exception to this rule are attributes of clist type, where undened value is regarded as empty clist for most purposes. prex net Network the route is talking about. Read-only. (See the chapter about routing tables.) enum scope The scope of the route. Possible values: SCOPE HOST for routes local to this host, SCOPE LINK for those specic for a physical link, SCOPE SITE and SCOPE ORGANIZATION for private routes and SCOPE UNIVERSE for globally visible routes. This attribute is not interpreted by BIRD and can be used to mark routes in lters. The default value for new routes is SCOPE UNIVERSE. int preference Preference of the route. Valid values are 0-65535. (See the chapter about routing tables.) ip from The router which the route has originated from. Read-only. ip gw Next hop packets routed using this route should be forwarded to. string proto The name of the protocol which the route has been imported from. Read-only. enum source what protocol has told me about this route. Possible values: RTS DUMMY, RTS STATIC, RTS INHERIT, RTS DEVICE, RTS STATIC DEVICE, RTS REDIRECT, RTS RIP, RTS OSPF, RTS OSPF IA, RTS OSPF EXT1, RTS OSPF EXT2, RTS BGP, RTS PIPE. enum cast Route type (Currently RTC UNICAST for normal routes, RTC BROADCAST, RTC MULTICAST, RTC ANYCAST will be used in the future for broadcast, multicast and anycast routes). Read-only.

5.6. Other statements

19

enum dest Type of destination the packets should be sent to (RTD ROUTER for forwarding to a neighboring router, RTD DEVICE for routing to a directly-connected network, RTD MULTIPATH for multipath destinations, RTD BLACKHOLE for packets to be silently discarded, RTD UNREACHABLE, RTD PROHIBIT for packets that should be returned with ICMP host unreachable / ICMP administratively prohibited messages). Can be changed, but only to RTD BLACKHOLE, RTD UNREACHABLE or RTD PROHIBIT. int igp metric The optional attribute that can be used to specify a distance to the network for routes that do not have a native protocol metric attribute (like ospf metric1 for OSPF routes). It is used mainly by BGP to compare internal distances to boundary routers (see below). It is also used when the route is exported to OSPF as a default value for OSPF type 1 metric. There also exist some protocol-specic attributes which are described in the corresponding protocol sections.

5.6

Other statements

The following statements are available: variable = expr Set variable to a given value. accept|reject [ expr ] Accept or reject the route, possibly printing expr . return expr Return expr from the current function, the function ends at this point. print|printn expr [, expr...] Prints given expressions; useful mainly while debugging lters. The printn variant does not terminate the line. quitbird Terminates BIRD. Useful when debugging the lter interpreter.

Chapter 6: Protocols
6.1 BGP

The Border Gateway Protocol is the routing protocol used for backbone level routing in the todays Internet. Contrary to the other protocols, its convergence doesnt rely on all routers following the same rules for route selection, making it possible to implement any routing policy at any router in the network, the only restriction being that if a router advertises a route, it must accept and forward packets according to it. BGP works in terms of autonomous systems (often abbreviated as AS). Each AS is a part of the network with common management and common routing policy. It is identied by a unique 16-bit number (ASN). Routers within each AS usually exchange AS-internal routing information with each other using an interior gateway protocol (IGP, such as OSPF or RIP). Boundary routers at the border of the AS communicate global (inter-AS) network reachability information with their neighbors in the neighboring ASes via exterior BGP (eBGP) and redistribute received information to other routers in the AS via interior BGP (iBGP). Each BGP router sends to its neighbors updates of the parts of its routing table it wishes to export along with complete path information (a list of ASes the packet will travel through if it uses the particular route) in order to avoid routing loops. BIRD supports all requirements of the BGP4 standard as dened in RFC 4271 It also supports the community attributes (RFC 1997), capability negotiation (RFC 3392), MD5 password authentication (RFC 2385), extended communities (RFC 4360), route reectors (RFC 4456), multiprotocol extensions (RFC 4760), 4B AS numbers (RFC 4893), and 4B AS numbers in extended communities (RFC 5668). For IPv6, it uses the standard multiprotocol extensions dened in RFC 2283 including changes described in the latest draft and applied to IPv6 according to RFC 2545.

6.1.1

Route selection rules

BGP doesnt have any simple metric, so the rules for selection of an optimal route among multiple BGP routes with the same preference are a bit more complex and they are implemented according to the following algorithm. It starts the rst rule, if there are more best routes, then it uses the second rule to choose among them and so on. Prefer route with the highest Local Preference attribute. Prefer route with the shortest AS path. Prefer IGP origin over EGP and EGP origin over incomplete. Prefer the lowest value of the Multiple Exit Discriminator. Prefer routes received via eBGP over ones received via iBGP. Prefer routes with lower internal distance to a boundary router. Prefer the route with the lowest value of router ID of the advertising router.

6.1.2

IGP routing table

BGP is mainly concerned with global network reachability and with routes to other autonomous systems. When such routes are redistributed to routers in the AS via BGP, they contain IP addresses of a boundary routers (in route attribute NEXT HOP). BGP depends on existing IGP routing table with AS-internal routes to determine immediate next hops for routes and to know their internal distances to boundary routers for the purpose of BGP route selection. In BIRD, there is usually one routing table used for both IGP routes and BGP routes. 20

6.1. BGP

21

6.1.3

Conguration

Each instance of the BGP corresponds to one neighboring router. This allows to set routing policy and all the other parameters dierently for each neighbor using the following conguration parameters: local [ip ] as number Dene which AS we are part of. (Note that contrary to other IP routers, BIRD is able to act as a router located in multiple ASes simultaneously, but in such cases you need to tweak the BGP paths manually in the lters to get consistent behavior.) Optional ip argument species a source address, equivalent to the source address option (see below). This parameter is mandatory. neighbor ip as number Dene neighboring router this instance will be talking to and what AS its located in. Unless you use the multihop clause, it must be directly connected to one of your routers interfaces. In case the neighbor is in the same AS as we are, we automatically switch to iBGP. This parameter is mandatory. multihop [number ] Congure multihop BGP session to a neighbor that isnt directly connected. Accurately, this option should be used if the congured neighbor IP address does not match with any local network subnets. Such IP address have to be reachable through system routing table. For multihop BGP it is recommended to explicitly congure source address to have it stable. Optional number argument can be used to specify the number of hops (used for TTL). Note that the number of networks (edges) in a path is counted, i.e. if two BGP speakers are separated by one router, the number of hops is 2. Default: switched o. source address ip Dene local address we should use for next hop calculation and as a source address for the BGP session. Default: the address of the local end of the interface our neighbor is connected to. next hop self Avoid calculation of the Next Hop attribute and always advertise our own source address as a next hop. This needs to be used only occasionally to circumvent miscongurations of other routers. Default: disabled. next hop keep Forward the received Next Hop attribute even in situations where the local address should be used instead, like when the route is sent to an interface with a dierent subnet. Default: disabled. missing lladdr self|drop|ignore Next Hop attribute in BGP-IPv6 sometimes contains just the global IPv6 address, but sometimes it has to contain both global and link-local IPv6 addresses. This option species what to do if BIRD have to send both addresses but does not know link-local address. This situation might happen when routes from other protocols are exported to BGP, or when improper updates are received from BGP peers. self means that BIRD advertises its own local address instead. drop means that BIRD skips that prexes and logs error. ignore means that BIRD ignores the problem and sends just the global address (and therefore forms improper BGP update). Default: self, unless BIRD is congured as a route server (option rs client), in that case default is ignore, because route servers usually do not forward packets themselves. gateway direct|recursive For received routes, their gw (immediate next hop) attribute is computed from received bgp next hop attribute. This option species how it is computed. Direct mode means that the IP address from bgp next hop is used if it is directly reachable, otherwise the neighbor IP address is used. Recursive mode means that the gateway is computed by an IGP routing table lookup for the IP address from bgp next hop. Recursive mode is the behavior specied by the BGP standard. Direct mode is simpler, does not require any routes in a routing table, and was used in older versions of BIRD, but does not handle well nontrivial iBGP setups and multihop. Recursive mode is incompatible with 2 (sorted tables). Default: direct for singlehop eBGP, recursive otherwise. igp table name Species a table that is used as an IGP routing table. Default: the same as the table BGP is connected to.

22

Chapter 6. Protocols

ttl security switch Use GTSM (RFC 5082 - the generalized TTL security mechanism). GTSM protects against spoofed packets by ignoring received packets with a smaller than expected TTL. To work properly, GTSM have to be enabled on both sides of a BGP session. If both ttl security and multihop options are enabled, multihop option should specify proper hop value to compute expected TTL. Kernel support required: Linux: 2.6.34+ (IPv4), 2.6.35+ (IPv6), BSD: since long ago, IPv4 only. Note that full (ICMP protection, for example) RFC 5082 support is provided by Linux only. Default: disabled. password string Use this password for MD5 authentication of BGP sessions. Default: no authentication. Password has to be set by external utility (e.g. setkey(8)) on BSD systems. passive switch Standard BGP behavior is both initiating outgoing connections and accepting incoming connections. In passive mode, outgoing connections are not initiated. Default: o. rr client Be a route reector and treat the neighbor as a route reection client. Default: disabled. rr cluster id IPv4 address Route reectors use cluster id to avoid route reection loops. When there is one route reector in a cluster it usually uses its router id as a cluster id, but when there are more route reectors in a cluster, these need to be congured (using this option) to use a common cluster id. Clients in a cluster need not know their cluster id and this option is not allowed for them. Default: the same as router id. rs client Be a route server and treat the neighbor as a route server client. A route server is used as a replacement for full mesh EBGP routing in Internet exchange points in a similar way to route reectors used in IBGP routing. BIRD does not implement obsoleted RFC 1863, but uses ad-hoc implementation, which behaves like plain EBGP but reduces modications to advertised route attributes to be transparent (for example does not prepend its AS number to AS PATH attribute and keeps MED attribute). Default: disabled. secondary switch Usually, if an import lter rejects a selected route, no other route is propagated for that network. This option allows to try the next route in order until one that is accepted is found or all routes for that network are rejected. This can be used for route servers that need to propagate dierent tables to each client but do not want to have these tables explicitly (to conserve memory). This option requires that the connected routing table is 2 (sorted). Default: o. enable route refresh switch When BGP speaker changes its import lter, it has to re-examine all routes received from its neighbor against the new lter. As these routes might not be available, there is a BGP protocol extension Route Refresh (specied in RFC 2918) that allows BGP speaker to request re-advertisement of all routes from its neighbor. This option species whether BIRD advertises this capability and accepts such requests. Even when disabled, BIRD can send route refresh requests. Default: on. interpret communities switch RFC 1997 demands that BGP speaker should process well-known communities like no-export (65535, 65281) or no-advertise (65535, 65282). For example, received route carrying a no-adverise community should not be advertised to any of its neighbors. If this option is enabled (which is by default), BIRD has such behavior automatically (it is evaluated when a route is exported to the BGP protocol just before the export lter). Otherwise, this integrated processing of well-known communities is disabled. In that case, similar behavior can be implemented in the export lter. Default: on. enable as4 switch BGP protocol was designed to use 2B AS numbers and was extended later to allow 4B AS number. BIRD supports 4B AS extension, but by disabling this option it can be persuaded not to advertise it and to maintain old-style sessions with its neighbors. This might be useful for circumventing bugs in neighbors implementation of 4B AS extension. Even when disabled (o), BIRD behaves internally as AS4-aware BGP router. Default: on.

6.1. BGP

23

capabilities switch Use capability advertisement to advertise optional capabilities. This is standard behavior for newer BGP implementations, but there might be some older BGP implementations that reject such connection attempts. When disabled (o), features that request it (4B AS support) are also disabled. Default: on, with automatic fallback to o when received capability-related error. advertise ipv4 switch Advertise IPv4 multiprotocol capability. This is not a correct behavior according to the strict interpretation of RFC 4760, but it is widespread and required by some BGP implementations (Cisco and Quagga). This option is relevant to IPv4 mode with enabled capability advertisement only. Default: on. route limit number The maximal number of routes that may be imported from the protocol. If the route limit is exceeded, the connection is closed with error. Limit is currently implemented as import limit number exceed restart. Default: no limit. disable after error switch When an error is encountered (either locally or by the other side), disable the instance automatically and wait for an administrator to x the problem manually. Default: o. hold time number Time in seconds to wait for a Keepalive message from the other side before considering the connection stale. Default: depends on agreement with the neighboring router, we prefer 240 seconds if the other side is willing to accept it. startup hold time number Value of the hold timer used before the routers have a chance to exchange open messages and agree on the real value. Default: 240 seconds. keepalive time number Delay in seconds between sending of two consecutive Keepalive messages. Default: One third of the hold time. connect retry time number Time in seconds to wait before retrying a failed attempt to connect. Default: 120 seconds. start delay time number Delay in seconds between protocol startup and the rst attempt to connect. Default: 5 seconds. error wait time number ,number Minimum and maximum delay in seconds between a protocol failure (either local or reported by the peer) and automatic restart. Doesnt apply when disable after error is congured. If consecutive errors happen, the delay is increased exponentially until it reaches the maximum. Default: 60, 300. error forget time number Maximum time in seconds between two protocol failures to treat them as a error sequence which makes the error wait time increase exponentially. Default: 300 seconds. path metric switch Enable comparison of path lengths when deciding which BGP route is the best one. Default: on. med metric switch Enable comparison of MED attributes (during best route selection) even between routes received from dierent ASes. This may be useful if all MED attributes contain some consistent metric, perhaps enforced in import lters of AS boundary routers. If this option is disabled, MED attributes are compared only if routes are received from the same AS (which is the standard behavior). Default: o. deterministic med switch BGP route selection algorithm is often viewed as a comparison between individual routes (e.g. if a new route appears and is better than the current best one, it is chosen as the new best one). But the proper route selection, as specied by RFC 4271, cannot be fully implemented in that way. The

24

Chapter 6. Protocols problem is mainly in handling the MED attribute. BIRD, by default, uses an simplication based on individual route comparison, which in some cases may lead to temporally dependent behavior (i.e. the selection is dependent on the order in which routes appeared). This option enables a dierent (and slower) algorithm implementing proper RFC 4271 route selection, which is deterministic. Alternative way how to get deterministic behavior is to use med metric option. This option is incompatible with 2 (sorted tables). Default: o.

igp metric switch Enable comparison of internal distances to boundary routers during best route selection. Default: on. prefer older switch Standard route selection algorithm breaks ties by comparing router IDs. This changes the behavior to prefer older routes (when both are external and from dierent peer). For details, see RFC 5004. Default: o. default bgp med number Value of the Multiple Exit Discriminator to be used during route selection when the MED attribute is missing. Default: 0. default bgp local pref number A default value for the Local Preference attribute. It is used when a new Local Preference attribute is attached to a route by the BGP protocol itself (for example, if a route is received through eBGP and therefore does not have such attribute). Default: 100 (0 in pre-1.2.0 versions of BIRD).

6.1.4

Attributes

BGP denes several route attributes. Some of them (those marked with I in the table below) are available on internal BGP connections only, some of them (marked with O) are optional. bgppath bgp path Sequence of AS numbers describing the AS path the packet will travel through when forwarded according to the particular route. In case of internal BGP it doesnt contain the number of the local AS. int bgp local pref [I] Local preference value used for selection among multiple BGP routes (see the selection rules above). Its used as an additional metric which is propagated through the whole local AS. int bgp med [O] The Multiple Exit Discriminator of the route is an optional attribute which is used on external (interAS) links to convey to an adjacent AS the optimal entry point into the local AS. The received attribute is also propagated over internal BGP links. The attribute value is zeroed when a route is exported to an external BGP instance to ensure that the attribute received from a neighboring AS is not propagated to other neighboring ASes. A new value might be set in the export lter of an external BGP instance. See RFC 4451 for further discussion of BGP MED attribute. enum bgp origin Origin of the route: either ORIGIN IGP if the route has originated in an interior routing protocol or ORIGIN EGP if its been imported from the EGP protocol (nowadays it seems to be obsolete) or ORIGIN INCOMPLETE if the origin is unknown. ip bgp next hop Next hop to be used for forwarding of packets to this destination. On internal BGP connections, its an address of the originating router if its inside the local AS or a boundary router the packet will leave the AS through if its an exterior route, so each BGP speaker within the AS has a chance to use the shortest interior path possible to this point. void bgp atomic aggr [O] This is an optional attribute which carries no value, but the sole presence of which indicates that the route has been aggregated from multiple routes by some router on the path from the originator.

6.2. Device

25

clist bgp community [O] List of community values associated with the route. Each such value is a pair (represented as a pair data type inside the lters) of 16-bit integers, the rst of them containing the number of the AS which denes the community and the second one being a per-AS identier. There are lots of uses of the community mechanism, but generally they are used to carry policy information like dont export to USA peers. As each AS can dene its own routing policy, it also has a complete freedom about which community attributes it denes and what will their semantics be. eclist bgp ext community [O] List of extended community values associated with the route. Extended communities have similar usage as plain communities, but they have an extended range (to allow 4B ASNs) and a nontrivial structure with a type eld. Individual community values are represented using an ec data type inside the lters. quad bgp originator id [I, O] This attribute is created by the route reector when reecting the route and contains the router ID of the originator of the route in the local AS. clist bgp cluster list [I, O] This attribute contains a list of cluster IDs of route reectors. Each route reector prepends its cluster ID when reecting the route.

6.1.5

Example
protocol bgp { local as 65000; # Use a private AS number neighbor 198.51.100.130 as 64496; # Our neighbor ... multihop; # ... which is connected indirectly export filter { # We use non-trivial export rules if source = RTS_STATIC then { # Export only static routes # Assign our community bgp_community.add((65000,64501)); # Artificially increase path length # by advertising local AS number twice if bgp_path ~ [= 65000 =] then bgp_path.prepend(65000); accept; } reject; }; import all; source address 198.51.100.14; # Use a non-standard source address }

6.2

Device

The Device protocol is not a real routing protocol. It doesnt generate any routes and it only serves as a module for getting information about network interfaces from the kernel. Except for very unusual circumstances, you probably should include this protocol in the conguration since almost all other protocols require network interfaces to be dened for them to work with.

6.2.1

Conguration

scan time number Time in seconds between two scans of the network interface list. On systems where we are notied about interface status changes asynchronously (such as newer versions of Linux), we need to scan the

26

Chapter 6. Protocols list only in order to avoid confusion by lost notication messages, so the default time is set to a large value.

primary [ "mask " ] prex If a network interface has more than one network address, BIRD has to choose one of them as a primary one. By default, BIRD chooses the lexicographically smallest address as the primary one. This option allows to specify which network address should be chosen as a primary one. Network addresses that match prex are preferred to non-matching addresses. If more primary options are used, the rst one has the highest preference. If mask is specied, then such primary option is relevant only to matching network interfaces. In all cases, an address marked by operating system as secondary cannot be chosen as the primary one. As the Device protocol doesnt generate any routes, it cannot have any attributes. Example conguration looks like this: protocol device { scan time 10; # Scan the interfaces often primary "eth0" 192.168.1.1; primary 192.168.0.0/16; }

6.3

Direct

The Direct protocol is a simple generator of device routes for all the directly connected networks according to the list of interfaces provided by the kernel via the Device protocol. The question is whether it is a good idea to have such device routes in BIRD routing table. OS kernel usually handles device routes for directly connected networks by itself so we dont need (and dont want) to export these routes to the kernel protocol. OSPF protocol creates device routes for its interfaces itself and BGP protocol is usually used for exporting aggregate routes. Although there are some use cases that use the direct protocol (like abusing eBGP as an IGP routing protocol), in most cases it is not needed to have these device routes in BIRD routing table and to use the direct protocol. There is one notable case when you denitely want to use the direct protocol running BIRD on BSD systems. Having high priority device routes for directly connected networks from the direct protocol protects kernel device routes from being overwritten or removed by IGP routes during some transient network conditions, because a lower priority IGP route for the same network is not exported to the kernel routing table. This is an issue on BSD systems only, as on Linux systems BIRD cannot change non-BIRD route in the kernel routing table. The only congurable thing about direct is what interfaces it watches: interface pattern [, ...] By default, the Direct protocol will generate device routes for all the interfaces available. If you want to restrict it to some subset of interfaces (for example if youre using multiple routing tables for policy routing and some of the policy domains dont contain all interfaces), just use this clause. Direct device routes dont contain any specic attributes. Example cong might look like this: protocol direct { interface "-arc*", "*"; }

# Exclude the ARCnets

6.4

Kernel

The Kernel protocol is not a real routing protocol. Instead of communicating with other routers in the network, it performs synchronization of BIRDs routing tables with the OS kernel. Basically, it sends all

6.4. Kernel

27

routing table updates to the kernel and from time to time it scans the kernel tables to see whether some routes have disappeared (for example due to unnoticed up/down transition of an interface) or whether an alien route has been added by someone else (depending on the learn switch, such routes are either ignored or accepted to our table). Unfortunately, there is one thing that makes the routing table synchronization a bit more complicated. In the kernel routing table there are also device routes for directly connected networks. These routes are usually managed by OS itself (as a part of IP address conguration) and we dont want to touch that. They are completely ignored during the scan of the kernel tables and also the export of device routes from BIRD tables to kernel routing tables is restricted to prevent accidental interference. This restriction can be disabled using device routes switch. If your OS supports only a single routing table, you can congure only one instance of the Kernel protocol. If it supports multiple tables (in order to allow policy routing; such an OS is for example Linux), you can run as many instances as you want, but each of them must be connected to a dierent BIRD routing table and to a dierent kernel table. Because the kernel protocol is partially integrated with the connected routing table, there are two limitations - it is not possible to connect more kernel protocols to the same routing table and changing route destination/gateway in an export lter of a kernel protocol does not work. Both limitations can be overcome using another routing table and the pipe protocol.

6.4.1

Conguration

persist switch Tell BIRD to leave all its routes in the routing tables when it exits (instead of cleaning them up). scan time number Time in seconds between two consecutive scans of the kernel routing table. learn switch Enable learning of routes added to the kernel routing tables by other routing daemons or by the system administrator. This is possible only on systems which support identication of route authorship. device routes switch Enable export of device routes to the kernel routing table. By default, such routes are rejected (with the exception of explicitly congured device routes from the static protocol) regardless of the export lter to protect device routes in kernel routing table (managed by OS itself) from accidental overwriting or erasing. kernel table number Select which kernel table should this particular instance of the Kernel protocol work with. Available only on systems supporting multiple routing tables.

6.4.2

Attributes

The Kernel protocol denes several attributes. These attributes are translated to appropriate system (and OS-specic) route attributes. We support these attributes: int krt source The original source of the imported kernel route. The value is system-dependent. On Linux, it is a value of the protocol eld of the route. See /etc/iproute2/rt protos for common values. On BSD, it is based on STATIC and PROTOx ags. The attribute is read-only. int krt metric The kernel metric of the route. When multiple same routes are in a kernel routing table, the Linux kernel chooses one with lower metric. ip krt prefsrc (Linux) The preferred source address. Used in source address selection for outgoing packets. Have to be one of IP addresses of the router.

28 int krt realm (Linux) The realm of the route. Can be used for trac classication.

Chapter 6. Protocols

6.4.3

Example

A simple conguration can look this way: protocol kernel { export all; } Or for a system with two routing tables: protocol kernel { learn; persist; scan time 10; import all; export all; } protocol kernel { table auxtable; kernel table 100; export all; } # # # # Primary routing table Learn alien routes from the kernel Dont remove routes on bird shutdown Scan kernel routing table every 10 seconds

# Secondary routing table

6.5
6.5.1

OSPF
Introduction

Open Shortest Path First (OSPF) is a quite complex interior gateway protocol. The current IPv4 version (OSPFv2) is dened in RFC 2328 and the current IPv6 version (OSPFv3) is dened in RFC 5340 Its a link state (a.k.a. shortest path rst) protocol each router maintains a database describing the autonomous systems topology. Each participating router has an identical copy of the database and all routers run the same algorithm calculating a shortest path tree with themselves as a root. OSPF chooses the least cost path as the best path. In OSPF, the autonomous system can be split to several areas in order to reduce the amount of resources consumed for exchanging the routing information and to protect the other areas from incorrect routing data. Topology of the area is hidden to the rest of the autonomous system. Another very important feature of OSPF is that it can keep routing information from other protocols (like Static or BGP) in its link state database as external routes. Each external route can be tagged by the advertising router, making it possible to pass additional information between routers on the boundary of the autonomous system. OSPF quickly detects topological changes in the autonomous system (such as router interface failures) and calculates new loop-free routes after a short period of convergence. Only a minimal amount of routing trac is involved. Each router participating in OSPF routing periodically sends Hello messages to all its interfaces. This allows neighbors to be discovered dynamically. Then the neighbors exchange theirs parts of the link state database and keep it identical by ooding updates. The ooding process is reliable and ensures that each router detects all changes.

6.5.2

Conguration

In the main part of conguration, there can be multiple denitions of OSPF areas, each with a dierent id. These denitions includes many other switches and multiple denitions of interfaces. Denition of interface may contain many switches and constant denitions and list of neighbors on nonbroadcast networks.

6.5. OSPF protocol ospf <name> { rfc1583compat <switch>; stub router <switch>; tick <num>; ecmp <switch> [limit <num>]; area <id> { stub; nssa; summary <switch>; default nssa <switch>; default cost <num>; default cost2 <num>; translator <switch>; translator stability <num>; networks { <prefix>; <prefix> hidden; } external { <prefix>; <prefix> hidden; <prefix> tag <num>; } stubnet <prefix>; stubnet <prefix> { hidden <switch>; summary <switch>; cost <num>; } interface <interface pattern> [instance <num>] { cost <num>; stub <switch>; hello <num>; poll <num>; retransmit <num>; priority <num>; wait <num>; dead count <num>; dead <num>; rx buffer [normal|large|<num>]; type [broadcast|bcast|pointopoint|ptp| nonbroadcast|nbma|pointomultipoint|ptmp]; strict nonbroadcast <switch>; real broadcast <switch>; ptp netmask <switch>; check link <switch>; ecmp weight <num>; ttl security [<switch>; | tx only] tx class|dscp <num>; tx priority <num>; authentication [none|simple|cryptographic]; password "<text>"; password "<text>" { id <num>; generate from "<date>"; generate to "<date>";

29

30 accept from "<date>"; accept to "<date>"; }; neighbors { <ip>; <ip> eligible; };

Chapter 6. Protocols

}; virtual link <id> [instance <num>] { hello <num>; retransmit <num>; wait <num>; dead count <num>; dead <num>; authentication [none|simple|cryptographic]; password "<text>"; }; }; } rfc1583compat switch This option controls compatibility of routing table calculation with RFC 1583. Default value is no. stub router switch This option congures the router to be a stub router, i.e., a router that participates in the OSPF topology but does not allow transit trac. In OSPFv2, this is implemented by advertising maximum metric for outgoing links, as suggested by RFC 3137. In OSPFv3, the stub router behavior is announced by clearing the R-bit in the router LSA. Default value is no. tick num The routing table calculation and clean-up of areas databases is not performed when a single link state change arrives. To lower the CPU utilization, its processed later at periodical intervals of num seconds. The default value is 1. ecmp switch [limit number ] This option species whether OSPF is allowed to generate ECMP (equal-cost multipath) routes. Such routes are used when there are several directions to the destination, each with the same (computed) cost. This option also allows to specify a limit on maximal number of nexthops in one route. By default, ECMP is disabled. If enabled, default value of the limit is 16. area id This denes an OSPF area with given area ID (an integer or an IPv4 address, similarly to a router ID). The most important area is the backbone (ID 0) to which every other area must be connected. stub This option congures the area to be a stub area. External routes are not ooded into stub areas. Also summary LSAs can be limited in stub areas (see option summary). By default, the area is not a stub area. nssa This option congures the area to be a NSSA (Not-So-Stubby Area). NSSA is a variant of a stub area which allows a limited way of external route propagation. Global external routes are not propagated into a NSSA, but an external route can be imported into NSSA as a (area-wide) NSSA-LSA (and possibly translated and/or aggregated on area boundary). By default, the area is not NSSA. summary switch This option controls propagation of summary LSAs into stub or NSSA areas. If enabled, summary LSAs are propagated as usual, otherwise just the default summary route (0.0.0.0/0) is propagated (this is sometimes called totally stubby area). If a stub area has more area boundary routers, propagating summary LSAs could lead to more ecient routing at the cost of larger link state database. Default value is no.

6.5. OSPF

31

default nssa switch When summary option is enabled, default summary route is no longer propagated to the NSSA. In that case, this option allows to originate default route as NSSA-LSA to the NSSA. Default value is no. default cost num This option controls the cost of a default route propagated to stub and NSSA areas. Default value is 1000. default cost2 num When a default route is originated as NSSA-LSA, its cost can use either type 1 or type 2 metric. This option allows to specify the cost of a default route in type 2 metric. By default, type 1 metric (option default cost) is used. translator switch This option controls translation of NSSA-LSAs into external LSAs. By default, one translator per NSSA is automatically elected from area boundary routers. If enabled, this area boundary router would unconditionally translate all NSSA-LSAs regardless of translator election. Default value is no. translator stability num This option controls the translator stability interval (in seconds). When the new translator is elected, the old one keeps translating until the interval is over. Default value is 40. networks { set } Denition of area IP ranges. This is used in summary LSA origination. Hidden networks are not propagated into other areas. external { set } Denition of external area IP ranges for NSSAs. This is used for NSSA-LSA translation. Hidden networks are not translated into external LSAs. Networks can have congured route tag. stubnet prex { options } Stub networks are networks that are not transit networks between OSPF routers. They are also propagated through an OSPF area as a part of a link state database. By default, BIRD generates a stub network record for each primary network address on each OSPF interface that does not have any OSPF neighbors, and also for each non-primary network address on each OSPF interface. This option allows to alter a set of stub networks propagated by this router. Each instance of this option adds a stub network with given network prex to the set of propagated stub network, unless option hidden is used. It also suppresses default stub networks for given network prex. When option summary is used, also default stub networks that are subnetworks of given stub network are suppressed. This might be used, for example, to aggregate generated stub networks. interface pattern [instance num ] Denes that the specied interfaces belong to the area being dened. See 3.3 (interface) common option for detailed description. In OSPFv3, you can specify instance ID for that interface description, so it is possible to have several instances of that interface with dierent options or even in dierent areas. virtual link id [instance num ] Virtual link to router with the router id. Virtual link acts as a point-to-point interface belonging to backbone. The actual area is used as transport area. This item cannot be in the backbone. In OSPFv3, you could also use several virtual links to one destination with dierent instance IDs. cost num Species output cost (metric) of an interface. Default value is 10. stub switch If set to interface it does not listen to any packet and does not send any hello. Default value is no. hello num Species interval in seconds between sending of Hello messages. Beware, all routers on the same network need to have the same hello interval. Default value is 10.

32

Chapter 6. Protocols

poll num Species interval in seconds between sending of Hello messages for some neighbors on NBMA network. Default value is 20. retransmit num Species interval in seconds between retransmissions of unacknowledged updates. Default value is 5. priority num On every multiple access network (e.g., the Ethernet) Designed Router and Backup Designed router are elected. These routers have some special functions in the ooding process. Higher priority increases preferences in this election. Routers with priority 0 are not eligible. Default value is 1. wait num After start, router waits for the specied number of seconds between starting election and building adjacency. Default value is 40. dead count num When the router does not receive any messages from a neighbor in dead count *hello seconds, it will consider the neighbor down. dead num When the router does not receive any messages from a neighbor in dead seconds, it will consider the neighbor down. If both directives dead count and dead are used, dead has precendence. rx buffer num This sets the size of buer used for receiving packets. The buer should be bigger than maximal size of any packets. Value NORMAL (default) means 2*MTU, value LARGE means maximal allowed packet - 65535. type broadcast|bcast BIRD detects a type of a connected network automatically, but sometimes its convenient to force use of a dierent type manually. On broadcast networks (like ethernet), ooding and Hello messages are sent using multicasts (a single packet for all the neighbors). A designated router is elected and it is responsible for synchronizing the link-state databases and originating network LSAs. This network type cannot be used on physically NBMA networks and on unnumbered networks (networks without proper IP prex). type pointopoint|ptp Point-to-point networks connect just 2 routers together. No election is performed and no network LSA is originated, which makes it simpler and faster to establish. This network type is useful not only for physically PtP ifaces (like PPP or tunnels), but also for broadcast networks used as PtP links. This network type cannot be used on physically NBMA networks. type nonbroadcast|nbma On NBMA networks, the packets are sent to each neighbor separately because of lack of multicast capabilities. Like on broadcast networks, a designated router is elected, which plays a central role in propagation of LSAs. This network type cannot be used on unnumbered networks. type pointomultipoint|ptmp This is another network type designed to handle NBMA networks. In this case the NBMA network is treated as a collection of PtP links. This is useful if not every pair of routers on the NBMA network has direct communication, or if the NBMA network is used as an (possibly unnumbered) PtP link. strict nonbroadcast switch If set, dont send hello to any undened neighbor. This switch is ignored on other than NBMA or PtMP networks. Default value is no. real broadcast switch In type broadcast or type ptp network conguration, OSPF packets are sent as IP multicast packets. This option changes the behavior to using old-fashioned IP broadcast packets. This may be useful as a workaround if IP multicast for some reason does not work or does not work reliably. This is a nonstandard option and probably is not interoperable with other OSPF implementations. Default value is no.

6.5. OSPF

33

ptp netmask switch In type ptp network congurations, OSPFv2 implementations should ignore received netmask eld in hello packets and should send hello packets with zero netmask eld on unnumbered PtP links. But some OSPFv2 implementations perform netmask checking even for PtP links. This option species whether real netmask will be used in hello packets on type ptp interfaces. You should ignore this option unless you meet some compatibility problems related to this issue. Default value is no for unnumbered PtP links, yes otherwise. check link switch If set, a hardware link state (reported by OS) is taken into consideration. When a link disappears (e.g. an ethernet cable is unplugged), neighbors are immediately considered unreachable and only the address of the iface (instead of whole network prex) is propagated. It is possible that some hardware drivers or platforms do not implement this feature. Default value is no. ttl security [switch | tx only] TTL security is a feature that protects routing protocols from remote spoofed packets by using TTL 255 instead of TTL 1 for protocol packets destined to neighbors. Because TTL is decremented when packets are forwarded, it is non-trivial to spoof packets with TTL 255 from remote locations. Note that this option would interfere with OSPF virtual links. If this option is enabled, the router will send OSPF packets with TTL 255 and drop received packets with TTL less than 255. If this option si set to tx only, TTL 255 is used for sent packets, but is not checked for received packets. Default value is no. tx class|dscp|priority num These options specify the ToS/DiServ/Trac class/Priority of the outgoing OSPF packets. See 3.3 (tx class) common option for detailed description. ecmp weight num When ECMP (multipath) routes are allowed, this value species a relative weight used for nexthops going through the iface. Allowed values are 1-256. Default value is 1. authentication none No passwords are sent in OSPF packets. This is the default value. authentication simple Every packet carries 8 bytes of password. Received packets lacking this password are ignored. This authentication mechanism is very weak. authentication cryptographic 16-byte long MD5 digest is appended to every packet. For the digest generation 16-byte long passwords are used. Those passwords are not sent via network, so this mechanism is quite secure. Packets can still be read by an attacker. password "text " An 8-byte or 16-byte password used for authentication. See 3.3 (password) common option for detailed description. neighbors { set } A set of neighbors to which Hello messages on NBMA or PtMP networks are to be sent. For NBMA networks, some of them could be marked as eligible. In OSPFv3, link-local addresses should be used, using global ones is possible, but it is nonstandard and might be problematic. And denitely, link-local and global addresses should not be mixed.

6.5.3

Attributes

OSPF denes four route attributes. Each internal route has a metric. Metric is ranging from 1 to innity (65535). External routes use metric type 1 or metric type 2. A metric of type 1 is comparable with internal metric, a metric of type 2 is always longer than any metric of type 1 or any internal metric. Internal metric or metric of type 1 is stored in attribute ospf metric1, metric type 2 is stored in attribute ospf metric2. If you specify both metrics only metric1 is used.

34

Chapter 6. Protocols

Each external route can also carry attribute ospf tag which is a 32-bit integer which is used when exporting routes to other protocols; otherwise, it doesnt aect routing inside the OSPF domain at all. The fourth attribute ospf router id is a router ID of the router advertising that route/network. This attribute is read-only. Default is ospf metric2 = 10000 and ospf tag = 0.

6.5.4

Example
protocol ospf MyOSPF { rfc1583compat yes; tick 2; export filter { if source = RTS_BGP then { ospf_metric1 = 100; accept; } reject; }; area 0.0.0.0 { interface "eth*" { cost 11; hello 15; priority 100; retransmit 7; authentication simple; password "aaa"; }; interface "ppp*" { cost 100; authentication cryptographic; password "abc" { id 1; generate to "22-04-2003 accept from "17-01-2001 }; password "def" { id 2; generate to "22-07-2005 accept from "22-02-2001 }; }; interface "arc0" { cost 10; stub yes; }; interface "arc1"; }; area 120 { stub yes; networks { 172.16.1.0/24; 172.16.2.0/24 hidden; } interface "-arc0" , "arc*" { type nonbroadcast; authentication none; strict nonbroadcast yes; wait 120;

11:00:06"; 12:01:05";

17:03:21"; 11:34:06";

6.6. Pipe poll 40; dead count 8; neighbors { 192.168.120.1 eligible; 192.168.120.2; 192.168.120.10; }; }; }; }

35

6.6
6.6.1

Pipe
Introduction

The Pipe protocol serves as a link between two routing tables, allowing routes to be passed from a table declared as primary (i.e., the one the pipe is connected to using the table conguration keyword) to the secondary one (declared using peer table) and vice versa, depending on whats allowed by the lters. Export lters control export of routes from the primary table to the secondary one, import lters control the opposite direction. The Pipe protocol may work in the transparent mode mode or in the opaque mode. In the transparent mode, the Pipe protocol retransmits all routes from one table to the other table, retaining their original source and attributes. If import and export lters are set to accept, then both tables would have the same content. The transparent mode is the default mode. In the opaque mode, the Pipe protocol retransmits optimal route from one table to the other table in a similar way like other protocols send and receive routes. Retransmitted route will have the source set to the Pipe protocol, which may limit access to protocol specic route attributes. This mode is mainly for compatibility, it is not suggested for new congs. The mode can be changed by mode option. The primary use of multiple routing tables and the Pipe protocol is for policy routing, where handling of a single packet doesnt depend only on its destination address, but also on its source address, source interface, protocol type and other similar parameters. In many systems (Linux being a good example), the kernel allows to enforce routing policies by dening routing rules which choose one of several routing tables to be used for a packet according to its parameters. Setting of these rules is outside the scope of BIRDs work (on Linux, you can use the ip command), but you can create several routing tables in BIRD, connect them to the kernel ones, use lters to control which routes appear in which tables and also you can employ the Pipe protocol for exporting a selected subset of one table to another one.

6.6.2

Conguration

peer table table Denes secondary routing table to connect to. The primary one is selected by the table keyword. mode opaque|transparent Species the mode for the pipe to work in. Default is transparent.

6.6.3

Attributes

The Pipe protocol doesnt dene any route attributes.

6.6.4

Example

Lets consider a router which serves as a boundary router of two dierent autonomous systems, each of them connected to a subset of interfaces of the router, having its own exterior connectivity and wishing to use the other AS as a backup connectivity in case of outage of its own exterior line. Probably the simplest solution to this situation is to use two routing tables (well call them as1 and as2) and set up kernel routing rules, so that packets having arrived from interfaces belonging to the rst AS will

36

Chapter 6. Protocols

be routed according to as1 and similarly for the second AS. Thus we have split our router to two logical routers, each one acting on its own routing table, having its own routing protocols on its own interfaces. In order to use the other ASs routes for backup purposes, we can pass the routes between the tables through a Pipe protocol while decreasing their preferences and correcting their BGP paths to reect the AS boundary crossing.

table as1; table as2; protocol kernel kern1 { table as1; kernel table 1; } protocol kernel kern2 { table as2; kernel table 2; } protocol bgp bgp1 { table as1; local as 1; neighbor 192.168.0.1 as 1001; export all; import all; } protocol bgp bgp2 { table as2; local as 2; neighbor 10.0.0.1 as 1002; export all; import all; }

# Define the tables

# Synchronize them with the kernel

# The outside connections

protocol pipe { # The Pipe table as1; peer table as2; export filter { if net ~ [ 1.0.0.0/8+] then { # Only AS1 networks if preference>10 then preference = preference-10; if source=RTS_BGP then bgp_path.prepend(1); accept; } reject; }; import filter { if net ~ [ 2.0.0.0/8+] then { # Only AS2 networks if preference>10 then preference = preference-10; if source=RTS_BGP then bgp_path.prepend(2); accept; } reject; }; }

6.7. RAdv

37

6.7
6.7.1

RAdv
Introduction

The RAdv protocol is an implementation of Router Advertisements, which are used in the IPv6 stateless autoconguration. IPv6 routers send (in irregular time intervals or as an answer to a request) advertisement packets to connected networks. These packets contain basic information about a local network (e.g. a list of network prexes), which allows network hosts to autocongure network addresses and choose a default route. BIRD implements router behavior as dened in RFC 4861 and also the DNS extensions from RFC 6106.

6.7.2

Conguration

There are several classes of denitions in RAdv conguration interface denitions, prex denitions and DNS denitions: interface pattern [, ...] { options } Interface denitions specify a set of interfaces on which the protocol is activated and contain interface specic options. See 3.3 (interface) common options for detailed description. prefix prex { options } Prex denitions allow to modify a list of advertised prexes. By default, the advertised prexes are the same as the network prexes assigned to the interface. For each network prex, the matching prex denition is found and its options are used. If no matching prex denition is found, the prex is used with default options. Prex denitions can be either global or interface-specic. The second ones are part of interface options. The prex denition matching is done in the rst-match style, when interface-specic denitions are processed before global denitions. As expected, the prex denition is matching if the network prex is a subnet of the prex in prex denition. rdnss { options } RDNSS denitions allow to specify a list of advertised recursive DNS servers together with their options. As options are seldom necessary, there is also a short variant rdnss address that just species one DNS server. Multiple denitions are cumulative. RDNSS denitions may also be interface-specic when used inside interface options. By default, interface uses both global and interface-specic options, but that can be changed by rdnss local option. dnssl { options } DNSSL denitions allow to specify a list of advertised DNS search domains together with their options. Like rdnss above, multiple denitions are cumulative, they can be used also as interface-specic options and there is a short variant dnssl domain that just species one DNS search domain. trigger prex RAdv protocol could be congured to change its behavior based on availability of routes. When this option is used, the protocol waits in suppressed state until a trigger route (for the specied network) is exported to the protocol, the protocol also returnsd to suppressed state if the trigger route disappears. Note that route export depends on specied export lter, as usual. This option could be used, e.g., for handling failover in multihoming scenarios. During suppressed state, router advertisements are generated, but with some elds zeroed. Exact behavior depends on which elds are zeroed, this can be congured by sensitive option for appropriate elds. By default, just default lifetime (also called router lifetime) is zeroed, which means hosts cannot use the router as a default router. preferred lifetime and valid lifetime could also be congured as sensitive for a prex, which would cause autocongured IPs to be deprecated or even removed. Interface specic options: max ra interval expr Unsolicited router advertisements are sent in irregular time intervals. This option species the maximum length of these intervals, in seconds. Valid values are 4-1800. Default: 600

38

Chapter 6. Protocols

min ra interval expr This option species the minimum length of that intervals, in seconds. Must be at least 3 and at most 3/4 * max ra interval. Default: about 1/3 * max ra interval. min delay expr The minimum delay between two consecutive router advertisements, in seconds. Default: 3 managed switch This option species whether hosts should use DHCPv6 for IP address conguration. Default: no other config switch This option species whether hosts should use DHCPv6 to receive other conguration information. Default: no link mtu expr This option species which value of MTU should be used by hosts. 0 means unspecied. Default: 0 reachable time expr This option species the time (in milliseconds) how long hosts should assume a neighbor is reachable (from the last conrmation). Maximum is 3600000, 0 means unspecied. Default 0. retrans timer expr This option species the time (in milliseconds) how long hosts should wait before retransmitting Neighbor Solicitation messages. 0 means unspecied. Default 0. current hop limit expr This option species which value of Hop Limit should be used by hosts. Valid values are 0-255, 0 means unspecied. Default: 64 default lifetime expr [sensitive switch ] This option species the time (in seconds) how long (after the receipt of RA) hosts may use the router as a default router. 0 means do not use as a default router. For sensitive option, see 6.7.2 (trigger). Default: 3 * max ra interval, sensitive yes. rdnss local switch Use only local (interface-specic) RDNSS denitions for this interface. Otherwise, both global and local denitions are used. Could also be used to disable RDNSS for given interface if no local denitons are specied. Default: no. dnssl local switch Use only local DNSSL denitions for this interface. See rdnss local option above. Default: no. Prex specic options: skip switch This option allows to specify that given prex should not be advertised. This is useful for making exceptions from a default policy of advertising all prexes. Note that for withdrawing an already advertised prex it is more useful to advertise it with zero valid lifetime. Default: no onlink switch This option species whether hosts may use the advertised prex for onlink determination. Default: yes autonomous switch This option species whether hosts may use the advertised prex for stateless autoconguration. Default: yes valid lifetime expr [sensitive switch ] This option species the time (in seconds) how long (after the receipt of RA) the prex information is valid, i.e., autocongured IP addresses can be assigned and hosts with that IP addresses are considered directly reachable. 0 means the prex is no longer valid. For sensitive option, see 6.7.2 (trigger). Default: 86400 (1 day), sensitive no.

6.7. RAdv

39

preferred lifetime expr [sensitive switch ] This option species the time (in seconds) how long (after the receipt of RA) IP addresses generated from the prex using stateless autoconguration remain preferred. For sensitive option, see 6.7.2 (trigger). Default: 14400 (4 hours), sensitive no. RDNSS specic options: ns address This option species one recursive DNS server. Can be used multiple times for multiple servers. It is mandatory to have at least one ns option in rdnss denition. lifetime [mult] expr This option species the time how long the RDNSS information may be used by clients after the receipt of RA. It is expressed either in seconds or (when mult is used) in multiples of max ra interval. Note that RDNSS information is also invalidated when default lifetime expires. 0 means these addresses are no longer valid DNS servers. Default: 3 * max ra interval. DNSSL specic options: domain address This option species one DNS search domain. Can be used multiple times for multiple domains. It is mandatory to have at least one domain option in dnssl denition. lifetime [mult] expr This option species the time how long the DNSSL information may be used by clients after the receipt of RA. Details are the same as for RDNSS lifetime option above. Default: 3 * max ra interval.

6.7.3

Example
protocol radv { interface "eth2" { max ra interval 5; # Fast failover with more routers managed yes; # Using DHCPv6 on eth2 prefix ::/0 { autonomous off; # So do not autoconfigure any IP }; }; interface "eth*"; prefix 2001:0DB8:1234::/48 { preferred lifetime 0; }; prefix 2001:0DB8:2000::/48 { autonomous off; }; rdnss 2001:0DB8:1234::10; rdnss { lifetime mult 10; ns 2001:0DB8:1234::11; ns 2001:0DB8:1234::12; }; dnssl { lifetime 3600; # No need for any other options

# Deprecated address range

# Do not autoconfigure

# Short form of RDNSS

40 domain "abc.com"; domain "xyz.com"; }; }

Chapter 6. Protocols

6.8
6.8.1

RIP
Introduction

The RIP protocol (also sometimes called Rest In Pieces) is a simple protocol, where each router broadcasts (to all its neighbors) distances to all networks it can reach. When a router hears distance to another network, it increments it and broadcasts it back. Broadcasts are done in regular intervals. Therefore, if some network goes unreachable, routers keep telling each other that its distance is the original distance plus 1 (actually, plus interface metric, which is usually one). After some time, the distance reaches innity (thats 15 in RIP) and all routers know that network is unreachable. RIP tries to minimize situations where counting to innity is necessary, because it is slow. Due to innity being 16, you cant use RIP on networks where maximal distance is higher than 15 hosts. You can read more about RIP at http://www.ietf.org/html.charters/ripcharter.html. Both IPv4 (RFC 1723) and IPv6 (RFC 2080) versions of RIP are supported by BIRD, historical RIPv1 (RFC 1058)is not currently supported. RIPv4 MD5 authentication (RFC 2082) is supported. RIP is a very simple protocol, and it has a lot of shortcomings. Slow convergence, big network load and inability to handle larger networks makes it pretty much obsolete. (It is still usable on very small networks.)

6.8.2

Conguration

In addition to options common for all to other protocols, RIP supports the following ones: authentication none|plaintext|md5 selects authentication method to be used. none means that packets are not authenticated at all, plaintext means that a plaintext password is embedded into each packet, and md5 means that packets are authenticated using a MD5 cryptographic hash. If you set authentication to not-none, it is a good idea to add password section. Default: none. honor always|neighbor|never species when should requests for dumping routing table be honored. (Always, when sent from a host on a directly connected network or never.) Routing table updates are honored only from neighbors, that is not congurable. Default: never. There are some options that can be specied per-interface: metric num This option species the metric of the interface. Valid mode multicast|broadcast|quiet|nolisten|version1 This option selects the mode for RIP to work in. If nothing is specied, RIP runs in multicast mode. version1 is currently equivalent to broadcast, and it makes RIP talk to a broadcast address even through multicast mode is possible. quiet option means that RIP will not transmit any periodic messages to this interface and nolisten means that RIP will send to this interface butnot listen to it. ttl security [switch | tx only] TTL security is a feature that protects routing protocols from remote spoofed packets by using TTL 255 instead of TTL 1 for protocol packets destined to neighbors. Because TTL is decremented when packets are forwarded, it is non-trivial to spoof packets with TTL 255 from remote locations. If this option is enabled, the router will send RIP packets with TTL 255 and drop received packets with TTL less than 255. If this option si set to tx only, TTL 255 is used for sent packets, but is not checked for received packets. Such setting does not oer protection, but oers compatibility with neighbors regardless of whether they use ttl security. Note that for RIPng, TTL security is a standard behavior (required by RFC 2080), but BIRD uses tx only by default, for compatibility with older versions. For IPv4 RIP, default value is no.

6.9. Static

41

tx class|dscp|priority num These options specify the ToS/DiServ/Trac class/Priority of the outgoing RIP packets. See 3.3 (tx class) common option for detailed description. The following options generally override behavior specied in RFC. If you use any of these options, BIRD will no longer be RFC-compliant, which means it will not be able to talk to anything other than equally congured BIRD. I have warned you. port number selects IP port to operate on, default 520. (This is useful when testing BIRD, if you set this to an address >1024, you will not need to run bird with UID==0). infinity number selects the value of innity, default is 16. Bigger values will make protocol convergence even slower. period number species the number of seconds between periodic updates. Default is 30 seconds. A lower number will mean faster convergence but bigger network load. Do not use values lower than 12. timeout time number species how old route has to be to be considered unreachable. Default is 4*period. garbage time number species how old route has to be to be discarded. Default is 10*period.

6.8.3

Attributes

RIP denes two route attributes: int rip metric RIP metric of the route (ranging from 0 to infinity). When routes from dierent RIP instances are available and all of them have the same preference, BIRD prefers the route with lowest rip metric. When importing a non-RIP route, the metric defaults to 5. int rip tag RIP route tag: a 16-bit number which can be used to carry additional information with the route (for example, an originating AS number in case of external routes). When importing a non-RIP route, the tag defaults to 0.

6.8.4

Example
protocol rip MyRIP_test { debug all; port 1520; period 12; garbage time 60; interface "eth0" { metric 3; mode multicast; }; interface "eth*" { metric 2; mode broadcast; }; honor neighbor; authentication none; import filter { print "importing"; accept; }; export filter { print "exporting"; accept; }; }

6.9

Static

The Static protocol doesnt communicate with other routers in the network, but instead it allows you to dene routes manually. This is often used for specifying how to forward packets to parts of the network

42

Chapter 6. Protocols

which dont use dynamic routing at all and also for dening sink routes (i.e., those telling to return packets as undeliverable if they are in your IP block, you dont have any specic destination for them and you dont want to send them out through the default route to prevent routing loops). There are ve types of static routes: classical routes telling to forward packets to a neighboring router, multipath routes specifying several (possibly weighted) neighboring routers, device routes specifying forwarding to hosts on a directly connected network, recursive routes computing their nexthops by doing route table lookups for a given IP and special routes (sink, blackhole etc.) which specify a special action to be done instead of forwarding the packet. When the particular destination is not available (the interface is down or the next hop of the route is not a neighbor at the moment), Static just uninstalls the route from the table it is connected to and adds it again as soon as the destination becomes adjacent again. The Static protocol does not have many conguration options. The denition of the protocol contains mainly a list of static routes: route prex via ip Static route through a neighboring router. route prex multipath via ip [weight num ] [via ...] Static multipath route. Contains several nexthops (gateways), possibly with their weights. route prex via interface Static device route through an interface to hosts on a directly connected network. route prex recursive ip Static recursive route, its nexthop depends on a route table lookup for given IP address. route prex blackhole|unreachable|prohibit Special routes specifying to silently drop the packet, return it as unreachable or return it as administratively prohibited. First two targets are also known as drop and reject. check link switch If set, hardware link states of network interfaces are taken into consideration. When link disappears (e.g. ethernet cable is unplugged), static routes directing to that interface are removed. It is possible that some hardware drivers or platforms do not implement this feature. Default: o. igp table name Species a table that is used for route table lookups of recursive routes. Default: the same table as the protocol is connected to. Static routes have no specic attributes. Example static cong might look like this: protocol static { table testable; # Connect to a non-default routing table route 0.0.0.0/0 via 198.51.100.130; # Default route route 10.0.0.0/8 multipath # Multipath route via 198.51.100.10 weight 2 via 198.51.100.20 via 192.0.2.1; route 203.0.113.0/24 unreachable; # Sink route route 10.2.0.0/24 via "arc0"; # Secondary network }

Chapter 7: Conclusions
7.1 Future work

Although BIRD supports all the commonly used routing protocols, there are still some features which would surely deserve to be implemented in future versions of BIRD: Opaque LSAs Route aggregation and ap dampening Multipath routes Multicast routing protocols Ports to other systems

7.2

Getting more help

If you use BIRD, youre welcome to join the bird-users mailing list (bird-users@bird.network.cz) where you can share your experiences with the other users and consult your problems with the authors. To subscribe to the list, just send a subscribe bird-users command in a body of a mail to (majordomo@bird.network.cz). The home page of BIRD can be found at http://bird.network.cz/. BIRD is a relatively young system and it probably contains some bugs. You can report any problems to the bird-users list and the authors will be glad to solve them, but before you do so, please make sure you have read the available documentation and that you are running the latest version (available at bird.network.cz:/pub/bird). (Of course, a patch which xes the bug is always welcome as an attachment.) If you want to understand what is going inside, Internet standards are a good and interesting reading. You can get them from ftp.rfc-editor.org (or a nicely sorted version from atrey.karlin.m.cuni.cz:/pub/rfc). Good luck!

43

You might also like