]> git.ipfire.org Git - thirdparty/bird.git/blob - doc/bird.sgml
Babel: Revamp cost computation and run route selection when cost change
[thirdparty/bird.git] / doc / bird.sgml
1 <!doctype birddoc system>
2
3 <!--
4 BIRD documentation
5
6 This documentation can have 4 forms: sgml (this is master copy), html, ASCII
7 text and dvi/postscript (generated from sgml using sgmltools). You should always
8 edit master copy.
9
10 This is a slightly modified linuxdoc dtd. Anything in <descrip> tags is
11 considered definition of configuration primitives, <cf> is fragment of
12 configuration within normal text, <m> is "meta" information within fragment of
13 configuration - something in config which is not keyword.
14
15 (set-fill-column 80)
16
17 Copyright 1999,2000 Pavel Machek <pavel@ucw.cz>, distribute under GPL version 2 or later.
18
19 -->
20
21 <book>
22
23 <title>BIRD User's Guide
24 <author>
25 Ondrej Filip <it/&lt;feela@network.cz&gt;/,
26 Pavel Machek <it/&lt;pavel@ucw.cz&gt;/,
27 Martin Mares <it/&lt;mj@ucw.cz&gt;/,
28 Ondrej Zajicek <it/&lt;santiago@crfreenet.org&gt;/
29 </author>
30
31 <abstract>
32 This document contains user documentation for the BIRD Internet Routing Daemon project.
33 </abstract>
34
35 <!-- Table of contents -->
36 <toc>
37
38 <!-- Begin the document -->
39
40
41 <chapt>Introduction
42 <label id="intro">
43
44 <sect>What is BIRD
45 <label id="what-is-bird">
46
47 <p>The name `BIRD' is actually an acronym standing for `BIRD Internet Routing
48 Daemon'. Let's take a closer look at the meaning of the name:
49
50 <p><em/BIRD/: Well, we think we have already explained that. It's an acronym
51 standing for `BIRD Internet Routing Daemon', you remember, don't you? :-)
52
53 <p><em/Internet Routing/: It's a program (well, a daemon, as you are going to
54 discover in a moment) which works as a dynamic router in an Internet type
55 network (that is, in a network running either the IPv4 or the IPv6 protocol).
56 Routers are devices which forward packets between interconnected networks in
57 order to allow hosts not connected directly to the same local area network to
58 communicate with each other. They also communicate with the other routers in the
59 Internet to discover the topology of the network which allows them to find
60 optimal (in terms of some metric) rules for forwarding of packets (which are
61 called routing tables) and to adapt themselves to the changing conditions such
62 as outages of network links, building of new connections and so on. Most of
63 these routers are costly dedicated devices running obscure firmware which is
64 hard to configure and not open to any changes (on the other hand, their special
65 hardware design allows them to keep up with lots of high-speed network
66 interfaces, better than general-purpose computer does). Fortunately, most
67 operating systems of the UNIX family allow an ordinary computer to act as a
68 router and forward packets belonging to the other hosts, but only according to a
69 statically configured table.
70
71 <p>A <em/Routing Daemon/ is in UNIX terminology a non-interactive program
72 running on background which does the dynamic part of Internet routing, that is
73 it communicates with the other routers, calculates routing tables and sends them
74 to the OS kernel which does the actual packet forwarding. There already exist
75 other such routing daemons: routed (RIP only), GateD (non-free),
76 <HTMLURL URL="http://www.zebra.org" name="Zebra"> and
77 <HTMLURL URL="http://sourceforge.net/projects/mrt" name="MRTD">,
78 but their capabilities are limited and they are relatively hard to configure
79 and maintain.
80
81 <p>BIRD is an Internet Routing Daemon designed to avoid all of these shortcomings,
82 to support all the routing technology used in the today's Internet or planned to
83 be used in near future and to have a clean extensible architecture allowing new
84 routing protocols to be incorporated easily. Among other features, BIRD
85 supports:
86
87 <itemize>
88 <item>both IPv4 and IPv6 protocols
89 <item>multiple routing tables
90 <item>the Border Gateway Protocol (BGPv4)
91 <item>the Routing Information Protocol (RIPv2)
92 <item>the Open Shortest Path First protocol (OSPFv2, OSPFv3)
93 <item>the Router Advertisements for IPv6 hosts
94 <item>a virtual protocol for exchange of routes between different
95 routing tables on a single host
96 <item>a command-line interface allowing on-line control and inspection
97 of status of the daemon
98 <item>soft reconfiguration (no need to use complex online commands to
99 change the configuration, just edit the configuration file and
100 notify BIRD to re-read it and it will smoothly switch itself to
101 the new configuration, not disturbing routing protocols unless
102 they are affected by the configuration changes)
103 <item>a powerful language for route filtering
104 </itemize>
105
106 <p>BIRD has been developed at the Faculty of Math and Physics, Charles
107 University, Prague, Czech Republic as a student project. It can be freely
108 distributed under the terms of the GNU General Public License.
109
110 <p>BIRD has been designed to work on all UNIX-like systems. It has been
111 developed and tested under Linux 2.0 to 2.6, and then ported to FreeBSD, NetBSD
112 and OpenBSD, porting to other systems (even non-UNIX ones) should be relatively
113 easy due to its highly modular architecture.
114
115 <p>BIRD supports either IPv4 or IPv6 protocol, but have to be compiled separately
116 for each one. Therefore, a dualstack router would run two instances of BIRD (one
117 for IPv4 and one for IPv6), with completely separate setups (configuration
118 files, tools ...).
119
120
121 <sect>Installing BIRD
122 <label id="install">
123
124 <p>On a recent UNIX system with GNU development tools (GCC, binutils, m4, make)
125 and Perl, installing BIRD should be as easy as:
126
127 <code>
128 ./configure
129 make
130 make install
131 vi /usr/local/etc/bird.conf
132 bird
133 </code>
134
135 <p>You can use <tt>./configure --help</tt> to get a list of configure
136 options. The most important ones are: <tt/--enable-ipv6/ which enables building
137 of an IPv6 version of BIRD, <tt/--with-protocols=/ to produce a slightly smaller
138 BIRD executable by configuring out routing protocols you don't use, and
139 <tt/--prefix=/ to install BIRD to a place different from <file>/usr/local</file>.
140
141
142 <sect>Running BIRD
143 <label id="argv">
144
145 <p>You can pass several command-line options to bird:
146
147 <descrip>
148 <tag><label id="argv-config">-c <m/config name/</tag>
149 use given configuration file instead of <it/prefix/<file>/etc/bird.conf</file>.
150
151 <tag><label id="argv-debug">-d</tag>
152 enable debug messages and run bird in foreground.
153
154 <tag><label id="argv-log-file">-D <m/filename of debug log/</tag>
155 log debugging information to given file instead of stderr.
156
157 <tag><label id="argv-foreground">-f</tag>
158 run bird in foreground.
159
160 <tag><label id="argv-group">-g <m/group/</tag>
161 use that group ID, see the next section for details.
162
163 <tag><label id="argv-help">-h, --help</tag>
164 display command-line options to bird.
165
166 <tag><label id="argv-local">-l</tag>
167 look for a configuration file and a communication socket in the current
168 working directory instead of in default system locations. However, paths
169 specified by options <cf/-c/, <cf/-s/ have higher priority.
170
171 <tag><label id="argv-parse">-p</tag>
172 just parse the config file and exit. Return value is zero if the config
173 file is valid, nonzero if there are some errors.
174
175 <tag><label id="argv-pid">-P <m/name of PID file/</tag>
176 create a PID file with given filename.
177
178 <tag><label id="argv-recovery">-R</tag>
179 apply graceful restart recovery after start.
180
181 <tag><label id="argv-socket">-s <m/name of communication socket/</tag>
182 use given filename for a socket for communications with the client,
183 default is <it/prefix/<file>/var/run/bird.ctl</file>.
184
185 <tag><label id="argv-user">-u <m/user/</tag>
186 drop privileges and use that user ID, see the next section for details.
187
188 <tag><label id="argv-version">--version</tag>
189 display bird version.
190 </descrip>
191
192 <p>BIRD writes messages about its work to log files or syslog (according to config).
193
194
195 <sect>Privileges
196 <label id="privileges">
197
198 <p>BIRD, as a routing daemon, uses several privileged operations (like setting
199 routing table and using raw sockets). Traditionally, BIRD is executed and runs
200 with root privileges, which may be prone to security problems. The recommended
201 way is to use a privilege restriction (options <cf/-u/, <cf/-g/). In that case
202 BIRD is executed with root privileges, but it changes its user and group ID to
203 an unprivileged ones, while using Linux capabilities to retain just required
204 privileges (capabilities CAP_NET_*). Note that the control socket is created
205 before the privileges are dropped, but the config file is read after that. The
206 privilege restriction is not implemented in BSD port of BIRD.
207
208 <p>An unprivileged user (as an argument to <cf/-u/ options) may be the user
209 <cf/nobody/, but it is suggested to use a new dedicated user account (like
210 <cf/bird/). The similar considerations apply for the group option, but there is
211 one more condition -- the users in the same group can use <file/birdc/ to
212 control BIRD.
213
214 <p>Finally, there is a possibility to use external tools to run BIRD in an
215 environment with restricted privileges. This may need some configuration, but it
216 is generally easy -- BIRD needs just the standard library, privileges to read
217 the config file and create the control socket and the CAP_NET_* capabilities.
218
219
220 <chapt>About routing tables
221 <label id="routing-tables">
222
223 <p>BIRD has one or more routing tables which may or may not be synchronized with
224 OS kernel and which may or may not be synchronized with each other (see the Pipe
225 protocol). Each routing table contains a list of known routes. Each route
226 consists of:
227
228 <itemize>
229 <item>network prefix this route is for (network address and prefix
230 length -- the number of bits forming the network part of the
231 address; also known as a netmask)
232 <item>preference of this route
233 <item>IP address of router which told us about this route
234 <item>IP address of router we should forward the packets to using this
235 route
236 <item>other attributes common to all routes
237 <item>dynamic attributes defined by protocols which may or may not be
238 present (typically protocol metrics)
239 </itemize>
240
241 Routing table maintains multiple entries for a network, but at most one entry
242 for one network and one protocol. The entry with the highest preference is used
243 for routing (we will call such an entry the <it/selected route/). If there are
244 more entries with the same preference and they are from the same protocol, the
245 protocol decides (typically according to metrics). If they aren't, an internal
246 ordering is used to break the tie. You can get the list of route attributes in
247 the Route attributes section.
248
249 <p>Each protocol is connected to a routing table through two filters which can
250 accept, reject and modify the routes. An <it/export/ filter checks routes passed
251 from the routing table to the protocol, an <it/import/ filter checks routes in
252 the opposite direction. When the routing table gets a route from a protocol, it
253 recalculates the selected route and broadcasts it to all protocols connected to
254 the table. The protocols typically send the update to other routers in the
255 network. Note that although most protocols are interested in receiving just
256 selected routes, some protocols (e.g. the <cf/Pipe/ protocol) receive and
257 process all entries in routing tables (accepted by filters).
258
259 <p><label id="dsc-table-sorted">Usually, a routing table just chooses a selected route
260 from a list of entries for one network. But if the <cf/sorted/ option is
261 activated, these lists of entries are kept completely sorted (according to
262 preference or some protocol-dependent metric). This is needed for some features
263 of some protocols (e.g. <cf/secondary/ option of BGP protocol, which allows to
264 accept not just a selected route, but the first route (in the sorted list) that
265 is accepted by filters), but it is incompatible with some other features (e.g.
266 <cf/deterministic med/ option of BGP protocol, which activates a way of choosing
267 selected route that cannot be described using comparison and ordering). Minor
268 advantage is that routes are shown sorted in <cf/show route/, minor disadvantage
269 is that it is slightly more computationally expensive.
270
271
272 <sect>Graceful restart
273 <label id="graceful-restart">
274
275 <p>When BIRD is started after restart or crash, it repopulates routing tables in
276 an uncoordinated manner, like after clean start. This may be impractical in some
277 cases, because if the forwarding plane (i.e. kernel routing tables) remains
278 intact, then its synchronization with BIRD would temporarily disrupt packet
279 forwarding until protocols converge. Graceful restart is a mechanism that could
280 help with this issue. Generally, it works by starting protocols and letting them
281 repopulate routing tables while deferring route propagation until protocols
282 acknowledge their convergence. Note that graceful restart behavior have to be
283 configured for all relevant protocols and requires protocol-specific support
284 (currently implemented for Kernel and BGP protocols), it is activated for
285 particular boot by option <cf/-R/.
286
287
288 <chapt>Configuration
289 <label id="config">
290
291 <sect>Introduction
292 <label id="config-intro">
293
294 <p>BIRD is configured using a text configuration file. Upon startup, BIRD reads
295 <it/prefix/<file>/etc/bird.conf</file> (unless the <tt/-c/ command line option
296 is given). Configuration may be changed at user's request: if you modify the
297 config file and then signal BIRD with <tt/SIGHUP/, it will adjust to the new
298 config. Then there's the client which allows you to talk with BIRD in an
299 extensive way.
300
301 <p>In the config, everything on a line after <cf/#/ or inside <cf>/* */</cf> is
302 a comment, whitespace characters are treated as a single space. If there's a
303 variable number of options, they are grouped using the <cf/{ }/ brackets. Each
304 option is terminated by a <cf/;/. Configuration is case sensitive. There are two
305 ways how to name symbols (like protocol names, filter names, constants etc.). You
306 can either use a simple string starting with a letter followed by any
307 combination of letters and numbers (e.g. "R123", "myfilter", "bgp5") or you can
308 enclose the name into apostrophes (<cf/'/) and than you can use any combination
309 of numbers, letters. hyphens, dots and colons (e.g. "'1:strange-name'",
310 "'-NAME-'", "'cool::name'").
311
312 <p>Here is an example of a simple config file. It enables synchronization of
313 routing tables with OS kernel, scans for new network interfaces every 10 seconds
314 and runs RIP on all network interfaces found.
315
316 <code>
317 protocol kernel {
318 persist; # Don't remove routes on BIRD shutdown
319 scan time 20; # Scan kernel routing table every 20 seconds
320 export all; # Default is export none
321 }
322
323 protocol device {
324 scan time 10; # Scan interfaces every 10 seconds
325 }
326
327 protocol rip {
328 export all;
329 import all;
330 interface "*";
331 }
332 </code>
333
334
335 <sect>Global options
336 <label id="global-opts">
337
338 <p><descrip>
339 <tag><label id="opt-include">include "<m/filename/"</tag>
340 This statement causes inclusion of a new file. <m/Filename/ could also
341 be a wildcard, in that case matching files are included in alphabetic
342 order. The maximal depth is 8. Note that this statement could be used
343 anywhere in the config file, not just as a top-level option.
344
345 <tag><label id="opt-log">log "<m/filename/"|syslog [name <m/name/]|stderr all|{ <m/list of classes/ }</tag>
346 Set logging of messages having the given class (either <cf/all/ or
347 <cf/{ error|trace [, <m/.../] }/ etc.) into selected destination (a file specified
348 as a filename string, syslog with optional name argument, or the stderr
349 output). Classes are:
350 <cf/info/, <cf/warning/, <cf/error/ and <cf/fatal/ for messages about local problems,
351 <cf/debug/ for debugging messages,
352 <cf/trace/ when you want to know what happens in the network,
353 <cf/remote/ for messages about misbehavior of remote machines,
354 <cf/auth/ about authentication failures,
355 <cf/bug/ for internal BIRD bugs.
356 You may specify more than one <cf/log/ line to establish logging to
357 multiple destinations. Default: log everything to the system log.
358
359 <tag><label id="opt-debug-protocols">debug protocols all|off|{ states|routes|filters|interfaces|events|packets [, <m/.../] }</tag>
360 Set global defaults of protocol debugging options. See <cf/debug/ in the
361 following section. Default: off.
362
363 <tag><label id="opt-debug-commands">debug commands <m/number/</tag>
364 Control logging of client connections (0 for no logging, 1 for logging
365 of connects and disconnects, 2 and higher for logging of all client
366 commands). Default: 0.
367
368 <tag><label id="opt-debug-latency">debug latency <m/switch/</tag>
369 Activate tracking of elapsed time for internal events. Recent events
370 could be examined using <cf/dump events/ command. Default: off.
371
372 <tag><label id="opt-debug-latency-limit">debug latency limit <m/time/</tag>
373 If <cf/debug latency/ is enabled, this option allows to specify a limit
374 for elapsed time. Events exceeding the limit are logged. Default: 1 s.
375
376 <tag><label id="opt-watchdog-warn">watchdog warning <m/time/</tag>
377 Set time limit for I/O loop cycle. If one iteration took more time to
378 complete, a warning is logged. Default: 5 s.
379
380 <tag><label id="opt-watchdog-timeout">watchdog timeout <m/time/</tag>
381 Set time limit for I/O loop cycle. If the limit is breached, BIRD is
382 killed by abort signal. The timeout has effective granularity of
383 seconds, zero means disabled. Default: disabled (0).
384
385 <tag><label id="opt-mrtdump">mrtdump "<m/filename/"</tag>
386 Set MRTdump file name. This option must be specified to allow MRTdump
387 feature. Default: no dump file.
388
389 <tag><label id="opt-mrtdump-protocols">mrtdump protocols all|off|{ states|messages [, <m/.../] }</tag>
390 Set global defaults of MRTdump options. See <cf/mrtdump/ in the
391 following section. Default: off.
392
393 <tag><label id="opt-filter">filter <m/name local variables/{ <m/commands/ }</tag>
394 Define a filter. You can learn more about filters in the following
395 chapter.
396
397 <tag><label id="opt-function">function <m/name/ (<m/parameters/) <m/local variables/ { <m/commands/ }</tag>
398 Define a function. You can learn more about functions in the following chapter.
399
400 <tag><label id="opt-protocol">protocol rip|ospf|bgp|<m/.../ [<m/name/ [from <m/name2/]] { <m>protocol options</m> }</tag>
401 Define a protocol instance called <cf><m/name/</cf> (or with a name like
402 "rip5" generated automatically if you don't specify any
403 <cf><m/name/</cf>). You can learn more about configuring protocols in
404 their own chapters. When <cf>from <m/name2/</cf> expression is used,
405 initial protocol options are taken from protocol or template
406 <cf><m/name2/</cf> You can run more than one instance of most protocols
407 (like RIP or BGP). By default, no instances are configured.
408
409 <tag><label id="opt-template">template rip|bgp|<m/.../ [<m/name/ [from <m/name2/]] { <m>protocol options</m> }</tag>
410 Define a protocol template instance called <m/name/ (or with a name like
411 "bgp1" generated automatically if you don't specify any <m/name/).
412 Protocol templates can be used to group common options when many
413 similarly configured protocol instances are to be defined. Protocol
414 instances (and other templates) can use templates by using <cf/from/
415 expression and the name of the template. At the moment templates (and
416 <cf/from/ expression) are not implemented for OSPF protocol.
417
418 <tag><label id="opt-define">define <m/constant/ = <m/expression/</tag>
419 Define a constant. You can use it later in every place you could use a
420 value of the same type. Besides, there are some predefined numeric
421 constants based on /etc/iproute2/rt_* files. A list of defined constants
422 can be seen (together with other symbols) using 'show symbols' command.
423
424 <tag><label id="opt-router-id">router id <m/IPv4 address/</tag>
425 Set BIRD's router ID. It's a world-wide unique identification of your
426 router, usually one of router's IPv4 addresses. Default: in IPv4
427 version, the lowest IP address of a non-loopback interface. In IPv6
428 version, this option is mandatory.
429
430 <tag><label id="opt-router-id-from">router id from [-] [ "<m/mask/" ] [ <m/prefix/ ] [, <m/.../]</tag>
431 Set BIRD's router ID based on an IP address of an interface specified by
432 an interface pattern. The option is applicable for IPv4 version only.
433 See <ref id="proto-iface" name="interface"> section for detailed
434 description of interface patterns with extended clauses.
435
436 <tag><label id="opt-listen-bgp">listen bgp [address <m/address/] [port <m/port/] [dual]</tag>
437 This option allows to specify address and port where BGP protocol should
438 listen. It is global option as listening socket is common to all BGP
439 instances. Default is to listen on all addresses (0.0.0.0) and port 179.
440 In IPv6 mode, option <cf/dual/ can be used to specify that BGP socket
441 should accept both IPv4 and IPv6 connections (but even in that case,
442 BIRD would accept IPv6 routes only). Such behavior was default in older
443 versions of BIRD.
444
445 <tag><label id="opt-graceful-restart">graceful restart wait <m/number/</tag>
446 During graceful restart recovery, BIRD waits for convergence of routing
447 protocols. This option allows to specify a timeout for the recovery to
448 prevent waiting indefinitely if some protocols cannot converge. Default:
449 240 seconds.
450
451 <tag><label id="opt-timeformat">timeformat route|protocol|base|log "<m/format1/" [<m/limit/ "<m/format2/"]</tag>
452 This option allows to specify a format of date/time used by BIRD. The
453 first argument specifies for which purpose such format is used.
454 <cf/route/ is a format used in 'show route' command output,
455 <cf/protocol/ is used in 'show protocols' command output, <cf/base/ is
456 used for other commands and <cf/log/ is used in a log file.
457
458 "<m/format1/" is a format string using <it/strftime(3)/ notation (see
459 <it/man strftime/ for details). It is extended to support sub-second
460 time part with variable precision (up to microseconds) using "%f"
461 conversion code (e.g., "%T.%3f" is hh:mm:ss.sss time). <m/limit/ and
462 "<m/format2/" allow to specify the second format string for times in
463 past deeper than <m/limit/ seconds.
464
465 There are several shorthands: <cf/iso long/ is a ISO 8601 date/time
466 format (YYYY-MM-DD hh:mm:ss) that can be also specified using <cf/"%F
467 %T"/. Similarly, <cf/iso long ms/ and <cf/iso long us/ are ISO 8601
468 date/time formats with millisecond or microsecond precision.
469 <cf/iso short/ is a variant of ISO 8601 that uses just the time format
470 (hh:mm:ss) for near times (up to 20 hours in the past) and the date
471 format (YYYY-MM-DD) for far times. This is a shorthand for <cf/"%T"
472 72000 "%F"/. And there are also <cf/iso short ms/ and <cf/iso short us/
473 high-precision variants of that.
474
475 By default, BIRD uses the <cf/iso short ms/ format for <cf/route/ and
476 <cf/protocol/ times, and the <cf/iso long ms/ format for <cf/base/ and
477 <cf/log/ times.
478
479 <tag><label id="opt-table">table <m/name/ [sorted]</tag>
480 Create a new routing table. The default routing table is created
481 implicitly, other routing tables have to be added by this command.
482 Option <cf/sorted/ can be used to enable sorting of routes, see
483 <ref id="dsc-table-sorted" name="sorted table"> description for details.
484
485 <tag><label id="opt-roa-table">roa table <m/name/ [ { <m/roa table options .../ } ]</tag>
486 Create a new ROA (Route Origin Authorization) table. ROA tables can be
487 used to validate route origination of BGP routes. A ROA table contains
488 ROA entries, each consist of a network prefix, a max prefix length and
489 an AS number. A ROA entry specifies prefixes which could be originated
490 by that AS number. ROA tables could be filled with data from RPKI (<rfc
491 id="6480">) or from public databases like Whois. ROA tables are
492 examined by <cf/roa_check()/ operator in filters.
493
494 Currently, there is just one option, <cf>roa <m/prefix/ max <m/num/ as
495 <m/num/</cf>, which can be used to populate the ROA table with static
496 ROA entries. The option may be used multiple times. Other entries can be
497 added dynamically by <cf/add roa/ command.
498
499 <tag><label id="opt-eval">eval <m/expr/</tag>
500 Evaluates given filter expression. It is used by us for testing of filters.
501 </descrip>
502
503
504 <sect>Protocol options
505 <label id="protocol-opts">
506
507 <p>For each protocol instance, you can configure a bunch of options. Some of
508 them (those described in this section) are generic, some are specific to the
509 protocol (see sections talking about the protocols).
510
511 <p>Several options use a <m/switch/ argument. It can be either <cf/on/,
512 <cf/yes/ or a numeric expression with a non-zero value for the option to be
513 enabled or <cf/off/, <cf/no/ or a numeric expression evaluating to zero to
514 disable it. An empty <m/switch/ is equivalent to <cf/on/ ("silence means
515 agreement").
516
517 <descrip>
518 <tag><label id="proto-preference">preference <m/expr/</tag>
519 Sets the preference of routes generated by this protocol. Default:
520 protocol dependent.
521
522 <tag><label id="proto-disabled">disabled <m/switch/</tag>
523 Disables the protocol. You can change the disable/enable status from the
524 command line interface without needing to touch the configuration.
525 Disabled protocols are not activated. Default: protocol is enabled.
526
527 <tag><label id="proto-debug">debug all|off|{ states|routes|filters|interfaces|events|packets [, <m/.../] }</tag>
528 Set protocol debugging options. If asked, each protocol is capable of
529 writing trace messages about its work to the log (with category
530 <cf/trace/). You can either request printing of <cf/all/ trace messages
531 or only of the types selected: <cf/states/ for protocol state changes
532 (protocol going up, down, starting, stopping etc.), <cf/routes/ for
533 routes exchanged with the routing table, <cf/filters/ for details on
534 route filtering, <cf/interfaces/ for interface change events sent to the
535 protocol, <cf/events/ for events internal to the protocol and <cf/packets/
536 for packets sent and received by the protocol. Default: off.
537
538 <tag><label id="proto-mrtdump">mrtdump all|off|{ states|messages [, <m/.../] }</tag>
539 Set protocol MRTdump flags. MRTdump is a standard binary format for
540 logging information from routing protocols and daemons. These flags
541 control what kind of information is logged from the protocol to the
542 MRTdump file (which must be specified by global <cf/mrtdump/ option, see
543 the previous section). Although these flags are similar to flags of
544 <cf/debug/ option, their meaning is different and protocol-specific. For
545 BGP protocol, <cf/states/ logs BGP state changes and <cf/messages/ logs
546 received BGP messages. Other protocols does not support MRTdump yet.
547
548 <tag><label id="proto-router-id">router id <m/IPv4 address/</tag>
549 This option can be used to override global router id for a given
550 protocol. Default: uses global router id.
551
552 <tag><label id="proto-import">import all | none | filter <m/name/ | filter { <m/filter commands/ } | where <m/filter expression/</tag>
553 Specify a filter to be used for filtering routes coming from the
554 protocol to the routing table. <cf/all/ is shorthand for <cf/where true/
555 and <cf/none/ is shorthand for <cf/where false/. Default: <cf/all/.
556
557 <tag><label id="proto-export">export <m/filter/</tag>
558 This is similar to the <cf>import</cf> keyword, except that it works in
559 the direction from the routing table to the protocol. Default: <cf/none/.
560
561 <tag><label id="proto-import-keep-filtered">import keep filtered <m/switch/</tag>
562 Usually, if an import filter rejects a route, the route is forgotten.
563 When this option is active, these routes are kept in the routing table,
564 but they are hidden and not propagated to other protocols. But it is
565 possible to show them using <cf/show route filtered/. Note that this
566 option does not work for the pipe protocol. Default: off.
567
568 <tag><label id="proto-import-limit">import limit [<m/number/ | off ] [action warn | block | restart | disable]</tag>
569 Specify an import route limit (a maximum number of routes imported from
570 the protocol) and optionally the action to be taken when the limit is
571 hit. Warn action just prints warning log message. Block action discards
572 new routes coming from the protocol. Restart and disable actions shut
573 the protocol down like appropriate commands. Disable is the default
574 action if an action is not explicitly specified. Note that limits are
575 reset during protocol reconfigure, reload or restart. Default: <cf/off/.
576
577 <tag><label id="proto-receive-limit">receive limit [<m/number/ | off ] [action warn | block | restart | disable]</tag>
578 Specify an receive route limit (a maximum number of routes received from
579 the protocol and remembered). It works almost identically to <cf>import
580 limit</cf> option, the only difference is that if <cf/import keep
581 filtered/ option is active, filtered routes are counted towards the
582 limit and blocked routes are forgotten, as the main purpose of the
583 receive limit is to protect routing tables from overflow. Import limit,
584 on the contrary, counts accepted routes only and routes blocked by the
585 limit are handled like filtered routes. Default: <cf/off/.
586
587 <tag><label id="proto-export-limit">export limit [ <m/number/ | off ] [action warn | block | restart | disable]</tag>
588 Specify an export route limit, works similarly to the <cf>import
589 limit</cf> option, but for the routes exported to the protocol. This
590 option is experimental, there are some problems in details of its
591 behavior -- the number of exported routes can temporarily exceed the
592 limit without triggering it during protocol reload, exported routes
593 counter ignores route blocking and block action also blocks route
594 updates of already accepted routes -- and these details will probably
595 change in the future. Default: <cf/off/.
596
597 <tag><label id="proto-description">description "<m/text/"</tag>
598 This is an optional description of the protocol. It is displayed as a
599 part of the output of 'show route all' command.
600
601 <tag><label id="proto-table">table <m/name/</tag>
602 Connect this protocol to a non-default routing table.
603 </descrip>
604
605 <p>There are several options that give sense only with certain protocols:
606
607 <descrip>
608 <tag><label id="proto-iface">interface [-] [ "<m/mask/" ] [ <m/prefix/ ] [, <m/.../] [ { <m/option/; [<m/.../] } ]</tag>
609 Specifies a set of interfaces on which the protocol is activated with
610 given interface-specific options. A set of interfaces specified by one
611 interface option is described using an interface pattern. The interface
612 pattern consists of a sequence of clauses (separated by commas), each
613 clause is a mask specified as a shell-like pattern. Interfaces are
614 matched by their name.
615
616 An interface matches the pattern if it matches any of its clauses. If
617 the clause begins with <cf/-/, matching interfaces are excluded. Patterns
618 are processed left-to-right, thus <cf/interface "eth0", -"eth*", "*";/
619 means eth0 and all non-ethernets.
620
621 Some protocols (namely OSPFv2 and Direct) support extended clauses that
622 may contain a mask, a prefix, or both of them. An interface matches such
623 clause if its name matches the mask (if specified) and its address
624 matches the prefix (if specified). Extended clauses are used when the
625 protocol handles multiple addresses on an interface independently.
626
627 An interface option can be used more times with different interface-specific
628 options, in that case for given interface the first matching interface
629 option is used.
630
631 This option is allowed in Babel, BFD, Direct, OSPF, RAdv and RIP
632 protocols, but in OSPF protocol it is used in the <cf/area/ subsection.
633
634 Default: none.
635
636 Examples:
637
638 <cf>interface "*" { type broadcast; };</cf> - start the protocol on all
639 interfaces with <cf>type broadcast</cf> option.
640
641 <cf>interface "eth1", "eth4", "eth5" { type ptp; };</cf> - start the
642 protocol on enumerated interfaces with <cf>type ptp</cf> option.
643
644 <cf>interface -192.168.1.0/24, 192.168.0.0/16;</cf> - start the protocol
645 on all interfaces that have address from 192.168.0.0/16, but not from
646 192.168.1.0/24.
647
648 <cf>interface -192.168.1.0/24, 192.168.0.0/16;</cf> - start the protocol
649 on all interfaces that have address from 192.168.0.0/16, but not from
650 192.168.1.0/24.
651
652 <cf>interface "eth*" 192.168.1.0/24;</cf> - start the protocol on all
653 ethernet interfaces that have address from 192.168.1.0/24.
654
655 <tag><label id="proto-tx-class">tx class|dscp <m/num/</tag>
656 This option specifies the value of ToS/DS/Class field in IP headers of
657 the outgoing protocol packets. This may affect how the protocol packets
658 are processed by the network relative to the other network traffic. With
659 <cf/class/ keyword, the value (0-255) is used for the whole ToS/Class
660 octet (but two bits reserved for ECN are ignored). With <cf/dscp/
661 keyword, the value (0-63) is used just for the DS field in the octet.
662 Default value is 0xc0 (DSCP 0x30 - CS6).
663
664 <tag><label id="proto-tx-priority">tx priority <m/num/</tag>
665 This option specifies the local packet priority. This may affect how the
666 protocol packets are processed in the local TX queues. This option is
667 Linux specific. Default value is 7 (highest priority, privileged traffic).
668
669 <tag><label id="proto-pass">password "<m/password/" [ { <m>password options</m> } ]</tag>
670 Specifies a password that can be used by the protocol as a shared secret
671 key. Password option can be used more times to specify more passwords.
672 If more passwords are specified, it is a protocol-dependent decision
673 which one is really used. Specifying passwords does not mean that
674 authentication is enabled, authentication can be enabled by separate,
675 protocol-dependent <cf/authentication/ option.
676
677 This option is allowed in BFD, OSPF and RIP protocols. BGP has also
678 <cf/password/ option, but it is slightly different and described
679 separately.
680 Default: none.
681 </descrip>
682
683 <p>Password option can contain section with some (not necessary all) password sub-options:
684
685 <descrip>
686 <tag><label id="proto-pass-id">id <M>num</M></tag>
687 ID of the password, (1-255). If it is not used, BIRD will choose ID based
688 on an order of the password item in the interface. For example, second
689 password item in one interface will have default ID 2. ID is used by
690 some routing protocols to identify which password was used to
691 authenticate protocol packets.
692
693 <tag><label id="proto-pass-gen-from">generate from "<m/time/"</tag>
694 The start time of the usage of the password for packet signing.
695 The format of <cf><m/time/</cf> is <tt>dd-mm-yyyy HH:MM:SS</tt>.
696
697 <tag><label id="proto-pass-gen-to">generate to "<m/time/"</tag>
698 The last time of the usage of the password for packet signing.
699
700 <tag><label id="proto-pass-accept-from">accept from "<m/time/"</tag>
701 The start time of the usage of the password for packet verification.
702
703 <tag><label id="proto-pass-accept-to">accept to "<m/time/"</tag>
704 The last time of the usage of the password for packet verification.
705
706 <tag><label id="proto-pass-from">from "<m/time/"</tag>
707 Shorthand for setting both <cf/generate from/ and <cf/accept from/.
708
709 <tag><label id="proto-pass-to">to "<m/time/"</tag>
710 Shorthand for setting both <cf/generate to/ and <cf/accept to/.
711
712 <tag><label id="proto-pass-algorithm">algorithm ( keyed md5 | keyed sha1 | hmac sha1 | hmac sha256 | hmac sha384 | hmac sha512 )</tag>
713 The message authentication algorithm for the password when cryptographic
714 authentication is enabled. The default value depends on the protocol.
715 For RIP and OSPFv2 it is Keyed-MD5 (for compatibility), for OSPFv3
716 protocol it is HMAC-SHA-256.
717
718 </descrip>
719
720
721 <sect>Flowspec network type
722 <label id="flowspec-network-type">
723
724 <p>The flow specification are rules for routers and firewalls for filtering
725 purpose. It is described by <rfc id="5575">. There are 3 types of arguments:
726 <m/inet4/ or <m/inet6/ prefixes, bitmasks matching expressions and numbers
727 matching expressions.
728
729 Bitmasks matching is written using <m/value/<cf>/</cf><m/mask/ or
730 <cf/!/<m/value/<cf>/</cf><m/mask/ pairs. It means that <cf/(/<m/data/ <cf/&/
731 <m/mask/<cf/)/ is or is not equal to <m/value/.
732
733 Numbers matching is a matching sequence of numbers and ranges separeted by a
734 commas (<cf/,/) (e.g. <cf/10,20,30/). Ranges can be written using double dots
735 <cf/../ notation (e.g. <cf/80..90,120..124/). An alternative notation are
736 sequence of one or more pairs of relational operators and values separated by
737 logical operators <cf/&&/ or <cf/||/. Allowed relational operators are <cf/=/,
738 <cf/!=/, <cf/</, <cf/<=/, <cf/>/, <cf/>=/, <cf/true/ and <cf/false/.
739
740 <sect1>IPv4 Flowspec
741
742 <p><descrip>
743 <tag><label id="flow-dst">dst <m/inet4/</tag>
744 Set a matching destination prefix (e.g. <cf>dst 192.168.0.0/16</cf>).
745 Only this option is mandatory in IPv4 Flowspec.
746
747 <tag><label id="flow-src">src <m/inet4/</tag>
748 Set a matching source prefix (e.g. <cf>src 10.0.0.0/8</cf>).
749
750 <tag><label id="flow-proto">proto <m/numbers-match/</tag>
751 Set a matching IP protocol numbers (e.g. <cf/proto 6/).
752
753 <tag><label id="flow-port">port <m/numbers-match/</tag>
754 Set a matching source or destination TCP/UDP port numbers (e.g.
755 <cf>port 1..1023,1194,3306</cf>).
756
757 <tag><label id="flow-dport">dport <m/numbers-match/</tag>
758 Set a mating destination port numbers (e.g. <cf>dport 49151</cf>).
759
760 <tag><label id="flow-sport">sport <m/numbers-match/</tag>
761 Set a matching source port numbers (e.g. <cf>sport = 0</cf>).
762
763 <tag><label id="flow-icmp-type">icmp type <m/numbers-match/</tag>
764 Set a matching type field number of an ICMP packet (e.g. <cf>icmp type
765 3</cf>)
766
767 <tag><label id="flow-icmp-code">icmp code <m/numbers-match/</tag>
768 Set a matching code field number of an ICMP packet (e.g. <cf>icmp code
769 1</cf>)
770
771 <tag><label id="flow-tcp-flags">tcp flags <m/bitmask-match/</tag>
772 Set a matching bitmask for TCP header flags (aka control bits) (e.g.
773 <cf>tcp flags 0x03/0x0f;</cf>). The maximum length of mask is 12 bits
774 (0xfff).
775
776 <tag><label id="flow-length">length <m/numbers-match/</tag>
777 Set a matching packet length (e.g. <cf>length > 1500;</cf>)
778
779 <tag><label id="flow-dscp">dscp <m/numbers-match/</tag>
780 Set a matching DiffServ Code Point number (e.g. <cf>length > 1500;</cf>).
781
782 <tag><label id="flow-fragment">fragment <m/fragmentation-type/</tag>
783 Set a matching type of packet fragmentation. Allowed fragmentation
784 types are <cf/dont_fragment/, <cf/is_fragment/, <cf/first_fragment/,
785 <cf/last_fragment/ (e.g. <cf>fragment is_fragment &&
786 !dont_fragment</cf>).
787 </descrip>
788
789 <p><code>
790 protocol static {
791 flow4;
792
793 route flow4 {
794 dst 10.0.0.0/8;
795 port > 24 && < 30 || 40..50,60..70,80 && >= 90;
796 tcp flags 0x03/0x0f;
797 length > 1024;
798 dscp = 63;
799 fragment dont_fragment, is_fragment || !first_fragment;
800 } drop;
801 }
802 </code>
803
804 <sect1>Differences for IPv6 Flowspec
805
806 <p>Flowspec IPv6 are same as Flowspec IPv4 with a few exceptions.
807 <itemize>
808 <item>Prefixes <m/inet6/ can be specified not only with prefix length,
809 but with prefix <cf/offset/ <m/num/ too (e.g.
810 <cf>::1234:5678:9800:0000/101 offset 64</cf>). Offset means to don't
811 care of <m/num/ first bits.
812 <item>IPv6 Flowspec hasn't mandatory any flowspec component.
813 <item>In IPv6 packets, there is a matching the last next header value
814 for a matching IP protocol number (e.g. <cf>next header 6</cf>).
815 <item>It is not possible to set <cf>dont_fragment</cf> as a type of
816 packet fragmentation.
817 </itemize>
818
819 <p><descrip>
820 <tag><label id="flow6-dst">dst <m/inet6/ [offset <m/num/]</tag>
821 Set a matching destination IPv6 prefix (e.g. <cf>dst
822 ::1c77:3769:27ad:a11a/128 offset 64</cf>).
823
824 <tag><label id="flow6-src">src <m/inet6/ [offset <m/num/]</tag>
825 Set a matching source IPv6 prefix (e.g. <cf>src fe80::/64</cf>).
826
827 <tag><label id="flow6-next-header">next header <m/numbers-match/</tag>
828 Set a matching IP protocol numbers (e.g. <cf>next header != 6</cf>).
829
830 <tag><label id="flow6-label">label <m/bitmask-match/</tag>
831 Set a 20-bit bitmask for matching Flow Label field in IPv6 packets
832 (e.g. <cf>label 0x8e5/0x8e5</cf>).
833 </descrip>
834
835 <p><code>
836 protocol static {
837 flow6;
838
839 route flow6 {
840 dst fec0:1122:3344:5566:7788:99aa:bbcc:ddee/128;
841 src 0000:0000:0000:0001:1234:5678:9800:0000/101 offset 63;
842 next header = 23;
843 sport > 24 && < 30 || = 40 || 50,60,70..80;
844 dport = 50;
845 tcp flags 0x03/0x0f, !0/0xff || 0x33/0x33;
846 fragment !is_fragment || !first_fragment;
847 label 0xaaaa/0xaaaa && 0x33/0x33;
848 } drop;
849 }
850 </code>
851
852 <chapt>Remote control
853 <label id="remote-control">
854
855 <p>You can use the command-line client <file>birdc</file> to talk with a running
856 BIRD. Communication is done using a <file/bird.ctl/ UNIX domain socket (unless
857 changed with the <tt/-s/ option given to both the server and the client). The
858 commands can perform simple actions such as enabling/disabling of protocols,
859 telling BIRD to show various information, telling it to show routing table
860 filtered by filter, or asking BIRD to reconfigure. Press <tt/?/ at any time to
861 get online help. Option <tt/-r/ can be used to enable a restricted mode of BIRD
862 client, which allows just read-only commands (<cf/show .../). Option <tt/-v/ can
863 be passed to the client, to make it dump numeric return codes along with the
864 messages. You do not necessarily need to use <file/birdc/ to talk to BIRD, your
865 own applications could do that, too -- the format of communication between BIRD
866 and <file/birdc/ is stable (see the programmer's documentation).
867
868 <p>There is also lightweight variant of BIRD client called <file/birdcl/, which
869 does not support command line editing and history and has minimal dependencies.
870 This is useful for running BIRD in resource constrained environments, where
871 Readline library (required for regular BIRD client) is not available.
872
873 <p>Many commands have the <m/name/ of the protocol instance as an argument.
874 This argument can be omitted if there exists only a single instance.
875
876 <p>Here is a brief list of supported functions:
877
878 <descrip>
879 <tag><label id="cli-show-status">show status</tag>
880 Show router status, that is BIRD version, uptime and time from last
881 reconfiguration.
882
883 <tag><label id="cli-show-interfaces">show interfaces [summary]</tag>
884 Show the list of interfaces. For each interface, print its type, state,
885 MTU and addresses assigned.
886
887 <tag><label id="cli-show-protocols">show protocols [all]</tag>
888 Show list of protocol instances along with tables they are connected to
889 and protocol status, possibly giving verbose information, if <cf/all/ is
890 specified.
891
892 <tag><label id="cli-show-ospf-iface">show ospf interface [<m/name/] ["<m/interface/"]</tag>
893 Show detailed information about OSPF interfaces.
894
895 <tag><label id="cli-show-ospf-neighbors">show ospf neighbors [<m/name/] ["<m/interface/"]</tag>
896 Show a list of OSPF neighbors and a state of adjacency to them.
897
898 <tag><label id="cli-show-ospf-state">show ospf state [all] [<m/name/]</tag>
899 Show detailed information about OSPF areas based on a content of the
900 link-state database. It shows network topology, stub networks,
901 aggregated networks and routers from other areas and external routes.
902 The command shows information about reachable network nodes, use option
903 <cf/all/ to show information about all network nodes in the link-state
904 database.
905
906 <tag><label id="cli-show-ospf-topology">show ospf topology [all] [<m/name/]</tag>
907 Show a topology of OSPF areas based on a content of the link-state
908 database. It is just a stripped-down version of 'show ospf state'.
909
910 <tag><label id="cli-show-ospf-lsadb">show ospf lsadb [global | area <m/id/ | link] [type <m/num/] [lsid <m/id/] [self | router <m/id/] [<m/name/] </tag>
911 Show contents of an OSPF LSA database. Options could be used to filter
912 entries.
913
914 <tag><label id="cli-show-rip-interfaces">show rip interfaces [<m/name/] ["<m/interface/"]</tag>
915 Show detailed information about RIP interfaces.
916
917 <tag><label id="cli-show-rip-neighbors">show rip neighbors [<m/name/] ["<m/interface/"]</tag>
918 Show a list of RIP neighbors and associated state.
919
920 <tag><label id="cli-show-static">show static [<m/name/]</tag>
921 Show detailed information about static routes.
922
923 <tag><label id="cli-show-bfd-sessions">show bfd sessions [<m/name/]</tag>
924 Show information about BFD sessions.
925
926 <tag><label id="cli-show-symbols">show symbols [table|filter|function|protocol|template|roa|<m/symbol/]</tag>
927 Show the list of symbols defined in the configuration (names of
928 protocols, routing tables etc.).
929
930 <tag><label id="cli-show-route">show route [[for] <m/prefix/|<m/IP/] [table (<m/t/ | all)] [filter <m/f/|where <m/c/] [(export|preexport|noexport) <m/p/] [protocol <m/p/] [(stats|count)] [<m/options/]</tag>
931 Show contents of specified routing tables, that is routes, their metrics
932 and (in case the <cf/all/ switch is given) all their attributes.
933
934 <p>You can specify a <m/prefix/ if you want to print routes for a
935 specific network. If you use <cf>for <m/prefix or IP/</cf>, you'll get
936 the entry which will be used for forwarding of packets to the given
937 destination. By default, all routes for each network are printed with
938 the selected one at the top, unless <cf/primary/ is given in which case
939 only the selected route is shown.
940
941 <p>The <cf/show route/ command can process one or multiple routing
942 tables. The set of selected tables is determined on three levels: First,
943 tables can be explicitly selected by <cf/table/ switch, which could be
944 used multiple times, all tables are specified by <cf/table all/. Second,
945 tables can be implicitly selected by channels or protocols that are
946 arguments of several other switches (e.g., <cf/export/, <cf/protocol/).
947 Last, the set of default tables is used: <cf/master4/, <cf/master6/ and
948 each first table of any other network type.
949
950 <p>You can also ask for printing only routes processed and accepted by
951 a given filter (<cf>filter <m/name/</cf> or <cf>filter { <m/filter/ }
952 </cf> or matching a given condition (<cf>where <m/condition/</cf>).
953
954 The <cf/export/, <cf/preexport/ and <cf/noexport/ switches ask for
955 printing of routes that are exported to the specified protocol or
956 channel. With <cf/preexport/, the export filter of the channel is
957 skipped. With <cf/noexport/, routes rejected by the export filter are
958 printed instead. Note that routes not exported for other reasons
959 (e.g. secondary routes or routes imported from that protocol) are not
960 printed even with <cf/noexport/. These switches also imply that
961 associated routing tables are selected instead of default ones.
962
963 <p>You can also select just routes added by a specific protocol.
964 <cf>protocol <m/p/</cf>. This switch also implies that associated
965 routing tables are selected instead of default ones.
966
967 <p>If BIRD is configured to keep filtered routes (see <cf/import keep
968 filtered/ option), you can show them instead of routes by using
969 <cf/filtered/ switch.
970
971 <p>The <cf/stats/ switch requests showing of route statistics (the
972 number of networks, number of routes before and after filtering). If
973 you use <cf/count/ instead, only the statistics will be printed.
974
975 <tag><label id="cli-configure">configure [soft] ["<m/config file/"] [timeout [<m/num/]]</tag>
976 Reload configuration from a given file. BIRD will smoothly switch itself
977 to the new configuration, protocols are reconfigured if possible,
978 restarted otherwise. Changes in filters usually lead to restart of
979 affected protocols.
980
981 If <cf/soft/ option is used, changes in filters does not cause BIRD to
982 restart affected protocols, therefore already accepted routes (according
983 to old filters) would be still propagated, but new routes would be
984 processed according to the new filters.
985
986 If <cf/timeout/ option is used, config timer is activated. The new
987 configuration could be either confirmed using <cf/configure confirm/
988 command, or it will be reverted to the old one when the config timer
989 expires. This is useful for cases when reconfiguration breaks current
990 routing and a router becomes inaccessible for an administrator. The
991 config timeout expiration is equivalent to <cf/configure undo/
992 command. The timeout duration could be specified, default is 300 s.
993
994 <tag><label id="cli-configure-confirm">configure confirm</tag>
995 Deactivate the config undo timer and therefore confirm the current
996 configuration.
997
998 <tag><label id="cli-configure-undo">configure undo</tag>
999 Undo the last configuration change and smoothly switch back to the
1000 previous (stored) configuration. If the last configuration change was
1001 soft, the undo change is also soft. There is only one level of undo, but
1002 in some specific cases when several reconfiguration requests are given
1003 immediately in a row and the intermediate ones are skipped then the undo
1004 also skips them back.
1005
1006 <tag><label id="cli-configure-check">configure check ["<m/config file/"]</tag>
1007 Read and parse given config file, but do not use it. useful for checking
1008 syntactic and some semantic validity of an config file.
1009
1010 <tag><label id="cli-enable-disable-restart">enable|disable|restart <m/name/|"<m/pattern/"|all</tag>
1011 Enable, disable or restart a given protocol instance, instances matching
1012 the <cf><m/pattern/</cf> or <cf/all/ instances.
1013
1014 <tag><label id="cli-reload">reload [in|out] <m/name/|"<m/pattern/"|all</tag>
1015 Reload a given protocol instance, that means re-import routes from the
1016 protocol instance and re-export preferred routes to the instance. If
1017 <cf/in/ or <cf/out/ options are used, the command is restricted to one
1018 direction (re-import or re-export).
1019
1020 This command is useful if appropriate filters have changed but the
1021 protocol instance was not restarted (or reloaded), therefore it still
1022 propagates the old set of routes. For example when <cf/configure soft/
1023 command was used to change filters.
1024
1025 Re-export always succeeds, but re-import is protocol-dependent and might
1026 fail (for example, if BGP neighbor does not support route-refresh
1027 extension). In that case, re-export is also skipped. Note that for the
1028 pipe protocol, both directions are always reloaded together (<cf/in/ or
1029 <cf/out/ options are ignored in that case).
1030
1031 <tag><label id="cli-down">down</tag>
1032 Shut BIRD down.
1033
1034 <tag><label id="cli-debug">debug <m/protocol/|<m/pattern/|all all|off|{ states|routes|filters|events|packets [, <m/.../] }</tag>
1035 Control protocol debugging.
1036
1037 <tag><label id="cli-dump">dump resources|sockets|interfaces|neighbors|attributes|routes|protocols</tag>
1038 Dump contents of internal data structures to the debugging output.
1039
1040 <tag><label id="cli-echo">echo all|off|{ <m/list of log classes/ } [ <m/buffer-size/ ]</tag>
1041 Control echoing of log messages to the command-line output.
1042 See <ref id="opt-log" name="log option"> for a list of log classes.
1043
1044 <tag><label id="cli-eval">eval <m/expr/</tag>
1045 Evaluate given expression.
1046 </descrip>
1047
1048
1049 <chapt>Filters
1050 <label id="filters">
1051
1052 <sect>Introduction
1053 <label id="filters-intro">
1054
1055 <p>BIRD contains a simple programming language. (No, it can't yet read mail :-).
1056 There are two objects in this language: filters and functions. Filters are
1057 interpreted by BIRD core when a route is being passed between protocols and
1058 routing tables. The filter language contains control structures such as if's and
1059 switches, but it allows no loops. An example of a filter using many features can
1060 be found in <file>filter/test.conf</file>.
1061
1062 <p>Filter gets the route, looks at its attributes and modifies some of them if
1063 it wishes. At the end, it decides whether to pass the changed route through
1064 (using <cf/accept/) or whether to <cf/reject/ it. A simple filter looks like
1065 this:
1066
1067 <code>
1068 filter not_too_far
1069 int var;
1070 {
1071 if defined( rip_metric ) then
1072 var = rip_metric;
1073 else {
1074 var = 1;
1075 rip_metric = 1;
1076 }
1077 if rip_metric &gt; 10 then
1078 reject "RIP metric is too big";
1079 else
1080 accept "ok";
1081 }
1082 </code>
1083
1084 <p>As you can see, a filter has a header, a list of local variables, and a body.
1085 The header consists of the <cf/filter/ keyword followed by a (unique) name of
1086 filter. The list of local variables consists of <cf><M>type name</M>;</cf>
1087 pairs where each pair defines one local variable. The body consists of <cf>
1088 { <M>statements</M> }</cf>. Each <m/statement/ is terminated by a <cf/;/. You
1089 can group several statements to a single compound statement by using braces
1090 (<cf>{ <M>statements</M> }</cf>) which is useful if you want to make a bigger
1091 block of code conditional.
1092
1093 <p>BIRD supports functions, so that you don't have to repeat the same blocks of
1094 code over and over. Functions can have zero or more parameters and they can have
1095 local variables. Recursion is not allowed. Function definitions look like this:
1096
1097 <code>
1098 function name ()
1099 int local_variable;
1100 {
1101 local_variable = 5;
1102 }
1103
1104 function with_parameters (int parameter)
1105 {
1106 print parameter;
1107 }
1108 </code>
1109
1110 <p>Unlike in C, variables are declared after the <cf/function/ line, but before
1111 the first <cf/{/. You can't declare variables in nested blocks. Functions are
1112 called like in C: <cf>name(); with_parameters(5);</cf>. Function may return
1113 values using the <cf>return <m/[expr]/</cf> command. Returning a value exits
1114 from current function (this is similar to C).
1115
1116 <p>Filters are declared in a way similar to functions except they can't have
1117 explicit parameters. They get a route table entry as an implicit parameter, it
1118 is also passed automatically to any functions called. The filter must terminate
1119 with either <cf/accept/ or <cf/reject/ statement. If there's a runtime error in
1120 filter, the route is rejected.
1121
1122 <p>A nice trick to debug filters is to use <cf>show route filter <m/name/</cf>
1123 from the command line client. An example session might look like:
1124
1125 <code>
1126 pavel@bug:~/bird$ ./birdc -s bird.ctl
1127 BIRD 0.0.0 ready.
1128 bird> show route
1129 10.0.0.0/8 dev eth0 [direct1 23:21] (240)
1130 195.113.30.2/32 dev tunl1 [direct1 23:21] (240)
1131 127.0.0.0/8 dev lo [direct1 23:21] (240)
1132 bird> show route ?
1133 show route [<prefix>] [table <t>] [filter <f>] [all] [primary]...
1134 bird> show route filter { if 127.0.0.5 &tilde; net then accept; }
1135 127.0.0.0/8 dev lo [direct1 23:21] (240)
1136 bird>
1137 </code>
1138
1139
1140 <sect>Data types
1141 <label id="data-types">
1142
1143 <p>Each variable and each value has certain type. Booleans, integers and enums
1144 are incompatible with each other (that is to prevent you from shooting in the
1145 foot).
1146
1147 <descrip>
1148 <tag><label id="type-bool">bool</tag>
1149 This is a boolean type, it can have only two values, <cf/true/ and
1150 <cf/false/. Boolean is the only type you can use in <cf/if/ statements.
1151
1152 <tag><label id="type-int">int</tag>
1153 This is a general integer type. It is an unsigned 32bit type; i.e., you
1154 can expect it to store values from 0 to 4294967295. Overflows are not
1155 checked. You can use <cf/0x1234/ syntax to write hexadecimal values.
1156
1157 <tag><label id="type-pair">pair</tag>
1158 This is a pair of two short integers. Each component can have values
1159 from 0 to 65535. Literals of this type are written as <cf/(1234,5678)/.
1160 The same syntax can also be used to construct a pair from two arbitrary
1161 integer expressions (for example <cf/(1+2,a)/).
1162
1163 <tag><label id="type-quad">quad</tag>
1164 This is a dotted quad of numbers used to represent router IDs (and
1165 others). Each component can have a value from 0 to 255. Literals of
1166 this type are written like IPv4 addresses.
1167
1168 <tag><label id="type-string">string</tag>
1169 This is a string of characters. There are no ways to modify strings in
1170 filters. You can pass them between functions, assign them to variables
1171 of type <cf/string/, print such variables, use standard string
1172 comparison operations (e.g. <cf/=, !=, &lt;, &gt;, &lt;=, &gt;=/), but
1173 you can't concatenate two strings. String literals are written as
1174 <cf/"This is a string constant"/. Additionally matching (<cf/&tilde;,
1175 !&tilde;/) operators could be used to match a string value against
1176 a shell pattern (represented also as a string).
1177
1178 <tag><label id="type-ip">ip</tag>
1179 This type can hold a single IP address. Depending on the compile-time
1180 configuration of BIRD you are using, it is either an IPv4 or IPv6
1181 address; this may be checked by <cf>.is_ip4</cf> which returns <cf/bool/.
1182 IP addresses are written in the standard notation
1183 (<cf/10.20.30.40/ or <cf/fec0:3:4::1/). You can apply special operator
1184 <cf>.mask(<M>num</M>)</cf> on values of type ip. It masks out all but
1185 first <cf><M>num</M></cf> bits from the IP address. So
1186 <cf/1.2.3.4.mask(8) = 1.0.0.0/ is true.
1187
1188 <tag><label id="type-prefix">prefix</tag>
1189 This type can hold a network prefix consisting of IP address, prefix
1190 length and several other values. This is the key in route tables.
1191
1192 Prefixes may be of several types, which can be determined by the special
1193 operator <cf/.type/. The type may be:
1194
1195 <cf/NET_IP4/ and <cf/NET_IP6/ prefixes hold an IP prefix. The literals
1196 are written as <cf><m/ipaddress//<m/pxlen/</cf>,
1197 or <cf><m>ipaddress</m>/<m>netmask</m></cf>. There are two special
1198 operators on IP prefixes: <cf/.ip/ which extracts the IP address from
1199 the pair, and <cf/.len/, which separates prefix length from the pair.
1200 So <cf>1.2.0.0/16.len = 16</cf> is true.
1201
1202 <cf/NET_VPN4/ and <cf/NET_VPN6/ prefixes hold an IP prefix with VPN
1203 Route Distinguisher (<rfc id="4364">). They support the same special
1204 operators as IP prefixes, and also <cf/.rd/ which extracts the Route
1205 Distinguisher. Their literals are written
1206 as <cf><m/vpnrd/ <m/ipprefix/</cf>
1207
1208 <cf/NET_ROA4/ and <cf/NET_ROA6/ prefixes hold an IP prefix range
1209 together with an ASN. They support the same special operators as IP
1210 prefixes, and also <cf/.maxlen/ which extracts maximal prefix length,
1211 and <cf/.asn/ which extracts the ASN.
1212
1213 <cf/NET_FLOW4/ and <cf/NET_FLOW6/ hold an IP prefix together with a
1214 flowspec rule. Filters currently don't support flowspec parsing.
1215
1216 <tag><label id="type-ec">ec</tag>
1217 This is a specialized type used to represent BGP extended community
1218 values. It is essentially a 64bit value, literals of this type are
1219 usually written as <cf>(<m/kind/, <m/key/, <m/value/)</cf>, where
1220 <cf/kind/ is a kind of extended community (e.g. <cf/rt/ / <cf/ro/ for a
1221 route target / route origin communities), the format and possible values
1222 of <cf/key/ and <cf/value/ are usually integers, but it depends on the
1223 used kind. Similarly to pairs, ECs can be constructed using expressions
1224 for <cf/key/ and <cf/value/ parts, (e.g. <cf/(ro, myas, 3*10)/, where
1225 <cf/myas/ is an integer variable).
1226
1227 <tag><label id="type-lc">lc</tag>
1228 This is a specialized type used to represent BGP large community
1229 values. It is essentially a triplet of 32bit values, where the first
1230 value is reserved for the AS number of the issuer, while meaning of
1231 remaining parts is defined by the issuer. Literals of this type are
1232 written as <cf/(123, 456, 789)/, with any integer values. Similarly to
1233 pairs, LCs can be constructed using expressions for its parts, (e.g.
1234 <cf/(myas, 10+20, 3*10)/, where <cf/myas/ is an integer variable).
1235
1236 <tag><label id="type-set">int|pair|quad|ip|prefix|ec|lc|enum set</tag>
1237 Filters recognize four types of sets. Sets are similar to strings: you
1238 can pass them around but you can't modify them. Literals of type <cf>int
1239 set</cf> look like <cf> [ 1, 2, 5..7 ]</cf>. As you can see, both simple
1240 values and ranges are permitted in sets.
1241
1242 For pair sets, expressions like <cf/(123,*)/ can be used to denote
1243 ranges (in that case <cf/(123,0)..(123,65535)/). You can also use
1244 <cf/(123,5..100)/ for range <cf/(123,5)..(123,100)/. You can also use
1245 <cf/*/ and <cf/a..b/ expressions in the first part of a pair, note that
1246 such expressions are translated to a set of intervals, which may be
1247 memory intensive. E.g. <cf/(*,4..20)/ is translated to <cf/(0,4..20),
1248 (1,4..20), (2,4..20), ... (65535, 4..20)/.
1249
1250 EC sets use similar expressions like pair sets, e.g. <cf/(rt, 123,
1251 10..20)/ or <cf/(ro, 123, *)/. Expressions requiring the translation
1252 (like <cf/(rt, *, 3)/) are not allowed (as they usually have 4B range
1253 for ASNs).
1254
1255 Also LC sets use similar expressions like pair sets. You can use ranges
1256 and wildcards, but if one field uses that, more specific (later) fields
1257 must be wildcards. E.g., <cf/(10, 20..30, *)/ or <cf/(10, 20, 30..40)/
1258 is valid, while <cf/(10, *, 20..30)/ or <cf/(10, 20..30, 40)/ is not
1259 valid.
1260
1261 You can also use expressions for int, pair, EC and LC set values.
1262 However, it must be possible to evaluate these expressions before daemon
1263 boots. So you can use only constants inside them. E.g.
1264
1265 <code>
1266 define one=1;
1267 define myas=64500;
1268 int set odds;
1269 pair set ps;
1270 ec set es;
1271
1272 odds = [ one, 2+1, 6-one, 2*2*2-1, 9, 11 ];
1273 ps = [ (1,one+one), (3,4)..(4,8), (5,*), (6,3..6), (7..9,*) ];
1274 es = [ (rt, myas, 3*10), (rt, myas+one, 0..16*16*16-1), (ro, myas+2, *) ];
1275 </code>
1276
1277 Sets of prefixes are special: their literals does not allow ranges, but
1278 allows prefix patterns that are written
1279 as <cf><M>ipaddress</M>/<M>pxlen</M>{<M>low</M>,<M>high</M>}</cf>.
1280 Prefix <cf><m>ip1</m>/<m>len1</m></cf> matches prefix
1281 pattern <cf><m>ip2</m>/<m>len2</m>{<m>l</m>,<m>h</m>}</cf> if the
1282 first <cf>min(len1, len2)</cf> bits of <cf/ip1/ and <cf/ip2/ are
1283 identical and <cf>len1 &lt;= ip1 &lt;= len2</cf>. A valid prefix pattern
1284 has to satisfy <cf>low &lt;= high</cf>, but <cf/pxlen/ is not
1285 constrained by <cf/low/ or <cf/high/. Obviously, a prefix matches a
1286 prefix set literal if it matches any prefix pattern in the prefix set
1287 literal.
1288
1289 There are also two shorthands for prefix patterns: <cf><m/address//<m/len/+</cf>
1290 is a shorthand for <cf><m/address//<m/len/{<m/len/,<m/maxlen/}</cf>
1291 (where <cf><m/maxlen/</cf> is 32 for IPv4 and 128 for IPv6), that means
1292 network prefix <cf><m/address//<m/len/</cf> and all its subnets.
1293 <cf><m/address//<m/len/-</cf> is a shorthand for
1294 <cf><m/address//<m/len/{0,<m/len/}</cf>, that means network prefix
1295 <cf><m/address//<m/len/</cf> and all its supernets (network prefixes
1296 that contain it).
1297
1298 For example, <cf>[ 1.0.0.0/8, 2.0.0.0/8+, 3.0.0.0/8-, 4.0.0.0/8{16,24}
1299 ]</cf> matches prefix <cf>1.0.0.0/8</cf>, all subprefixes of
1300 <cf>2.0.0.0/8</cf>, all superprefixes of <cf>3.0.0.0/8</cf> and prefixes
1301 <cf/4.X.X.X/ whose prefix length is 16 to 24. <cf>[ 0.0.0.0/0{20,24} ]</cf>
1302 matches all prefixes (regardless of IP address) whose prefix length is
1303 20 to 24, <cf>[ 1.2.3.4/32- ]</cf> matches any prefix that contains IP
1304 address <cf>1.2.3.4</cf>. <cf>1.2.0.0/16 &tilde; [ 1.0.0.0/8{15,17} ]</cf>
1305 is true, but <cf>1.0.0.0/16 &tilde; [ 1.0.0.0/8- ]</cf> is false.
1306
1307 Cisco-style patterns like <cf>10.0.0.0/8 ge 16 le 24</cf> can be expressed
1308 in BIRD as <cf>10.0.0.0/8{16,24}</cf>, <cf>192.168.0.0/16 le 24</cf> as
1309 <cf>192.168.0.0/16{16,24}</cf> and <cf>192.168.0.0/16 ge 24</cf> as
1310 <cf>192.168.0.0/16{24,32}</cf>.
1311
1312 <tag><label id="type-enum">enum</tag>
1313 Enumeration types are fixed sets of possibilities. You can't define your
1314 own variables of such type, but some route attributes are of enumeration
1315 type. Enumeration types are incompatible with each other.
1316
1317 <tag><label id="type-bgppath">bgppath</tag>
1318 BGP path is a list of autonomous system numbers. You can't write
1319 literals of this type. There are several special operators on bgppaths:
1320
1321 <cf><m/P/.first</cf> returns the first ASN (the neighbor ASN) in path <m/P/.
1322
1323 <cf><m/P/.last</cf> returns the last ASN (the source ASN) in path <m/P/.
1324
1325 <cf><m/P/.last_nonaggregated</cf> returns the last ASN in the non-aggregated part of the path <m/P/.
1326
1327 Both <cf/first/ and <cf/last/ return zero if there is no appropriate
1328 ASN, for example if the path contains an AS set element as the first (or
1329 the last) part. If the path ends with an AS set, <cf/last_nonaggregated/
1330 may be used to get last ASN before any AS set.
1331
1332 <cf><m/P/.len</cf> returns the length of path <m/P/.
1333
1334 <cf>prepend(<m/P/,<m/A/)</cf> prepends ASN <m/A/ to path <m/P/ and
1335 returns the result.
1336
1337 <cf>delete(<m/P/,<m/A/)</cf> deletes all instances of ASN <m/A/ from
1338 from path <m/P/ and returns the result. <m/A/ may also be an integer
1339 set, in that case the operator deletes all ASNs from path <m/P/ that are
1340 also members of set <m/A/.
1341
1342 <cf>filter(<m/P/,<m/A/)</cf> deletes all ASNs from path <m/P/ that are
1343 not members of integer set <m/A/. I.e., <cf/filter/ do the same as
1344 <cf/delete/ with inverted set <m/A/.
1345
1346 Statement <cf><m/P/ = prepend(<m/P/, <m/A/);</cf> can be shortened to
1347 <cf><m/P/.prepend(<m/A/);</cf> if <m/P/ is appropriate route attribute
1348 (for example <cf/bgp_path/). Similarly for <cf/delete/ and <cf/filter/.
1349
1350 <tag><label id="type-bgpmask">bgpmask</tag>
1351 BGP masks are patterns used for BGP path matching (using <cf>path
1352 &tilde; [= 2 3 5 * =]</cf> syntax). The masks resemble wildcard patterns
1353 as used by UNIX shells. Autonomous system numbers match themselves,
1354 <cf/*/ matches any (even empty) sequence of arbitrary AS numbers and
1355 <cf/?/ matches one arbitrary AS number. For example, if <cf>bgp_path</cf>
1356 is 4 3 2 1, then: <tt>bgp_path &tilde; [= * 4 3 * =]</tt> is true,
1357 but <tt>bgp_path &tilde; [= * 4 5 * =]</tt> is false. BGP mask
1358 expressions can also contain integer expressions enclosed in parenthesis
1359 and integer variables, for example <tt>[= * 4 (1+2) a =]</tt>. You can
1360 also use ranges, for example <tt>[= * 3..5 2 100..200 * =]</tt>.
1361 There is also old (deprecated) syntax that uses / .. / instead of [= .. =]
1362 and ? instead of *.
1363
1364 <tag><label id="type-clist">clist</tag>
1365 Clist is similar to a set, except that unlike other sets, it can be
1366 modified. The type is used for community list (a set of pairs) and for
1367 cluster list (a set of quads). There exist no literals of this type.
1368 There are three special operators on clists:
1369
1370 <cf><m/C/.len</cf> returns the length of clist <m/C/.
1371
1372 <cf>add(<m/C/,<m/P/)</cf> adds pair (or quad) <m/P/ to clist <m/C/ and
1373 returns the result. If item <m/P/ is already in clist <m/C/, it does
1374 nothing. <m/P/ may also be a clist, in that case all its members are
1375 added; i.e., it works as clist union.
1376
1377 <cf>delete(<m/C/,<m/P/)</cf> deletes pair (or quad) <m/P/ from clist
1378 <m/C/ and returns the result. If clist <m/C/ does not contain item
1379 <m/P/, it does nothing. <m/P/ may also be a pair (or quad) set, in that
1380 case the operator deletes all items from clist <m/C/ that are also
1381 members of set <m/P/. Moreover, <m/P/ may also be a clist, which works
1382 analogously; i.e., it works as clist difference.
1383
1384 <cf>filter(<m/C/,<m/P/)</cf> deletes all items from clist <m/C/ that are
1385 not members of pair (or quad) set <m/P/. I.e., <cf/filter/ do the same
1386 as <cf/delete/ with inverted set <m/P/. <m/P/ may also be a clist, which
1387 works analogously; i.e., it works as clist intersection.
1388
1389 Statement <cf><m/C/ = add(<m/C/, <m/P/);</cf> can be shortened to
1390 <cf><m/C/.add(<m/P/);</cf> if <m/C/ is appropriate route attribute (for
1391 example <cf/bgp_community/). Similarly for <cf/delete/ and <cf/filter/.
1392
1393 <tag><label id="type-eclist">eclist</tag>
1394 Eclist is a data type used for BGP extended community lists. Eclists
1395 are very similar to clists, but they are sets of ECs instead of pairs.
1396 The same operations (like <cf/add/, <cf/delete/ or <cf/&tilde;/ and
1397 <cf/!&tilde;/ membership operators) can be used to modify or test
1398 eclists, with ECs instead of pairs as arguments.
1399
1400 <tag><label id="type-lclist">lclist/</tag>
1401 Lclist is a data type used for BGP large community lists. Like eclists,
1402 lclists are very similar to clists, but they are sets of LCs instead of
1403 pairs. The same operations (like <cf/add/, <cf/delete/ or <cf/&tilde;/
1404 and <cf/!&tilde;/ membership operators) can be used to modify or test
1405 lclists, with LCs instead of pairs as arguments.
1406 </descrip>
1407
1408
1409 <sect>Operators
1410 <label id="operators">
1411
1412 <p>The filter language supports common integer operators <cf>(+,-,*,/)</cf>,
1413 parentheses <cf/(a*(b+c))/, comparison <cf/(a=b, a!=b, a&lt;b, a&gt;=b)/.
1414 Logical operations include unary not (<cf/!/), and (<cf/&amp;&amp;/) and or
1415 (<cf/&verbar;&verbar;/). Special operators include (<cf/&tilde;/,
1416 <cf/!&tilde;/) for "is (not) element of a set" operation - it can be used on
1417 element and set of elements of the same type (returning true if element is
1418 contained in the given set), or on two strings (returning true if first string
1419 matches a shell-like pattern stored in second string) or on IP and prefix
1420 (returning true if IP is within the range defined by that prefix), or on prefix
1421 and prefix (returning true if first prefix is more specific than second one) or
1422 on bgppath and bgpmask (returning true if the path matches the mask) or on
1423 number and bgppath (returning true if the number is in the path) or on bgppath
1424 and int (number) set (returning true if any ASN from the path is in the set) or
1425 on pair/quad and clist (returning true if the pair/quad is element of the
1426 clist) or on clist and pair/quad set (returning true if there is an element of
1427 the clist that is also a member of the pair/quad set).
1428
1429 <p>There is one operator related to ROA infrastructure - <cf/roa_check()/. It
1430 examines a ROA table and does <rfc id="6483"> route origin validation for a
1431 given network prefix. The basic usage is <cf>roa_check(<m/table/)</cf>, which
1432 checks current route (which should be from BGP to have AS_PATH argument) in the
1433 specified ROA table and returns ROA_UNKNOWN if there is no relevant ROA,
1434 ROA_VALID if there is a matching ROA, or ROA_INVALID if there are some relevant
1435 ROAs but none of them match. There is also an extended variant
1436 <cf>roa_check(<m/table/, <m/prefix/, <m/asn/)</cf>, which allows to specify a
1437 prefix and an ASN as arguments.
1438
1439
1440 <sect>Control structures
1441 <label id="control-structures">
1442
1443 <p>Filters support two control structures: conditions and case switches.
1444
1445 <p>Syntax of a condition is: <cf>if <M>boolean expression</M> then <m/command1/;
1446 else <m/command2/;</cf> and you can use <cf>{ <m/command_1/; <m/command_2/;
1447 <M>...</M> }</cf> instead of either command. The <cf>else</cf> clause may be
1448 omitted. If the <cf><m>boolean expression</m></cf> is true, <m/command1/ is
1449 executed, otherwise <m/command2/ is executed.
1450
1451 <p>The <cf>case</cf> is similar to case from Pascal. Syntax is <cf>case
1452 <m/expr/ { else: | <m/num_or_prefix [ .. num_or_prefix]/: <m/statement/ ; [
1453 ... ] }</cf>. The expression after <cf>case</cf> can be of any type which can be
1454 on the left side of the &tilde; operator and anything that could be a member of
1455 a set is allowed before <cf/:/. Multiple commands are allowed without <cf/{}/
1456 grouping. If <cf><m/expr/</cf> matches one of the <cf/:/ clauses, statements
1457 between it and next <cf/:/ statement are executed. If <cf><m/expr/</cf> matches
1458 neither of the <cf/:/ clauses, the statements after <cf/else:/ are executed.
1459
1460 <p>Here is example that uses <cf/if/ and <cf/case/ structures:
1461
1462 <code>
1463 case arg1 {
1464 2: print "two"; print "I can do more commands without {}";
1465 3 .. 5: print "three to five";
1466 else: print "something else";
1467 }
1468
1469 if 1234 = i then printn "."; else {
1470 print "not 1234";
1471 print "You need {} around multiple commands";
1472 }
1473 </code>
1474
1475
1476 <sect>Route attributes
1477 <label id="route-attributes">
1478
1479 <p>A filter is implicitly passed a route, and it can access its attributes just
1480 like it accesses variables. Attempts to access undefined attribute result in a
1481 runtime error; you can check if an attribute is defined by using the
1482 <cf>defined( <m>attribute</m> )</cf> operator. One notable exception to this
1483 rule are attributes of clist type, where undefined value is regarded as empty
1484 clist for most purposes.
1485
1486 <descrip>
1487 <tag><label id="rta-net"><m/prefix/ net</tag>
1488 Network the route is talking about. Read-only. (See the chapter about
1489 routing tables.)
1490
1491 <tag><label id="rta-scope"><m/enum/ scope</tag>
1492 The scope of the route. Possible values: <cf/SCOPE_HOST/ for routes
1493 local to this host, <cf/SCOPE_LINK/ for those specific for a physical
1494 link, <cf/SCOPE_SITE/ and <cf/SCOPE_ORGANIZATION/ for private routes and
1495 <cf/SCOPE_UNIVERSE/ for globally visible routes. This attribute is not
1496 interpreted by BIRD and can be used to mark routes in filters. The
1497 default value for new routes is <cf/SCOPE_UNIVERSE/.
1498
1499 <tag><label id="rta-preference"><m/int/ preference</tag>
1500 Preference of the route. Valid values are 0-65535. (See the chapter
1501 about routing tables.)
1502
1503 <tag><label id="rta-from"><m/ip/ from</tag>
1504 The router which the route has originated from.
1505
1506 <tag><label id="rta-gw"><m/ip/ gw</tag>
1507 Next hop packets routed using this route should be forwarded to.
1508
1509 <tag><label id="rta-proto"><m/string/ proto</tag>
1510 The name of the protocol which the route has been imported from.
1511 Read-only.
1512
1513 <tag><label id="rta-source"><m/enum/ source</tag>
1514 what protocol has told me about this route. Possible values:
1515 <cf/RTS_DUMMY/, <cf/RTS_STATIC/, <cf/RTS_INHERIT/, <cf/RTS_DEVICE/,
1516 <cf/RTS_STATIC_DEVICE/, <cf/RTS_REDIRECT/, <cf/RTS_RIP/, <cf/RTS_OSPF/,
1517 <cf/RTS_OSPF_IA/, <cf/RTS_OSPF_EXT1/, <cf/RTS_OSPF_EXT2/, <cf/RTS_BGP/,
1518 <cf/RTS_PIPE/, <cf/RTS_BABEL/.
1519
1520 <tag><label id="rta-cast"><m/enum/ cast</tag>
1521 Route type (Currently <cf/RTC_UNICAST/ for normal routes,
1522 <cf/RTC_BROADCAST/, <cf/RTC_MULTICAST/, <cf/RTC_ANYCAST/ will be used in
1523 the future for broadcast, multicast and anycast routes). Read-only.
1524
1525 <tag><label id="rta-dest"><m/enum/ dest</tag>
1526 Type of destination the packets should be sent to
1527 (<cf/RTD_ROUTER/ for forwarding to a neighboring router,
1528 <cf/RTD_DEVICE/ for routing to a directly-connected network,
1529 <cf/RTD_MULTIPATH/ for multipath destinations,
1530 <cf/RTD_BLACKHOLE/ for packets to be silently discarded,
1531 <cf/RTD_UNREACHABLE/, <cf/RTD_PROHIBIT/ for packets that should be
1532 returned with ICMP host unreachable / ICMP administratively prohibited
1533 messages). Can be changed, but only to <cf/RTD_BLACKHOLE/,
1534 <cf/RTD_UNREACHABLE/ or <cf/RTD_PROHIBIT/.
1535
1536 <tag><label id="rta-ifname"><m/string/ ifname</tag>
1537 Name of the outgoing interface. Sink routes (like blackhole, unreachable
1538 or prohibit) and multipath routes have no interface associated with
1539 them, so <cf/ifname/ returns an empty string for such routes. Read-only.
1540
1541 <tag><label id="rta-ifindex"><m/int/ ifindex</tag>
1542 Index of the outgoing interface. System wide index of the interface. May
1543 be used for interface matching, however indexes might change on interface
1544 creation/removal. Zero is returned for routes with undefined outgoing
1545 interfaces. Read-only.
1546
1547 <tag><label id="rta-igp-metric"><m/int/ igp_metric</tag>
1548 The optional attribute that can be used to specify a distance to the
1549 network for routes that do not have a native protocol metric attribute
1550 (like <cf/ospf_metric1/ for OSPF routes). It is used mainly by BGP to
1551 compare internal distances to boundary routers (see below). It is also
1552 used when the route is exported to OSPF as a default value for OSPF type
1553 1 metric.
1554 </descrip>
1555
1556 <p>There also exist some protocol-specific attributes which are described in the
1557 corresponding protocol sections.
1558
1559
1560 <sect>Other statements
1561 <label id="other-statements">
1562
1563 <p>The following statements are available:
1564
1565 <descrip>
1566 <tag><label id="assignment"><m/variable/ = <m/expr/</tag>
1567 Set variable to a given value.
1568
1569 <tag><label id="filter-accept-reject">accept|reject [ <m/expr/ ]</tag>
1570 Accept or reject the route, possibly printing <cf><m>expr</m></cf>.
1571
1572 <tag><label id="return">return <m/expr/</tag>
1573 Return <cf><m>expr</m></cf> from the current function, the function ends
1574 at this point.
1575
1576 <tag><label id="print">print|printn <m/expr/ [<m/, expr.../]</tag>
1577 Prints given expressions; useful mainly while debugging filters. The
1578 <cf/printn/ variant does not terminate the line.
1579
1580 <tag><label id="quitbird">quitbird</tag>
1581 Terminates BIRD. Useful when debugging the filter interpreter.
1582 </descrip>
1583
1584
1585 <chapt>Protocols
1586 <label id="protocols">
1587
1588 <sect>Babel
1589 <label id="babel">
1590
1591 <sect1>Introduction
1592 <label id="babel-intro">
1593
1594 <p>The Babel protocol
1595 (<rfc id="6126">) is a loop-avoiding distance-vector routing protocol that is
1596 robust and efficient both in ordinary wired networks and in wireless mesh
1597 networks. Babel is conceptually very simple in its operation and "just works"
1598 in its default configuration, though some configuration is possible and in some
1599 cases desirable.
1600
1601 <p>The Babel protocol is dual stack; i.e., it can carry both IPv4 and IPv6
1602 routes over the same IPv6 transport. For sending and receiving Babel packets,
1603 only a link-local IPv6 address is needed.
1604
1605 <p>BIRD does not implement any Babel extensions, but will coexist with
1606 implementations using extensions (and will just ignore extension messages).
1607
1608 <sect1>Configuration
1609 <label id="babel-config">
1610
1611 <p>Babel supports no global configuration options apart from those common to all
1612 other protocols, but supports the following per-interface configuration options:
1613
1614 <code>
1615 protocol babel [<name>] {
1616 interface <interface pattern> {
1617 type <wired|wireless>;
1618 rxcost <number>;
1619 limit <number>;
1620 hello interval <number>;
1621 update interval <number>;
1622 port <number>;
1623 tx class|dscp <number>;
1624 tx priority <number>;
1625 rx buffer <number>;
1626 tx length <number>;
1627 check link <switch>;
1628 next hop ipv4 <address>;
1629 next hop ipv6 <address>;
1630 };
1631 }
1632 </code>
1633
1634 <descrip>
1635 <tag><label id="babel-type">type wired|wireless </tag>
1636 This option specifies the interface type: Wired or wireless. On wired
1637 interfaces a neighbor is considered unreachable after a small number of
1638 Hello packets are lost, as described by <cf/limit/ option. On wireless
1639 interfaces the ETX link quality estimation technique is used to compute
1640 the metrics of routes discovered over this interface. This technique will
1641 gradually degrade the metric of routes when packets are lost rather than
1642 the more binary up/down mechanism of wired type links. Default:
1643 <cf/wired/.
1644
1645 <tag><label id="babel-rxcost">rxcost <m/num/</tag>
1646 This option specifies the nominal RX cost of the interface. The effective
1647 neighbor costs for route metrics will be computed from this value with a
1648 mechanism determined by the interface <cf/type/. Note that in contrast to
1649 other routing protocols like RIP or OSPF, the <cf/rxcost/ specifies the
1650 cost of RX instead of TX, so it affects primarily neighbors' route
1651 selection and not local route selection. Default: 96 for wired interfaces,
1652 256 for wireless.
1653
1654 <tag><label id="babel-limit">limit <m/num/</tag>
1655 BIRD keeps track of received Hello messages from each neighbor to
1656 establish neighbor reachability. For wired type interfaces, this option
1657 specifies how many of last 16 hellos have to be correctly received in
1658 order to neighbor is assumed to be up. The option is ignored on wireless
1659 type interfaces, where gradual cost degradation is used instead of sharp
1660 limit. Default: 12.
1661
1662 <tag><label id="babel-hello">hello interval <m/num/</tag>
1663 Interval at which periodic Hello messages are sent on this interface,
1664 in seconds. Default: 4 seconds.
1665
1666 <tag><label id="babel-update">update interval <m/num/</tag>
1667 Interval at which periodic (full) updates are sent. Default: 4 times the
1668 hello interval.
1669
1670 <tag><label id="babel-port">port <m/number/</tag>
1671 This option selects an UDP port to operate on. The default is to operate
1672 on port 6696 as specified in the Babel RFC.
1673
1674 <tag><label id="babel-tx-class">tx class|dscp|priority <m/number/</tag>
1675 These options specify the ToS/DiffServ/Traffic class/Priority of the
1676 outgoing Babel packets. See <ref id="proto-tx-class" name="tx class"> common
1677 option for detailed description.
1678
1679 <tag><label id="babel-rx-buffer">rx buffer <m/number/</tag>
1680 This option specifies the size of buffers used for packet processing.
1681 The buffer size should be bigger than maximal size of received packets.
1682 The default value is the interface MTU, and the value will be clamped to a
1683 minimum of 512 bytes + IP packet overhead.
1684
1685 <tag><label id="babel-tx-length">tx length <m/number/</tag>
1686 This option specifies the maximum length of generated Babel packets. To
1687 avoid IP fragmentation, it should not exceed the interface MTU value.
1688 The default value is the interface MTU value, and the value will be
1689 clamped to a minimum of 512 bytes + IP packet overhead.
1690
1691 <tag><label id="babel-check-link">check link <m/switch/</tag>
1692 If set, the hardware link state (as reported by OS) is taken into
1693 consideration. When the link disappears (e.g. an ethernet cable is
1694 unplugged), neighbors are immediately considered unreachable and all
1695 routes received from them are withdrawn. It is possible that some
1696 hardware drivers or platforms do not implement this feature. Default:
1697 yes.
1698
1699 <tag><label id="babel-next-hop-ipv4">next hop ipv4 <m/address/</tag>
1700 Set the next hop address advertised for IPv4 routes advertised on this
1701 interface. If not set, the first IPv4 address found on the interface will
1702 be used, so it should only be necessary to set this option if this
1703 auto-detection fails or finds the wrong address.
1704
1705 <tag><label id="babel-next-hop-ipv6">next hop ipv6 <m/address/</tag>
1706 Set the next hop address advertised for IPv6 routes advertised on this
1707 interface. If not set, the same link-local address that is used as the
1708 source for Babel packets will be used. In normal operation, it should not
1709 be necessary to set this option.
1710 </descrip>
1711
1712 <sect1>Attributes
1713 <label id="babel-attr">
1714
1715 <p>Babel defines just one attribute: the internal babel metric of the route. It
1716 is exposed as the <cf/babel_metric/ attribute and has range from 1 to infinity
1717 (65535).
1718
1719 <sect1>Example
1720 <label id="babel-exam">
1721
1722 <p><code>
1723 protocol babel {
1724 interface "eth*" {
1725 type wired;
1726 };
1727 interface "wlan0", "wlan1" {
1728 type wireless;
1729 hello interval 1;
1730 rxcost 512;
1731 };
1732 interface "tap0";
1733
1734 # This matches the default of babeld: redistribute all addresses
1735 # configured on local interfaces, plus re-distribute all routes received
1736 # from other babel peers.
1737
1738 ipv4 {
1739 export where (source = RTS_DEVICE) || (source = RTS_BABEL);
1740 };
1741 ipv6 {
1742 export where (source = RTS_DEVICE) || (source = RTS_BABEL);
1743 };
1744 }
1745 </code>
1746
1747
1748 <sect>BFD
1749 <label id="bfd">
1750
1751 <sect1>Introduction
1752 <label id="bfd-intro">
1753
1754 <p>Bidirectional Forwarding Detection (BFD) is not a routing protocol itself, it
1755 is an independent tool providing liveness and failure detection. Routing
1756 protocols like OSPF and BGP use integrated periodic "hello" messages to monitor
1757 liveness of neighbors, but detection times of these mechanisms are high (e.g. 40
1758 seconds by default in OSPF, could be set down to several seconds). BFD offers
1759 universal, fast and low-overhead mechanism for failure detection, which could be
1760 attached to any routing protocol in an advisory role.
1761
1762 <p>BFD consists of mostly independent BFD sessions. Each session monitors an
1763 unicast bidirectional path between two BFD-enabled routers. This is done by
1764 periodically sending control packets in both directions. BFD does not handle
1765 neighbor discovery, BFD sessions are created on demand by request of other
1766 protocols (like OSPF or BGP), which supply appropriate information like IP
1767 addresses and associated interfaces. When a session changes its state, these
1768 protocols are notified and act accordingly (e.g. break an OSPF adjacency when
1769 the BFD session went down).
1770
1771 <p>BIRD implements basic BFD behavior as defined in <rfc id="5880"> (some
1772 advanced features like the echo mode or authentication are not implemented), IP
1773 transport for BFD as defined in <rfc id="5881"> and <rfc id="5883"> and
1774 interaction with client protocols as defined in <rfc id="5882">.
1775
1776 <p>Note that BFD implementation in BIRD is currently a new feature in
1777 development, expect some rough edges and possible UI and configuration changes
1778 in the future. Also note that we currently support at most one protocol instance.
1779
1780 <p>BFD packets are sent with a dynamic source port number. Linux systems use by
1781 default a bit different dynamic port range than the IANA approved one
1782 (49152-65535). If you experience problems with compatibility, please adjust
1783 <cf>/proc/sys/net/ipv4/ip_local_port_range</cf>
1784
1785 <sect1>Configuration
1786 <label id="bfd-config">
1787
1788 <p>BFD configuration consists mainly of multiple definitions of interfaces.
1789 Most BFD config options are session specific. When a new session is requested
1790 and dynamically created, it is configured from one of these definitions. For
1791 sessions to directly connected neighbors, <cf/interface/ definitions are chosen
1792 based on the interface associated with the session, while <cf/multihop/
1793 definition is used for multihop sessions. If no definition is relevant, the
1794 session is just created with the default configuration. Therefore, an empty BFD
1795 configuration is often sufficient.
1796
1797 <p>Note that to use BFD for other protocols like OSPF or BGP, these protocols
1798 also have to be configured to request BFD sessions, usually by <cf/bfd/ option.
1799
1800 <p>Some of BFD session options require <m/time/ value, which has to be specified
1801 with the appropriate unit: <m/num/ <cf/s/|<cf/ms/|<cf/us/. Although microseconds
1802 are allowed as units, practical minimum values are usually in order of tens of
1803 milliseconds.
1804
1805 <code>
1806 protocol bfd [&lt;name&gt;] {
1807 interface &lt;interface pattern&gt; {
1808 interval &lt;time&gt;;
1809 min rx interval &lt;time&gt;;
1810 min tx interval &lt;time&gt;;
1811 idle tx interval &lt;time&gt;;
1812 multiplier &lt;num&gt;;
1813 passive &lt;switch&gt;;
1814 authentication none;
1815 authentication simple;
1816 authentication [meticulous] keyed md5|sha1;
1817 password "&lt;text&gt;";
1818 password "&lt;text&gt;" {
1819 id &lt;num&gt;;
1820 generate from "&lt;date&gt;";
1821 generate to "&lt;date&gt;";
1822 accept from "&lt;date&gt;";
1823 accept to "&lt;date&gt;";
1824 from "&lt;date&gt;";
1825 to "&lt;date&gt;";
1826 };
1827 };
1828 multihop {
1829 interval &lt;time&gt;;
1830 min rx interval &lt;time&gt;;
1831 min tx interval &lt;time&gt;;
1832 idle tx interval &lt;time&gt;;
1833 multiplier &lt;num&gt;;
1834 passive &lt;switch&gt;;
1835 };
1836 neighbor &lt;ip&gt; [dev "&lt;interface&gt;"] [local &lt;ip&gt;] [multihop &lt;switch&gt;];
1837 }
1838 </code>
1839
1840 <descrip>
1841 <tag><label id="bfd-iface">interface <m/pattern/ [, <m/.../] { <m/options/ }</tag>
1842 Interface definitions allow to specify options for sessions associated
1843 with such interfaces and also may contain interface specific options.
1844 See <ref id="proto-iface" name="interface"> common option for a detailed
1845 description of interface patterns. Note that contrary to the behavior of
1846 <cf/interface/ definitions of other protocols, BFD protocol would accept
1847 sessions (in default configuration) even on interfaces not covered by
1848 such definitions.
1849
1850 <tag><label id="bfd-multihop">multihop { <m/options/ }</tag>
1851 Multihop definitions allow to specify options for multihop BFD sessions,
1852 in the same manner as <cf/interface/ definitions are used for directly
1853 connected sessions. Currently only one such definition (for all multihop
1854 sessions) could be used.
1855
1856 <tag><label id="bfd-neighbor">neighbor <m/ip/ [dev "<m/interface/"] [local <m/ip/] [multihop <m/switch/]</tag>
1857 BFD sessions are usually created on demand as requested by other
1858 protocols (like OSPF or BGP). This option allows to explicitly add
1859 a BFD session to the specified neighbor regardless of such requests.
1860
1861 The session is identified by the IP address of the neighbor, with
1862 optional specification of used interface and local IP. By default
1863 the neighbor must be directly connected, unless the session is
1864 configured as multihop. Note that local IP must be specified for
1865 multihop sessions.
1866 </descrip>
1867
1868 <p>Session specific options (part of <cf/interface/ and <cf/multihop/ definitions):
1869
1870 <descrip>
1871 <tag><label id="bfd-interval">interval <m/time/</tag>
1872 BFD ensures availability of the forwarding path associated with the
1873 session by periodically sending BFD control packets in both
1874 directions. The rate of such packets is controlled by two options,
1875 <cf/min rx interval/ and <cf/min tx interval/ (see below). This option
1876 is just a shorthand to set both of these options together.
1877
1878 <tag><label id="bfd-min-rx-interval">min rx interval <m/time/</tag>
1879 This option specifies the minimum RX interval, which is announced to the
1880 neighbor and used there to limit the neighbor's rate of generated BFD
1881 control packets. Default: 10 ms.
1882
1883 <tag><label id="bfd-min-tx-interval">min tx interval <m/time/</tag>
1884 This option specifies the desired TX interval, which controls the rate
1885 of generated BFD control packets (together with <cf/min rx interval/
1886 announced by the neighbor). Note that this value is used only if the BFD
1887 session is up, otherwise the value of <cf/idle tx interval/ is used
1888 instead. Default: 100 ms.
1889
1890 <tag><label id="bfd-idle-tx-interval">idle tx interval <m/time/</tag>
1891 In order to limit unnecessary traffic in cases where a neighbor is not
1892 available or not running BFD, the rate of generated BFD control packets
1893 is lower when the BFD session is not up. This option specifies the
1894 desired TX interval in such cases instead of <cf/min tx interval/.
1895 Default: 1 s.
1896
1897 <tag><label id="bfd-multiplier">multiplier <m/num/</tag>
1898 Failure detection time for BFD sessions is based on established rate of
1899 BFD control packets (<cf>min rx/tx interval</cf>) multiplied by this
1900 multiplier, which is essentially (ignoring jitter) a number of missed
1901 packets after which the session is declared down. Note that rates and
1902 multipliers could be different in each direction of a BFD session.
1903 Default: 5.
1904
1905 <tag><label id="bfd-passive">passive <m/switch/</tag>
1906 Generally, both BFD session endpoints try to establish the session by
1907 sending control packets to the other side. This option allows to enable
1908 passive mode, which means that the router does not send BFD packets
1909 until it has received one from the other side. Default: disabled.
1910
1911 <tag>authentication none</tag>
1912 No passwords are sent in BFD packets. This is the default value.
1913
1914 <tag>authentication simple</tag>
1915 Every packet carries 16 bytes of password. Received packets lacking this
1916 password are ignored. This authentication mechanism is very weak.
1917
1918 <tag>authentication [meticulous] keyed md5|sha1</tag>
1919 An authentication code is appended to each packet. The cryptographic
1920 algorithm is keyed MD5 or keyed SHA-1. Note that the algorithm is common
1921 for all keys (on one interface), in contrast to OSPF or RIP, where it
1922 is a per-key option. Passwords (keys) are not sent open via network.
1923
1924 The <cf/meticulous/ variant means that cryptographic sequence numbers
1925 are increased for each sent packet, while in the basic variant they are
1926 increased about once per second. Generally, the <cf/meticulous/ variant
1927 offers better resistance to replay attacks but may require more
1928 computation.
1929
1930 <tag>password "<M>text</M>"</tag>
1931 Specifies a password used for authentication. See <ref id="dsc-pass"
1932 name="password"> common option for detailed description. Note that
1933 password option <cf/algorithm/ is not available in BFD protocol. The
1934 algorithm is selected by <cf/authentication/ option for all passwords.
1935
1936 </descrip>
1937
1938 <sect1>Example
1939 <label id="bfd-exam">
1940
1941 <p><code>
1942 protocol bfd {
1943 interface "eth*" {
1944 min rx interval 20 ms;
1945 min tx interval 50 ms;
1946 idle tx interval 300 ms;
1947 };
1948 interface "gre*" {
1949 interval 200 ms;
1950 multiplier 10;
1951 passive;
1952 };
1953 multihop {
1954 interval 200 ms;
1955 multiplier 10;
1956 };
1957
1958 neighbor 192.168.1.10;
1959 neighbor 192.168.2.2 dev "eth2";
1960 neighbor 192.168.10.1 local 192.168.1.1 multihop;
1961 }
1962 </code>
1963
1964
1965 <sect>BGP
1966 <label id="bgp">
1967
1968 <p>The Border Gateway Protocol is the routing protocol used for backbone level
1969 routing in the today's Internet. Contrary to other protocols, its convergence
1970 does not rely on all routers following the same rules for route selection,
1971 making it possible to implement any routing policy at any router in the network,
1972 the only restriction being that if a router advertises a route, it must accept
1973 and forward packets according to it.
1974
1975 <p>BGP works in terms of autonomous systems (often abbreviated as AS). Each AS
1976 is a part of the network with common management and common routing policy. It is
1977 identified by a unique 16-bit number (ASN). Routers within each AS usually
1978 exchange AS-internal routing information with each other using an interior
1979 gateway protocol (IGP, such as OSPF or RIP). Boundary routers at the border of
1980 the AS communicate global (inter-AS) network reachability information with their
1981 neighbors in the neighboring AS'es via exterior BGP (eBGP) and redistribute
1982 received information to other routers in the AS via interior BGP (iBGP).
1983
1984 <p>Each BGP router sends to its neighbors updates of the parts of its routing
1985 table it wishes to export along with complete path information (a list of AS'es
1986 the packet will travel through if it uses the particular route) in order to
1987 avoid routing loops.
1988
1989 <sect1>Supported standards:
1990 <label id="bgp-standards">
1991
1992 <itemize>
1993 <item> <rfc id="4271"> - Border Gateway Protocol 4 (BGP)
1994 <item> <rfc id="1997"> - BGP Communities Attribute
1995 <item> <rfc id="2385"> - Protection of BGP Sessions via TCP MD5 Signature
1996 <item> <rfc id="2545"> - Use of BGP Multiprotocol Extensions for IPv6
1997 <item> <rfc id="2918"> - Route Refresh Capability
1998 <item> <rfc id="3107"> - Carrying Label Information in BGP
1999 <item> <rfc id="4360"> - BGP Extended Communities Attribute
2000 <item> <rfc id="4364"> - BGP/MPLS IPv4 Virtual Private Networks
2001 <item> <rfc id="4456"> - BGP Route Reflection
2002 <item> <rfc id="4486"> - Subcodes for BGP Cease Notification Message
2003 <item> <rfc id="4659"> - BGP/MPLS IPv6 Virtual Private Networks
2004 <item> <rfc id="4724"> - Graceful Restart Mechanism for BGP
2005 <item> <rfc id="4760"> - Multiprotocol extensions for BGP
2006 <item> <rfc id="4798"> - Connecting IPv6 Islands over IPv4 MPLS
2007 <item> <rfc id="5065"> - AS confederations for BGP
2008 <item> <rfc id="5082"> - Generalized TTL Security Mechanism
2009 <item> <rfc id="5492"> - Capabilities Advertisement with BGP
2010 <item> <rfc id="5549"> - Advertising IPv4 NLRI with an IPv6 Next Hop
2011 <item> <rfc id="5575"> - Dissemination of Flow Specification Rules
2012 <item> <rfc id="5668"> - 4-Octet AS Specific BGP Extended Community
2013 <item> <rfc id="6286"> - AS-Wide Unique BGP Identifier
2014 <item> <rfc id="6608"> - Subcodes for BGP Finite State Machine Error
2015 <item> <rfc id="6793"> - BGP Support for 4-Octet AS Numbers
2016 <item> <rfc id="7313"> - Enhanced Route Refresh Capability for BGP
2017 <item> <rfc id="7606"> - Revised Error Handling for BGP UPDATE Messages
2018 <item> <rfc id="7911"> - Advertisement of Multiple Paths in BGP
2019 <item> <rfc id="7947"> - Internet Exchange BGP Route Server
2020 <item> <rfc id="8092"> - BGP Large Communities Attribute
2021 </itemize>
2022
2023 <sect1>Route selection rules
2024 <label id="bgp-route-select-rules">
2025
2026 <p>BGP doesn't have any simple metric, so the rules for selection of an optimal
2027 route among multiple BGP routes with the same preference are a bit more complex
2028 and they are implemented according to the following algorithm. It starts the
2029 first rule, if there are more "best" routes, then it uses the second rule to
2030 choose among them and so on.
2031
2032 <itemize>
2033 <item>Prefer route with the highest Local Preference attribute.
2034 <item>Prefer route with the shortest AS path.
2035 <item>Prefer IGP origin over EGP and EGP origin over incomplete.
2036 <item>Prefer the lowest value of the Multiple Exit Discriminator.
2037 <item>Prefer routes received via eBGP over ones received via iBGP.
2038 <item>Prefer routes with lower internal distance to a boundary router.
2039 <item>Prefer the route with the lowest value of router ID of the
2040 advertising router.
2041 </itemize>
2042
2043 <sect1>IGP routing table
2044 <label id="bgp-igp-routing-table">
2045
2046 <p>BGP is mainly concerned with global network reachability and with routes to
2047 other autonomous systems. When such routes are redistributed to routers in the
2048 AS via BGP, they contain IP addresses of a boundary routers (in route attribute
2049 NEXT_HOP). BGP depends on existing IGP routing table with AS-internal routes to
2050 determine immediate next hops for routes and to know their internal distances to
2051 boundary routers for the purpose of BGP route selection. In BIRD, there is
2052 usually one routing table used for both IGP routes and BGP routes.
2053
2054 <sect1>Configuration
2055 <label id="bgp-config">
2056
2057 <p>Each instance of the BGP corresponds to one neighboring router. This allows
2058 to set routing policy and all the other parameters differently for each neighbor
2059 using the following configuration parameters:
2060
2061 <descrip>
2062 <tag><label id="bgp-local">local [<m/ip/] as <m/number/</tag>
2063 Define which AS we are part of. (Note that contrary to other IP routers,
2064 BIRD is able to act as a router located in multiple AS'es simultaneously,
2065 but in such cases you need to tweak the BGP paths manually in the filters
2066 to get consistent behavior.) Optional <cf/ip/ argument specifies a source
2067 address, equivalent to the <cf/source address/ option (see below). This
2068 parameter is mandatory.
2069
2070 <tag><label id="bgp-neighbor">neighbor [<m/ip/] [port <m/number/] [as <m/number/]</tag>
2071 Define neighboring router this instance will be talking to and what AS
2072 it is located in. In case the neighbor is in the same AS as we are, we
2073 automatically switch to iBGP. Optionally, the remote port may also be
2074 specified. The parameter may be used multiple times with different
2075 sub-options (e.g., both <cf/neighbor 10.0.0.1 as 65000;/ and
2076 <cf/neighbor 10.0.0.1; neighbor as 65000;/ are valid). This parameter is
2077 mandatory.
2078
2079 <tag><label id="bgp-iface">interface <m/string/</tag>
2080 Define interface we should use for link-local BGP IPv6 sessions.
2081 Interface can also be specified as a part of <cf/neighbor address/
2082 (e.g., <cf/neighbor fe80::1234%eth0 as 65000;/). The option may also be
2083 used for non link-local sessions when it is necessary to explicitly
2084 specify an interface, but only for direct (not multihop) sessions.
2085
2086 <tag><label id="bgp-direct">direct</tag>
2087 Specify that the neighbor is directly connected. The IP address of the
2088 neighbor must be from a directly reachable IP range (i.e. associated
2089 with one of your router's interfaces), otherwise the BGP session
2090 wouldn't start but it would wait for such interface to appear. The
2091 alternative is the <cf/multihop/ option. Default: enabled for eBGP.
2092
2093 <tag><label id="bgp-multihop">multihop [<m/number/]</tag>
2094 Configure multihop BGP session to a neighbor that isn't directly
2095 connected. Accurately, this option should be used if the configured
2096 neighbor IP address does not match with any local network subnets. Such
2097 IP address have to be reachable through system routing table. The
2098 alternative is the <cf/direct/ option. For multihop BGP it is
2099 recommended to explicitly configure the source address to have it
2100 stable. Optional <cf/number/ argument can be used to specify the number
2101 of hops (used for TTL). Note that the number of networks (edges) in a
2102 path is counted; i.e., if two BGP speakers are separated by one router,
2103 the number of hops is 2. Default: enabled for iBGP.
2104
2105 <tag><label id="bgp-source-address">source address <m/ip/</tag>
2106 Define local address we should use for next hop calculation and as a
2107 source address for the BGP session. Default: the address of the local
2108 end of the interface our neighbor is connected to.
2109
2110 <tag><label id="bgp-strict-bind">strict bind <m/switch/</tag>
2111 Specify whether BGP listening socket should be bound to a specific local
2112 address (the same as the <cf/source address/) and associated interface,
2113 or to all addresses. Binding to a specific address could be useful in
2114 cases like running multiple BIRD instances on a machine, each using its
2115 IP address. Note that listening sockets bound to a specific address and
2116 to all addresses collide, therefore either all BGP protocols (of the
2117 same address family and using the same local port) should have set
2118 <cf/strict bind/, or none of them. Default: disabled.
2119
2120 <tag><label id="bgp-next-hop-self">next hop self</tag>
2121 Avoid calculation of the Next Hop attribute and always advertise our own
2122 source address as a next hop. This needs to be used only occasionally to
2123 circumvent misconfigurations of other routers. Default: disabled.
2124
2125 <tag><label id="bgp-next-hop-keep">next hop keep</tag>
2126 Forward the received Next Hop attribute even in situations where the
2127 local address should be used instead, like when the route is sent to an
2128 interface with a different subnet. Default: disabled.
2129
2130 <tag><label id="bgp-missing-lladdr">missing lladdr self|drop|ignore</tag>
2131 Next Hop attribute in BGP-IPv6 sometimes contains just the global IPv6
2132 address, but sometimes it has to contain both global and link-local IPv6
2133 addresses. This option specifies what to do if BIRD have to send both
2134 addresses but does not know link-local address. This situation might
2135 happen when routes from other protocols are exported to BGP, or when
2136 improper updates are received from BGP peers. <cf/self/ means that BIRD
2137 advertises its own local address instead. <cf/drop/ means that BIRD
2138 skips that prefixes and logs error. <cf/ignore/ means that BIRD ignores
2139 the problem and sends just the global address (and therefore forms
2140 improper BGP update). Default: <cf/self/, unless BIRD is configured as a
2141 route server (option <cf/rs client/), in that case default is <cf/ignore/,
2142 because route servers usually do not forward packets themselves.
2143
2144 <tag><label id="bgp-gateway">gateway direct|recursive</tag>
2145 For received routes, their <cf/gw/ (immediate next hop) attribute is
2146 computed from received <cf/bgp_next_hop/ attribute. This option
2147 specifies how it is computed. Direct mode means that the IP address from
2148 <cf/bgp_next_hop/ is used if it is directly reachable, otherwise the
2149 neighbor IP address is used. Recursive mode means that the gateway is
2150 computed by an IGP routing table lookup for the IP address from
2151 <cf/bgp_next_hop/. Note that there is just one level of indirection in
2152 recursive mode - the route obtained by the lookup must not be recursive
2153 itself, to prevent mutually recursive routes.
2154
2155 Recursive mode is the behavior specified by the BGP
2156 standard. Direct mode is simpler, does not require any routes in a
2157 routing table, and was used in older versions of BIRD, but does not
2158 handle well nontrivial iBGP setups and multihop. Recursive mode is
2159 incompatible with <ref id="dsc-table-sorted" name="sorted tables">. Default:
2160 <cf/direct/ for direct sessions, <cf/recursive/ for multihop sessions.
2161
2162 <tag><label id="bgp-igp-table">igp table <m/name/</tag>
2163 Specifies a table that is used as an IGP routing table. Default: the
2164 same as the table BGP is connected to.
2165
2166 <tag><label id="bgp-check-link">check link <M>switch</M></tag>
2167 BGP could use hardware link state into consideration. If enabled,
2168 BIRD tracks the link state of the associated interface and when link
2169 disappears (e.g. an ethernet cable is unplugged), the BGP session is
2170 immediately shut down. Note that this option cannot be used with
2171 multihop BGP. Default: disabled.
2172
2173 <tag><label id="bgp-bfd">bfd <M>switch</M></tag>
2174 BGP could use BFD protocol as an advisory mechanism for neighbor
2175 liveness and failure detection. If enabled, BIRD setups a BFD session
2176 for the BGP neighbor and tracks its liveness by it. This has an
2177 advantage of an order of magnitude lower detection times in case of
2178 failure. Note that BFD protocol also has to be configured, see
2179 <ref id="bfd" name="BFD"> section for details. Default: disabled.
2180
2181 <tag><label id="bgp-ttl-security">ttl security <m/switch/</tag>
2182 Use GTSM (<rfc id="5082"> - the generalized TTL security mechanism). GTSM
2183 protects against spoofed packets by ignoring received packets with a
2184 smaller than expected TTL. To work properly, GTSM have to be enabled on
2185 both sides of a BGP session. If both <cf/ttl security/ and
2186 <cf/multihop/ options are enabled, <cf/multihop/ option should specify
2187 proper hop value to compute expected TTL. Kernel support required:
2188 Linux: 2.6.34+ (IPv4), 2.6.35+ (IPv6), BSD: since long ago, IPv4 only.
2189 Note that full (ICMP protection, for example) <rfc id="5082"> support is
2190 provided by Linux only. Default: disabled.
2191
2192 <tag><label id="bgp-password">password <m/string/</tag>
2193 Use this password for MD5 authentication of BGP sessions (<rfc id="2385">). When
2194 used on BSD systems, see also <cf/setkey/ option below. Default: no
2195 authentication.
2196
2197 <tag><label id="bgp-setkey">setkey <m/switch/</tag>
2198 On BSD systems, keys for TCP MD5 authentication are stored in the global
2199 SA/SP database, which can be accessed by external utilities (e.g.
2200 setkey(8)). BIRD configures security associations in the SA/SP database
2201 automatically based on <cf/password/ options (see above), this option
2202 allows to disable automatic updates by BIRD when manual configuration by
2203 external utilities is preferred. Note that automatic SA/SP database
2204 updates are currently implemented only for FreeBSD. Passwords have to be
2205 set manually by an external utility on NetBSD and OpenBSD. Default:
2206 enabled (ignored on non-FreeBSD).
2207
2208 <tag><label id="bgp-passive">passive <m/switch/</tag>
2209 Standard BGP behavior is both initiating outgoing connections and
2210 accepting incoming connections. In passive mode, outgoing connections
2211 are not initiated. Default: off.
2212
2213 <tag><label id="bgp-confederation">confederation <m/number/</tag>
2214 BGP confederations (<rfc id="5065">) are collections of autonomous
2215 systems that act as one entity to external systems, represented by one
2216 confederation identifier (instead of AS numbers). This option allows to
2217 enable BGP confederation behavior and to specify the local confederation
2218 identifier. When BGP confederations are used, all BGP speakers that are
2219 members of the BGP confederation should have the same confederation
2220 identifier configured. Default: 0 (no confederation).
2221
2222 <tag><label id="bgp-confederation-member">confederation member <m/switch/</tag>
2223 When BGP confederations are used, this option allows to specify whether
2224 the BGP neighbor is a member of the same confederation as the local BGP
2225 speaker. The option is unnecessary (and ignored) for IBGP sessions, as
2226 the same AS number implies the same confederation. Default: no.
2227
2228 <tag><label id="bgp-rr-client">rr client</tag>
2229 Be a route reflector and treat the neighbor as a route reflection
2230 client. Default: disabled.
2231
2232 <tag><label id="bgp-rr-cluster-id">rr cluster id <m/IPv4 address/</tag>
2233 Route reflectors use cluster id to avoid route reflection loops. When
2234 there is one route reflector in a cluster it usually uses its router id
2235 as a cluster id, but when there are more route reflectors in a cluster,
2236 these need to be configured (using this option) to use a common cluster
2237 id. Clients in a cluster need not know their cluster id and this option
2238 is not allowed for them. Default: the same as router id.
2239
2240 <tag><label id="bgp-rs-client">rs client</tag>
2241 Be a route server and treat the neighbor as a route server client.
2242 A route server is used as a replacement for full mesh EBGP routing in
2243 Internet exchange points in a similar way to route reflectors used in
2244 IBGP routing. BIRD does not implement obsoleted <rfc id="1863">, but
2245 uses ad-hoc implementation, which behaves like plain EBGP but reduces
2246 modifications to advertised route attributes to be transparent (for
2247 example does not prepend its AS number to AS PATH attribute and
2248 keeps MED attribute). Default: disabled.
2249
2250 <tag><label id="bgp-secondary">secondary <m/switch/</tag>
2251 Usually, if an export filter rejects a selected route, no other route is
2252 propagated for that network. This option allows to try the next route in
2253 order until one that is accepted is found or all routes for that network
2254 are rejected. This can be used for route servers that need to propagate
2255 different tables to each client but do not want to have these tables
2256 explicitly (to conserve memory). This option requires that the connected
2257 routing table is <ref id="dsc-table-sorted" name="sorted">. Default: off.
2258
2259 <tag><label id="bgp-add-paths">add paths <m/switch/|rx|tx</tag>
2260 Standard BGP can propagate only one path (route) per destination network
2261 (usually the selected one). This option controls the add-path protocol
2262 extension, which allows to advertise any number of paths to a
2263 destination. Note that to be active, add-path has to be enabled on both
2264 sides of the BGP session, but it could be enabled separately for RX and
2265 TX direction. When active, all available routes accepted by the export
2266 filter are advertised to the neighbor. Default: off.
2267
2268 <tag><label id="bgp-allow-local-pref">allow bgp_local_pref <m/switch/</tag>
2269 A standard BGP implementation do not send the Local Preference attribute
2270 to eBGP neighbors and ignore this attribute if received from eBGP
2271 neighbors, as per <rfc id="4271">. When this option is enabled on an
2272 eBGP session, this attribute will be sent to and accepted from the peer,
2273 which is useful for example if you have a setup like in <rfc id="7938">.
2274 The option does not affect iBGP sessions. Default: off.
2275
2276 <tag><label id="bgp-allow-local-as">allow local as [<m/number/]</tag>
2277 BGP prevents routing loops by rejecting received routes with the local
2278 AS number in the AS path. This option allows to loose or disable the
2279 check. Optional <cf/number/ argument can be used to specify the maximum
2280 number of local ASNs in the AS path that is allowed for received
2281 routes. When the option is used without the argument, the check is
2282 completely disabled and you should ensure loop-free behavior by some
2283 other means. Default: 0 (no local AS number allowed).
2284
2285 <tag><label id="bgp-enable-route-refresh">enable route refresh <m/switch/</tag>
2286 After the initial route exchange, BGP protocol uses incremental updates
2287 to keep BGP speakers synchronized. Sometimes (e.g., if BGP speaker
2288 changes its import filter, or if there is suspicion of inconsistency) it
2289 is necessary to do a new complete route exchange. BGP protocol extension
2290 Route Refresh (<rfc id="2918">) allows BGP speaker to request
2291 re-advertisement of all routes from its neighbor. BGP protocol
2292 extension Enhanced Route Refresh (<rfc id="7313">) specifies explicit
2293 begin and end for such exchanges, therefore the receiver can remove
2294 stale routes that were not advertised during the exchange. This option
2295 specifies whether BIRD advertises these capabilities and supports
2296 related procedures. Note that even when disabled, BIRD can send route
2297 refresh requests. Default: on.
2298
2299 <tag><label id="bgp-graceful-restart">graceful restart <m/switch/|aware</tag>
2300 When a BGP speaker restarts or crashes, neighbors will discard all
2301 received paths from the speaker, which disrupts packet forwarding even
2302 when the forwarding plane of the speaker remains intact. <rfc
2303 id="4724"> specifies an optional graceful restart mechanism to
2304 alleviate this issue. This option controls the mechanism. It has three
2305 states: Disabled, when no support is provided. Aware, when the graceful
2306 restart support is announced and the support for restarting neighbors
2307 is provided, but no local graceful restart is allowed (i.e.
2308 receiving-only role). Enabled, when the full graceful restart
2309 support is provided (i.e. both restarting and receiving role). Note
2310 that proper support for local graceful restart requires also
2311 configuration of other protocols. Default: aware.
2312
2313 <tag><label id="bgp-graceful-restart-time">graceful restart time <m/number/</tag>
2314 The restart time is announced in the BGP graceful restart capability
2315 and specifies how long the neighbor would wait for the BGP session to
2316 re-establish after a restart before deleting stale routes. Default:
2317 120 seconds.
2318
2319 <tag><label id="bgp-interpret-communities">interpret communities <m/switch/</tag>
2320 <rfc id="1997"> demands that BGP speaker should process well-known
2321 communities like no-export (65535, 65281) or no-advertise (65535,
2322 65282). For example, received route carrying a no-adverise community
2323 should not be advertised to any of its neighbors. If this option is
2324 enabled (which is by default), BIRD has such behavior automatically (it
2325 is evaluated when a route is exported to the BGP protocol just before
2326 the export filter). Otherwise, this integrated processing of
2327 well-known communities is disabled. In that case, similar behavior can
2328 be implemented in the export filter. Default: on.
2329
2330 <tag><label id="bgp-enable-as4">enable as4 <m/switch/</tag>
2331 BGP protocol was designed to use 2B AS numbers and was extended later to
2332 allow 4B AS number. BIRD supports 4B AS extension, but by disabling this
2333 option it can be persuaded not to advertise it and to maintain old-style
2334 sessions with its neighbors. This might be useful for circumventing bugs
2335 in neighbor's implementation of 4B AS extension. Even when disabled
2336 (off), BIRD behaves internally as AS4-aware BGP router. Default: on.
2337
2338 <tag><label id="bgp-enable-extended-messages">enable extended messages <m/switch/</tag>
2339 The BGP protocol uses maximum message length of 4096 bytes. This option
2340 provides an extension to allow extended messages with length up
2341 to 65535 bytes. Default: off.
2342
2343 <tag><label id="bgp-capabilities">capabilities <m/switch/</tag>
2344 Use capability advertisement to advertise optional capabilities. This is
2345 standard behavior for newer BGP implementations, but there might be some
2346 older BGP implementations that reject such connection attempts. When
2347 disabled (off), features that request it (4B AS support) are also
2348 disabled. Default: on, with automatic fallback to off when received
2349 capability-related error.
2350
2351 <tag><label id="bgp-advertise-ipv4">advertise ipv4 <m/switch/</tag>
2352 Advertise IPv4 multiprotocol capability. This is not a correct behavior
2353 according to the strict interpretation of <rfc id="4760">, but it is
2354 widespread and required by some BGP implementations (Cisco and Quagga).
2355 This option is relevant to IPv4 mode with enabled capability
2356 advertisement only. Default: on.
2357
2358 <tag><label id="bgp-disable-after-error">disable after error <m/switch/</tag>
2359 When an error is encountered (either locally or by the other side),
2360 disable the instance automatically and wait for an administrator to fix
2361 the problem manually. Default: off.
2362
2363 <tag><label id="bgp-hold-time">hold time <m/number/</tag>
2364 Time in seconds to wait for a Keepalive message from the other side
2365 before considering the connection stale. Default: depends on agreement
2366 with the neighboring router, we prefer 240 seconds if the other side is
2367 willing to accept it.
2368
2369 <tag><label id="bgp-startup-hold-time">startup hold time <m/number/</tag>
2370 Value of the hold timer used before the routers have a chance to exchange
2371 open messages and agree on the real value. Default: 240 seconds.
2372
2373 <tag><label id="bgp-keepalive-time">keepalive time <m/number/</tag>
2374 Delay in seconds between sending of two consecutive Keepalive messages.
2375 Default: One third of the hold time.
2376
2377 <tag><label id="bgp-connect-delay-time">connect delay time <m/number/</tag>
2378 Delay in seconds between protocol startup and the first attempt to
2379 connect. Default: 5 seconds.
2380
2381 <tag><label id="bgp-connect-retry-time">connect retry time <m/number/</tag>
2382 Time in seconds to wait before retrying a failed attempt to connect.
2383 Default: 120 seconds.
2384
2385 <tag><label id="bgp-error-wait-time">error wait time <m/number/,<m/number/</tag>
2386 Minimum and maximum delay in seconds between a protocol failure (either
2387 local or reported by the peer) and automatic restart. Doesn't apply
2388 when <cf/disable after error/ is configured. If consecutive errors
2389 happen, the delay is increased exponentially until it reaches the
2390 maximum. Default: 60, 300.
2391
2392 <tag><label id="bgp-error-forget-time">error forget time <m/number/</tag>
2393 Maximum time in seconds between two protocol failures to treat them as a
2394 error sequence which makes <cf/error wait time/ increase exponentially.
2395 Default: 300 seconds.
2396
2397 <tag><label id="bgp-path-metric">path metric <m/switch/</tag>
2398 Enable comparison of path lengths when deciding which BGP route is the
2399 best one. Default: on.
2400
2401 <tag><label id="bgp-med-metric">med metric <m/switch/</tag>
2402 Enable comparison of MED attributes (during best route selection) even
2403 between routes received from different ASes. This may be useful if all
2404 MED attributes contain some consistent metric, perhaps enforced in
2405 import filters of AS boundary routers. If this option is disabled, MED
2406 attributes are compared only if routes are received from the same AS
2407 (which is the standard behavior). Default: off.
2408
2409 <tag><label id="bgp-deterministic-med">deterministic med <m/switch/</tag>
2410 BGP route selection algorithm is often viewed as a comparison between
2411 individual routes (e.g. if a new route appears and is better than the
2412 current best one, it is chosen as the new best one). But the proper
2413 route selection, as specified by <rfc id="4271">, cannot be fully
2414 implemented in that way. The problem is mainly in handling the MED
2415 attribute. BIRD, by default, uses an simplification based on individual
2416 route comparison, which in some cases may lead to temporally dependent
2417 behavior (i.e. the selection is dependent on the order in which routes
2418 appeared). This option enables a different (and slower) algorithm
2419 implementing proper <rfc id="4271"> route selection, which is
2420 deterministic. Alternative way how to get deterministic behavior is to
2421 use <cf/med metric/ option. This option is incompatible with <ref
2422 id="dsc-table-sorted" name="sorted tables">. Default: off.
2423
2424 <tag><label id="bgp-igp-metric">igp metric <m/switch/</tag>
2425 Enable comparison of internal distances to boundary routers during best
2426 route selection. Default: on.
2427
2428 <tag><label id="bgp-prefer-older">prefer older <m/switch/</tag>
2429 Standard route selection algorithm breaks ties by comparing router IDs.
2430 This changes the behavior to prefer older routes (when both are external
2431 and from different peer). For details, see <rfc id="5004">. Default: off.
2432
2433 <tag><label id="bgp-default-med">default bgp_med <m/number/</tag>
2434 Value of the Multiple Exit Discriminator to be used during route
2435 selection when the MED attribute is missing. Default: 0.
2436
2437 <tag><label id="bgp-default-local-pref">default bgp_local_pref <m/number/</tag>
2438 A default value for the Local Preference attribute. It is used when
2439 a new Local Preference attribute is attached to a route by the BGP
2440 protocol itself (for example, if a route is received through eBGP and
2441 therefore does not have such attribute). Default: 100 (0 in pre-1.2.0
2442 versions of BIRD).
2443 </descrip>
2444
2445 <sect1>Attributes
2446 <label id="bgp-attr">
2447
2448 <p>BGP defines several route attributes. Some of them (those marked with
2449 `<tt/I/' in the table below) are available on internal BGP connections only,
2450 some of them (marked with `<tt/O/') are optional.
2451
2452 <descrip>
2453 <tag><label id="rta-bgp-path">bgppath bgp_path/</tag>
2454 Sequence of AS numbers describing the AS path the packet will travel
2455 through when forwarded according to the particular route. In case of
2456 internal BGP it doesn't contain the number of the local AS.
2457
2458 <tag><label id="rta-bgp-local-pref">int bgp_local_pref/ [I]</tag>
2459 Local preference value used for selection among multiple BGP routes (see
2460 the selection rules above). It's used as an additional metric which is
2461 propagated through the whole local AS.
2462
2463 <tag><label id="rta-bgp-med">int bgp_med/ [O]</tag>
2464 The Multiple Exit Discriminator of the route is an optional attribute
2465 which is used on external (inter-AS) links to convey to an adjacent AS
2466 the optimal entry point into the local AS. The received attribute is
2467 also propagated over internal BGP links. The attribute value is zeroed
2468 when a route is exported to an external BGP instance to ensure that the
2469 attribute received from a neighboring AS is not propagated to other
2470 neighboring ASes. A new value might be set in the export filter of an
2471 external BGP instance. See <rfc id="4451"> for further discussion of
2472 BGP MED attribute.
2473
2474 <tag><label id="rta-bgp-origin">enum bgp_origin/</tag>
2475 Origin of the route: either <cf/ORIGIN_IGP/ if the route has originated
2476 in an interior routing protocol or <cf/ORIGIN_EGP/ if it's been imported
2477 from the <tt>EGP</tt> protocol (nowadays it seems to be obsolete) or
2478 <cf/ORIGIN_INCOMPLETE/ if the origin is unknown.
2479
2480 <tag><label id="rta-bgp-next-hop">ip bgp_next_hop/</tag>
2481 Next hop to be used for forwarding of packets to this destination. On
2482 internal BGP connections, it's an address of the originating router if
2483 it's inside the local AS or a boundary router the packet will leave the
2484 AS through if it's an exterior route, so each BGP speaker within the AS
2485 has a chance to use the shortest interior path possible to this point.
2486
2487 <tag><label id="rta-bgp-atomic-aggr">void bgp_atomic_aggr/ [O]</tag>
2488 This is an optional attribute which carries no value, but the sole
2489 presence of which indicates that the route has been aggregated from
2490 multiple routes by some router on the path from the originator.
2491
2492 <!-- we don't handle aggregators right since they are of a very obscure type
2493 <tag>bgp_aggregator</tag>
2494 -->
2495 <tag><label id="rta-bgp-community">clist bgp_community/ [O]</tag>
2496 List of community values associated with the route. Each such value is a
2497 pair (represented as a <cf/pair/ data type inside the filters) of 16-bit
2498 integers, the first of them containing the number of the AS which
2499 defines the community and the second one being a per-AS identifier.
2500 There are lots of uses of the community mechanism, but generally they
2501 are used to carry policy information like "don't export to USA peers".
2502 As each AS can define its own routing policy, it also has a complete
2503 freedom about which community attributes it defines and what will their
2504 semantics be.
2505
2506 <tag><label id="rta-bgp-ext-community">eclist bgp_ext_community/ [O]</tag>
2507 List of extended community values associated with the route. Extended
2508 communities have similar usage as plain communities, but they have an
2509 extended range (to allow 4B ASNs) and a nontrivial structure with a type
2510 field. Individual community values are represented using an <cf/ec/ data
2511 type inside the filters.
2512
2513 <tag><label id="rta-bgp-large-community">lclist <cf/bgp_large_community/ [O]</tag>
2514 List of large community values associated with the route. Large BGP
2515 communities is another variant of communities, but contrary to extended
2516 communities they behave very much the same way as regular communities,
2517 just larger -- they are uniform untyped triplets of 32bit numbers.
2518 Individual community values are represented using an <cf/lc/ data type
2519 inside the filters.
2520
2521 <tag><label id="rta-bgp-originator-id">quad bgp_originator_id/ [I, O]</tag>
2522 This attribute is created by the route reflector when reflecting the
2523 route and contains the router ID of the originator of the route in the
2524 local AS.
2525
2526 <tag><label id="rta-bgp-cluster-list">clist bgp_cluster_list/ [I, O]</tag>
2527 This attribute contains a list of cluster IDs of route reflectors. Each
2528 route reflector prepends its cluster ID when reflecting the route.
2529 </descrip>
2530
2531 <sect1>Example
2532 <label id="bgp-exam">
2533
2534 <p><code>
2535 protocol bgp {
2536 local as 65000; # Use a private AS number
2537 neighbor 198.51.100.130 as 64496; # Our neighbor ...
2538 multihop; # ... which is connected indirectly
2539 export filter { # We use non-trivial export rules
2540 if source = RTS_STATIC then { # Export only static routes
2541 # Assign our community
2542 bgp_community.add((65000,64501));
2543 # Artificially increase path length
2544 # by advertising local AS number twice
2545 if bgp_path ~ [= 65000 =] then
2546 bgp_path.prepend(65000);
2547 accept;
2548 }
2549 reject;
2550 };
2551 import all;
2552 source address 198.51.100.14; # Use a non-standard source address
2553 }
2554 </code>
2555
2556
2557 <sect>Device
2558 <label id="device">
2559
2560 <p>The Device protocol is not a real routing protocol. It doesn't generate any
2561 routes and it only serves as a module for getting information about network
2562 interfaces from the kernel.
2563
2564 <p>Except for very unusual circumstances, you probably should include this
2565 protocol in the configuration since almost all other protocols require network
2566 interfaces to be defined for them to work with.
2567
2568 <sect1>Configuration
2569 <label id="device-config">
2570
2571 <p><descrip>
2572
2573 <tag><label id="device-scan-time">scan time <m/number/</tag>
2574 Time in seconds between two scans of the network interface list. On
2575 systems where we are notified about interface status changes
2576 asynchronously (such as newer versions of Linux), we need to scan the
2577 list only in order to avoid confusion by lost notification messages,
2578 so the default time is set to a large value.
2579
2580 <tag><label id="device-primary">primary [ "<m/mask/" ] <m/prefix/</tag>
2581 If a network interface has more than one network address, BIRD has to
2582 choose one of them as a primary one. By default, BIRD chooses the
2583 lexicographically smallest address as the primary one.
2584
2585 This option allows to specify which network address should be chosen as
2586 a primary one. Network addresses that match <m/prefix/ are preferred to
2587 non-matching addresses. If more <cf/primary/ options are used, the first
2588 one has the highest preference. If "<m/mask/" is specified, then such
2589 <cf/primary/ option is relevant only to matching network interfaces.
2590
2591 In all cases, an address marked by operating system as secondary cannot
2592 be chosen as the primary one.
2593 </descrip>
2594
2595 <p>As the Device protocol doesn't generate any routes, it cannot have
2596 any attributes. Example configuration looks like this:
2597
2598 <p><code>
2599 protocol device {
2600 scan time 10; # Scan the interfaces often
2601 primary "eth0" 192.168.1.1;
2602 primary 192.168.0.0/16;
2603 }
2604 </code>
2605
2606
2607 <sect>Direct
2608 <label id="direct">
2609
2610 <p>The Direct protocol is a simple generator of device routes for all the
2611 directly connected networks according to the list of interfaces provided by the
2612 kernel via the Device protocol.
2613
2614 <p>The question is whether it is a good idea to have such device routes in BIRD
2615 routing table. OS kernel usually handles device routes for directly connected
2616 networks by itself so we don't need (and don't want) to export these routes to
2617 the kernel protocol. OSPF protocol creates device routes for its interfaces
2618 itself and BGP protocol is usually used for exporting aggregate routes. Although
2619 there are some use cases that use the direct protocol (like abusing eBGP as an
2620 IGP routing protocol), in most cases it is not needed to have these device
2621 routes in BIRD routing table and to use the direct protocol.
2622
2623 <p>There is one notable case when you definitely want to use the direct protocol
2624 -- running BIRD on BSD systems. Having high priority device routes for directly
2625 connected networks from the direct protocol protects kernel device routes from
2626 being overwritten or removed by IGP routes during some transient network
2627 conditions, because a lower priority IGP route for the same network is not
2628 exported to the kernel routing table. This is an issue on BSD systems only, as
2629 on Linux systems BIRD cannot change non-BIRD route in the kernel routing table.
2630
2631 <p>There are just few configuration options for the Direct protocol:
2632
2633 <p><descrip>
2634 <tag><label id="direct-iface">interface <m/pattern/ [, <m/.../]</tag>
2635 By default, the Direct protocol will generate device routes for all the
2636 interfaces available. If you want to restrict it to some subset of
2637 interfaces or addresses (e.g. if you're using multiple routing tables
2638 for policy routing and some of the policy domains don't contain all
2639 interfaces), just use this clause. See <ref id="proto-iface" name="interface">
2640 common option for detailed description. The Direct protocol uses
2641 extended interface clauses.
2642
2643 <tag><label id="direct-check-link">check link <m/switch/</tag>
2644 If enabled, a hardware link state (reported by OS) is taken into
2645 consideration. Routes for directly connected networks are generated only
2646 if link up is reported and they are withdrawn when link disappears
2647 (e.g., an ethernet cable is unplugged). Default value is no.
2648 </descrip>
2649
2650 <p>Direct device routes don't contain any specific attributes.
2651
2652 <p>Example config might look like this:
2653
2654 <p><code>
2655 protocol direct {
2656 interface "-arc*", "*"; # Exclude the ARCnets
2657 }
2658 </code>
2659
2660
2661 <sect>Kernel
2662 <label id="krt">
2663
2664 <p>The Kernel protocol is not a real routing protocol. Instead of communicating
2665 with other routers in the network, it performs synchronization of BIRD's routing
2666 tables with the OS kernel. Basically, it sends all routing table updates to the
2667 kernel and from time to time it scans the kernel tables to see whether some
2668 routes have disappeared (for example due to unnoticed up/down transition of an
2669 interface) or whether an `alien' route has been added by someone else (depending
2670 on the <cf/learn/ switch, such routes are either ignored or accepted to our
2671 table).
2672
2673 <p>Unfortunately, there is one thing that makes the routing table synchronization
2674 a bit more complicated. In the kernel routing table there are also device routes
2675 for directly connected networks. These routes are usually managed by OS itself
2676 (as a part of IP address configuration) and we don't want to touch that. They
2677 are completely ignored during the scan of the kernel tables and also the export
2678 of device routes from BIRD tables to kernel routing tables is restricted to
2679 prevent accidental interference. This restriction can be disabled using
2680 <cf/device routes/ switch.
2681
2682 <p>If your OS supports only a single routing table, you can configure only one
2683 instance of the Kernel protocol. If it supports multiple tables (in order to
2684 allow policy routing; such an OS is for example Linux), you can run as many
2685 instances as you want, but each of them must be connected to a different BIRD
2686 routing table and to a different kernel table.
2687
2688 <p>Because the kernel protocol is partially integrated with the connected
2689 routing table, there are two limitations - it is not possible to connect more
2690 kernel protocols to the same routing table and changing route destination
2691 (gateway) in an export filter of a kernel protocol does not work. Both
2692 limitations can be overcome using another routing table and the pipe protocol.
2693
2694 <sect1>Configuration
2695 <label id="krt-config">
2696
2697 <p><descrip>
2698 <tag><label id="krt-persist">persist <m/switch/</tag>
2699 Tell BIRD to leave all its routes in the routing tables when it exits
2700 (instead of cleaning them up).
2701
2702 <tag><label id="krt-scan-time">scan time <m/number/</tag>
2703 Time in seconds between two consecutive scans of the kernel routing
2704 table.
2705
2706 <tag><label id="krt-learn">learn <m/switch/</tag>
2707 Enable learning of routes added to the kernel routing tables by other
2708 routing daemons or by the system administrator. This is possible only on
2709 systems which support identification of route authorship.
2710
2711 <tag><label id="krt-device-routes">device routes <m/switch/</tag>
2712 Enable export of device routes to the kernel routing table. By default,
2713 such routes are rejected (with the exception of explicitly configured
2714 device routes from the static protocol) regardless of the export filter
2715 to protect device routes in kernel routing table (managed by OS itself)
2716 from accidental overwriting or erasing.
2717
2718 <tag><label id="krt-kernel-table">kernel table <m/number/</tag>
2719 Select which kernel table should this particular instance of the Kernel
2720 protocol work with. Available only on systems supporting multiple
2721 routing tables.
2722
2723 <tag><label id="krt-metric">metric <m/number/</tag> (Linux)
2724 Use specified value as a kernel metric (priority) for all routes sent to
2725 the kernel. When multiple routes for the same network are in the kernel
2726 routing table, the Linux kernel chooses one with lower metric. Also,
2727 routes with different metrics do not clash with each other, therefore
2728 using dedicated metric value is a reliable way to avoid overwriting
2729 routes from other sources (e.g. kernel device routes). Metric 0 has a
2730 special meaning of undefined metric, in which either OS default is used,
2731 or per-route metric can be set using <cf/krt_metric/ attribute. Default:
2732 32.
2733
2734 <tag><label id="krt-graceful-restart">graceful restart <m/switch/</tag>
2735 Participate in graceful restart recovery. If this option is enabled and
2736 a graceful restart recovery is active, the Kernel protocol will defer
2737 synchronization of routing tables until the end of the recovery. Note
2738 that import of kernel routes to BIRD is not affected.
2739
2740 <tag><label id="krt-merge-paths">merge paths <M>switch</M> [limit <M>number</M>]</tag>
2741 Usually, only best routes are exported to the kernel protocol. With path
2742 merging enabled, both best routes and equivalent non-best routes are
2743 merged during export to generate one ECMP (equal-cost multipath) route
2744 for each network. This is useful e.g. for BGP multipath. Note that best
2745 routes are still pivotal for route export (responsible for most
2746 properties of resulting ECMP routes), while exported non-best routes are
2747 responsible just for additional multipath next hops. This option also
2748 allows to specify a limit on maximal number of nexthops in one route. By
2749 default, multipath merging is disabled. If enabled, default value of the
2750 limit is 16.
2751 </descrip>
2752
2753 <sect1>Attributes
2754 <label id="krt-attr">
2755
2756 <p>The Kernel protocol defines several attributes. These attributes are
2757 translated to appropriate system (and OS-specific) route attributes. We support
2758 these attributes:
2759
2760 <descrip>
2761 <tag><label id="rta-krt-source">int krt_source/</tag>
2762 The original source of the imported kernel route. The value is
2763 system-dependent. On Linux, it is a value of the protocol field of the
2764 route. See /etc/iproute2/rt_protos for common values. On BSD, it is
2765 based on STATIC and PROTOx flags. The attribute is read-only.
2766
2767 <tag><label id="rta-krt-metric">int krt_metric/</tag> (Linux)
2768 The kernel metric of the route. When multiple same routes are in a
2769 kernel routing table, the Linux kernel chooses one with lower metric.
2770 Note that preferred way to set kernel metric is to use protocol option
2771 <cf/metric/, unless per-route metric values are needed.
2772
2773 <tag><label id="rta-krt-prefsrc">ip krt_prefsrc/</tag> (Linux)
2774 The preferred source address. Used in source address selection for
2775 outgoing packets. Has to be one of the IP addresses of the router.
2776
2777 <tag><label id="rta-krt-realm">int krt_realm/</tag> (Linux)
2778 The realm of the route. Can be used for traffic classification.
2779
2780 <tag><label id="rta-krt-scope">int krt_scope/</tag> (Linux IPv4)
2781 The scope of the route. Valid values are 0-254, although Linux kernel
2782 may reject some values depending on route type and nexthop. It is
2783 supposed to represent `indirectness' of the route, where nexthops of
2784 routes are resolved through routes with a higher scope, but in current
2785 kernels anything below <it/link/ (253) is treated as <it/global/ (0).
2786 When not present, global scope is implied for all routes except device
2787 routes, where link scope is used by default.
2788 </descrip>
2789
2790 <p>In Linux, there is also a plenty of obscure route attributes mostly focused
2791 on tuning TCP performance of local connections. BIRD supports most of these
2792 attributes, see Linux or iproute2 documentation for their meaning. Attributes
2793 <cf/krt_lock_*/ and <cf/krt_feature_*/ have type bool, others have type int.
2794 Supported attributes are:
2795
2796 <cf/krt_mtu/, <cf/krt_lock_mtu/, <cf/krt_window/, <cf/krt_lock_window/,
2797 <cf/krt_rtt/, <cf/krt_lock_rtt/, <cf/krt_rttvar/, <cf/krt_lock_rttvar/,
2798 <cf/krt_sstresh/, <cf/krt_lock_sstresh/, <cf/krt_cwnd/, <cf/krt_lock_cwnd/,
2799 <cf/krt_advmss/, <cf/krt_lock_advmss/, <cf/krt_reordering/, <cf/krt_lock_reordering/,
2800 <cf/krt_hoplimit/, <cf/krt_lock_hoplimit/, <cf/krt_rto_min/, <cf/krt_lock_rto_min/,
2801 <cf/krt_initcwnd/, <cf/krt_initrwnd/, <cf/krt_quickack/,
2802 <cf/krt_feature_ecn/, <cf/krt_feature_allfrag/
2803
2804 <sect1>Example
2805 <label id="krt-exam">
2806
2807 <p>A simple configuration can look this way:
2808
2809 <p><code>
2810 protocol kernel {
2811 export all;
2812 }
2813 </code>
2814
2815 <p>Or for a system with two routing tables:
2816
2817 <p><code>
2818 protocol kernel { # Primary routing table
2819 learn; # Learn alien routes from the kernel
2820 persist; # Don't remove routes on bird shutdown
2821 scan time 10; # Scan kernel routing table every 10 seconds
2822 import all;
2823 export all;
2824 }
2825
2826 protocol kernel { # Secondary routing table
2827 table auxtable;
2828 kernel table 100;
2829 export all;
2830 }
2831 </code>
2832
2833
2834 <sect>OSPF
2835 <label id="ospf">
2836
2837 <sect1>Introduction
2838 <label id="ospf-intro">
2839
2840 <p>Open Shortest Path First (OSPF) is a quite complex interior gateway
2841 protocol. The current IPv4 version (OSPFv2) is defined in <rfc id="2328"> and
2842 the current IPv6 version (OSPFv3) is defined in <rfc id="5340"> It's a link
2843 state (a.k.a. shortest path first) protocol -- each router maintains a database
2844 describing the autonomous system's topology. Each participating router has an
2845 identical copy of the database and all routers run the same algorithm
2846 calculating a shortest path tree with themselves as a root. OSPF chooses the
2847 least cost path as the best path.
2848
2849 <p>In OSPF, the autonomous system can be split to several areas in order to
2850 reduce the amount of resources consumed for exchanging the routing information
2851 and to protect the other areas from incorrect routing data. Topology of the area
2852 is hidden to the rest of the autonomous system.
2853
2854 <p>Another very important feature of OSPF is that it can keep routing information
2855 from other protocols (like Static or BGP) in its link state database as external
2856 routes. Each external route can be tagged by the advertising router, making it
2857 possible to pass additional information between routers on the boundary of the
2858 autonomous system.
2859
2860 <p>OSPF quickly detects topological changes in the autonomous system (such as
2861 router interface failures) and calculates new loop-free routes after a short
2862 period of convergence. Only a minimal amount of routing traffic is involved.
2863
2864 <p>Each router participating in OSPF routing periodically sends Hello messages
2865 to all its interfaces. This allows neighbors to be discovered dynamically. Then
2866 the neighbors exchange theirs parts of the link state database and keep it
2867 identical by flooding updates. The flooding process is reliable and ensures that
2868 each router detects all changes.
2869
2870 <sect1>Configuration
2871 <label id="ospf-config">
2872
2873 <p>First, the desired OSPF version can be specified by using <cf/ospf v2/ or
2874 <cf/ospf v3/ as a protocol type. By default, OSPFv2 is used. In the main part of
2875 configuration, there can be multiple definitions of OSPF areas, each with a
2876 different id. These definitions includes many other switches and multiple
2877 definitions of interfaces. Definition of interface may contain many switches and
2878 constant definitions and list of neighbors on nonbroadcast networks.
2879
2880 <code>
2881 protocol ospf [v2|v3] &lt;name&gt; {
2882 rfc1583compat &lt;switch&gt;;
2883 rfc5838 &lt;switch&gt;;
2884 instance id &lt;num&gt;;
2885 stub router &lt;switch&gt;;
2886 tick &lt;num&gt;;
2887 ecmp &lt;switch&gt; [limit &lt;num&gt;];
2888 merge external &lt;switch&gt;;
2889 area &lt;id&gt; {
2890 stub;
2891 nssa;
2892 summary &lt;switch&gt;;
2893 default nssa &lt;switch&gt;;
2894 default cost &lt;num&gt;;
2895 default cost2 &lt;num&gt;;
2896 translator &lt;switch&gt;;
2897 translator stability &lt;num&gt;;
2898
2899 networks {
2900 &lt;prefix&gt;;
2901 &lt;prefix&gt; hidden;
2902 }
2903 external {
2904 &lt;prefix&gt;;
2905 &lt;prefix&gt; hidden;
2906 &lt;prefix&gt; tag &lt;num&gt;;
2907 }
2908 stubnet &lt;prefix&gt;;
2909 stubnet &lt;prefix&gt; {
2910 hidden &lt;switch&gt;;
2911 summary &lt;switch&gt;;
2912 cost &lt;num&gt;;
2913 }
2914 interface &lt;interface pattern&gt; [instance &lt;num&gt;] {
2915 cost &lt;num&gt;;
2916 stub &lt;switch&gt;;
2917 hello &lt;num&gt;;
2918 poll &lt;num&gt;;
2919 retransmit &lt;num&gt;;
2920 priority &lt;num&gt;;
2921 wait &lt;num&gt;;
2922 dead count &lt;num&gt;;
2923 dead &lt;num&gt;;
2924 secondary &lt;switch&gt;;
2925 rx buffer [normal|large|&lt;num&gt;];
2926 tx length &lt;num&gt;;
2927 type [broadcast|bcast|pointopoint|ptp|
2928 nonbroadcast|nbma|pointomultipoint|ptmp];
2929 link lsa suppression &lt;switch&gt;;
2930 strict nonbroadcast &lt;switch&gt;;
2931 real broadcast &lt;switch&gt;;
2932 ptp netmask &lt;switch&gt;;
2933 check link &lt;switch&gt;;
2934 bfd &lt;switch&gt;;
2935 ecmp weight &lt;num&gt;;
2936 ttl security [&lt;switch&gt;; | tx only]
2937 tx class|dscp &lt;num&gt;;
2938 tx priority &lt;num&gt;;
2939 authentication none|simple|cryptographic;
2940 password "&lt;text&gt;";
2941 password "&lt;text&gt;" {
2942 id &lt;num&gt;;
2943 generate from "&lt;date&gt;";
2944 generate to "&lt;date&gt;";
2945 accept from "&lt;date&gt;";
2946 accept to "&lt;date&gt;";
2947 from "&lt;date&gt;";
2948 to "&lt;date&gt;";
2949 algorithm ( keyed md5 | keyed sha1 | hmac sha1 | hmac sha256 | hmac sha384 | hmac sha512 );
2950 };
2951 neighbors {
2952 &lt;ip&gt;;
2953 &lt;ip&gt; eligible;
2954 };
2955 };
2956 virtual link &lt;id&gt; [instance &lt;num&gt;] {
2957 hello &lt;num&gt;;
2958 retransmit &lt;num&gt;;
2959 wait &lt;num&gt;;
2960 dead count &lt;num&gt;;
2961 dead &lt;num&gt;;
2962 authentication none|simple|cryptographic;
2963 password "&lt;text&gt;";
2964 password "&lt;text&gt;" {
2965 id &lt;num&gt;;
2966 generate from "&lt;date&gt;";
2967 generate to "&lt;date&gt;";
2968 accept from "&lt;date&gt;";
2969 accept to "&lt;date&gt;";
2970 from "&lt;date&gt;";
2971 to "&lt;date&gt;";
2972 algorithm ( keyed md5 | keyed sha1 | hmac sha1 | hmac sha256 | hmac sha384 | hmac sha512 );
2973 };
2974 };
2975 };
2976 }
2977 </code>
2978
2979 <descrip>
2980 <tag><label id="ospf-rfc1583compat">rfc1583compat <M>switch</M></tag>
2981 This option controls compatibility of routing table calculation with
2982 <rfc id="1583">. Default value is no.
2983
2984 <tag><label id="ospf-rfc5838">rfc5838 <m/switch/</tag>
2985 Basic OSPFv3 is limited to IPv6 unicast routing. The <rfc id="5838">
2986 extension defines support for more address families (IPv4, IPv6, both
2987 unicast and multicast). The extension is enabled by default, but can be
2988 disabled if necessary, as it restricts the range of available instance
2989 IDs. Default value is yes.
2990
2991 <tag><label id="ospf-instance-id">instance id <m/num/</tag>
2992 When multiple OSPF protocol instances are active on the same links, they
2993 should use different instance IDs to distinguish their packets. Although
2994 it could be done on per-interface basis, it is often preferred to set
2995 one instance ID to whole OSPF domain/topology (e.g., when multiple
2996 instances are used to represent separate logical topologies on the same
2997 physical network). This option specifies the instance ID for all
2998 interfaces of the OSPF instance, but can be overridden by
2999 <cf/interface/ option. Default value is 0 unless OSPFv3-AF extended
3000 address families are used, see <rfc id="5838"> for that case.
3001
3002 <tag><label id="ospf-stub-router">stub router <M>switch</M></tag>
3003 This option configures the router to be a stub router, i.e., a router
3004 that participates in the OSPF topology but does not allow transit
3005 traffic. In OSPFv2, this is implemented by advertising maximum metric
3006 for outgoing links. In OSPFv3, the stub router behavior is announced by
3007 clearing the R-bit in the router LSA. See <rfc id="6987"> for details.
3008 Default value is no.
3009
3010 <tag><label id="ospf-tick">tick <M>num</M></tag>
3011 The routing table calculation and clean-up of areas' databases is not
3012 performed when a single link state change arrives. To lower the CPU
3013 utilization, it's processed later at periodical intervals of <m/num/
3014 seconds. The default value is 1.
3015
3016 <tag><label id="ospf-ecmp">ecmp <M>switch</M> [limit <M>number</M>]</tag>
3017 This option specifies whether OSPF is allowed to generate ECMP
3018 (equal-cost multipath) routes. Such routes are used when there are
3019 several directions to the destination, each with the same (computed)
3020 cost. This option also allows to specify a limit on maximum number of
3021 nexthops in one route. By default, ECMP is disabled. If enabled,
3022 default value of the limit is 16.
3023
3024 <tag><label id="ospf-merge-external">merge external <M>switch</M></tag>
3025 This option specifies whether OSPF should merge external routes from
3026 different routers/LSAs for the same destination. When enabled together
3027 with <cf/ecmp/, equal-cost external routes will be combined to multipath
3028 routes in the same way as regular routes. When disabled, external routes
3029 from different LSAs are treated as separate even if they represents the
3030 same destination. Default value is no.
3031
3032 <tag><label id="ospf-area">area <M>id</M></tag>
3033 This defines an OSPF area with given area ID (an integer or an IPv4
3034 address, similarly to a router ID). The most important area is the
3035 backbone (ID 0) to which every other area must be connected.
3036
3037 <tag><label id="ospf-stub">stub</tag>
3038 This option configures the area to be a stub area. External routes are
3039 not flooded into stub areas. Also summary LSAs can be limited in stub
3040 areas (see option <cf/summary/). By default, the area is not a stub
3041 area.
3042
3043 <tag><label id="ospf-nssa">nssa</tag>
3044 This option configures the area to be a NSSA (Not-So-Stubby Area). NSSA
3045 is a variant of a stub area which allows a limited way of external route
3046 propagation. Global external routes are not propagated into a NSSA, but
3047 an external route can be imported into NSSA as a (area-wide) NSSA-LSA
3048 (and possibly translated and/or aggregated on area boundary). By
3049 default, the area is not NSSA.
3050
3051 <tag><label id="ospf-summary">summary <M>switch</M></tag>
3052 This option controls propagation of summary LSAs into stub or NSSA
3053 areas. If enabled, summary LSAs are propagated as usual, otherwise just
3054 the default summary route (0.0.0.0/0) is propagated (this is sometimes
3055 called totally stubby area). If a stub area has more area boundary
3056 routers, propagating summary LSAs could lead to more efficient routing
3057 at the cost of larger link state database. Default value is no.
3058
3059 <tag><label id="ospf-default-nssa">default nssa <M>switch</M></tag>
3060 When <cf/summary/ option is enabled, default summary route is no longer
3061 propagated to the NSSA. In that case, this option allows to originate
3062 default route as NSSA-LSA to the NSSA. Default value is no.
3063
3064 <tag><label id="ospf-default-cost">default cost <M>num</M></tag>
3065 This option controls the cost of a default route propagated to stub and
3066 NSSA areas. Default value is 1000.
3067
3068 <tag><label id="ospf-default-cost2">default cost2 <M>num</M></tag>
3069 When a default route is originated as NSSA-LSA, its cost can use either
3070 type 1 or type 2 metric. This option allows to specify the cost of a
3071 default route in type 2 metric. By default, type 1 metric (option
3072 <cf/default cost/) is used.
3073
3074 <tag><label id="ospf-translator">translator <M>switch</M></tag>
3075 This option controls translation of NSSA-LSAs into external LSAs. By
3076 default, one translator per NSSA is automatically elected from area
3077 boundary routers. If enabled, this area boundary router would
3078 unconditionally translate all NSSA-LSAs regardless of translator
3079 election. Default value is no.
3080
3081 <tag><label id="ospf-translator-stability">translator stability <M>num</M></tag>
3082 This option controls the translator stability interval (in seconds).
3083 When the new translator is elected, the old one keeps translating until
3084 the interval is over. Default value is 40.
3085
3086 <tag><label id="ospf-networks">networks { <m/set/ }</tag>
3087 Definition of area IP ranges. This is used in summary LSA origination.
3088 Hidden networks are not propagated into other areas.
3089
3090 <tag><label id="ospf-external">external { <m/set/ }</tag>
3091 Definition of external area IP ranges for NSSAs. This is used for
3092 NSSA-LSA translation. Hidden networks are not translated into external
3093 LSAs. Networks can have configured route tag.
3094
3095 <tag><label id="ospf-stubnet">stubnet <m/prefix/ { <m/options/ }</tag>
3096 Stub networks are networks that are not transit networks between OSPF
3097 routers. They are also propagated through an OSPF area as a part of a
3098 link state database. By default, BIRD generates a stub network record
3099 for each primary network address on each OSPF interface that does not
3100 have any OSPF neighbors, and also for each non-primary network address
3101 on each OSPF interface. This option allows to alter a set of stub
3102 networks propagated by this router.
3103
3104 Each instance of this option adds a stub network with given network
3105 prefix to the set of propagated stub network, unless option <cf/hidden/
3106 is used. It also suppresses default stub networks for given network
3107 prefix. When option <cf/summary/ is used, also default stub networks
3108 that are subnetworks of given stub network are suppressed. This might be
3109 used, for example, to aggregate generated stub networks.
3110
3111 <tag><label id="ospf-iface">interface <M>pattern</M> [instance <m/num/]</tag>
3112 Defines that the specified interfaces belong to the area being defined.
3113 See <ref id="proto-iface" name="interface"> common option for detailed
3114 description. In OSPFv2, extended interface clauses are used, because
3115 each network prefix is handled as a separate virtual interface.
3116
3117 You can specify alternative instance ID for the interface definition,
3118 therefore it is possible to have several instances of that interface
3119 with different options or even in different areas. For OSPFv2, instance
3120 ID support is an extension (<rfc id="6549">) and is supposed to be set
3121 per-protocol. For OSPFv3, it is an integral feature.
3122
3123 <tag><label id="ospf-virtual-link">virtual link <M>id</M> [instance <m/num/]</tag>
3124 Virtual link to router with the router id. Virtual link acts as a
3125 point-to-point interface belonging to backbone. The actual area is used
3126 as a transport area. This item cannot be in the backbone. Like with
3127 <cf/interface/ option, you could also use several virtual links to one
3128 destination with different instance IDs.
3129
3130 <tag><label id="ospf-cost">cost <M>num</M></tag>
3131 Specifies output cost (metric) of an interface. Default value is 10.
3132
3133 <tag><label id="ospf-stub-iface">stub <M>switch</M></tag>
3134 If set to interface it does not listen to any packet and does not send
3135 any hello. Default value is no.
3136
3137 <tag><label id="ospf-hello">hello <M>num</M></tag>
3138 Specifies interval in seconds between sending of Hello messages. Beware,
3139 all routers on the same network need to have the same hello interval.
3140 Default value is 10.
3141
3142 <tag><label id="ospf-poll">poll <M>num</M></tag>
3143 Specifies interval in seconds between sending of Hello messages for some
3144 neighbors on NBMA network. Default value is 20.
3145
3146 <tag><label id="ospf-retransmit">retransmit <M>num</M></tag>
3147 Specifies interval in seconds between retransmissions of unacknowledged
3148 updates. Default value is 5.
3149
3150 <tag><label id="ospf-priority">priority <M>num</M></tag>
3151 On every multiple access network (e.g., the Ethernet) Designated Router
3152 and Backup Designated router are elected. These routers have some special
3153 functions in the flooding process. Higher priority increases preferences
3154 in this election. Routers with priority 0 are not eligible. Default
3155 value is 1.
3156
3157 <tag><label id="ospf-wait">wait <M>num</M></tag>
3158 After start, router waits for the specified number of seconds between
3159 starting election and building adjacency. Default value is 4*<m/hello/.
3160
3161 <tag><label id="ospf-dead-count">dead count <M>num</M></tag>
3162 When the router does not receive any messages from a neighbor in
3163 <m/dead count/*<m/hello/ seconds, it will consider the neighbor down.
3164
3165 <tag><label id="ospf-dead">dead <M>num</M></tag>
3166 When the router does not receive any messages from a neighbor in
3167 <m/dead/ seconds, it will consider the neighbor down. If both directives
3168 <cf/dead count/ and <cf/dead/ are used, <cf/dead/ has precedence.
3169
3170 <tag><label id="ospf-secondary">secondary <M>switch</M></tag>
3171 On BSD systems, older versions of BIRD supported OSPFv2 only for the
3172 primary IP address of an interface, other IP ranges on the interface
3173 were handled as stub networks. Since v1.4.1, regular operation on
3174 secondary IP addresses is supported, but disabled by default for
3175 compatibility. This option allows to enable it. The option is a
3176 transitional measure, will be removed in the next major release as the
3177 behavior will be changed. On Linux systems, the option is irrelevant, as
3178 operation on non-primary addresses is already the regular behavior.
3179
3180 <tag><label id="ospf-rx-buffer">rx buffer <M>num</M></tag>
3181 This option allows to specify the size of buffers used for packet
3182 processing. The buffer size should be bigger than maximal size of any
3183 packets. By default, buffers are dynamically resized as needed, but a
3184 fixed value could be specified. Value <cf/large/ means maximal allowed
3185 packet size - 65535.
3186
3187 <tag><label id="ospf-tx-length">tx length <M>num</M></tag>
3188 Transmitted OSPF messages that contain large amount of information are
3189 segmented to separate OSPF packets to avoid IP fragmentation. This
3190 option specifies the soft ceiling for the length of generated OSPF
3191 packets. Default value is the MTU of the network interface. Note that
3192 larger OSPF packets may still be generated if underlying OSPF messages
3193 cannot be splitted (e.g. when one large LSA is propagated).
3194
3195 <tag><label id="ospf-type-bcast">type broadcast|bcast</tag>
3196 BIRD detects a type of a connected network automatically, but sometimes
3197 it's convenient to force use of a different type manually. On broadcast
3198 networks (like ethernet), flooding and Hello messages are sent using
3199 multicasts (a single packet for all the neighbors). A designated router
3200 is elected and it is responsible for synchronizing the link-state
3201 databases and originating network LSAs. This network type cannot be used
3202 on physically NBMA networks and on unnumbered networks (networks without
3203 proper IP prefix).
3204
3205 <tag><label id="ospf-type-ptp">type pointopoint|ptp</tag>
3206 Point-to-point networks connect just 2 routers together. No election is
3207 performed and no network LSA is originated, which makes it simpler and
3208 faster to establish. This network type is useful not only for physically
3209 PtP ifaces (like PPP or tunnels), but also for broadcast networks used
3210 as PtP links. This network type cannot be used on physically NBMA
3211 networks.
3212
3213 <tag><label id="ospf-type-nbma">type nonbroadcast|nbma</tag>
3214 On NBMA networks, the packets are sent to each neighbor separately
3215 because of lack of multicast capabilities. Like on broadcast networks,
3216 a designated router is elected, which plays a central role in propagation
3217 of LSAs. This network type cannot be used on unnumbered networks.
3218
3219 <tag><label id="ospf-type-ptmp">type pointomultipoint|ptmp</tag>
3220 This is another network type designed to handle NBMA networks. In this
3221 case the NBMA network is treated as a collection of PtP links. This is
3222 useful if not every pair of routers on the NBMA network has direct
3223 communication, or if the NBMA network is used as an (possibly
3224 unnumbered) PtP link.
3225
3226 <tag><label id="ospf-link-lsa-suppression">link lsa suppression <m/switch/</tag>
3227 In OSPFv3, link LSAs are generated for each link, announcing link-local
3228 IPv6 address of the router to its local neighbors. These are useless on
3229 PtP or PtMP networks and this option allows to suppress the link LSA
3230 origination for such interfaces. The option is ignored on other than PtP
3231 or PtMP interfaces. Default value is no.
3232
3233 <tag><label id="ospf-strict-nonbroadcast">strict nonbroadcast <m/switch/</tag>
3234 If set, don't send hello to any undefined neighbor. This switch is
3235 ignored on other than NBMA or PtMP interfaces. Default value is no.
3236
3237 <tag><label id="ospf-real-broadcast">real broadcast <m/switch/</tag>
3238 In <cf/type broadcast/ or <cf/type ptp/ network configuration, OSPF
3239 packets are sent as IP multicast packets. This option changes the
3240 behavior to using old-fashioned IP broadcast packets. This may be useful
3241 as a workaround if IP multicast for some reason does not work or does
3242 not work reliably. This is a non-standard option and probably is not
3243 interoperable with other OSPF implementations. Default value is no.
3244
3245 <tag><label id="ospf-ptp-netmask">ptp netmask <m/switch/</tag>
3246 In <cf/type ptp/ network configurations, OSPFv2 implementations should
3247 ignore received netmask field in hello packets and should send hello
3248 packets with zero netmask field on unnumbered PtP links. But some OSPFv2
3249 implementations perform netmask checking even for PtP links. This option
3250 specifies whether real netmask will be used in hello packets on <cf/type
3251 ptp/ interfaces. You should ignore this option unless you meet some
3252 compatibility problems related to this issue. Default value is no for
3253 unnumbered PtP links, yes otherwise.
3254
3255 <tag><label id="ospf-check-link">check link <M>switch</M></tag>
3256 If set, a hardware link state (reported by OS) is taken into consideration.
3257 When a link disappears (e.g. an ethernet cable is unplugged), neighbors
3258 are immediately considered unreachable and only the address of the iface
3259 (instead of whole network prefix) is propagated. It is possible that
3260 some hardware drivers or platforms do not implement this feature.
3261 Default value is no.
3262
3263 <tag><label id="ospf-bfd">bfd <M>switch</M></tag>
3264 OSPF could use BFD protocol as an advisory mechanism for neighbor
3265 liveness and failure detection. If enabled, BIRD setups a BFD session
3266 for each OSPF neighbor and tracks its liveness by it. This has an
3267 advantage of an order of magnitude lower detection times in case of
3268 failure. Note that BFD protocol also has to be configured, see
3269 <ref id="bfd" name="BFD"> section for details. Default value is no.
3270
3271 <tag><label id="ospf-ttl-security">ttl security [<m/switch/ | tx only]</tag>
3272 TTL security is a feature that protects routing protocols from remote
3273 spoofed packets by using TTL 255 instead of TTL 1 for protocol packets
3274 destined to neighbors. Because TTL is decremented when packets are
3275 forwarded, it is non-trivial to spoof packets with TTL 255 from remote
3276 locations. Note that this option would interfere with OSPF virtual
3277 links.
3278
3279 If this option is enabled, the router will send OSPF packets with TTL
3280 255 and drop received packets with TTL less than 255. If this option si
3281 set to <cf/tx only/, TTL 255 is used for sent packets, but is not
3282 checked for received packets. Default value is no.
3283
3284 <tag><label id="ospf-tx-class">tx class|dscp|priority <m/num/</tag>
3285 These options specify the ToS/DiffServ/Traffic class/Priority of the
3286 outgoing OSPF packets. See <ref id="proto-tx-class" name="tx class"> common
3287 option for detailed description.
3288
3289 <tag><label id="ospf-ecmp-weight">ecmp weight <M>num</M></tag>
3290 When ECMP (multipath) routes are allowed, this value specifies a
3291 relative weight used for nexthops going through the iface. Allowed
3292 values are 1-256. Default value is 1.
3293
3294 <tag><label id="ospf-auth-none">authentication none</tag>
3295 No passwords are sent in OSPF packets. This is the default value.
3296
3297 <tag><label id="ospf-auth-simple">authentication simple</tag>
3298 Every packet carries 8 bytes of password. Received packets lacking this
3299 password are ignored. This authentication mechanism is very weak.
3300 This option is not available in OSPFv3.
3301
3302 <tag><label id="ospf-auth-cryptographic">authentication cryptographic</tag>
3303 An authentication code is appended to every packet. The specific
3304 cryptographic algorithm is selected by option <cf/algorithm/ for each
3305 key. The default cryptographic algorithm for OSPFv2 keys is Keyed-MD5
3306 and for OSPFv3 keys is HMAC-SHA-256. Passwords are not sent open via
3307 network, so this mechanism is quite secure. Packets can still be read by
3308 an attacker.
3309
3310 <tag><label id="ospf-pass">password "<M>text</M>"</tag>
3311 Specifies a password used for authentication. See
3312 <ref id="proto-pass" name="password"> common option for detailed
3313 description.
3314
3315 <tag><label id="ospf-neighbors">neighbors { <m/set/ } </tag>
3316 A set of neighbors to which Hello messages on NBMA or PtMP networks are
3317 to be sent. For NBMA networks, some of them could be marked as eligible.
3318 In OSPFv3, link-local addresses should be used, using global ones is
3319 possible, but it is nonstandard and might be problematic. And definitely,
3320 link-local and global addresses should not be mixed.
3321 </descrip>
3322
3323 <sect1>Attributes
3324 <label id="ospf-attr">
3325
3326 <p>OSPF defines four route attributes. Each internal route has a <cf/metric/.
3327
3328 <p>Metric is ranging from 1 to infinity (65535). External routes use
3329 <cf/metric type 1/ or <cf/metric type 2/. A <cf/metric of type 1/ is comparable
3330 with internal <cf/metric/, a <cf/metric of type 2/ is always longer than any
3331 <cf/metric of type 1/ or any <cf/internal metric/. <cf/Internal metric/ or
3332 <cf/metric of type 1/ is stored in attribute <cf/ospf_metric1/, <cf/metric type
3333 2/ is stored in attribute <cf/ospf_metric2/. If you specify both metrics only
3334 metric1 is used.
3335
3336 <p>Each external route can also carry attribute <cf/ospf_tag/ which is a 32-bit
3337 integer which is used when exporting routes to other protocols; otherwise, it
3338 doesn't affect routing inside the OSPF domain at all. The fourth attribute
3339 <cf/ospf_router_id/ is a router ID of the router advertising that route /
3340 network. This attribute is read-only. Default is <cf/ospf_metric2 = 10000/ and
3341 <cf/ospf_tag = 0/.
3342
3343 <sect1>Example
3344 <label id="ospf-exam">
3345
3346 <p><code>
3347 protocol ospf MyOSPF {
3348 rfc1583compat yes;
3349 tick 2;
3350 export filter {
3351 if source = RTS_BGP then {
3352 ospf_metric1 = 100;
3353 accept;
3354 }
3355 reject;
3356 };
3357 area 0.0.0.0 {
3358 interface "eth*" {
3359 cost 11;
3360 hello 15;
3361 priority 100;
3362 retransmit 7;
3363 authentication simple;
3364 password "aaa";
3365 };
3366 interface "ppp*" {
3367 cost 100;
3368 authentication cryptographic;
3369 password "abc" {
3370 id 1;
3371 generate to "22-04-2003 11:00:06";
3372 accept from "17-01-2001 12:01:05";
3373 algorithm hmac sha384;
3374 };
3375 password "def" {
3376 id 2;
3377 generate to "22-07-2005 17:03:21";
3378 accept from "22-02-2001 11:34:06";
3379 algorithm hmac sha512;
3380 };
3381 };
3382 interface "arc0" {
3383 cost 10;
3384 stub yes;
3385 };
3386 interface "arc1";
3387 };
3388 area 120 {
3389 stub yes;
3390 networks {
3391 172.16.1.0/24;
3392 172.16.2.0/24 hidden;
3393 }
3394 interface "-arc0" , "arc*" {
3395 type nonbroadcast;
3396 authentication none;
3397 strict nonbroadcast yes;
3398 wait 120;
3399 poll 40;
3400 dead count 8;
3401 neighbors {
3402 192.168.120.1 eligible;
3403 192.168.120.2;
3404 192.168.120.10;
3405 };
3406 };
3407 };
3408 }
3409 </code>
3410
3411
3412 <sect>Pipe
3413 <label id="pipe">
3414
3415 <sect1>Introduction
3416 <label id="pipe-intro">
3417
3418 <p>The Pipe protocol serves as a link between two routing tables, allowing
3419 routes to be passed from a table declared as primary (i.e., the one the pipe is
3420 connected to using the <cf/table/ configuration keyword) to the secondary one
3421 (declared using <cf/peer table/) and vice versa, depending on what's allowed by
3422 the filters. Export filters control export of routes from the primary table to
3423 the secondary one, import filters control the opposite direction.
3424
3425 <p>The Pipe protocol may work in the transparent mode mode or in the opaque
3426 mode. In the transparent mode, the Pipe protocol retransmits all routes from
3427 one table to the other table, retaining their original source and attributes.
3428 If import and export filters are set to accept, then both tables would have
3429 the same content. The transparent mode is the default mode.
3430
3431 <p>In the opaque mode, the Pipe protocol retransmits optimal route from one
3432 table to the other table in a similar way like other protocols send and receive
3433 routes. Retransmitted route will have the source set to the Pipe protocol, which
3434 may limit access to protocol specific route attributes. This mode is mainly for
3435 compatibility, it is not suggested for new configs. The mode can be changed by
3436 <tt/mode/ option.
3437
3438 <p>The primary use of multiple routing tables and the Pipe protocol is for
3439 policy routing, where handling of a single packet doesn't depend only on its
3440 destination address, but also on its source address, source interface, protocol
3441 type and other similar parameters. In many systems (Linux being a good example),
3442 the kernel allows to enforce routing policies by defining routing rules which
3443 choose one of several routing tables to be used for a packet according to its
3444 parameters. Setting of these rules is outside the scope of BIRD's work (on
3445 Linux, you can use the <tt/ip/ command), but you can create several routing
3446 tables in BIRD, connect them to the kernel ones, use filters to control which
3447 routes appear in which tables and also you can employ the Pipe protocol for
3448 exporting a selected subset of one table to another one.
3449
3450 <sect1>Configuration
3451 <label id="pipe-config">
3452
3453 <p><descrip>
3454 <tag><label id="pipe-peer-table">peer table <m/table/</tag>
3455 Defines secondary routing table to connect to. The primary one is
3456 selected by the <cf/table/ keyword.
3457
3458 <tag><label id="pipe-mode">mode opaque|transparent</tag>
3459 Specifies the mode for the pipe to work in. Default is transparent.
3460 </descrip>
3461
3462 <sect1>Attributes
3463 <label id="pipe-attr">
3464
3465 <p>The Pipe protocol doesn't define any route attributes.
3466
3467 <sect1>Example
3468 <label id="pipe-exam">
3469
3470 <p>Let's consider a router which serves as a boundary router of two different
3471 autonomous systems, each of them connected to a subset of interfaces of the
3472 router, having its own exterior connectivity and wishing to use the other AS as
3473 a backup connectivity in case of outage of its own exterior line.
3474
3475 <p>Probably the simplest solution to this situation is to use two routing tables
3476 (we'll call them <cf/as1/ and <cf/as2/) and set up kernel routing rules, so that
3477 packets having arrived from interfaces belonging to the first AS will be routed
3478 according to <cf/as1/ and similarly for the second AS. Thus we have split our
3479 router to two logical routers, each one acting on its own routing table, having
3480 its own routing protocols on its own interfaces. In order to use the other AS's
3481 routes for backup purposes, we can pass the routes between the tables through a
3482 Pipe protocol while decreasing their preferences and correcting their BGP paths
3483 to reflect the AS boundary crossing.
3484
3485 <code>
3486 table as1; # Define the tables
3487 table as2;
3488
3489 protocol kernel kern1 { # Synchronize them with the kernel
3490 table as1;
3491 kernel table 1;
3492 }
3493
3494 protocol kernel kern2 {
3495 table as2;
3496 kernel table 2;
3497 }
3498
3499 protocol bgp bgp1 { # The outside connections
3500 table as1;
3501 local as 1;
3502 neighbor 192.168.0.1 as 1001;
3503 export all;
3504 import all;
3505 }
3506
3507 protocol bgp bgp2 {
3508 table as2;
3509 local as 2;
3510 neighbor 10.0.0.1 as 1002;
3511 export all;
3512 import all;
3513 }
3514
3515 protocol pipe { # The Pipe
3516 table as1;
3517 peer table as2;
3518 export filter {
3519 if net ~ [ 1.0.0.0/8+] then { # Only AS1 networks
3520 if preference>10 then preference = preference-10;
3521 if source=RTS_BGP then bgp_path.prepend(1);
3522 accept;
3523 }
3524 reject;
3525 };
3526 import filter {
3527 if net ~ [ 2.0.0.0/8+] then { # Only AS2 networks
3528 if preference>10 then preference = preference-10;
3529 if source=RTS_BGP then bgp_path.prepend(2);
3530 accept;
3531 }
3532 reject;
3533 };
3534 }
3535 </code>
3536
3537
3538 <sect>RAdv
3539 <label id="radv">
3540
3541 <sect1>Introduction
3542 <label id="radv-intro">
3543
3544 <p>The RAdv protocol is an implementation of Router Advertisements, which are
3545 used in the IPv6 stateless autoconfiguration. IPv6 routers send (in irregular
3546 time intervals or as an answer to a request) advertisement packets to connected
3547 networks. These packets contain basic information about a local network (e.g. a
3548 list of network prefixes), which allows network hosts to autoconfigure network
3549 addresses and choose a default route. BIRD implements router behavior as defined
3550 in <rfc id="4861"> and also the DNS extensions from <rfc id="6106">.
3551
3552 <sect1>Configuration
3553 <label id="radv-config">
3554
3555 <p>There are several classes of definitions in RAdv configuration -- interface
3556 definitions, prefix definitions and DNS definitions:
3557
3558 <descrip>
3559 <tag><label id="radv-iface">interface <m/pattern/ [, <m/.../] { <m/options/ }</tag>
3560 Interface definitions specify a set of interfaces on which the
3561 protocol is activated and contain interface specific options.
3562 See <ref id="proto-iface" name="interface"> common options for
3563 detailed description.
3564
3565 <tag><label id="radv-prefix">prefix <m/prefix/ { <m/options/ }</tag>
3566 Prefix definitions allow to modify a list of advertised prefixes. By
3567 default, the advertised prefixes are the same as the network prefixes
3568 assigned to the interface. For each network prefix, the matching prefix
3569 definition is found and its options are used. If no matching prefix
3570 definition is found, the prefix is used with default options.
3571
3572 Prefix definitions can be either global or interface-specific. The
3573 second ones are part of interface options. The prefix definition
3574 matching is done in the first-match style, when interface-specific
3575 definitions are processed before global definitions. As expected, the
3576 prefix definition is matching if the network prefix is a subnet of the
3577 prefix in prefix definition.
3578
3579 <tag><label id="radv-rdnss">rdnss { <m/options/ }</tag>
3580 RDNSS definitions allow to specify a list of advertised recursive DNS
3581 servers together with their options. As options are seldom necessary,
3582 there is also a short variant <cf>rdnss <m/address/</cf> that just
3583 specifies one DNS server. Multiple definitions are cumulative. RDNSS
3584 definitions may also be interface-specific when used inside interface
3585 options. By default, interface uses both global and interface-specific
3586 options, but that can be changed by <cf/rdnss local/ option.
3587 dsc-iface
3588 <tag><label id="radv-dnssl">dnssl { <m/options/ }</tag>
3589 DNSSL definitions allow to specify a list of advertised DNS search
3590 domains together with their options. Like <cf/rdnss/ above, multiple
3591 definitions are cumulative, they can be used also as interface-specific
3592 options and there is a short variant <cf>dnssl <m/domain/</cf> that just
3593 specifies one DNS search domain.
3594
3595 <tag><label id="radv-trigger">trigger <m/prefix/</tag>
3596 RAdv protocol could be configured to change its behavior based on
3597 availability of routes. When this option is used, the protocol waits in
3598 suppressed state until a <it/trigger route/ (for the specified network)
3599 is exported to the protocol, the protocol also returnsd to suppressed
3600 state if the <it/trigger route/ disappears. Note that route export
3601 depends on specified export filter, as usual. This option could be used,
3602 e.g., for handling failover in multihoming scenarios.
3603
3604 During suppressed state, router advertisements are generated, but with
3605 some fields zeroed. Exact behavior depends on which fields are zeroed,
3606 this can be configured by <cf/sensitive/ option for appropriate
3607 fields. By default, just <cf/default lifetime/ (also called <cf/router
3608 lifetime/) is zeroed, which means hosts cannot use the router as a
3609 default router. <cf/preferred lifetime/ and <cf/valid lifetime/ could
3610 also be configured as <cf/sensitive/ for a prefix, which would cause
3611 autoconfigured IPs to be deprecated or even removed.
3612 </descrip>
3613
3614 <p>Interface specific options:
3615
3616 <descrip>
3617 <tag><label id="radv-iface-max-ra-interval">max ra interval <m/expr/</tag>
3618 Unsolicited router advertisements are sent in irregular time intervals.
3619 This option specifies the maximum length of these intervals, in seconds.
3620 Valid values are 4-1800. Default: 600
3621
3622 <tag><label id="radv-iface-min-ra-interval">min ra interval <m/expr/</tag>
3623 This option specifies the minimum length of that intervals, in seconds.
3624 Must be at least 3 and at most 3/4 * <cf/max ra interval/. Default:
3625 about 1/3 * <cf/max ra interval/.
3626
3627 <tag><label id="radv-iface-min-delay">min delay <m/expr/</tag>
3628 The minimum delay between two consecutive router advertisements, in
3629 seconds. Default: 3
3630
3631 <tag><label id="radv-iface-managed">managed <m/switch/</tag>
3632 This option specifies whether hosts should use DHCPv6 for IP address
3633 configuration. Default: no
3634
3635 <tag><label id="radv-iface-other-config">other config <m/switch/</tag>
3636 This option specifies whether hosts should use DHCPv6 to receive other
3637 configuration information. Default: no
3638
3639 <tag><label id="radv-iface-link-mtu">link mtu <m/expr/</tag>
3640 This option specifies which value of MTU should be used by hosts. 0
3641 means unspecified. Default: 0
3642
3643 <tag><label id="radv-iface-reachable-time">reachable time <m/expr/</tag>
3644 This option specifies the time (in milliseconds) how long hosts should
3645 assume a neighbor is reachable (from the last confirmation). Maximum is
3646 3600000, 0 means unspecified. Default 0.
3647
3648 <tag><label id="radv-iface-retrans-timer">retrans timer <m/expr/</tag>
3649 This option specifies the time (in milliseconds) how long hosts should
3650 wait before retransmitting Neighbor Solicitation messages. 0 means
3651 unspecified. Default 0.
3652
3653 <tag><label id="radv-iface-current-hop-limit">current hop limit <m/expr/</tag>
3654 This option specifies which value of Hop Limit should be used by
3655 hosts. Valid values are 0-255, 0 means unspecified. Default: 64
3656
3657 <tag><label id="radv-iface-default-lifetime">default lifetime <m/expr/ [sensitive <m/switch/]</tag>
3658 This option specifies the time (in seconds) how long (after the receipt
3659 of RA) hosts may use the router as a default router. 0 means do not use
3660 as a default router. For <cf/sensitive/ option, see <ref id="radv-trigger" name="trigger">.
3661 Default: 3 * <cf/max ra interval/, <cf/sensitive/ yes.
3662
3663 <tag><label id="radv-iface-default-preference-low">default preference low|medium|high</tag>
3664 This option specifies the Default Router Preference value to advertise
3665 to hosts. Default: medium.
3666
3667 <tag><label id="radv-iface-rdnss-local">rdnss local <m/switch/</tag>
3668 Use only local (interface-specific) RDNSS definitions for this
3669 interface. Otherwise, both global and local definitions are used. Could
3670 also be used to disable RDNSS for given interface if no local definitons
3671 are specified. Default: no.
3672
3673 <tag><label id="radv-iface-dnssl-local">dnssl local <m/switch/</tag>
3674 Use only local DNSSL definitions for this interface. See <cf/rdnss local/
3675 option above. Default: no.
3676 </descrip>
3677
3678
3679 <p>Prefix specific options
3680
3681 <descrip>
3682 <tag><label id="radv-prefix-skip">skip <m/switch/</tag>
3683 This option allows to specify that given prefix should not be
3684 advertised. This is useful for making exceptions from a default policy
3685 of advertising all prefixes. Note that for withdrawing an already
3686 advertised prefix it is more useful to advertise it with zero valid
3687 lifetime. Default: no
3688
3689 <tag><label id="radv-prefix-onlink">onlink <m/switch/</tag>
3690 This option specifies whether hosts may use the advertised prefix for
3691 onlink determination. Default: yes
3692
3693 <tag><label id="radv-prefix-autonomous">autonomous <m/switch/</tag>
3694 This option specifies whether hosts may use the advertised prefix for
3695 stateless autoconfiguration. Default: yes
3696
3697 <tag><label id="radv-prefix-valid-lifetime">valid lifetime <m/expr/ [sensitive <m/switch/]</tag>
3698 This option specifies the time (in seconds) how long (after the
3699 receipt of RA) the prefix information is valid, i.e., autoconfigured
3700 IP addresses can be assigned and hosts with that IP addresses are
3701 considered directly reachable. 0 means the prefix is no longer
3702 valid. For <cf/sensitive/ option, see <ref id="radv-trigger" name="trigger">.
3703 Default: 86400 (1 day), <cf/sensitive/ no.
3704
3705 <tag><label id="radv-prefix-preferred-lifetime">preferred lifetime <m/expr/ [sensitive <m/switch/]</tag>
3706 This option specifies the time (in seconds) how long (after the
3707 receipt of RA) IP addresses generated from the prefix using stateless
3708 autoconfiguration remain preferred. For <cf/sensitive/ option,
3709 see <ref id="radv-trigger" name="trigger">. Default: 14400 (4 hours),
3710 <cf/sensitive/ no.
3711 </descrip>
3712
3713
3714 <p>RDNSS specific options:
3715
3716 <descrip>
3717 <tag><label id="radv-rdnss-ns">ns <m/address/</tag>
3718 This option specifies one recursive DNS server. Can be used multiple
3719 times for multiple servers. It is mandatory to have at least one
3720 <cf/ns/ option in <cf/rdnss/ definition.
3721
3722 <tag><label id="radv-rdnss-lifetime">lifetime [mult] <m/expr/</tag>
3723 This option specifies the time how long the RDNSS information may be
3724 used by clients after the receipt of RA. It is expressed either in
3725 seconds or (when <cf/mult/ is used) in multiples of <cf/max ra
3726 interval/. Note that RDNSS information is also invalidated when
3727 <cf/default lifetime/ expires. 0 means these addresses are no longer
3728 valid DNS servers. Default: 3 * <cf/max ra interval/.
3729 </descrip>
3730
3731
3732 <p>DNSSL specific options:
3733
3734 <descrip>
3735 <tag><label id="radv-dnssl-domain">domain <m/address/</tag>
3736 This option specifies one DNS search domain. Can be used multiple times
3737 for multiple domains. It is mandatory to have at least one <cf/domain/
3738 option in <cf/dnssl/ definition.
3739
3740 <tag><label id="radv-dnssl-lifetime">lifetime [mult] <m/expr/</tag>
3741 This option specifies the time how long the DNSSL information may be
3742 used by clients after the receipt of RA. Details are the same as for
3743 RDNSS <cf/lifetime/ option above. Default: 3 * <cf/max ra interval/.
3744 </descrip>
3745
3746
3747 <sect1>Example
3748 <label id="radv-exam">
3749
3750 <p><code>
3751 protocol radv {
3752 interface "eth2" {
3753 max ra interval 5; # Fast failover with more routers
3754 managed yes; # Using DHCPv6 on eth2
3755 prefix ::/0 {
3756 autonomous off; # So do not autoconfigure any IP
3757 };
3758 };
3759
3760 interface "eth*"; # No need for any other options
3761
3762 prefix 2001:0DB8:1234::/48 {
3763 preferred lifetime 0; # Deprecated address range
3764 };
3765
3766 prefix 2001:0DB8:2000::/48 {
3767 autonomous off; # Do not autoconfigure
3768 };
3769
3770 rdnss 2001:0DB8:1234::10; # Short form of RDNSS
3771
3772 rdnss {
3773 lifetime mult 10;
3774 ns 2001:0DB8:1234::11;
3775 ns 2001:0DB8:1234::12;
3776 };
3777
3778 dnssl {
3779 lifetime 3600;
3780 domain "abc.com";
3781 domain "xyz.com";
3782 };
3783 }
3784 </code>
3785
3786
3787 <sect>RIP
3788 <label id="rip">
3789
3790 <sect1>Introduction
3791 <label id="rip-intro">
3792
3793 <p>The RIP protocol (also sometimes called Rest In Pieces) is a simple protocol,
3794 where each router broadcasts (to all its neighbors) distances to all networks it
3795 can reach. When a router hears distance to another network, it increments it and
3796 broadcasts it back. Broadcasts are done in regular intervals. Therefore, if some
3797 network goes unreachable, routers keep telling each other that its distance is
3798 the original distance plus 1 (actually, plus interface metric, which is usually
3799 one). After some time, the distance reaches infinity (that's 15 in RIP) and all
3800 routers know that network is unreachable. RIP tries to minimize situations where
3801 counting to infinity is necessary, because it is slow. Due to infinity being 16,
3802 you can't use RIP on networks where maximal distance is higher than 15
3803 hosts.
3804
3805 <p>BIRD supports RIPv1 (<rfc id="1058">), RIPv2 (<rfc id="2453">), RIPng (<rfc
3806 id="2080">), and RIP cryptographic authentication (<rfc id="4822">).
3807
3808 <p>RIP is a very simple protocol, and it has a lot of shortcomings. Slow
3809 convergence, big network load and inability to handle larger networks makes it
3810 pretty much obsolete. It is still usable on very small networks.
3811
3812 <sect1>Configuration
3813 <label id="rip-config">
3814
3815 <p>RIP configuration consists mainly of common protocol options and interface
3816 definitions, most RIP options are interface specific. RIPng (RIP for IPv6)
3817 protocol instance can be configured by using <cf/rip ng/ instead of just
3818 <cf/rip/ as a protocol type.
3819
3820 <code>
3821 protocol rip [ng] [&lt;name&gt;] {
3822 infinity &lt;number&gt;;
3823 ecmp &lt;switch&gt; [limit &lt;number&gt;];
3824 interface &lt;interface pattern&gt; {
3825 metric &lt;number&gt;;
3826 mode multicast|broadcast;
3827 passive &lt;switch&gt;;
3828 address &lt;ip&gt;;
3829 port &lt;number&gt;;
3830 version 1|2;
3831 split horizon &lt;switch&gt;;
3832 poison reverse &lt;switch&gt;;
3833 check zero &lt;switch&gt;;
3834 update time &lt;number&gt;;
3835 timeout time &lt;number&gt;;
3836 garbage time &lt;number&gt;;
3837 ecmp weight &lt;number&gt;;
3838 ttl security &lt;switch&gt;; | tx only;
3839 tx class|dscp &lt;number&gt;;
3840 tx priority &lt;number&gt;;
3841 rx buffer &lt;number&gt;;
3842 tx length &lt;number&gt;;
3843 check link &lt;switch&gt;;
3844 authentication none|plaintext|cryptographic;
3845 password "&lt;text&gt;";
3846 password "&lt;text&gt;" {
3847 id &lt;num&gt;;
3848 generate from "&lt;date&gt;";
3849 generate to "&lt;date&gt;";
3850 accept from "&lt;date&gt;";
3851 accept to "&lt;date&gt;";
3852 from "&lt;date&gt;";
3853 to "&lt;date&gt;";
3854 algorithm ( keyed md5 | keyed sha1 | hmac sha1 | hmac sha256 | hmac sha384 | hmac sha512 );
3855 };
3856 };
3857 }
3858 </code>
3859
3860 <descrip>
3861 <tag><label id="rip-infinity">infinity <M>number</M></tag>
3862 Selects the distance of infinity. Bigger values will make
3863 protocol convergence even slower. The default value is 16.
3864
3865 <tag><label id="rip-ecmp">ecmp <M>switch</M> [limit <M>number</M>]</tag>
3866 This option specifies whether RIP is allowed to generate ECMP
3867 (equal-cost multipath) routes. Such routes are used when there are
3868 several directions to the destination, each with the same (computed)
3869 cost. This option also allows to specify a limit on maximum number of
3870 nexthops in one route. By default, ECMP is disabled. If enabled,
3871 default value of the limit is 16.
3872
3873 <tag><label id="rip-iface">interface <m/pattern/ [, <m/.../] { <m/options/ }</tag>
3874 Interface definitions specify a set of interfaces on which the
3875 protocol is activated and contain interface specific options.
3876 See <ref id="proto-iface" name="interface"> common options for
3877 detailed description.
3878 </descrip>
3879
3880 <p>Interface specific options:
3881
3882 <descrip>
3883 <tag><label id="rip-iface-metric">metric <m/num/</tag>
3884 This option specifies the metric of the interface. When a route is
3885 received from the interface, its metric is increased by this value
3886 before further processing. Valid values are 1-255, but values higher
3887 than infinity has no further meaning. Default: 1.
3888
3889 <tag><label id="rip-iface-mode">mode multicast|broadcast</tag>
3890 This option selects the mode for RIP to use on the interface. The
3891 default is multicast mode for RIPv2 and broadcast mode for RIPv1.
3892 RIPng always uses the multicast mode.
3893
3894 <tag><label id="rip-iface-passive">passive <m/switch/</tag>
3895 Passive interfaces receive routing updates but do not transmit any
3896 messages. Default: no.
3897
3898 <tag><label id="rip-iface-address">address <m/ip/</tag>
3899 This option specifies a destination address used for multicast or
3900 broadcast messages, the default is the official RIP (224.0.0.9) or RIPng
3901 (ff02::9) multicast address, or an appropriate broadcast address in the
3902 broadcast mode.
3903
3904 <tag><label id="rip-iface-port">port <m/number/</tag>
3905 This option selects an UDP port to operate on, the default is the
3906 official RIP (520) or RIPng (521) port.
3907
3908 <tag><label id="rip-iface-version">version 1|2</tag>
3909 This option selects the version of RIP used on the interface. For RIPv1,
3910 automatic subnet aggregation is not implemented, only classful network
3911 routes and host routes are propagated. Note that BIRD allows RIPv1 to be
3912 configured with features that are defined for RIPv2 only, like
3913 authentication or using multicast sockets. The default is RIPv2 for IPv4
3914 RIP, the option is not supported for RIPng, as no further versions are
3915 defined.
3916
3917 <tag><label id="rip-iface-version-only">version only <m/switch/</tag>
3918 Regardless of RIP version configured for the interface, BIRD accepts
3919 incoming packets of any RIP version. This option restrict accepted
3920 packets to the configured version. Default: no.
3921
3922 <tag><label id="rip-iface-split-horizon">split horizon <m/switch/</tag>
3923 Split horizon is a scheme for preventing routing loops. When split
3924 horizon is active, routes are not regularly propagated back to the
3925 interface from which they were received. They are either not propagated
3926 back at all (plain split horizon) or propagated back with an infinity
3927 metric (split horizon with poisoned reverse). Therefore, other routers
3928 on the interface will not consider the router as a part of an
3929 independent path to the destination of the route. Default: yes.
3930
3931 <tag><label id="rip-iface-poison-reverse">poison reverse <m/switch/</tag>
3932 When split horizon is active, this option specifies whether the poisoned
3933 reverse variant (propagating routes back with an infinity metric) is
3934 used. The poisoned reverse has some advantages in faster convergence,
3935 but uses more network traffic. Default: yes.
3936
3937 <tag><label id="rip-iface-check-zero">check zero <m/switch/</tag>
3938 Received RIPv1 packets with non-zero values in reserved fields should
3939 be discarded. This option specifies whether the check is performed or
3940 such packets are just processed as usual. Default: yes.
3941
3942 <tag><label id="rip-iface-update-time">update time <m/number/</tag>
3943 Specifies the number of seconds between periodic updates. A lower number
3944 will mean faster convergence but bigger network load. Default: 30.
3945
3946 <tag><label id="rip-iface-timeout-time">timeout time <m/number/</tag>
3947 Specifies the time interval (in seconds) between the last received route
3948 announcement and the route expiration. After that, the network is
3949 considered unreachable, but still is propagated with infinity distance.
3950 Default: 180.
3951
3952 <tag><label id="rip-iface-garbage-time">garbage time <m/number/</tag>
3953 Specifies the time interval (in seconds) between the route expiration
3954 and the removal of the unreachable network entry. The garbage interval,
3955 when a route with infinity metric is propagated, is used for both
3956 internal (after expiration) and external (after withdrawal) routes.
3957 Default: 120.
3958
3959 <tag><label id="rip-iface-ecmp-weight">ecmp weight <m/number/</tag>
3960 When ECMP (multipath) routes are allowed, this value specifies a
3961 relative weight used for nexthops going through the iface. Valid
3962 values are 1-256. Default value is 1.
3963
3964 <tag><label id="rip-iface-auth">authentication none|plaintext|cryptographic</tag>
3965 Selects authentication method to be used. <cf/none/ means that packets
3966 are not authenticated at all, <cf/plaintext/ means that a plaintext
3967 password is embedded into each packet, and <cf/cryptographic/ means that
3968 packets are authenticated using some cryptographic hash function
3969 selected by option <cf/algorithm/ for each key. The default
3970 cryptographic algorithm for RIP keys is Keyed-MD5. If you set
3971 authentication to not-none, it is a good idea to add <cf>password</cf>
3972 section. Default: none.
3973
3974 <tag><label id="rip-iface-pass">password "<m/text/"</tag>
3975 Specifies a password used for authentication. See <ref id="proto-pass"
3976 name="password"> common option for detailed description.
3977
3978 <tag><label id="rip-iface-ttl-security">ttl security [<m/switch/ | tx only]</tag>
3979 TTL security is a feature that protects routing protocols from remote
3980 spoofed packets by using TTL 255 instead of TTL 1 for protocol packets
3981 destined to neighbors. Because TTL is decremented when packets are
3982 forwarded, it is non-trivial to spoof packets with TTL 255 from remote
3983 locations.
3984
3985 If this option is enabled, the router will send RIP packets with TTL 255
3986 and drop received packets with TTL less than 255. If this option si set
3987 to <cf/tx only/, TTL 255 is used for sent packets, but is not checked
3988 for received packets. Such setting does not offer protection, but offers
3989 compatibility with neighbors regardless of whether they use ttl
3990 security.
3991
3992 For RIPng, TTL security is a standard behavior (required by <rfc
3993 id="2080">) and therefore default value is yes. For IPv4 RIP, default
3994 value is no.
3995
3996 <tag><label id="rip-iface-tx-class">tx class|dscp|priority <m/number/</tag>
3997 These options specify the ToS/DiffServ/Traffic class/Priority of the
3998 outgoing RIP packets. See <ref id="proto-tx-class" name="tx class"> common
3999 option for detailed description.
4000
4001 <tag><label id="rip-iface-rx-buffer">rx buffer <m/number/</tag>
4002 This option specifies the size of buffers used for packet processing.
4003 The buffer size should be bigger than maximal size of received packets.
4004 The default value is 532 for IPv4 RIP and interface MTU value for RIPng.
4005
4006 <tag><label id="rip-iface-tx-length">tx length <m/number/</tag>
4007 This option specifies the maximum length of generated RIP packets. To
4008 avoid IP fragmentation, it should not exceed the interface MTU value.
4009 The default value is 532 for IPv4 RIP and interface MTU value for RIPng.
4010
4011 <tag><label id="rip-iface-check-link">check link <m/switch/</tag>
4012 If set, the hardware link state (as reported by OS) is taken into
4013 consideration. When the link disappears (e.g. an ethernet cable is
4014 unplugged), neighbors are immediately considered unreachable and all
4015 routes received from them are withdrawn. It is possible that some
4016 hardware drivers or platforms do not implement this feature.
4017 Default: no.
4018 </descrip>
4019
4020 <sect1>Attributes
4021 <label id="rip-attr">
4022
4023 <p>RIP defines two route attributes:
4024
4025 <descrip>
4026 <tag>int <cf/rip_metric/</tag>
4027 RIP metric of the route (ranging from 0 to <cf/infinity/). When routes
4028 from different RIP instances are available and all of them have the same
4029 preference, BIRD prefers the route with lowest <cf/rip_metric/. When a
4030 non-RIP route is exported to RIP, the default metric is 1.
4031
4032 <tag><label id="rta-rip-tag">int rip_tag/</tag>
4033 RIP route tag: a 16-bit number which can be used to carry additional
4034 information with the route (for example, an originating AS number in
4035 case of external routes). When a non-RIP route is exported to RIP, the
4036 default tag is 0.
4037 </descrip>
4038
4039 <sect1>Example
4040 <label id="rip-exam">
4041
4042 <p><code>
4043 protocol rip {
4044 import all;
4045 export all;
4046 interface "eth*" {
4047 metric 2;
4048 port 1520;
4049 mode multicast;
4050 update time 12;
4051 timeout time 60;
4052 authentication cryptographic;
4053 password "secret" { algorithm hmac sha256; };
4054 };
4055 }
4056 </code>
4057
4058 <sect>RPKI
4059
4060 <sect1>Introduction
4061
4062 <p>The Resource Public Key Infrastructure (RPKI) is mechanism for origin
4063 validation of BGP routes (RFC 6480). BIRD supports only so-called RPKI-based
4064 origin validation. There is implemented RPKI to Router (RPKI-RTR) protocol (RFC
4065 6810). It uses some of the RPKI data to allow a router to verify that the
4066 autonomous system announcing an IP address prefix is in fact authorized to do
4067 so. This is not crypto checked so can be violated. But it should prevent the
4068 vast majority of accidental hijackings on the Internet today, e.g. the famous
4069 Pakastani accidental announcement of YouTube's address space.
4070
4071 <p>The RPKI-RTR protocol receives and maintains a set of ROAs from a cache
4072 server (also called validator). You can validate routes (RFC 6483) using
4073 function <cf/roa_check()/ in filter and set it as import filter at the BGP
4074 protocol. BIRD should re-validate all of affected routes after RPKI update by
4075 RFC 6811, but we don't support it yet! You can use a BIRD's client command
4076 <cf>reload in <m/bgp_protocol_name/</cf> for manual call of revalidation of all
4077 routes.
4078
4079 <sect1>Supported transports
4080 <itemize>
4081 <item>Unprotected transport over TCP uses a port 323. The cache server
4082 and BIRD router should be on the same trusted and controlled network
4083 for security reasons.
4084 <item>SSHv2 encrypted transport connection uses the normal SSH port
4085 22.
4086 </itemize>
4087
4088 <sect1>Configuration
4089
4090 <p>We currently support just one cache server per protocol. However you can
4091 define more RPKI protocols generally.
4092
4093 <code>
4094 protocol rpki [&lt;name&gt;] {
4095 roa4 { table &lt;tab&gt;; };
4096 roa6 { table &lt;tab&gt;; };
4097 remote &lt;ip&gt; | "&lt;domain&gt;" [port &lt;num&gt;];
4098 port &lt;num&gt;;
4099 refresh [keep] &lt;num&gt;;
4100 retry [keep] &lt;num&gt;;
4101 expire [keep] &lt;num&gt;;
4102 transport tcp;
4103 transport ssh {
4104 bird private key "&lt;/path/to/id_rsa&gt;";
4105 remote public key "&lt;/path/to/known_host&gt;";
4106 user "&lt;name&gt;";
4107 };
4108 }
4109 </code>
4110
4111 <p>Alse note that you have to specify ROA table into which will be imported
4112 routes from a cache server. If you want to import only IPv4 prefixes you have
4113 to specify only roa4 table. Similarly with IPv6 prefixes only. If you want to
4114 fetch both IPv4 and even IPv6 ROAs you have to specify both types of ROA
4115 tables.
4116
4117 <sect2>RPKI protocol options
4118
4119 <descrip>
4120 <tag>remote <m/ip/ | "<m/hostname/" [port <m/num/]</tag> Specifies
4121 a destination address of the cache server. Can be specified by an IP
4122 address or by full domain name string. Only one cache can be specified
4123 per protocol. This option is required.
4124
4125 <tag>port <m/num/</tag> Specifies the port number. The default port
4126 number is 323 for transport without any encryption and 22 for transport
4127 with SSH encryption.
4128
4129 <tag>refresh [keep] <m/num/</tag> Time period in seconds. Tells how
4130 long to wait before next attempting to poll the cache using a Serial
4131 Query or a Reset Query packet. Must be lower than 86400 seconds (one
4132 day). Too low value can caused a false positive detection of
4133 network connection problems. A keyword <cf/keep/ suppresses updating
4134 this value by a cache server.
4135 Default: 3600 seconds
4136
4137 <tag>retry [keep] <m/num/</tag> Time period in seconds between a failed
4138 Serial/Reset Query and a next attempt. Maximum allowed value is 7200
4139 seconds (two hours). Too low value can caused a false positive
4140 detection of network connection problems. A keyword <cf/keep/
4141 suppresses updating this value by a cache server.
4142 Default: 600 seconds
4143
4144 <tag>expire [keep] <m/num/</tag> Time period in seconds. Received
4145 records are deleted if the client was unable to successfully refresh
4146 data for this time period. Must be in range from 600 seconds (ten
4147 minutes) to 172800 seconds (two days). A keyword <cf/keep/
4148 suppresses updating this value by a cache server.
4149 Default: 7200 seconds
4150
4151 <tag>transport tcp</tag> Unprotected transport over TCP. It's a default
4152 transport. Should be used only on secure private networks.
4153 Default: tcp
4154
4155 <tag>transport ssh { <m/SSH transport options.../ }</tag> It enables a
4156 SSHv2 transport encryption. Cannot be combined with a TCP transport.
4157 Default: off
4158 </descrip>
4159
4160 <sect3>SSH transport options
4161 <descrip>
4162 <tag>bird private key "<m>/path/to/id_rsa</m>"</tag>
4163 A path to the BIRD's private SSH key for authentication.
4164 It can be a <cf><m>id_rsa</m></cf> file.
4165
4166 <tag>remote public key "<m>/path/to/known_host</m>"</tag>
4167 A path to the cache's public SSH key for verification identity
4168 of the cache server. It could be a path to <cf><m>known_host</m></cf> file.
4169
4170 <tag>user "<m/name/"</tag>
4171 A SSH user name for authentication. This option is a required.
4172 </descrip>
4173
4174 <sect1>Examples
4175 <sect2>BGP origin validation
4176 <p>Policy: Don't import <cf/ROA_INVALID/ routes.
4177 <code>
4178 roa4 table r4;
4179 roa6 table r6;
4180
4181 protocol rpki {
4182 debug all;
4183
4184 roa4 { table r4; };
4185 roa6 { table r6; };
4186
4187 # Please, do not use rpki-validator.realmv6.org in production
4188 remote "rpki-validator.realmv6.org" port 8282;
4189
4190 retry keep 5;
4191 refresh keep 30;
4192 expire 600;
4193 }
4194
4195 filter peer_in {
4196 if (roa_check(r4, net, bgp_path.last) = ROA_INVALID ||
4197 roa_check(r6, net, bgp_path.last) = ROA_INVALID) then
4198 {
4199 print "Ignore invalid ROA ", net, " for ASN ", bgp_path.last;
4200 reject;
4201 }
4202 accept;
4203 }
4204
4205 protocol bgp {
4206 debug all;
4207 local as 65000;
4208 neighbor 192.168.2.1 as 65001;
4209 import filter peer_in;
4210 }
4211 </code>
4212
4213 <sect2>SSHv2 transport encryption
4214 <code>
4215 roa4 table r4;
4216 roa6 table r6;
4217
4218 protocol rpki {
4219 debug all;
4220
4221 roa4 { table r4; };
4222 roa6 { table r6; };
4223
4224 remote 127.0.0.1 port 2345;
4225 transport ssh {
4226 bird private key "/home/birdgeek/.ssh/id_rsa";
4227 remote public key "/home/birdgeek/.ssh/known_hosts";
4228 user "birdgeek";
4229 };
4230
4231 # Default interval values
4232 }
4233 </code>
4234
4235
4236
4237 <sect>Static
4238 <label id="static">
4239
4240 <p>The Static protocol doesn't communicate with other routers in the network,
4241 but instead it allows you to define routes manually. This is often used for
4242 specifying how to forward packets to parts of the network which don't use
4243 dynamic routing at all and also for defining sink routes (i.e., those telling to
4244 return packets as undeliverable if they are in your IP block, you don't have any
4245 specific destination for them and you don't want to send them out through the
4246 default route to prevent routing loops).
4247
4248 <p>There are four types of static routes: `classical' routes telling to forward
4249 packets to a neighboring router (single path or multipath, possibly weighted),
4250 device routes specifying forwarding to hosts on a directly connected network,
4251 recursive routes computing their nexthops by doing route table lookups for a
4252 given IP, and special routes (sink, blackhole etc.) which specify a special
4253 action to be done instead of forwarding the packet.
4254
4255 <p>When the particular destination is not available (the interface is down or
4256 the next hop of the route is not a neighbor at the moment), Static just
4257 uninstalls the route from the table it is connected to and adds it again as soon
4258 as the destination becomes adjacent again.
4259
4260 <p>There are three classes of definitions in Static protocol configuration --
4261 global options, static route definitions, and per-route options. Usually, the
4262 definition of the protocol contains mainly a list of static routes.
4263
4264 <p>Global options:
4265
4266 <descrip>
4267 <tag><label id="static-check-link">check link <m/switch/</tag>
4268 If set, hardware link states of network interfaces are taken into
4269 consideration. When link disappears (e.g. ethernet cable is unplugged),
4270 static routes directing to that interface are removed. It is possible
4271 that some hardware drivers or platforms do not implement this feature.
4272 Default: off.
4273
4274 <tag><label id="static-igp-table">igp table <m/name/</tag>
4275 Specifies a table that is used for route table lookups of recursive
4276 routes. Default: the same table as the protocol is connected to.
4277 </descrip>
4278
4279 <p>Route definitions (each may also contain a block of per-route options):
4280
4281 <descrip>
4282 <tag><label id="static-route-via-ip">route <m/prefix/ via <m/ip/ [mpls <m/num/[/<m/num/[/<m/num/[...]]]]</tag>
4283 Static single path route through a neighboring router. For link-local next hops,
4284 interface can be specified as a part of the address (e.g.,
4285 <cf/via fe80::1234%eth0/). MPLS labels should be specified in outer-first order.
4286
4287 <tag><label id="static-route-via-mpath">route <m/prefix/ via <m/ip/ [mpls <m/num/[/<m/num/[/<m/num/[...]]]] [weight <m/num/] [bfd <m/switch/] [via ...]</tag>
4288 Static multipath route. Contains several nexthops (gateways), possibly
4289 with their weights and MPLS labels.
4290
4291 <tag><label id="static-route-via-iface">route <m/prefix/ via <m/"interface"/</tag>
4292 Static device route through an interface to hosts on a directly
4293 connected network.
4294
4295 <tag><label id="static-route-recursive">route <m/prefix/ recursive <m/ip/</tag>
4296 Static recursive route, its nexthop depends on a route table lookup for
4297 given IP address.
4298
4299 <tag><label id="static-route-drop">route <m/prefix/ blackhole|unreachable|prohibit</tag>
4300 Special routes specifying to silently drop the packet, return it as
4301 unreachable or return it as administratively prohibited. First two
4302 targets are also known as <cf/drop/ and <cf/reject/.
4303 </descrip>
4304
4305 <p>Per-route options:
4306
4307 <descrip>
4308 <tag><label id="static-route-bfd">bfd <m/switch/</tag>
4309 The Static protocol could use BFD protocol for next hop liveness
4310 detection. If enabled, a BFD session to the route next hop is created
4311 and the static route is BFD-controlled -- the static route is announced
4312 only if the next hop liveness is confirmed by BFD. If the BFD session
4313 fails, the static route is removed. Note that this is a bit different
4314 compared to other protocols, which may use BFD as an advisory mechanism
4315 for fast failure detection but ignores it if a BFD session is not even
4316 established.
4317
4318 This option can be used for static routes with a direct next hop, or
4319 also for for individual next hops in a static multipath route (see
4320 above). Note that BFD protocol also has to be configured, see
4321 <ref id="bfd" name="BFD"> section for details. Default value is no.
4322
4323 <tag><label id="static-route-filter"><m/filter expression/</tag>
4324 This is a special option that allows filter expressions to be configured
4325 on per-route basis. Can be used multiple times. These expressions are
4326 evaluated when the route is originated, similarly to the import filter
4327 of the static protocol. This is especially useful for configuring route
4328 attributes, e.g., <cf/ospf_metric1 = 100;/ for a route that will be
4329 exported to the OSPF protocol.
4330 </descrip>
4331
4332 <p>Static routes have no specific attributes.
4333
4334 <p>Example static config might look like this:
4335
4336 <p><code>
4337 protocol static {
4338 table testable; # Connect to a non-default routing table
4339 check link; # Advertise routes only if link is up
4340 route 0.0.0.0/0 via 198.51.100.130; # Default route
4341 route 10.0.0.0/8 multipath # Multipath route
4342 via 198.51.100.10 weight 2
4343 via 198.51.100.20 bfd # BFD-controlled next hop
4344 via 192.0.2.1;
4345 route 203.0.113.0/24 unreachable; # Sink route
4346 route 10.2.0.0/24 via "arc0"; # Secondary network
4347 route 192.168.10.0/24 via 198.51.100.100 {
4348 ospf_metric1 = 20; # Set extended attribute
4349 }
4350 route 192.168.10.0/24 via 198.51.100.100 {
4351 ospf_metric2 = 100; # Set extended attribute
4352 ospf_tag = 2; # Set extended attribute
4353 bfd; # BFD-controlled route
4354 }
4355 }
4356 </code>
4357
4358
4359 <chapt>Conclusions
4360 <label id="conclusion">
4361
4362 <sect>Future work
4363 <label id="future-work">
4364
4365 <p>Although BIRD supports all the commonly used routing protocols, there are
4366 still some features which would surely deserve to be implemented in future
4367 versions of BIRD:
4368
4369 <itemize>
4370 <item>Opaque LSA's
4371 <item>Route aggregation and flap dampening
4372 <item>Multipath routes
4373 <item>Multicast routing protocols
4374 <item>Ports to other systems
4375 </itemize>
4376
4377
4378 <sect>Getting more help
4379 <label id="help">
4380
4381 <p>If you use BIRD, you're welcome to join the bird-users mailing list
4382 (<HTMLURL URL="mailto:bird-users@network.cz" name="bird-users@network.cz">)
4383 where you can share your experiences with the other users and consult
4384 your problems with the authors. To subscribe to the list, visit
4385 <HTMLURL URL="http://bird.network.cz/?m_list" name="http://bird.network.cz/?m_list">.
4386 The home page of BIRD can be found at <HTMLURL URL="http://bird.network.cz/" name="http://bird.network.cz/">.
4387
4388 <p>BIRD is a relatively young system and it probably contains some bugs. You can
4389 report any problems to the bird-users list and the authors will be glad to solve
4390 them, but before you do so, please make sure you have read the available
4391 documentation and that you are running the latest version (available at
4392 <HTMLURL URL="ftp://bird.network.cz/pub/bird" name="bird.network.cz:/pub/bird">).
4393 (Of course, a patch which fixes the bug is always welcome as an attachment.)
4394
4395 <p>If you want to understand what is going inside, Internet standards are a good
4396 and interesting reading. You can get them from
4397 <HTMLURL URL="ftp://ftp.rfc-editor.org/" name="ftp.rfc-editor.org"> (or a
4398 nicely sorted version from <HTMLURL URL="ftp://atrey.karlin.mff.cuni.cz/pub/rfc"
4399 name="atrey.karlin.mff.cuni.cz:/pub/rfc">).
4400
4401 <p><it/Good luck!/
4402
4403 </book>
4404
4405 <!--
4406 LocalWords: GPL IPv GateD BGPv RIPv OSPFv Linux sgml html dvi sgmltools Pavel
4407 LocalWords: linuxdoc dtd descrip config conf syslog stderr auth ospf bgp Mbps
4408 LocalWords: router's eval expr num birdc ctl UNIX if's enums bool int ip GCC
4409 LocalWords: len ipaddress pxlen netmask enum bgppath bgpmask clist gw md eth
4410 LocalWords: RTS printn quitbird iBGP AS'es eBGP RFC multiprotocol IGP Machek
4411 LocalWords: EGP misconfigurations keepalive pref aggr aggregator BIRD's RTC
4412 LocalWords: OS'es AS's multicast nolisten misconfigured UID blackhole MRTD MTU
4413 LocalWords: uninstalls ethernets IP binutils ANYCAST anycast dest RTD ICMP rfc
4414 LocalWords: compat multicasts nonbroadcast pointopoint loopback sym stats
4415 LocalWords: Perl SIGHUP dd mm yy HH MM SS EXT IA UNICAST multihop Discriminator txt
4416 LocalWords: proto wildcard Ondrej Filip
4417 -->