Statistics
| Branch: | Revision:

iof-bird-daemon / doc / bird.sgml @ 6cf72d7a

History | View | Annotate | Download (150 KB)

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

    
43
<sect>What is BIRD
44

    
45
<p><label id="intro">
46
The name `BIRD' is actually an acronym standing for `BIRD Internet Routing
47
Daemon'. Let's take a closer look at the meaning of the name:
48

    
49
<p><em/BIRD/: Well, we think we have already explained that. It's an acronym
50
standing for `BIRD Internet Routing Daemon', you remember, don't you? :-)
51

    
52
<p><em/Internet Routing/: It's a program (well, a daemon, as you are going to
53
discover in a moment) which works as a dynamic router in an Internet type
54
network (that is, in a network running either the IPv4 or the IPv6 protocol).
55
Routers are devices which forward packets between interconnected networks in
56
order to allow hosts not connected directly to the same local area network to
57
communicate with each other. They also communicate with the other routers in the
58
Internet to discover the topology of the network which allows them to find
59
optimal (in terms of some metric) rules for forwarding of packets (which are
60
called routing tables) and to adapt themselves to the changing conditions such
61
as outages of network links, building of new connections and so on. Most of
62
these routers are costly dedicated devices running obscure firmware which is
63
hard to configure and not open to any changes (on the other hand, their special
64
hardware design allows them to keep up with lots of high-speed network
65
interfaces, better than general-purpose computer does). Fortunately, most
66
operating systems of the UNIX family allow an ordinary computer to act as a
67
router and forward packets belonging to the other hosts, but only according to a
68
statically configured table.
69

    
70
<p>A <em/Routing Daemon/ is in UNIX terminology a non-interactive program
71
running on background which does the dynamic part of Internet routing, that is
72
it communicates with the other routers, calculates routing tables and sends them
73
to the OS kernel which does the actual packet forwarding. There already exist
74
other such routing daemons: routed (RIP only), GateD (non-free),
75
Zebra <HTMLURL URL="http://www.zebra.org"> and
76
MRTD <HTMLURL URL="http://sourceforge.net/projects/mrt">,
77
but their capabilities are limited and they are relatively hard to configure
78
and maintain.
79

    
80
<p>BIRD is an Internet Routing Daemon designed to avoid all of these shortcomings,
81
to support all the routing technology used in the today's Internet or planned to
82
be used in near future and to have a clean extensible architecture allowing new
83
routing protocols to be incorporated easily. Among other features, BIRD
84
supports:
85

    
86
<itemize>
87
	<item>both IPv4 and IPv6 protocols
88
	<item>multiple routing tables
89
	<item>the Border Gateway Protocol (BGPv4)
90
	<item>the Routing Information Protocol (RIPv2)
91
	<item>the Open Shortest Path First protocol (OSPFv2, OSPFv3)
92
	<item>the Router Advertisements for IPv6 hosts
93
	<item>a virtual protocol for exchange of routes between different
94
		routing tables on a single host
95
	<item>a command-line interface allowing on-line control and inspection
96
		of status of the daemon
97
	<item>soft reconfiguration (no need to use complex online commands to
98
		change the configuration, just edit the configuration file and
99
		notify BIRD to re-read it and it will smoothly switch itself to
100
		the new configuration, not disturbing routing protocols unless
101
		they are affected by the configuration changes)
102
	<item>a powerful language for route filtering
103
</itemize>
104

    
105
<p>BIRD has been developed at the Faculty of Math and Physics, Charles
106
University, Prague, Czech Republic as a student project. It can be freely
107
distributed under the terms of the GNU General Public License.
108

    
109
<p>BIRD has been designed to work on all UNIX-like systems. It has been
110
developed and tested under Linux 2.0 to 2.6, and then ported to FreeBSD, NetBSD
111
and OpenBSD, porting to other systems (even non-UNIX ones) should be relatively
112
easy due to its highly modular architecture.
113

    
114
<p>BIRD supports either IPv4 or IPv6 protocol, but have to be compiled separately
115
for each one. Therefore, a dualstack router would run two instances of BIRD (one
116
for IPv4 and one for IPv6), with completely separate setups (configuration
117
files, tools ...).
118

    
119

    
120
<sect>Installing BIRD
121

    
122
<p>On a recent UNIX system with GNU development tools (GCC, binutils, m4, make)
123
and Perl, installing BIRD should be as easy as:
124

    
125
<code>
126
	./configure
127
	make
128
	make install
129
	vi /usr/local/etc/bird.conf
130
	bird
131
</code>
132

    
133
<p>You can use <tt>./configure --help</tt> to get a list of configure
134
options. The most important ones are: <tt/--enable-ipv6/ which enables building
135
of an IPv6 version of BIRD, <tt/--with-protocols=/ to produce a slightly smaller
136
BIRD executable by configuring out routing protocols you don't use, and
137
<tt/--prefix=/ to install BIRD to a place different from <file>/usr/local</file>.
138

    
139

    
140
<sect>Running BIRD
141

    
142
<p>You can pass several command-line options to bird:
143

    
144
<descrip>
145
	<tag>-c <m/config name/</tag>
146
	use given configuration file instead of <it/prefix/<file>/etc/bird.conf</file>.
147

    
148
	<tag>-d</tag>
149
	enable debug messages and run bird in foreground.
150

    
151
	<tag>-D <m/filename of debug log/</tag>
152
	log debugging information to given file instead of stderr.
153

    
154
	<tag>-p</tag>
155
	just parse the config file and exit. Return value is zero if the config
156
	file is valid, nonzero if there are some errors.
157

    
158
	<tag>-s <m/name of communication socket/</tag>
159
	use given filename for a socket for communications with the client,
160
	default is <it/prefix/<file>/var/run/bird.ctl</file>.
161

    
162
	<tag>-P <m/name of PID file/</tag>
163
	create a PID file with given filename.
164

    
165
	<tag>-u <m/user/</tag>
166
	drop privileges and use that user ID, see the next section for details.
167

    
168
	<tag>-g <m/group/</tag>
169
	use that group ID, see the next section for details.
170

    
171
	<tag>-f</tag>
172
	run bird in foreground.
173

    
174
	<tag>-R</tag>
175
	apply graceful restart recovery after start.
176
</descrip>
177

    
178
<p>BIRD writes messages about its work to log files or syslog (according to config).
179

    
180

    
181
<sect>Privileges
182

    
183
<p>BIRD, as a routing daemon, uses several privileged operations (like setting
184
routing table and using raw sockets). Traditionally, BIRD is executed and runs
185
with root privileges, which may be prone to security problems. The recommended
186
way is to use a privilege restriction (options <cf/-u/, <cf/-g/). In that case
187
BIRD is executed with root privileges, but it changes its user and group ID to
188
an unprivileged ones, while using Linux capabilities to retain just required
189
privileges (capabilities CAP_NET_*). Note that the control socket is created
190
before the privileges are dropped, but the config file is read after that. The
191
privilege restriction is not implemented in BSD port of BIRD.
192

    
193
<p>A nonprivileged user (as an argument to <cf/-u/ options) may be the user
194
<cf/nobody/, but it is suggested to use a new dedicated user account (like
195
<cf/bird/). The similar considerations apply for the group option, but there is
196
one more condition -- the users in the same group can use <file/birdc/ to
197
control BIRD.
198

    
199
<p>Finally, there is a possibility to use external tools to run BIRD in an
200
environment with restricted privileges. This may need some configuration, but it
201
is generally easy -- BIRD needs just the standard library, privileges to read
202
the config file and create the control socket and the CAP_NET_* capabilities.
203

    
204

    
205
<chapt>About routing tables
206

    
207
<p>BIRD has one or more routing tables which may or may not be synchronized with
208
OS kernel and which may or may not be synchronized with each other (see the Pipe
209
protocol). Each routing table contains a list of known routes. Each route
210
consists of:
211

    
212
<itemize>
213
	<item>network prefix this route is for (network address and prefix
214
		length -- the number of bits forming the network part of the
215
		address; also known as a netmask)
216
	<item>preference of this route
217
	<item>IP address of router which told us about this route
218
	<item>IP address of router we should forward the packets to using this
219
		route
220
	<item>other attributes common to all routes
221
	<item>dynamic attributes defined by protocols which may or may not be
222
		present (typically protocol metrics)
223
</itemize>
224

    
225
Routing table maintains multiple entries for a network, but at most one entry
226
for one network and one protocol. The entry with the highest preference is used
227
for routing (we will call such an entry the <it/selected route/). If there are
228
more entries with the same preference and they are from the same protocol, the
229
protocol decides (typically according to metrics). If they aren't, an internal
230
ordering is used to break the tie. You can get the list of route attributes in
231
the Route attributes section.
232

    
233
<p>Each protocol is connected to a routing table through two filters which can
234
accept, reject and modify the routes. An <it/export/ filter checks routes passed
235
from the routing table to the protocol, an <it/import/ filter checks routes in
236
the opposite direction. When the routing table gets a route from a protocol, it
237
recalculates the selected route and broadcasts it to all protocols connected to
238
the table. The protocols typically send the update to other routers in the
239
network. Note that although most protocols are interested in receiving just
240
selected routes, some protocols (e.g. the <cf/Pipe/ protocol) receive and
241
process all entries in routing tables (accepted by filters).
242

    
243
<p><label id="dsc-sorted">Usually, a routing table just chooses a selected route
244
from a list of entries for one network. But if the <cf/sorted/ option is
245
activated, these lists of entries are kept completely sorted (according to
246
preference or some protocol-dependent metric). This is needed for some features
247
of some protocols (e.g. <cf/secondary/ option of BGP protocol, which allows to
248
accept not just a selected route, but the first route (in the sorted list) that
249
is accepted by filters), but it is incompatible with some other features (e.g.
250
<cf/deterministic med/ option of BGP protocol, which activates a way of choosing
251
selected route that cannot be described using comparison and ordering). Minor
252
advantage is that routes are shown sorted in <cf/show route/, minor disadvantage
253
is that it is slightly more computationally expensive.
254

    
255

    
256
<sect>Graceful restart
257

    
258
<p>When BIRD is started after restart or crash, it repopulates routing tables in
259
an uncoordinated manner, like after clean start. This may be impractical in some
260
cases, because if the forwarding plane (i.e. kernel routing tables) remains
261
intact, then its synchronization with BIRD would temporarily disrupt packet
262
forwarding until protocols converge. Graceful restart is a mechanism that could
263
help with this issue. Generally, it works by starting protocols and letting them
264
repopulate routing tables while deferring route propagation until protocols
265
acknowledge their convergence. Note that graceful restart behavior have to be
266
configured for all relevant protocols and requires protocol-specific support
267
(currently implemented for Kernel and BGP protocols), it is activated for
268
particular boot by option <cf/-R/.
269

    
270

    
271
<chapt>Configuration
272

    
273
<sect>Introduction
274

    
275
<p>BIRD is configured using a text configuration file. Upon startup, BIRD reads
276
<it/prefix/<file>/etc/bird.conf</file> (unless the <tt/-c/ command line option
277
is given). Configuration may be changed at user's request: if you modify the
278
config file and then signal BIRD with <tt/SIGHUP/, it will adjust to the new
279
config. Then there's the client which allows you to talk with BIRD in an
280
extensive way.
281

    
282
<p>In the config, everything on a line after <cf/#/ or inside <cf>/* */</cf> is
283
a comment, whitespace characters are treated as a single space. If there's a
284
variable number of options, they are grouped using the <cf/{ }/ brackets. Each
285
option is terminated by a <cf/;/. Configuration is case sensitive. There are two
286
ways how to name symbols (like protocol names, filter names, constats etc.). You
287
can either use a simple string starting with a letter followed by any
288
combination of letters and numbers (e.g. "R123", "myfilter", "bgp5") or you can
289
enclose the name into apostrophes (<cf/'/) and than you can use any combination
290
of numbers, letters. hyphens, dots and colons (e.g. "'1:strange-name'",
291
"'-NAME-'", "'cool::name'").
292

    
293
<p>Here is an example of a simple config file. It enables synchronization of
294
routing tables with OS kernel, scans for new network interfaces every 10 seconds
295
and runs RIP on all network interfaces found.
296

    
297
<code>
298
protocol kernel {
299
	persist;		# Don't remove routes on BIRD shutdown
300
	scan time 20;		# Scan kernel routing table every 20 seconds
301
	export all;		# Default is export none
302
}
303

    
304
protocol device {
305
	scan time 10;		# Scan interfaces every 10 seconds
306
}
307

    
308
protocol rip {
309
	export all;
310
	import all;
311
	interface "*";
312
}
313
</code>
314

    
315

    
316
<sect>Global options
317

    
318
<p><descrip>
319
	<tag>include "<m/filename/"</tag>
320
	This statement causes inclusion of a new file. <m/Filename/ could also
321
	be a wildcard. The maximal depth is 8. Note that this statement could be
322
	used anywhere in the config file, not just as a top-level option.
323

    
324
	<tag><label id="dsc-log">log "<m/filename/"|syslog [name <m/name/]|stderr all|{ <m/list of classes/ }</tag>
325
	Set logging of messages having the given class (either <cf/all/ or
326
	<cf/{ error, trace }/ etc.) into selected destination (a file specified
327
	as a filename string, syslog with optional name argument, or the stderr
328
	output). Classes are:
329
	<cf/info/, <cf/warning/, <cf/error/ and <cf/fatal/ for messages about local problems,
330
	<cf/debug/ for debugging messages,
331
	<cf/trace/ when you want to know what happens in the network,
332
	<cf/remote/ for messages about misbehavior of remote machines,
333
	<cf/auth/ about authentication failures,
334
	<cf/bug/ for internal BIRD bugs.
335
	You may specify more than one <cf/log/ line to establish logging to
336
	multiple destinations. Default: log everything to the system log.
337

    
338
	<tag>debug protocols all|off|{ states, routes, filters, interfaces, events, packets }</tag>
339
	Set global defaults of protocol debugging options. See <cf/debug/ in the
340
	following section. Default: off.
341

    
342
	<tag>debug commands <m/number/</tag>
343
	Control logging of client connections (0 for no logging, 1 for logging
344
	of connects and disconnects, 2 and higher for logging of all client
345
	commands). Default: 0.
346

    
347
	<tag>mrtdump "<m/filename/"</tag>
348
	Set MRTdump file name. This option must be specified to allow MRTdump
349
	feature. Default: no dump file.
350

    
351
	<tag>mrtdump protocols all|off|{ states, messages }</tag>
352
	Set global defaults of MRTdump options. See <cf/mrtdump/ in the
353
	following section. Default: off.
354

    
355
	<tag>filter <m/name local variables/{ <m/commands/ }</tag>
356
	Define a filter. You can learn more about filters in the following
357
	chapter.
358

    
359
	<tag>function <m/name/ (<m/parameters/) <m/local variables/ { <m/commands/ }</tag>
360
	Define a function. You can learn more about functions in the following chapter.
361

    
362
	<tag>protocol rip|ospf|bgp|... [<m/name/ [from <m/name2/]] { <m>protocol options</m> }</tag>
363
	Define a protocol instance called <cf><m/name/</cf> (or with a name like
364
	"rip5" generated automatically if you don't specify any
365
	<cf><m/name/</cf>). You can learn more about configuring protocols in
366
	their own chapters. When <cf>from <m/name2/</cf> expression is used,
367
	initial protocol options are taken from protocol or template
368
	<cf><m/name2/</cf> You can run more than one instance of most protocols
369
	(like RIP or BGP). By default, no instances are configured.
370

    
371
	<tag>template rip|bgp|... [<m/name/ [from <m/name2/]] { <m>protocol options</m> }</tag>
372
	Define a protocol template instance called <m/name/ (or with a name like
373
	"bgp1" generated automatically if you don't specify any	<m/name/).
374
	Protocol templates can be used to group common options when many
375
	similarly configured protocol instances are to be defined. Protocol
376
	instances (and other templates) can use templates by using <cf/from/
377
	expression and the name of the template. At the moment templates (and
378
	<cf/from/ expression) are not implemented for OSPF protocol.
379

    
380
	<tag>define <m/constant/ = <m/expression/</tag>
381
	Define a constant. You can use it later in every place you could use a
382
	value of the same type. Besides, there are some predefined numeric
383
	constants based on /etc/iproute2/rt_* files. A list of defined constants
384
	can be seen (together with other symbols) using 'show symbols' command.
385

    
386
	<tag>router id <m/IPv4 address/</tag>
387
 	Set BIRD's router ID. It's a world-wide unique identification of your
388
	router, usually one of router's IPv4 addresses. Default: in IPv4
389
	version, the lowest IP address of a non-loopback interface. In IPv6
390
	version, this option is mandatory.
391

    
392
	<tag>router id from [-] [ "<m/mask/" ] [ <m/prefix/ ] [, ...]</tag>
393
	Set BIRD's router ID based on an IP address of an interface specified by
394
	an interface pattern. The option is applicable for IPv4 version only.
395
	See <ref id="dsc-iface" name="interface"> section for detailed
396
	description of interface patterns with extended clauses.
397

    
398
	<tag>listen bgp [address <m/address/] [port <m/port/] [dual]</tag>
399
	This option allows to specify address and port where BGP protocol should
400
	listen. It is global option as listening socket is common to all BGP
401
	instances. Default is to listen on all addresses (0.0.0.0) and port 179.
402
	In IPv6 mode, option <cf/dual/ can be used to specify that BGP socket
403
	should accept both IPv4 and IPv6 connections (but even in that case,
404
	BIRD would accept IPv6 routes only). Such behavior was default in older
405
	versions of BIRD.
406

    
407
	<tag>graceful restart wait <m/number/</tag>
408
	During graceful restart recovery, BIRD waits for convergence of routing
409
	protocols. This option allows to specify a timeout for the recovery to
410
	prevent waiting indefinitely if some protocols cannot converge. Default:
411
	240 seconds.
412

    
413
	<tag>timeformat route|protocol|base|log "<m/format1/" [<m/limit/ "<m/format2/"]</tag>
414
	This option allows to specify a format of date/time used by BIRD. The
415
	first argument specifies for which purpose such format is used.
416
	<cf/route/ is a format used in 'show route' command output,
417
	<cf/protocol/ is used in 'show protocols' command output, <cf/base/ is
418
	used for other commands and <cf/log/ is used in a log file.
419

    
420
	"<m/format1/" is a format string using <it/strftime(3)/ notation (see
421
	<it/man strftime/ for details). <m/limit> and "<m/format2/" allow to
422
	specify the second format string for times in past deeper than <m/limit/
423
 	seconds. There are few shorthands: <cf/iso long/ is a ISO 8601 date/time
424
	format (YYYY-MM-DD hh:mm:ss) that can be also specified using <cf/"%F %T"/.
425
	<cf/iso short/ is a variant of ISO 8601 that uses just the time format
426
	(hh:mm:ss) for near times (up to 20 hours in the past) and the date
427
	format (YYYY-MM-DD) for far times. This is a shorthand for
428
	<cf/"%T" 72000 "%F"/.
429

    
430
	By default, BIRD uses the <cf/iso short/ format for <cf/route/ and
431
	<cf/protocol/ times, and the <cf/iso long/ format for <cf/base/ and
432
	<cf/log/ times.
433

    
434
	In pre-1.4.0 versions, BIRD used an short, ad-hoc format for <cf/route/
435
	and <cf/protocol/ times, and a <cf/iso long/ similar format (DD-MM-YYYY
436
	hh:mm:ss) for <cf/base/ and <cf/log/. These timeformats could be set by
437
	<cf/old short/ and <cf/old long/ compatibility shorthands.
438

    
439
	<tag>table <m/name/ [sorted]</tag>
440
	Create a new routing table. The default routing table is created
441
	implicitly, other routing tables have to be added by this command.
442
	Option <cf/sorted/ can be used to enable sorting of routes, see
443
	<ref id="dsc-sorted" name="sorted table"> description for details.
444

    
445
	<tag>roa table <m/name/ [ { roa table options ... } ]</tag>
446
	Create a new ROA (Route Origin Authorization) table. ROA tables can be
447
	used to validate route origination of BGP routes. A ROA table contains
448
	ROA entries, each consist of a network prefix, a max prefix length and
449
	an AS number. A ROA entry specifies prefixes which could be originated
450
	by that AS number. ROA tables could be filled with data from RPKI (RFC
451
	6480) or from public databases like Whois. ROA tables are examined by
452
	<cf/roa_check()/ operator in filters.
453

    
454
	Currently, there is just one option, <cf>roa <m/prefix/ max <m/num/ as
455
	<m/num/</cf>, which can be used to populate the ROA table with static
456
	ROA entries. The option may be used multiple times. Other entries can be
457
	added dynamically by <cf/add roa/ command.
458

    
459
	<tag>eval <m/expr/</tag>
460
	Evaluates given filter expression. It is used by us for	testing of filters.
461
</descrip>
462

    
463

    
464
<sect>Protocol options
465

    
466
<p>For each protocol instance, you can configure a bunch of options. Some of
467
them (those described in this section) are generic, some are specific to the
468
protocol (see sections talking about the protocols).
469

    
470
<p>Several options use a <m/switch/ argument. It can be either <cf/on/,
471
<cf/yes/ or a numeric expression with a non-zero value for the option to be
472
enabled or <cf/off/, <cf/no/ or a numeric expression evaluating to zero to
473
disable it. An empty <m/switch/ is equivalent to <cf/on/ ("silence means
474
agreement").
475

    
476
<descrip>
477
	<tag>preference <m/expr/</tag>
478
	Sets the preference of routes generated by this protocol. Default:
479
	protocol dependent.
480

    
481
	<tag>disabled <m/switch/</tag>
482
	Disables the protocol. You can change the disable/enable status from the
483
	command line interface without needing to touch the configuration.
484
	Disabled protocols are not activated. Default: protocol is enabled.
485

    
486
	<tag>debug all|off|{ states, routes, filters, interfaces, events, packets }</tag>
487
	Set protocol debugging options. If asked, each protocol is capable of
488
	writing trace messages about its work to the log (with category
489
	<cf/trace/). You can either request printing of <cf/all/ trace messages
490
	or only of the types selected: <cf/states/ for protocol state changes
491
	(protocol going up, down, starting, stopping etc.), <cf/routes/ for
492
	routes exchanged with the routing table, <cf/filters/ for details on
493
	route filtering, <cf/interfaces/ for interface change events sent to the
494
	protocol, <cf/events/ for events internal to the protocol and <cf/packets/
495
	for packets sent and received by the protocol. Default: off.
496

    
497
	<tag>mrtdump all|off|{ states, messages }</tag>
498
	Set protocol MRTdump flags. MRTdump is a standard binary format for
499
	logging information from routing protocols and daemons. These flags
500
	control what kind of information is logged from the protocol to the
501
	MRTdump file (which must be specified by global <cf/mrtdump/ option, see
502
	the previous section). Although these flags are similar to flags of
503
	<cf/debug/ option, their meaning is different and protocol-specific. For
504
	BGP protocol, <cf/states/ logs BGP state changes and <cf/messages/ logs
505
	received BGP messages. Other protocols does not support MRTdump yet.
506

    
507
	<tag>router id <m/IPv4 address/</tag>
508
	This option can be used to override global router id for a given
509
	protocol. Default: uses global router id.
510

    
511
	<tag>import all | none | filter <m/name/ | filter { <m/filter commands/ } | where <m/filter expression/</tag>
512
	Specify a filter to be used for filtering routes coming from the
513
	protocol to the routing table. <cf/all/ is shorthand for <cf/where true/
514
	and <cf/none/ is shorthand for <cf/where false/. Default: <cf/all/.
515

    
516
	<tag>export <m/filter/</tag>
517
	This is similar to the <cf>import</cf> keyword, except that it works in
518
	the direction from the routing table to the protocol. Default: <cf/none/.
519

    
520
	<tag>import keep filtered <m/switch/</tag>
521
	Usually, if an import filter rejects a route, the route is forgotten.
522
	When this option is active, these routes are kept in the routing table,
523
	but they are hidden and not propagated to other protocols. But it is
524
	possible to show them using <cf/show route filtered/. Note that this
525
	option does not work for the pipe protocol. Default: off.
526

    
527
	<tag><label id="import-limit">import limit [<m/number/ | off ] [action warn | block | restart | disable]</tag>
528
	Specify an import route limit (a maximum number of routes imported from
529
	the protocol) and optionally the action to be taken when the limit is
530
	hit. Warn action just prints warning log message. Block action discards
531
	new routes coming from the protocol. Restart and disable actions shut
532
	the protocol down like appropriate commands. Disable is the default
533
	action if an action is not explicitly specified. Note that limits are
534
	reset during protocol reconfigure, reload or restart. Default: <cf/off/.
535

    
536
	<tag>receive limit [<m/number/ | off ] [action warn | block | restart | disable]</tag>
537
	Specify an receive route limit (a maximum number of routes received from
538
	the protocol and remembered). It works almost identically to <cf>import
539
	limit</cf> option, the only difference is that if <cf/import keep
540
	filtered/ option is active, filtered routes are counted towards the
541
	limit and blocked routes are forgotten, as the main purpose of the
542
	receive limit is to protect routing tables from overflow. Import limit,
543
	on the contrary, counts accepted routes only and routes blocked by the
544
	limit are handled like filtered routes. Default: <cf/off/.
545

    
546
	<tag>export limit [ <m/number/ | off ] [action warn | block | restart | disable]</tag>
547
	Specify an export route limit, works similarly to the <cf>import
548
	limit</cf> option, but for the routes exported to the protocol. This
549
	option is experimental, there are some problems in details of its
550
	behavior -- the number of exported routes can temporarily exceed the
551
	limit without triggering it during protocol reload, exported routes
552
	counter ignores route blocking and block action also blocks route
553
	updates of already accepted routes -- and these details will probably
554
	change in the future. Default: <cf/off/.
555

    
556
	<tag>description "<m/text/"</tag>
557
	This is an optional description of the protocol. It is displayed as a
558
	part of the output of 'show route all' command.
559

    
560
	<tag>table <m/name/</tag>
561
	Connect this protocol to a non-default routing table.
562
</descrip>
563

    
564
<p>There are several options that give sense only with certain protocols:
565

    
566
<descrip>
567
	<tag><label id="dsc-iface">interface [-] [ "<m/mask/" ] [ <m/prefix/ ] [, ...] [ { <m/option/ ; [...] } ]</tag>
568
	Specifies a set of interfaces on which the protocol is activated with
569
	given interface-specific options. A set of interfaces specified by one
570
	interface option is described using an interface pattern. The interface
571
	pattern consists of a sequence of clauses (separated by commas), each
572
	clause is a mask specified as a shell-like pattern. Interfaces are
573
	matched by their name.
574

    
575
	An interface matches the pattern if it matches any of its clauses. If
576
	the clause begins with <cf/-/, matching interfaces are excluded. Patterns
577
	are processed left-to-right, thus <cf/interface "eth0", -"eth*", "*";/
578
	means eth0 and all non-ethernets.
579

    
580
	Some protocols (namely OSPFv2 and Direct) support extended clauses that
581
	may contain a mask, a prefix, or both of them. An interface matches such
582
	clause if its name matches the mask (if specified) and its address
583
	matches the prefix (if specified). Extended clauses are used when the
584
	protocol handles multiple addresses on an interface independently.
585

    
586
	An interface option can be used more times with different interface-specific
587
	options, in that case for given interface the first matching interface
588
	option is used.
589

    
590
	This option is allowed in BFD, Direct, OSPF, RAdv and RIP protocols, but
591
	in OSPF protocol it is used in the <cf/area/ subsection.
592

    
593
	Default: none.
594

    
595
	Examples:
596

    
597
	<cf>interface "*" { type broadcast; };</cf> - start the protocol on all
598
	interfaces with <cf>type broadcast</cf> option.
599

    
600
	<cf>interface "eth1", "eth4", "eth5" { type ptp; };</cf> - start the
601
	protocol on enumerated interfaces with <cf>type ptp</cf> option.
602

    
603
	<cf>interface -192.168.1.0/24, 192.168.0.0/16;</cf> - start the protocol
604
	on all interfaces that have address from 192.168.0.0/16, but not from
605
	192.168.1.0/24.
606

    
607
	<cf>interface -192.168.1.0/24, 192.168.0.0/16;</cf> - start the protocol
608
	on all interfaces that have address from 192.168.0.0/16, but not from
609
	192.168.1.0/24.
610

    
611
	<cf>interface "eth*" 192.168.1.0/24;</cf> - start the protocol on all
612
	ethernet interfaces that have address from 192.168.1.0/24.
613

    
614
	<tag><label id="dsc-prio">tx class|dscp <m/num/</tag>
615
	This option specifies the value of ToS/DS/Class field in IP headers of
616
	the outgoing protocol packets. This may affect how the protocol packets
617
	are processed by the network relative to the other network traffic. With
618
	<cf/class/ keyword, the value (0-255) is used for the whole ToS/Class
619
	octet (but two bits reserved for ECN are ignored). With	<cf/dscp/
620
	keyword, the value (0-63) is used just for the DS field in the octet.
621
	Default value is 0xc0 (DSCP 0x30 - CS6).
622

    
623
	<tag>tx priority <m/num/</tag>
624
	This option specifies the local packet priority. This may affect how the
625
	protocol packets are processed in the local TX queues. This option is
626
	Linux specific. Default value is 7 (highest priority, privileged traffic).
627

    
628
	<tag><label id="dsc-pass">password "<m/password/" [ { id <m/num/; generate from <m/time/; generate to <m/time/; accept from <m/time/; accept to <m/time/; } ]</tag>
629
	Specifies a password that can be used by the protocol. Password option
630
	can be used more times to specify more passwords. If more passwords are
631
	specified, it is a protocol-dependent decision which one is really
632
	used. Specifying passwords does not mean that authentication is enabled,
633
	authentication can be enabled by separate, protocol-dependent
634
	<cf/authentication/ option.
635

    
636
	This option is allowed in OSPF and RIP protocols. BGP has also
637
	<cf/password/ option, but it is slightly different and described
638
	separately.
639

    
640
	Default: none.
641
</descrip>
642

    
643
<p>Password option can contain section with some (not necessary all) password sub-options:
644

    
645
<descrip>
646
	<tag>id <M>num</M></tag>
647
	ID of the password, (0-255). If it's not used, BIRD will choose ID based
648
	on an order of the password item in the interface. For example, second
649
	password item in one interface will have default ID 2. ID is used by
650
	some routing protocols to identify which password was used to
651
	authenticate protocol packets.
652

    
653
	<tag>generate from "<m/time/"</tag>
654
	The start time of the usage of the password for packet signing.
655
	The format of <cf><m/time/</cf> is <tt>dd-mm-yyyy HH:MM:SS</tt>.
656

    
657
	<tag>generate to "<m/time/"</tag>
658
	The last time of the usage of the password for packet signing.
659

    
660
	<tag>accept from "<m/time/"</tag>
661
	The start time of the usage of the password for packet verification.
662

    
663
	<tag>accept to "<m/time/"</tag>
664
	The last time of the usage of the password for packet verification.
665
</descrip>
666

    
667
<chapt>Remote control
668

    
669
<p>You can use the command-line client <file>birdc</file> to talk with a running
670
BIRD. Communication is done using a <file/bird.ctl/ UNIX domain socket (unless
671
changed with the <tt/-s/ option given to both the server and the client). The
672
commands can perform simple actions such as enabling/disabling of protocols,
673
telling BIRD to show various information, telling it to show routing table
674
filtered by filter, or asking BIRD to reconfigure. Press <tt/?/ at any time to
675
get online help. Option <tt/-r/ can be used to enable a restricted mode of BIRD
676
client, which allows just read-only commands (<cf/show .../). Option <tt/-v/ can
677
be passed to the client, to make it dump numeric return codes along with the
678
messages. You do not necessarily need to use <file/birdc/ to talk to BIRD, your
679
own applications could do that, too -- the format of communication between BIRD
680
and <file/birdc/ is stable (see the programmer's documentation).
681

    
682
<p>There is also lightweight variant of BIRD client called <file/birdcl/, which
683
does not support command line editing and history and has minimal dependencies.
684
This is useful for running BIRD in resource constrained environments, where
685
Readline library (required for regular BIRD client) is not available.
686

    
687
<p>Many commands have the <m/name/ of the protocol instance as an argument.
688
This argument can be omitted if there exists only a single instance.
689

    
690
<p>Here is a brief list of supported functions:
691

    
692
<descrip>
693
	<tag>show status</tag>
694
	Show router status, that is BIRD version, uptime and time from last
695
	reconfiguration.
696

    
697
	<tag>show protocols [all]</tag>
698
	Show list of protocol instances along with tables they are connected to
699
	and protocol status, possibly giving verbose information, if <cf/all/ is
700
	specified.
701

    
702
	<tag>show ospf interface [<m/name/] ["<m/interface/"]</tag>
703
	Show detailed information about OSPF interfaces.
704

    
705
	<tag>show ospf neighbors [<m/name/] ["<m/interface/"]</tag>
706
	Show a list of OSPF neighbors and a state of adjacency to them.
707

    
708
	<tag>show ospf state [all] [<m/name/]</tag>
709
	Show detailed information about OSPF areas based on a content of the
710
	link-state database. It shows network topology, stub networks,
711
	aggregated networks and routers from other areas and external routes.
712
	The command shows information about reachable network nodes, use option
713
	<cf/all/ to show information about all network nodes in the link-state
714
	database.
715

    
716
	<tag>show ospf topology [all] [<m/name/]</tag>
717
	Show a topology of OSPF areas based on a content of the link-state
718
	database. It is just a stripped-down version of 'show ospf state'.
719

    
720
	<tag>show ospf lsadb [global | area <m/id/ | link] [type <m/num/] [lsid <m/id/] [self | router <m/id/] [<m/name/] </tag>
721
	Show contents of an OSPF LSA database. Options could be used to filter
722
	entries.
723

    
724
	<tag>show static [<m/name/]</tag>
725
	Show detailed information about static routes.
726

    
727
	<tag>show bfd sessions [<m/name/]</tag>
728
	Show information about BFD sessions.
729

    
730
	<tag>show interfaces [summary]</tag>
731
	Show the list of interfaces. For each interface, print its type, state,
732
	MTU and addresses assigned.
733

    
734
	<tag>show symbols [table|filter|function|protocol|template|roa|<m/symbol/]</tag>
735
	Show the list of symbols defined in the configuration (names of
736
	protocols, routing tables etc.).
737

    
738
	<tag>show route [[for] <m/prefix/|<m/IP/] [table <m/sym/] [filter <m/f/|where <m/c/] [(export|preexport|noexport) <m/p/] [protocol <m/p/] [<m/options/]</tag>
739
	Show contents of a routing table (by default of the main one or the
740
	table attached to a respective protocol), that is routes, their metrics
741
	and (in case the <cf/all/ switch is given) all their attributes.
742

    
743
	<p>You can specify a <m/prefix/ if you want to print routes for a
744
	specific network. If you use <cf>for <m/prefix or IP/</cf>, you'll get
745
	the entry which will be used for forwarding of packets to the given
746
	destination. By default, all routes for each network are printed with
747
	the selected one at the top, unless <cf/primary/ is given in which case
748
	only the selected route is shown.
749

    
750
	<p>You can also ask for printing only routes processed and accepted by
751
	a given filter (<cf>filter <m/name/</cf> or <cf>filter { <m/filter/ }
752
	</cf> or matching a given condition (<cf>where <m/condition/</cf>).
753

    
754
	The <cf/export/, <cf/preexport/ and <cf/noexport/ switches ask for
755
	printing of routes that are exported to the specified protocol.
756
	With <cf/preexport/, the export filter of the protocol is skipped.
757
	With <cf/noexport/, routes rejected by the export filter are printed
758
	instead. Note that routes not exported to the protocol for other reasons
759
	(e.g. secondary routes or routes imported from that protocol) are not
760
	printed even with <cf/noexport/.
761

    
762
	<p>You can also select just routes added by a specific protocol.
763
	<cf>protocol <m/p/</cf>.
764

    
765
	<p>If BIRD is configured to keep filtered routes (see <cf/import keep
766
	filtered/ option), you can show them instead of routes by using
767
	<cf/filtered/ switch.
768

    
769
	<p>The <cf/stats/ switch requests showing of route statistics (the
770
	number of networks, number of routes before and after filtering). If
771
	you use <cf/count/ instead, only the statistics will be printed.
772

    
773
	<tag>show roa [<m/prefix/ | in <m/prefix/ | for <m/prefix/] [as <m/num/] [table <m/t/>]</tag>
774
	Show contents of a ROA table (by default of the first one). You can
775
	specify a <m/prefix/ to print ROA entries for a specific network. If you
776
	use <cf>for <m/prefix/</cf>, you'll get all entries relevant for route
777
	validation of the network prefix; i.e., ROA entries whose prefixes cover
778
	the network prefix. Or you can use <cf>in <m/prefix/</cf> to get ROA
779
	entries covered by the network prefix. You could also use <cf/as/ option
780
	to show just entries for given AS.
781

    
782
	<tag>add roa <m/prefix/ max <m/num/] as <m/num/ [table <m/t/>]</tag>
783
	Add a new ROA entry to a ROA table. Such entry is called <it/dynamic/
784
	compared to <it/static/ entries specified in the config file. These
785
	dynamic entries survive reconfiguration.
786

    
787
	<tag>delete roa <m/prefix/ max <m/num/] as <m/num/ [table <m/t/>]</tag>
788
	Delete the specified ROA entry from a ROA table. Only dynamic ROA
789
	entries (i.e., the ones added by <cf/add roa/ command) can be deleted.
790

    
791
	<tag>flush roa [table <m/t/>]</tag>
792
	Remove all dynamic ROA entries from a ROA table.
793

    
794
	<tag>configure [soft] ["<m/config file/"] [timeout [<m/num/]]</tag>
795
	Reload configuration from a given file. BIRD will smoothly switch itself
796
	to the new configuration, protocols are reconfigured if possible,
797
	restarted otherwise. Changes in filters usually lead to restart of
798
	affected protocols.
799

    
800
	If <cf/soft/ option is used, changes in filters does not cause BIRD to
801
	restart affected protocols, therefore already accepted routes (according
802
	to old filters) would be still propagated, but new routes would be
803
	processed according to the new filters.
804

    
805
	If <cf/timeout/ option is used, config timer is activated. The new
806
	configuration could be either confirmed using <cf/configure confirm/
807
	command, or it will be reverted to the old one when the config timer
808
	expires. This is useful for cases when reconfiguration breaks current
809
	routing and a router becames inaccessible for an administrator. The
810
	config timeout expiration is equivalent to <cf/configure undo/
811
	command. The timeout duration could be specified, default is 300 s.
812

    
813
	<tag>configure confirm</tag>
814
	Deactivate the config undo timer and therefore confirm the current
815
	configuration.
816

    
817
	<tag>configure undo</tag>
818
	Undo the last configuration change and smoothly switch back to the
819
	previous (stored) configuration. If the last configuration change was
820
	soft, the undo change is also soft. There is only one level of undo, but
821
	in some specific cases when several reconfiguration requests are given
822
	immediately in a row and the intermediate ones are skipped then the undo
823
	also skips them back.
824

    
825
	<tag>configure check ["<m/config file/"]</tag>
826
	Read and parse given config file, but do not use it. useful for checking
827
	syntactic and some semantic validity of an config file.
828

    
829
	<tag>enable|disable|restart <m/name/|"<m/pattern/"|all</tag>
830
	Enable, disable or restart a given protocol instance, instances matching
831
	the <cf><m/pattern/</cf> or <cf/all/ instances.
832

    
833
	<tag>reload [in|out] <m/name/|"<m/pattern/"|all</tag>
834
	Reload a given protocol instance, that means re-import routes from the
835
	protocol instance and re-export preferred routes to the instance. If
836
	<cf/in/ or <cf/out/ options are used, the command is restricted to one
837
	direction (re-import or re-export).
838

    
839
	This command is useful if appropriate filters have changed but the
840
	protocol instance was not restarted (or reloaded), therefore it still
841
	propagates the old set of routes. For example when <cf/configure soft/
842
	command was used to change filters.
843

    
844
	Re-export always succeeds, but re-import is protocol-dependent and might
845
	fail (for example, if BGP neighbor does not support route-refresh
846
	extension). In that case, re-export is also skipped. Note that for the
847
	pipe protocol, both directions are always reloaded together (<cf/in/ or
848
	<cf/out/ options are ignored in that case).
849

    
850
	<tag/down/
851
	Shut BIRD down.
852

    
853
	<tag>debug <m/protocol/|<m/pattern/|all all|off|{ states | routes | filters | events | packets }</tag>
854
	Control protocol debugging.
855

    
856
	<tag>dump resources|sockets|interfaces|neighbors|attributes|routes|protocols</tag>
857
	Dump contents of internal data structures to the debugging output.
858

    
859
	<tag>echo all|off|{ <m/list of log classes/ } [ <m/buffer-size/ ]</tag>
860
	Control echoing of log messages to the command-line output.
861
	See <ref id="dsc-log" name="log option"> for a list of log classes.
862

    
863
	<tag>eval <m/expr/</tag>
864
	Evaluate given expression.
865
</descrip>
866

    
867

    
868
<chapt>Filters
869

    
870
<sect>Introduction
871

    
872
<p>BIRD contains a simple programming language. (No, it can't yet read mail :-).
873
There are two objects in this language: filters and functions. Filters are
874
interpreted by BIRD core when a route is being passed between protocols and
875
routing tables. The filter language contains control structures such as if's and
876
switches, but it allows no loops. An example of a filter using many features can
877
be found in <file>filter/test.conf</file>.
878

    
879
<p>Filter gets the route, looks at its attributes and modifies some of them if
880
it wishes. At the end, it decides whether to pass the changed route through
881
(using <cf/accept/) or whether to <cf/reject/ it. A simple filter looks like
882
this:
883

    
884
<code>
885
filter not_too_far
886
int var;
887
{
888
	if defined( rip_metric ) then
889
		var = rip_metric;
890
	else {
891
		var = 1;
892
		rip_metric = 1;
893
	}
894
	if rip_metric &gt; 10 then
895
		reject "RIP metric is too big";
896
	else
897
		accept "ok";
898
}
899
</code>
900

    
901
<p>As you can see, a filter has a header, a list of local variables, and a body.
902
The header consists of the <cf/filter/ keyword followed by a (unique) name of
903
filter. The list of local variables consists of <cf><M>type name</M>;</cf>
904
pairs where each pair defines one local variable. The body consists of <cf>
905
{ <M>statements</M> }</cf>. Each <m/statement/ is terminated by a <cf/;/. You
906
can group several statements to a single compound statement by using braces
907
(<cf>{ <M>statements</M> }</cf>) which is useful if you want to make a bigger
908
block of code conditional.
909

    
910
<p>BIRD supports functions, so that you don't have to repeat the same blocks of
911
code over and over. Functions can have zero or more parameters and they can have
912
local variables. Recursion is not allowed. Function definitions look like this:
913

    
914
<code>
915
function name ()
916
int local_variable;
917
{
918
	local_variable = 5;
919
}
920

    
921
function with_parameters (int parameter)
922
{
923
	print parameter;
924
}
925
</code>
926

    
927
<p>Unlike in C, variables are declared after the <cf/function/ line, but before
928
the first <cf/{/. You can't declare variables in nested blocks. Functions are
929
called like in C: <cf>name(); with_parameters(5);</cf>. Function may return
930
values using the <cf>return <m/[expr]/</cf> command. Returning a value exits
931
from current function (this is similar to C).
932

    
933
<p>Filters are declared in a way similar to functions except they can't have
934
explicit parameters. They get a route table entry as an implicit parameter, it
935
is also passed automatically to any functions called. The filter must terminate
936
with either <cf/accept/ or <cf/reject/ statement. If there's a runtime error in
937
filter, the route is rejected.
938

    
939
<p>A nice trick to debug filters is to use <cf>show route filter <m/name/</cf>
940
from the command line client. An example session might look like:
941

    
942
<code>
943
pavel@bug:~/bird$ ./birdc -s bird.ctl
944
BIRD 0.0.0 ready.
945
bird> show route
946
10.0.0.0/8         dev eth0 [direct1 23:21] (240)
947
195.113.30.2/32    dev tunl1 [direct1 23:21] (240)
948
127.0.0.0/8        dev lo [direct1 23:21] (240)
949
bird> show route ?
950
show route [<prefix>] [table <t>] [filter <f>] [all] [primary]...
951
bird> show route filter { if 127.0.0.5 &tilde; net then accept; }
952
127.0.0.0/8        dev lo [direct1 23:21] (240)
953
bird>
954
</code>
955

    
956

    
957
<sect>Data types
958

    
959
<p>Each variable and each value has certain type. Booleans, integers and enums
960
are incompatible with each other (that is to prevent you from shooting in the
961
foot).
962

    
963
<descrip>
964
	<tag/bool/
965
	This is a boolean type, it can have only two values, <cf/true/ and
966
	<cf/false/. Boolean is the only type you can use in <cf/if/ statements.
967

    
968
	<tag/int/
969
	This is a general integer type. It is an unsigned 32bit type; i.e., you
970
	can expect it to store values from 0 to 4294967295. Overflows are not
971
	checked. You can use <cf/0x1234/ syntax to write hexadecimal values.
972

    
973
	<tag/pair/
974
	This is a pair of two short integers. Each component can have values
975
	from 0 to 65535. Literals of this type are written as <cf/(1234,5678)/.
976
	The same syntax can also be used to construct a pair from two arbitrary
977
	integer expressions (for example <cf/(1+2,a)/).
978

    
979
	<tag/quad/
980
	This is a dotted quad of numbers used to represent router IDs (and
981
	others). Each component can have a value from 0 to 255. Literals of
982
	this type are written like IPv4 addresses.
983

    
984
	<tag/string/
985
	This is a string of characters. There are no ways to modify strings in
986
	filters. You can pass them between functions, assign them to variables
987
	of type <cf/string/, print such variables, use standard string
988
	comparison operations (e.g. <cf/=, !=, &lt;, &gt;, &lt;=, &gt;=/), but
989
	you can't concatenate two strings. String literals are written as
990
	<cf/"This is a string constant"/. Additionaly matching <cf/&tilde;/
991
	operator could be used to match a string value against a shell pattern
992
	(represented also as a string).
993

    
994
	<tag/ip/
995
	This type can hold a single IP address. Depending on the compile-time
996
	configuration of BIRD you are using, it is either an IPv4 or IPv6
997
	address. IP addresses are written in the standard notation
998
	(<cf/10.20.30.40/ or <cf/fec0:3:4::1/). You can apply special operator
999
	<cf>.mask(<M>num</M>)</cf> on values of type ip. It masks out all but
1000
	first <cf><M>num</M></cf> bits from the IP address. So
1001
	<cf/1.2.3.4.mask(8) = 1.0.0.0/ is true.
1002

    
1003
	<tag/prefix/
1004
	This type can hold a network prefix consisting of IP address and prefix
1005
	length. Prefix literals are written as <cf><m/ipaddress//<m/pxlen/</cf>,
1006
	or <cf><m>ipaddress</m>/<m>netmask</m></cf>. There are two special
1007
	operators on prefixes: <cf/.ip/ which extracts the IP address from the
1008
	pair, and <cf/.len/, which separates prefix length from the pair.
1009
	So <cf>1.2.0.0/16.pxlen = 16</cf> is true.
1010

    
1011
	<tag/ec/
1012
	This is a specialized type used to represent BGP extended community
1013
	values. It is essentially a 64bit value, literals of this type are
1014
	usually written as <cf>(<m/kind/, <m/key/, <m/value/)</cf>, where
1015
	<cf/kind/ is a kind of extended community (e.g. <cf/rt/ / <cf/ro/ for a
1016
	route target / route origin communities), the format and possible values
1017
	of <cf/key/ and <cf/value/ are usually integers, but it depends on the
1018
	used kind. Similarly to pairs, ECs can be constructed using expressions
1019
	for <cf/key/ and <cf/value/ parts, (e.g. <cf/(ro, myas, 3*10)/, where
1020
	<cf/myas/ is an integer variable).
1021

    
1022
	<tag/int|pair|quad|ip|prefix|ec|enum set/
1023
	Filters recognize four types of sets. Sets are similar to strings: you
1024
	can pass them around but you can't modify them. Literals of type <cf>int
1025
	set</cf> look like <cf> [ 1, 2, 5..7 ]</cf>. As you can see, both simple
1026
	values and ranges are permitted in sets.
1027

    
1028
	For pair sets, expressions like <cf/(123,*)/ can be used to denote
1029
	ranges (in that case <cf/(123,0)..(123,65535)/). You can also use
1030
	<cf/(123,5..100)/ for range <cf/(123,5)..(123,100)/. You can also use
1031
	<cf/*/ and <cf/a..b/ expressions in the first part of a pair, note that
1032
	such expressions are translated to a set of intervals, which may be
1033
	memory intensive. E.g. <cf/(*,4..20)/ is translated to <cf/(0,4..20),
1034
	(1,4..20), (2,4..20), ... (65535, 4..20)/.
1035

    
1036
	EC sets use similar expressions like pair sets, e.g. <cf/(rt, 123,
1037
	10..20)/ or <cf/(ro, 123, *)/. Expressions requiring the translation
1038
	(like <cf/(rt, *, 3)/) are not allowed (as they usually have 4B range
1039
	for ASNs).
1040

    
1041
	You can also use expressions for int, pair and EC set values. However it
1042
	must be possible to evaluate these expressions before daemon boots. So
1043
	you can use only constants inside them. E.g.
1044

    
1045
	<code>
1046
	 define one=1;
1047
	 define myas=64500;
1048
	 int set odds;
1049
	 pair set ps;
1050
	 ec set es;
1051

    
1052
	 odds = [ one, 2+1, 6-one, 2*2*2-1, 9, 11 ];
1053
	 ps = [ (1,one+one), (3,4)..(4,8), (5,*), (6,3..6), (7..9,*) ];
1054
	 es = [ (rt, myas, 3*10), (rt, myas+one, 0..16*16*16-1), (ro, myas+2, *) ];
1055
	</code>
1056

    
1057
	Sets of prefixes are special: their literals does not allow ranges, but
1058
	allows prefix patterns that are written
1059
	as <cf><M>ipaddress</M>/<M>pxlen</M>{<M>low</M>,<M>high</M>}</cf>.
1060
	Prefix <cf><m>ip1</m>/<m>len1</m></cf> matches prefix
1061
	pattern <cf><m>ip2</m>/<m>len2</m>{<m>l</m>,<m>h</m>}</cf> if the
1062
	first <cf>min(len1, len2)</cf> bits of <cf/ip1/ and <cf/ip2/ are
1063
	identical and <cf>len1 &lt;= ip1 &lt;= len2</cf>. A valid prefix pattern
1064
	has to satisfy <cf>low &lt;= high</cf>, but <cf/pxlen/ is not
1065
	constrained by <cf/low/ or <cf/high/. Obviously, a prefix matches a
1066
	prefix set literal if it matches any prefix pattern in the prefix set
1067
	literal.
1068

    
1069
	There are also two shorthands for prefix patterns: <cf><m/address//<m/len/+</cf>
1070
	is a shorthand for <cf><m/address//<m/len/{<m/len/,<m/maxlen/}</cf>
1071
	(where <cf><m/maxlen/</cf> is 32 for IPv4 and 128 for IPv6), that means
1072
	network prefix <cf><m/address//<m/len/</cf> and all its	subnets.
1073
	<cf><m/address//<m/len/-</cf> is a shorthand for
1074
	<cf><m/address//<m/len/{0,<m/len/}</cf>, that means network prefix
1075
	<cf><m/address//<m/len/</cf> and all its supernets (network prefixes
1076
	that contain it).
1077

    
1078
	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}
1079
	]</cf> matches prefix <cf>1.0.0.0/8</cf>, all subprefixes of
1080
	<cf>2.0.0.0/8</cf>, all superprefixes of <cf>3.0.0.0/8</cf> and prefixes
1081
	<cf/4.X.X.X/ whose prefix length is 16 to 24. <cf>[ 0.0.0.0/0{20,24} ]</cf>
1082
	matches all prefixes (regardless of IP address) whose prefix length is
1083
	20 to 24, <cf>[ 1.2.3.4/32- ]</cf> matches any prefix that contains IP
1084
	address <cf>1.2.3.4</cf>. <cf>1.2.0.0/16 &tilde; [ 1.0.0.0/8{15,17} ]</cf>
1085
	is true, but <cf>1.0.0.0/16 &tilde; [ 1.0.0.0/8- ]</cf> is false.
1086

    
1087
	Cisco-style patterns like <cf>10.0.0.0/8 ge 16 le 24</cf> can be expressed
1088
	in BIRD as <cf>10.0.0.0/8{16,24}</cf>, <cf>192.168.0.0/16 le 24</cf> as
1089
	<cf>192.168.0.0/16{16,24}</cf> and <cf>192.168.0.0/16 ge 24</cf> as
1090
	<cf>192.168.0.0/16{24,32}</cf>.
1091

    
1092
	<tag/enum/
1093
	Enumeration types are fixed sets of possibilities. You can't define your
1094
	own variables of such type, but some route attributes are of enumeration
1095
	type. Enumeration types are incompatible with each other.
1096

    
1097
	<tag/bgppath/
1098
	BGP path is a list of autonomous system numbers. You can't write
1099
	literals of this type. There are several special operators on bgppaths:
1100

    
1101
	<cf><m/P/.first</cf> returns the first ASN (the neighbor ASN) in path <m/P/.
1102

    
1103
	<cf><m/P/.last</cf> returns the last ASN (the source ASN) in path <m/P/.
1104

    
1105
	Both <cf/first/ and <cf/last/ return zero if there is no appropriate
1106
	ASN, for example if the path contains an AS set element as the first (or
1107
	the last) part.
1108

    
1109
	<cf><m/P/.len</cf> returns the length of path <m/P/.
1110

    
1111
	<cf>prepend(<m/P/,<m/A/)</cf> prepends ASN <m/A/ to path <m/P/ and
1112
	returns the result.
1113

    
1114
	<cf>delete(<m/P/,<m/A/)</cf> deletes all instances of ASN <m/A/ from
1115
	from path <m/P/ and returns the result. <m/A/ may also be an integer
1116
	set, in that case the operator deletes all ASNs from path <m/P/ that are
1117
	also members of set <m/A/.
1118

    
1119
	<cf>filter(<m/P/,<m/A/)</cf> deletes all ASNs from path <m/P/ that are
1120
	not members of integer set <m/A/. I.e., <cf/filter/ do the same as
1121
	<cf/delete/ with inverted set <m/A/.
1122

    
1123
	Statement <cf><m/P/ = prepend(<m/P/, <m/A/);</cf> can be shortened to
1124
	<cf><m/P/.prepend(<m/A/);</cf> if <m/P/ is appropriate route attribute
1125
	(for example <cf/bgp_path/). Similarly for <cf/delete/ and <cf/filter/.
1126

    
1127
	<tag/bgpmask/
1128
	BGP masks are patterns used for BGP path matching (using <cf>path
1129
	&tilde; [= 2 3 5 * =]</cf> syntax). The masks resemble wildcard patterns
1130
	as used by UNIX shells. Autonomous system numbers match themselves,
1131
	<cf/*/ matches any (even empty) sequence of arbitrary AS numbers and
1132
	<cf/?/ matches one arbitrary AS number. For example, if <cf>bgp_path</cf>
1133
 	is 4 3 2 1, then: <tt>bgp_path &tilde; [= * 4 3 * =]</tt> is true,
1134
	but <tt>bgp_path &tilde; [= * 4 5 * =]</tt> is false. BGP mask
1135
	expressions can also contain integer expressions enclosed in parenthesis
1136
	and integer variables, for example <tt>[= * 4 (1+2) a =]</tt>. There is
1137
	also old syntax that uses / .. / instead of [= .. =] and ? instead of *.
1138

    
1139
	<tag/clist/
1140
	Clist is similar to a set, except that unlike other sets, it can be
1141
	modified. The type is used for community list (a set of pairs) and for
1142
	cluster list (a set of quads). There exist no literals of this type.
1143
	There are three special operators on clists:
1144

    
1145
	<cf><m/C/.len</cf> returns the length of clist <m/C/.
1146

    
1147
	<cf>add(<m/C/,<m/P/)</cf> adds pair (or quad) <m/P/ to clist <m/C/ and
1148
	returns the result. If item <m/P/ is already in clist <m/C/, it does
1149
	nothing. <m/P/ may also be a clist, in that case all its members are
1150
	added; i.e., it works as clist union.
1151

    
1152
	<cf>delete(<m/C/,<m/P/)</cf> deletes pair (or quad) <m/P/ from clist
1153
	<m/C/ and returns the result. If clist <m/C/ does not contain item
1154
	<m/P/, it does nothing. <m/P/ may also be a pair (or quad) set, in that
1155
	case the operator deletes all items from clist <m/C/ that are also
1156
	members of set <m/P/. Moreover, <m/P/ may also be a clist, which works
1157
	analogously; i.e., it works as clist difference.
1158

    
1159
	<cf>filter(<m/C/,<m/P/)</cf> deletes all items from clist <m/C/ that are
1160
	not members of pair (or quad) set <m/P/. I.e., <cf/filter/ do the same
1161
	as <cf/delete/ with inverted set <m/P/. <m/P/ may also be a clist, which
1162
	works analogously; i.e., it works as clist intersection.
1163

    
1164
	Statement <cf><m/C/ = add(<m/C/, <m/P/);</cf> can be shortened to
1165
	<cf><m/C/.add(<m/P/);</cf> if <m/C/ is appropriate route attribute (for
1166
	example <cf/bgp_community/). Similarly for <cf/delete/ and <cf/filter/.
1167

    
1168
	<tag/eclist/
1169
	Eclist is a data type used for BGP extended community lists. Eclists
1170
	are very similar to clists, but they are sets of ECs instead of pairs.
1171
	The same operations (like <cf/add/, <cf/delete/, or <cf/&tilde;/
1172
	membership operator) can be used to modify or test eclists, with ECs
1173
	instead of pairs as arguments.
1174
</descrip>
1175

    
1176

    
1177
<sect>Operators
1178

    
1179
<p>The filter language supports common integer operators <cf>(+,-,*,/)</cf>,
1180
parentheses <cf/(a*(b+c))/, comparison <cf/(a=b, a!=b, a&lt;b, a&gt;=b)/.
1181
Logical operations include unary not (<cf/!/), and (<cf/&amp;&amp;/) and or
1182
(<cf/&verbar;&verbar;/). Special operators include <cf/&tilde;/ for "is element
1183
of a set" operation - it can be used on element and set of elements of the same
1184
type (returning true if element is contained in the given set), or on two
1185
strings (returning true if first string matches a shell-like pattern stored in
1186
second string) or on IP and prefix (returning true if IP is within the range
1187
defined by that prefix), or on prefix and prefix (returning true if first prefix
1188
is more specific than second one) or on bgppath and bgpmask (returning true if
1189
the path matches the mask) or on number and bgppath (returning true if the
1190
number is in the path) or on bgppath and int (number) set (returning true if any
1191
ASN from the path is in the set) or on pair/quad and clist (returning true if
1192
the pair/quad is element of the clist) or on clist and pair/quad set (returning
1193
true if there is an element of the clist that is also a member of the pair/quad
1194
set).
1195

    
1196
<p>There is one operator related to ROA infrastructure - <cf/roa_check()/. It
1197
examines a ROA table and does RFC 6483 route origin validation for a given
1198
network prefix. The basic usage is <cf>roa_check(<m/table/)</cf>, which checks
1199
current route (which should be from BGP to have AS_PATH argument) in the
1200
specified ROA table and returns ROA_UNKNOWN if there is no relevant ROA,
1201
ROA_VALID if there is a matching ROA, or ROA_INVALID if there are some relevant
1202
ROAs but none of them match. There is also an extended variant
1203
<cf>roa_check(<m/table/, <m/prefix/, <m/asn/)</cf>, which allows to specify a
1204
prefix and an ASN as arguments.
1205

    
1206

    
1207
<sect>Control structures
1208

    
1209
<p>Filters support two control structures: conditions and case switches.
1210

    
1211
<p>Syntax of a condition is: <cf>if <M>boolean expression</M> then <m/command1/;
1212
else <m/command2/;</cf> and you can use <cf>{ <m/command_1/; <m/command_2/;
1213
<M>...</M> }</cf> instead of either command. The <cf>else</cf> clause may be
1214
omitted. If the <cf><m>boolean expression</m></cf> is true, <m/command1/ is
1215
executed, otherwise <m/command2/ is executed.
1216

    
1217
<p>The <cf>case</cf> is similar to case from Pascal. Syntax is <cf>case
1218
<m/expr/ { else: | <m/num_or_prefix [ .. num_or_prefix]/: <m/statement/ ; [
1219
... ] }</cf>. The expression after <cf>case</cf> can be of any type which can be
1220
on the left side of the &tilde; operator and anything that could be a member of
1221
a set is allowed before <cf/:/. Multiple commands are allowed without <cf/{}/
1222
grouping. If <cf><m/expr/</cf> matches one of the <cf/:/ clauses, statements
1223
between it and next <cf/:/ statement are executed. If <cf><m/expr/</cf> matches
1224
neither of the <cf/:/ clauses, the statements after <cf/else:/ are executed.
1225

    
1226
<p>Here is example that uses <cf/if/ and <cf/case/ structures:
1227

    
1228
<code>
1229
case arg1 {
1230
	2: print "two"; print "I can do more commands without {}";
1231
	3 .. 5: print "three to five";
1232
	else: print "something else";
1233
}
1234

    
1235
if 1234 = i then printn "."; else {
1236
  print "not 1234";
1237
  print "You need {} around multiple commands";
1238
}
1239
</code>
1240

    
1241

    
1242
<sect>Route attributes
1243

    
1244
<p>A filter is implicitly passed a route, and it can access its attributes just
1245
like it accesses variables. Attempts to access undefined attribute result in a
1246
runtime error; you can check if an attribute is defined by using the
1247
<cf>defined( <m>attribute</m> )</cf> operator. One notable exception to this
1248
rule are attributes of clist type, where undefined value is regarded as empty
1249
clist for most purposes.
1250

    
1251
<descrip>
1252
	<tag><m/prefix/ net</tag>
1253
	Network the route is talking about. Read-only. (See the chapter about
1254
	routing tables.)
1255

    
1256
	<tag><m/enum/ scope</tag>
1257
	The scope of the route. Possible values: <cf/SCOPE_HOST/ for routes
1258
	local to this host, <cf/SCOPE_LINK/ for those specific for a physical
1259
	link, <cf/SCOPE_SITE/ and <cf/SCOPE_ORGANIZATION/ for private routes and
1260
	<cf/SCOPE_UNIVERSE/ for globally visible routes. This attribute is not
1261
	interpreted by BIRD and can be used to mark routes in filters. The
1262
	default value for new routes is <cf/SCOPE_UNIVERSE/.
1263

    
1264
	<tag><m/int/ preference</tag>
1265
	Preference of the route. Valid values are 0-65535. (See the chapter
1266
	about routing tables.)
1267

    
1268
	<tag><m/ip/ from</tag>
1269
	The router which the route has originated from.
1270

    
1271
	<tag><m/ip/ gw</tag>
1272
	Next hop packets routed using this route should be forwarded to.
1273

    
1274
	<tag><m/string/ proto</tag>
1275
	The name of the protocol which the route has been imported from.
1276
	Read-only.
1277

    
1278
	<tag><m/enum/ source</tag>
1279
	what protocol has told me about this route. Possible values:
1280
	<cf/RTS_DUMMY/, <cf/RTS_STATIC/, <cf/RTS_INHERIT/, <cf/RTS_DEVICE/,
1281
	<cf/RTS_STATIC_DEVICE/, <cf/RTS_REDIRECT/, <cf/RTS_RIP/, <cf/RTS_OSPF/,
1282
	<cf/RTS_OSPF_IA/, <cf/RTS_OSPF_EXT1/, <cf/RTS_OSPF_EXT2/, <cf/RTS_BGP/,
1283
	<cf/RTS_PIPE/.
1284

    
1285
	<tag><m/enum/ cast</tag>
1286
	Route type (Currently <cf/RTC_UNICAST/ for normal routes,
1287
	<cf/RTC_BROADCAST/, <cf/RTC_MULTICAST/, <cf/RTC_ANYCAST/ will be used in
1288
	the future for broadcast, multicast and anycast routes). Read-only.
1289

    
1290
	<tag><m/enum/ dest</tag>
1291
	Type of destination the packets should be sent to
1292
	(<cf/RTD_ROUTER/ for forwarding to a neighboring router,
1293
	<cf/RTD_DEVICE/ for routing to a directly-connected network,
1294
	<cf/RTD_MULTIPATH/ for multipath destinations,
1295
	<cf/RTD_BLACKHOLE/ for packets to be silently discarded,
1296
	<cf/RTD_UNREACHABLE/, <cf/RTD_PROHIBIT/ for packets that should be
1297
	returned with ICMP host unreachable / ICMP administratively prohibited
1298
	messages). Can be changed, but only to <cf/RTD_BLACKHOLE/,
1299
	<cf/RTD_UNREACHABLE/ or <cf/RTD_PROHIBIT/.
1300

    
1301
	<tag><m/string/ ifname</tag>
1302
	Name of the outgoing interface. Sink routes (like blackhole, unreachable
1303
	or prohibit) and multipath routes have no interface associated with
1304
	them, so <cf/ifname/ returns an empty string for such routes. Read-only.
1305

    
1306
	<tag><m/int/ ifindex</tag>
1307
	Index of the outgoing interface. System wide index of the interface. May
1308
	be used for interface matching, however indexes might change on interface
1309
	creation/removal. Zero is returned for routes with undefined outgoing
1310
	interfaces. Read-only.
1311

    
1312
	<tag><m/int/ igp_metric</tag>
1313
	The optional attribute that can be used to specify a distance to the
1314
	network for routes that do not have a native protocol metric attribute
1315
	(like <cf/ospf_metric1/ for OSPF routes). It is used mainly by BGP to
1316
	compare internal distances to boundary routers (see below). It is also
1317
	used when the route is exported to OSPF as a default value for OSPF type
1318
	1 metric.
1319
</descrip>
1320

    
1321
<p>There also exist some protocol-specific attributes which are described in the
1322
corresponding protocol sections.
1323

    
1324

    
1325
<sect>Other statements
1326

    
1327
<p>The following statements are available:
1328

    
1329
<descrip>
1330
	<tag><m/variable/ = <m/expr/</tag>
1331
	Set variable to a given value.
1332

    
1333
	<tag>accept|reject [ <m/expr/ ]</tag>
1334
	Accept or reject the route, possibly printing <cf><m>expr</m></cf>.
1335

    
1336
	<tag>return <m/expr/</tag>
1337
	Return <cf><m>expr</m></cf> from the current function, the function ends
1338
	at this point.
1339

    
1340
	<tag>print|printn <m/expr/ [<m/, expr.../]</tag>
1341
	Prints given expressions; useful mainly while debugging filters. The
1342
	<cf/printn/ variant does not terminate the line.
1343

    
1344
	<tag>quitbird</tag>
1345
	Terminates BIRD. Useful when debugging the filter interpreter.
1346
</descrip>
1347

    
1348

    
1349
<chapt>Protocols
1350

    
1351
<sect><label id="sect-bfd">BFD
1352

    
1353
<sect1>Introduction
1354

    
1355
<p>Bidirectional Forwarding Detection (BFD) is not a routing protocol itself, it
1356
is an independent tool providing liveness and failure detection. Routing
1357
protocols like OSPF and BGP use integrated periodic "hello" messages to monitor
1358
liveness of neighbors, but detection times of these mechanisms are high (e.g. 40
1359
seconds by default in OSPF, could be set down to several seconds). BFD offers
1360
universal, fast and low-overhead mechanism for failure detection, which could be
1361
attached to any routing protocol in an advisory role.
1362

    
1363
<p>BFD consists of mostly independent BFD sessions. Each session monitors an
1364
unicast bidirectional path between two BFD-enabled routers. This is done by
1365
periodically sending control packets in both directions. BFD does not handle
1366
neighbor discovery, BFD sessions are created on demand by request of other
1367
protocols (like OSPF or BGP), which supply appropriate information like IP
1368
addresses and associated interfaces. When a session changes its state, these
1369
protocols are notified and act accordingly (e.g. break an OSPF adjacency when
1370
the BFD session went down).
1371

    
1372
<p>BIRD implements basic BFD behavior as defined in
1373
RFC 5880<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc5880.txt">
1374
(some advanced features like the echo mode or authentication are not implemented),
1375
IP transport for BFD as defined in
1376
RFC 5881<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc5881.txt"> and
1377
RFC 5883<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc5883.txt">
1378
and interaction with client protocols as defined in
1379
RFC 5882<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc5882.txt">.
1380

    
1381
<p>Note that BFD implementation in BIRD is currently a new feature in
1382
development, expect some rough edges and possible UI and configuration changes
1383
in the future. Also note that we currently support at most one protocol instance.
1384

    
1385
<p>BFD packets are sent with a dynamic source port number. Linux systems use by
1386
default a bit different dynamic port range than the IANA approved one
1387
(49152-65535). If you experience problems with compatibility, please adjust
1388
<cf>/proc/sys/net/ipv4/ip_local_port_range</cf>
1389

    
1390
<sect1>Configuration
1391

    
1392
<p>BFD configuration consists mainly of multiple definitions of interfaces.
1393
Most BFD config options are session specific. When a new session is requested
1394
and dynamically created, it is configured from one of these definitions. For
1395
sessions to directly connected neighbors, <cf/interface/ definitions are chosen
1396
based on the interface associated with the session, while <cf/multihop/
1397
definition is used for multihop sessions. If no definition is relevant, the
1398
session is just created with the default configuration. Therefore, an empty BFD
1399
configuration is often sufficient.
1400

    
1401
<p>Note that to use BFD for other protocols like OSPF or BGP, these protocols
1402
also have to be configured to request BFD sessions, usually by <cf/bfd/ option.
1403

    
1404
<p>Some of BFD session options require <m/time/ value, which has to be specified
1405
with the appropriate unit: <m/num/ <cf/s/|<cf/ms/|<cf/us/. Although microseconds
1406
are allowed as units, practical minimum values are usually in order of tens of
1407
milliseconds.
1408

    
1409
<code>
1410
protocol bfd [&lt;name&gt;] {
1411
	interface &lt;interface pattern&gt; {
1412
		interval &lt;time&gt;;
1413
		min rx interval &lt;time&gt;;
1414
		min tx interval &lt;time&gt;;
1415
		idle tx interval &lt;time&gt;;
1416
		multiplier &lt;num&gt;;
1417
		passive &lt;switch&gt;;
1418
	};
1419
	multihop {
1420
		interval &lt;time&gt;;
1421
		min rx interval &lt;time&gt;;
1422
		min tx interval &lt;time&gt;;
1423
		idle tx interval &lt;time&gt;;
1424
		multiplier &lt;num&gt;;
1425
		passive &lt;switch&gt;;
1426
	};
1427
	neighbor &lt;ip&gt; [dev "&lt;interface&gt;"] [local &lt;ip&gt;] [multihop &lt;switch&gt;];
1428
}
1429
</code>
1430

    
1431
<descrip>
1432
	<tag>interface <m/pattern [, ...]/ { <m/options/ }</tag>
1433
	Interface definitions allow to specify options for sessions associated
1434
	with such interfaces and also may contain interface specific options.
1435
	See <ref id="dsc-iface" name="interface"> common option for a detailed
1436
	description of interface patterns. Note that contrary to the behavior of
1437
	<cf/interface/ definitions of other protocols, BFD protocol would accept
1438
	sessions (in default configuration) even on interfaces not covered by
1439
	such definitions.
1440

    
1441
	<tag>multihop { <m/options/ }</tag>
1442
	Multihop definitions allow to specify options for multihop BFD sessions,
1443
	in the same manner as <cf/interface/ definitions are used for directly
1444
	connected sessions. Currently only one such definition (for all multihop
1445
	sessions) could be used.
1446

    
1447
	<tag>neighbor <m/ip/ [dev "<m/interface/"] [local <m/ip/] [multihop <m/switch/]</tag>
1448
	BFD sessions are usually created on demand as requested by other
1449
	protocols (like OSPF or BGP). This option allows to explicitly add
1450
	a BFD session to the specified neighbor regardless of such requests.
1451

    
1452
	The session is identified by the IP address of the neighbor, with
1453
	optional specification of used interface and local IP. By default
1454
	the neighbor must be directly connected, unless the the session is
1455
	configured as multihop. Note that local IP must be specified for
1456
	multihop sessions.
1457
</descrip>
1458

    
1459
<p>Session specific options (part of <cf/interface/ and <cf/multihop/ definitions):
1460

    
1461
<descrip>
1462
	<tag>interval <m/time/</tag>
1463
	BFD ensures availability of the forwarding path associated with the
1464
	session by periodically sending BFD control packets in both
1465
	directions. The rate of such packets is controlled by two options,
1466
	<cf/min rx interval/ and <cf/min tx interval/ (see below). This option
1467
	is just a shorthand to set both of these options together.
1468

    
1469
	<tag>min rx interval <m/time/</tag>
1470
	This option specifies the minimum RX interval, which is announced to the
1471
	neighbor and used there to limit the neighbor's rate of generated BFD
1472
	control packets. Default: 10 ms.
1473

    
1474
	<tag>min tx interval <m/time/</tag>
1475
	This option specifies the desired TX interval, which controls the rate
1476
	of generated BFD control packets (together with <cf/min rx interval/
1477
	announced by the neighbor). Note that this value is used only if the BFD
1478
	session is up, otherwise the value of <cf/idle tx interval/ is used
1479
	instead. Default: 100 ms.
1480

    
1481
	<tag>idle tx interval <m/time/</tag>
1482
	In order to limit unnecessary traffic in cases where a neighbor is not
1483
	available or not running BFD, the rate of generated BFD control packets
1484
	is lower when the BFD session is not up. This option specifies the
1485
	desired TX interval in such cases instead of <cf/min tx interval/.
1486
	Default: 1 s.
1487

    
1488
	<tag>multiplier <m/num/</tag>
1489
	Failure detection time for BFD sessions is based on established rate of
1490
	BFD control packets (<cf>min rx/tx interval</cf>) multiplied by this
1491
	multiplier, which is essentially (ignoring jitter) a number of missed
1492
	packets after which the session is declared down. Note that rates and
1493
	multipliers could be different in each direction of a BFD session.
1494
	Default: 5.
1495

    
1496
	<tag>passive <m/switch/</tag>
1497
	Generally, both BFD session endpoinds try to establish the session by
1498
	sending control packets to the other side. This option allows to enable
1499
	passive mode, which means that the router does not send BFD packets
1500
	until it has received one from the other side. Default: disabled.
1501
</descrip>
1502

    
1503
<sect1>Example
1504

    
1505
<p><code>
1506
protocol bfd {
1507
	interface "eth*" {
1508
		min rx interval 20 ms;
1509
		min tx interval 50 ms;
1510
		idle tx interval 300 ms;
1511
	};
1512
	interface "gre*" {
1513
		interval 200 ms;
1514
		multiplier 10;
1515
		passive;
1516
	};
1517
	multihop {
1518
		interval 200 ms;
1519
		multiplier 10;
1520
	};
1521

    
1522
	neighbor 192.168.1.10;
1523
	neighbor 192.168.2.2 dev "eth2";
1524
	neighbor 192.168.10.1 local 192.168.1.1 multihop;
1525
}
1526
</code>
1527

    
1528

    
1529
<sect>BGP
1530

    
1531
<p>The Border Gateway Protocol is the routing protocol used for backbone level
1532
routing in the today's Internet. Contrary to other protocols, its convergence
1533
does not rely on all routers following the same rules for route selection,
1534
making it possible to implement any routing policy at any router in the network,
1535
the only restriction being that if a router advertises a route, it must accept
1536
and forward packets according to it.
1537

    
1538
<p>BGP works in terms of autonomous systems (often abbreviated as AS). Each AS
1539
is a part of the network with common management and common routing policy. It is
1540
identified by a unique 16-bit number (ASN). Routers within each AS usually
1541
exchange AS-internal routing information with each other using an interior
1542
gateway protocol (IGP, such as OSPF or RIP). Boundary routers at the border of
1543
the AS communicate global (inter-AS) network reachability information with their
1544
neighbors in the neighboring AS'es via exterior BGP (eBGP) and redistribute
1545
received information to other routers in the AS via interior BGP (iBGP).
1546

    
1547
<p>Each BGP router sends to its neighbors updates of the parts of its routing
1548
table it wishes to export along with complete path information (a list of AS'es
1549
the packet will travel through if it uses the particular route) in order to
1550
avoid routing loops.
1551

    
1552
<p>BIRD supports all requirements of the BGP4 standard as defined in
1553
RFC 4271<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc4271.txt">
1554
It also supports the community attributes
1555
(RFC 1997<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc1997.txt">),
1556
capability negotiation
1557
(RFC 3392<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc3392.txt">),
1558
MD5 password authentication
1559
(RFC 2385<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc2385.txt">),
1560
extended communities
1561
(RFC 4360<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc4360.txt">),
1562
route reflectors
1563
(RFC 4456<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc4456.txt">),
1564
graceful restart
1565
(RFC 4724<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc4724.txt">),
1566
multiprotocol extensions
1567
(RFC 4760<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc4760.txt">),
1568
4B AS numbers
1569
(RFC 4893<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc4893.txt">),
1570
and 4B AS numbers in extended communities
1571
(RFC 5668<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc5668.txt">).
1572

    
1573

    
1574
For IPv6, it uses the standard multiprotocol extensions defined in
1575
RFC 4760<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc4760.txt">
1576
and applied to IPv6 according to
1577
RFC 2545<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc2545.txt">.
1578

    
1579
<sect1>Route selection rules
1580

    
1581
<p>BGP doesn't have any simple metric, so the rules for selection of an optimal
1582
route among multiple BGP routes with the same preference are a bit more complex
1583
and they are implemented according to the following algorithm. It starts the
1584
first rule, if there are more "best" routes, then it uses the second rule to
1585
choose among them and so on.
1586

    
1587
<itemize>
1588
	<item>Prefer route with the highest Local Preference attribute.
1589
	<item>Prefer route with the shortest AS path.
1590
	<item>Prefer IGP origin over EGP and EGP origin over incomplete.
1591
	<item>Prefer the lowest value of the Multiple Exit Discriminator.
1592
	<item>Prefer routes received via eBGP over ones received via iBGP.
1593
	<item>Prefer routes with lower internal distance to a boundary router.
1594
	<item>Prefer the route with the lowest value of router ID of the
1595
	advertising router.
1596
</itemize>
1597

    
1598
<sect1>IGP routing table
1599

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

    
1608
<sect1>Configuration
1609

    
1610
<p>Each instance of the BGP corresponds to one neighboring router. This allows
1611
to set routing policy and all the other parameters differently for each neighbor
1612
using the following configuration parameters:
1613

    
1614
<descrip>
1615
	<tag>local [<m/ip/] as <m/number/</tag>
1616
	Define which AS we are part of. (Note that contrary to other IP routers,
1617
	BIRD is able to act as a router located in multiple AS'es simultaneously,
1618
	but in such cases you need to tweak the BGP paths manually in the filters
1619
	to get consistent behavior.) Optional <cf/ip/ argument specifies a source
1620
	address, equivalent to the <cf/source address/ option (see below). This
1621
	parameter is mandatory.
1622

    
1623
	<tag>neighbor [<m/ip/] [port <m/number/] [as <m/number/]</tag>
1624
	Define neighboring router this instance will be talking to and what AS
1625
	it is located in. In case the neighbor is in the same AS as we are, we
1626
	automatically switch to iBGP. Optionally, the remote port may also be
1627
	specified. The parameter may be used multiple times with different
1628
	sub-options (e.g., both <cf/neighbor 10.0.0.1 as 65000;/ and
1629
	<cf/neighbor 10.0.0.1; neighbor as 65000;/ are valid). This parameter is
1630
	mandatory.
1631

    
1632
	<tag>interface <m/string/</tag>
1633
	Define interface we should use for link-local BGP IPv6 sessions.
1634
	Interface can also be specified as a part of <cf/neighbor address/
1635
	(e.g., <cf/neighbor fe80::1234%eth0 as 65000;/). It is an error to use
1636
	this parameter for non link-local sessions.
1637

    
1638
	<tag>direct</tag>
1639
	Specify that the neighbor is directly connected. The IP address of the
1640
	neighbor must be from a directly reachable IP range (i.e. associated
1641
	with one of your router's interfaces), otherwise the BGP session
1642
	wouldn't start but it would wait for such interface to appear. The
1643
	alternative is the <cf/multihop/ option. Default: enabled for eBGP.
1644

    
1645
	<tag>multihop [<m/number/]</tag>
1646
	Configure multihop BGP session to a neighbor that isn't directly
1647
	connected. Accurately, this option should be used if the configured
1648
	neighbor IP address does not match with any local network subnets. Such
1649
	IP address have to be reachable through system routing table. The
1650
	alternative is the <cf/direct/ option. For multihop BGP it is
1651
	recommended to explicitly configure the source address to have it
1652
	stable. Optional <cf/number/ argument can be used to specify the number
1653
	of hops (used for TTL). Note that the number of networks (edges) in a
1654
	path is counted; i.e., if two BGP speakers are separated by one router,
1655
	the number of hops is 2. Default: enabled for iBGP.
1656

    
1657
	<tag>source address <m/ip/</tag>
1658
	Define local address we should use for next hop calculation and as a
1659
	source address for the BGP session. Default: the address of the local
1660
	end of the interface our neighbor is connected to.
1661

    
1662
	<tag>next hop self</tag>
1663
	Avoid calculation of the Next Hop attribute and always advertise our own
1664
	source address as a next hop. This needs to be used only occasionally to
1665
	circumvent misconfigurations of other routers. Default: disabled.
1666

    
1667
	<tag>next hop keep</tag>
1668
	Forward the received Next Hop attribute even in situations where the
1669
	local address should be used instead, like when the route is sent to an
1670
	interface with a different subnet. Default: disabled.
1671

    
1672
	<tag>missing lladdr self|drop|ignore</tag>
1673
	Next Hop attribute in BGP-IPv6 sometimes contains just the global IPv6
1674
	address, but sometimes it has to contain both global and link-local IPv6
1675
	addresses. This option specifies what to do if BIRD have to send both
1676
	addresses but does not know link-local address. This situation might
1677
	happen when routes from other protocols are exported to BGP, or when
1678
	improper updates are received from BGP peers. <cf/self/ means that BIRD
1679
	advertises its own local address instead. <cf/drop/ means that BIRD
1680
	skips that prefixes and logs error. <cf/ignore/ means that BIRD ignores
1681
	the problem and sends just the global address (and therefore forms
1682
	improper BGP update). Default: <cf/self/, unless BIRD is configured as a
1683
	route server (option <cf/rs client/), in that case default is <cf/ignore/,
1684
	because route servers usually do not forward packets themselves.
1685

    
1686
	<tag>gateway direct|recursive</tag>
1687
	For received routes, their <cf/gw/ (immediate next hop) attribute is
1688
	computed from received <cf/bgp_next_hop/ attribute. This option
1689
	specifies how it is computed. Direct mode means that the IP address from
1690
	<cf/bgp_next_hop/ is used if it is directly reachable, otherwise the
1691
	neighbor IP address is used. Recursive mode means that the gateway is
1692
	computed by an IGP routing table lookup for the IP address from
1693
	<cf/bgp_next_hop/. Recursive mode is the behavior specified by the BGP
1694
	standard. Direct mode is simpler, does not require any routes in a
1695
	routing table, and was used in older versions of BIRD, but does not
1696
	handle well nontrivial iBGP setups and multihop. Recursive mode is
1697
	incompatible with <ref id="dsc-sorted" name="sorted tables">. Default:
1698
	<cf/direct/ for direct sessions, <cf/recursive/ for multihop sessions.
1699

    
1700
	<tag>igp table <m/name/</tag>
1701
	Specifies a table that is used as an IGP routing table. Default: the
1702
	same as the table BGP is connected to.
1703

    
1704
	<tag>check link <M>switch</M></tag>
1705
	BGP could use hardware link state into consideration.  If enabled,
1706
	BIRD tracks the link state of the associated interface and when link
1707
	disappears (e.g. an ethernet cable is unplugged), the BGP session is
1708
	immediately shut down. Note that this option cannot be used with
1709
	multihop BGP. Default: disabled.
1710

    
1711
	<tag>bfd <M>switch</M></tag>
1712
	BGP could use BFD protocol as an advisory mechanism for neighbor
1713
	liveness and failure detection. If enabled, BIRD setups a BFD session
1714
	for the BGP neighbor and tracks its liveness by it. This has an
1715
	advantage of an order of magnitude lower detection times in case of
1716
	failure. Note that BFD protocol also has to be configured, see
1717
	<ref id="sect-bfd" name="BFD"> section for details. Default: disabled.
1718

    
1719
	<tag>ttl security <m/switch/</tag>
1720
	Use GTSM (RFC 5082 - the generalized TTL security mechanism). GTSM
1721
	protects against spoofed packets by ignoring received packets with a
1722
	smaller than expected TTL. To work properly, GTSM have to be enabled on
1723
	both sides of a BGP session. If both <cf/ttl security/ and <cf/multihop/
1724
	options are enabled, <cf/multihop/ option should specify proper hop
1725
	value to compute expected TTL. Kernel support required: Linux: 2.6.34+
1726
	(IPv4), 2.6.35+ (IPv6), BSD: since long ago, IPv4 only. Note that full
1727
	(ICMP protection, for example) RFC 5082 support is provided by Linux
1728
	only. Default: disabled.
1729

    
1730
	<tag>password <m/string/</tag>
1731
	Use this password for MD5 authentication of BGP sessions. Default: no
1732
	authentication. Password has to be set by external utility
1733
	(e.g. setkey(8)) on BSD systems.
1734

    
1735
	<tag>passive <m/switch/</tag>
1736
	Standard BGP behavior is both initiating outgoing connections and
1737
	accepting incoming connections. In passive mode, outgoing connections
1738
	are not initiated. Default: off.
1739

    
1740
	<tag>rr client</tag>
1741
	Be a route reflector and treat the neighbor as a route reflection
1742
	client. Default: disabled.
1743

    
1744
	<tag>rr cluster id <m/IPv4 address/</tag>
1745
	Route reflectors use cluster id to avoid route reflection loops. When
1746
	there is one route reflector in a cluster it usually uses its router id
1747
	as a cluster id, but when there are more route reflectors in a cluster,
1748
	these need to be configured (using this option) to use a common cluster
1749
	id. Clients in a cluster need not know their cluster id and this option
1750
	is not allowed for them. Default: the same as router id.
1751

    
1752
	<tag>rs client</tag>
1753
	Be a route server and treat the neighbor as a route server client.
1754
	A route server is used as a replacement for full mesh EBGP routing in
1755
	Internet exchange points in a similar way to route reflectors used in
1756
	IBGP routing. BIRD does not implement obsoleted RFC 1863, but uses
1757
	ad-hoc implementation, which behaves like plain EBGP but reduces
1758
	modifications to advertised route attributes to be transparent (for
1759
	example does not prepend its AS number to AS PATH attribute and keeps
1760
	MED attribute). Default: disabled.
1761

    
1762
	<tag>secondary <m/switch/</tag>
1763
	Usually, if an export filter rejects a selected route, no other route is
1764
	propagated for that network. This option allows to try the next route in
1765
	order until one that is accepted is found or all routes for that network
1766
	are rejected. This can be used for route servers that need to propagate
1767
	different tables to each client but do not want to have these tables
1768
	explicitly (to conserve memory). This option requires that the connected
1769
	routing table is <ref id="dsc-sorted" name="sorted">. Default: off.
1770

    
1771
	<tag>add paths <m/switch/|rx|tx</tag>
1772
	Standard BGP can propagate only one path (route) per destination network
1773
	(usually the selected one). This option controls the add-path protocol
1774
	extension, which allows to advertise any number of paths to a
1775
	destination. Note that to be active, add-path has to be enabled on both
1776
	sides of the BGP session, but it could be enabled separately for RX and
1777
	TX direction. When active, all available routes accepted by the export
1778
	filter are advertised to the neighbor. Default: off.
1779

    
1780
	<tag>allow local as [<m/number/]</tag>
1781
	BGP prevents routing loops by rejecting received routes with the local
1782
	AS number in the AS path. This option allows to loose or disable the
1783
	check. Optional <cf/number/ argument can be used to specify the maximum
1784
	number of local ASNs in the AS path that is allowed for received
1785
	routes. When the option is used without the argument, the check is
1786
	completely disabled and you should ensure loop-free behavior by some
1787
	other means. Default: 0 (no local AS number allowed).
1788

    
1789
	<tag>enable route refresh <m/switch/</tag>
1790
	When BGP speaker changes its import filter, it has to re-examine all
1791
	routes received from its neighbor against the new filter. As these
1792
	routes might not be available, there is a BGP protocol extension Route
1793
	Refresh (specified in RFC 2918) that allows BGP speaker to request
1794
	re-advertisement of all routes from its neighbor. This option specifies
1795
	whether BIRD advertises this capability and accepts such requests. Even
1796
	when disabled, BIRD can send route refresh requests. Default: on.
1797

    
1798
	<tag>graceful restart <m/switch/|aware</tag>
1799
	When a BGP speaker restarts or crashes, neighbors will discard all
1800
	received paths from the speaker, which disrupts packet forwarding even
1801
	when the forwarding plane of the speaker remains intact. RFC 4724
1802
	specifies an optional graceful restart mechanism to alleviate this
1803
	issue. This option controls the mechanism. It has three states:
1804
	Disabled, when no support is provided. Aware, when the graceful restart
1805
	support is announced and the support for restarting neighbors is
1806
	provided, but no local graceful restart is allowed (i.e. receiving-only
1807
	role). Enabled, when the full graceful restart support is provided
1808
	(i.e. both restarting and receiving role). Note that proper support for
1809
	local graceful restart requires also configuration of other protocols.
1810
	Default: aware.
1811

    
1812
	<tag>graceful restart time <m/number/</tag>
1813
	The restart time is announced in the BGP graceful restart capability
1814
	and specifies how long the neighbor would wait for the BGP session to
1815
	re-establish after a restart before deleting stale routes. Default:
1816
	120 seconds.
1817

    
1818
	<tag>interpret communities <m/switch/</tag>
1819
	RFC 1997 demands that BGP speaker should process well-known communities
1820
	like no-export (65535, 65281) or no-advertise (65535, 65282). For
1821
	example, received route carrying a no-adverise community should not be
1822
	advertised to any of its neighbors. If this option is enabled (which is
1823
	by default), BIRD has such behavior automatically (it is evaluated when
1824
	a route is exported to the BGP protocol just before the export filter).
1825
	Otherwise, this integrated processing of well-known communities is
1826
	disabled. In that case, similar behavior can be implemented in the
1827
	export filter. Default: on.
1828

    
1829
	<tag>enable as4 <m/switch/</tag>
1830
	BGP protocol was designed to use 2B AS numbers and was extended later to
1831
	allow 4B AS number. BIRD supports 4B AS extension, but by disabling this
1832
	option it can be persuaded not to advertise it and to maintain old-style
1833
	sessions with its neighbors. This might be useful for circumventing bugs
1834
	in neighbor's implementation of 4B AS extension. Even when disabled
1835
	(off), BIRD behaves internally as AS4-aware BGP router. Default: on.
1836

    
1837
	<tag>capabilities <m/switch/</tag>
1838
	Use capability advertisement to advertise optional capabilities. This is
1839
	standard behavior for newer BGP implementations, but there might be some
1840
	older BGP implementations that reject such connection attempts. When
1841
	disabled (off), features that request it (4B AS support) are also
1842
	disabled. Default: on, with automatic fallback to off when received
1843
	capability-related error.
1844

    
1845
	<tag>advertise ipv4 <m/switch/</tag>
1846
	Advertise IPv4 multiprotocol capability. This is not a correct behavior
1847
	according to the strict interpretation of RFC 4760, but it is widespread
1848
	and required by some BGP implementations (Cisco and Quagga). This option
1849
	is relevant to IPv4 mode with enabled capability advertisement
1850
	only. Default: on.
1851

    
1852
	<tag>route limit <m/number/</tag>
1853
	The maximal number of routes that may be imported from the protocol. If
1854
	the route limit is exceeded, the connection is closed with an error.
1855
	Limit is currently implemented as <cf>import limit <m/number/ action
1856
	restart</cf>. This option is obsolete and it is replaced by
1857
	<ref id="import-limit" name="import limit option">. Default: no	limit.
1858

    
1859
	<tag>disable after error <m/switch/</tag>
1860
	When an error is encountered (either locally or by the other side),
1861
	disable the instance automatically and wait for an administrator to fix
1862
	the problem manually. Default: off.
1863

    
1864
	<tag>hold time <m/number/</tag>
1865
	Time in seconds to wait for a Keepalive message from the other side
1866
	before considering the connection stale. Default: depends on agreement
1867
	with the neighboring router, we prefer 240 seconds if the other side is
1868
	willing to accept it.
1869

    
1870
	<tag>startup hold time <m/number/</tag>
1871
	Value of the hold timer used before the routers have a chance to exchange
1872
	open messages and agree on the real value. Default: 240	seconds.
1873

    
1874
	<tag>keepalive time <m/number/</tag>
1875
	Delay in seconds between sending of two consecutive Keepalive messages.
1876
	Default: One third of the hold time.
1877

    
1878
	<tag>connect delay time <m/number/</tag>
1879
	Delay in seconds between protocol startup and the first attempt to
1880
	connect. Default: 5 seconds.
1881

    
1882
	<tag>connect retry time <m/number/</tag>
1883
	Time in seconds to wait before retrying a failed attempt to connect.
1884
	Default: 120 seconds.
1885

    
1886
	<tag>error wait time <m/number/,<m/number/</tag>
1887
	Minimum and maximum delay in seconds between a protocol failure (either
1888
	local or reported by the peer) and automatic restart. Doesn't apply
1889
	when <cf/disable after error/ is configured. If consecutive errors
1890
	happen, the delay is increased exponentially until it reaches the
1891
	maximum. Default: 60, 300.
1892

    
1893
	<tag>error forget time <m/number/</tag>
1894
	Maximum time in seconds between two protocol failures to treat them as a
1895
	error sequence which makes <cf/error wait time/ increase exponentially.
1896
	Default: 300 seconds.
1897

    
1898
	<tag>path metric <m/switch/</tag>
1899
	Enable comparison of path lengths when deciding which BGP route is the
1900
	best one. Default: on.
1901

    
1902
	<tag>med metric <m/switch/</tag>
1903
	Enable comparison of MED attributes (during best route selection) even
1904
	between routes received from different ASes. This may be useful if all
1905
	MED attributes contain some consistent metric, perhaps enforced in
1906
	import filters of AS boundary routers. If this option is disabled, MED
1907
	attributes are compared only if routes are received from the same AS
1908
	(which is the standard behavior). Default: off.
1909

    
1910
	<tag>deterministic med <m/switch/</tag>
1911
	BGP route selection algorithm is often viewed as a comparison between
1912
	individual routes (e.g. if a new route appears and is better than the
1913
	current best one, it is chosen as the new best one). But the proper
1914
	route selection, as specified by RFC 4271, cannot be fully implemented
1915
	in that way. The problem is mainly in handling the MED attribute. BIRD,
1916
	by default, uses an simplification based on individual route comparison,
1917
	which in some cases may lead to temporally dependent behavior (i.e. the
1918
	selection is dependent on the order in which routes appeared). This
1919
	option enables a different (and slower) algorithm implementing proper
1920
	RFC 4271 route selection, which is deterministic. Alternative way how to
1921
	get deterministic behavior is to use <cf/med metric/ option. This option
1922
	is incompatible with <ref id="dsc-sorted" name="sorted tables">.
1923
	Default: off.
1924

    
1925
	<tag>igp metric <m/switch/</tag>
1926
	Enable comparison of internal distances to boundary routers during best
1927
 	route selection. Default: on.
1928

    
1929
	<tag>prefer older <m/switch/</tag>
1930
	Standard route selection algorithm breaks ties by comparing router IDs.
1931
	This changes the behavior to prefer older routes (when both are external
1932
	and from different peer). For details, see RFC 5004. Default: off.
1933

    
1934
	<tag>default bgp_med <m/number/</tag>
1935
	Value of the Multiple Exit Discriminator to be used during route
1936
	selection when the MED attribute is missing. Default: 0.
1937

    
1938
	<tag>default bgp_local_pref <m/number/</tag>
1939
	A default value for the Local Preference attribute. It is used when
1940
	a new Local Preference attribute is attached to a route by the BGP
1941
	protocol itself (for example, if a route is received through eBGP and
1942
	therefore does not have such attribute). Default: 100 (0 in pre-1.2.0
1943
	versions of BIRD).
1944
</descrip>
1945

    
1946
<sect1>Attributes
1947

    
1948
<p>BGP defines several route attributes. Some of them (those marked with
1949
`<tt/I/' in the table below) are available on internal BGP connections only,
1950
some of them (marked with `<tt/O/') are optional.
1951

    
1952
<descrip>
1953
	<tag>bgppath <cf/bgp_path/</tag>
1954
	Sequence of AS numbers describing the AS path the packet will travel
1955
	through when forwarded according to the particular route. In case of
1956
	internal BGP it doesn't contain the number of the local AS.
1957

    
1958
	<tag>int <cf/bgp_local_pref/ [I]</tag>
1959
	Local preference value used for selection among multiple BGP routes (see
1960
	the selection rules above). It's used as an additional metric which is
1961
	propagated through the whole local AS.
1962

    
1963
	<tag>int <cf/bgp_med/ [O]</tag>
1964
	The Multiple Exit Discriminator of the route is an optional attribute
1965
	which is used on external (inter-AS) links to convey to an adjacent AS
1966
	the optimal entry point into the local AS. The received attribute is
1967
	also propagated over internal BGP links. The attribute value is zeroed
1968
	when a route is exported to an external BGP instance to ensure that the
1969
	attribute received from a neighboring AS is not propagated to other
1970
	neighboring ASes. A new value might be set in the export filter of an
1971
	external BGP instance. See RFC 4451<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc4451.txt">
1972
	for further discussion of BGP MED attribute.
1973

    
1974
	<tag>enum <cf/bgp_origin/</tag>
1975
	Origin of the route: either <cf/ORIGIN_IGP/ if the route has originated
1976
	in an interior routing protocol or <cf/ORIGIN_EGP/ if it's been imported
1977
	from the <tt>EGP</tt> protocol (nowadays it seems to be obsolete) or
1978
	<cf/ORIGIN_INCOMPLETE/ if the origin is unknown.
1979

    
1980
	<tag>ip <cf/bgp_next_hop/</tag>
1981
	Next hop to be used for forwarding of packets to this destination. On
1982
	internal BGP connections, it's an address of the originating router if
1983
	it's inside the local AS or a boundary router the packet will leave the
1984
	AS through if it's an exterior route, so each BGP speaker within the AS
1985
	has a chance to use the shortest interior path possible to this point.
1986

    
1987
	<tag>void <cf/bgp_atomic_aggr/ [O]</tag>
1988
	This is an optional attribute which carries no value, but the sole
1989
	presence of which indicates that the route has been aggregated from
1990
	multiple routes by some router on the path from the originator.
1991

    
1992
<!-- we don't handle aggregators right since they are of a very obscure type
1993
	<tag>bgp_aggregator</tag>
1994
-->
1995
	<tag>clist <cf/bgp_community/ [O]</tag>
1996
	List of community values associated with the route. Each such value is a
1997
	pair (represented as a <cf/pair/ data type inside the filters) of 16-bit
1998
	integers, the first of them containing the number of the AS which
1999
	defines the community and the second one being a per-AS identifier.
2000
	There are lots of uses of the community mechanism, but generally they
2001
	are used to carry policy information like "don't export to USA peers".
2002
	As each AS can define its own routing policy, it also has a complete
2003
	freedom about which community attributes it defines and what will their
2004
	semantics be.
2005

    
2006
	<tag>eclist <cf/bgp_ext_community/ [O]</tag>
2007
	List of extended community values associated with the route. Extended
2008
	communities have similar usage as plain communities, but they have an
2009
	extended range (to allow 4B ASNs) and a nontrivial structure with a type
2010
	field. Individual community values are represented using an <cf/ec/ data
2011
	type inside the filters.
2012

    
2013
	<tag>quad <cf/bgp_originator_id/ [I, O]</tag>
2014
	This attribute is created by the route reflector when reflecting the
2015
	route and contains the router ID of the originator of the route in the
2016
	local AS.
2017

    
2018
	<tag>clist <cf/bgp_cluster_list/ [I, O]</tag>
2019
	This attribute contains a list of cluster IDs of route reflectors. Each
2020
	route reflector prepends its cluster ID when reflecting the route.
2021
</descrip>
2022

    
2023
<sect1>Example
2024

    
2025
<p><code>
2026
protocol bgp {
2027
	local as 65000;			     # Use a private AS number
2028
	neighbor 198.51.100.130 as 64496;    # Our neighbor ...
2029
	multihop;			     # ... which is connected indirectly
2030
	export filter {			     # We use non-trivial export rules
2031
		if source = RTS_STATIC then { # Export only static routes
2032
		        # Assign our community
2033
			bgp_community.add((65000,64501));
2034
			# Artificially increase path length
2035
			# by advertising local AS number twice
2036
			if bgp_path ~ [= 65000 =] then
2037
				bgp_path.prepend(65000);
2038
			accept;
2039
		}
2040
		reject;
2041
	};
2042
	import all;
2043
	source address 198.51.100.14;	# Use a non-standard source address
2044
}
2045
</code>
2046

    
2047

    
2048
<sect>Device
2049

    
2050
<p>The Device protocol is not a real routing protocol. It doesn't generate any
2051
routes and it only serves as a module for getting information about network
2052
interfaces from the kernel.
2053

    
2054
<p>Except for very unusual circumstances, you probably should include this
2055
protocol in the configuration since almost all other protocols require network
2056
interfaces to be defined for them to work with.
2057

    
2058
<sect1>Configuration
2059

    
2060
<p><descrip>
2061

    
2062
	<tag>scan time <m/number/</tag>
2063

    
2064
	Time in seconds between two scans of the network interface list. On
2065
	systems where we are notified about interface status changes
2066
	asynchronously (such as newer versions of Linux), we need to scan the
2067
	list only in order to avoid confusion by lost notification messages,
2068
	so the default time is set to a large value.
2069

    
2070
	<tag>primary [ "<m/mask/" ] <m/prefix/</tag>
2071
	If a network interface has more than one network address, BIRD has to
2072
	choose one of them as a primary one. By default, BIRD chooses the
2073
	lexicographically smallest address as the primary one.
2074

    
2075
	This option allows to specify which network address should be chosen as
2076
	a primary one. Network addresses that match <m/prefix/ are preferred to
2077
	non-matching addresses. If more <cf/primary/ options are used, the first
2078
	one has the highest preference. If "<m/mask/" is specified, then such
2079
	<cf/primary/ option is relevant only to matching network interfaces.
2080

    
2081
	In all cases, an address marked by operating system as secondary cannot
2082
	be chosen as the primary one.
2083
</descrip>
2084

    
2085
<p>As the Device protocol doesn't generate any routes, it cannot have
2086
any attributes. Example configuration looks like this:
2087

    
2088
<p><code>
2089
protocol device {
2090
	scan time 10;		# Scan the interfaces often
2091
	primary "eth0" 192.168.1.1;
2092
	primary 192.168.0.0/16;
2093
}
2094
</code>
2095

    
2096

    
2097
<sect>Direct
2098

    
2099
<p>The Direct protocol is a simple generator of device routes for all the
2100
directly connected networks according to the list of interfaces provided by the
2101
kernel via the Device protocol.
2102

    
2103
<p>The question is whether it is a good idea to have such device routes in BIRD
2104
routing table. OS kernel usually handles device routes for directly connected
2105
networks by itself so we don't need (and don't want) to export these routes to
2106
the kernel protocol. OSPF protocol creates device routes for its interfaces
2107
itself and BGP protocol is usually used for exporting aggregate routes. Although
2108
there are some use cases that use the direct protocol (like abusing eBGP as an
2109
IGP routing protocol), in most cases it is not needed to have these device
2110
routes in BIRD routing table and to use the direct protocol.
2111

    
2112
<p>There is one notable case when you definitely want to use the direct protocol
2113
-- running BIRD on BSD systems. Having high priority device routes for directly
2114
connected networks from the direct protocol protects kernel device routes from
2115
being overwritten or removed by IGP routes during some transient network
2116
conditions, because a lower priority IGP route for the same network is not
2117
exported to the kernel routing table. This is an issue on BSD systems only, as
2118
on Linux systems BIRD cannot change non-BIRD route in the kernel routing table.
2119

    
2120
<p>The only configurable thing about direct is what interfaces it watches:
2121

    
2122
<p><descrip>
2123
	<tag>interface <m/pattern [, ...]/</tag>
2124
	By default, the Direct protocol will generate device routes for all the
2125
	interfaces available. If you want to restrict it to some subset of
2126
	interfaces or addresses (e.g. if you're using multiple routing tables
2127
	for policy routing and some of the policy domains don't contain all
2128
	interfaces), just use this clause. See <ref id="dsc-iface" name="interface">
2129
	common option for detailed description. The Direct protocol uses
2130
	extended interface clauses.
2131
</descrip>
2132

    
2133
<p>Direct device routes don't contain any specific attributes.
2134

    
2135
<p>Example config might look like this:
2136

    
2137
<p><code>
2138
protocol direct {
2139
	interface "-arc*", "*";		# Exclude the ARCnets
2140
}
2141
</code>
2142

    
2143

    
2144
<sect>Kernel
2145

    
2146
<p>The Kernel protocol is not a real routing protocol. Instead of communicating
2147
with other routers in the network, it performs synchronization of BIRD's routing
2148
tables with the OS kernel. Basically, it sends all routing table updates to the
2149
kernel and from time to time it scans the kernel tables to see whether some
2150
routes have disappeared (for example due to unnoticed up/down transition of an
2151
interface) or whether an `alien' route has been added by someone else (depending
2152
on the <cf/learn/ switch, such routes are either ignored or accepted to our
2153
table).
2154

    
2155
<p>Unfortunately, there is one thing that makes the routing table synchronization
2156
a bit more complicated. In the kernel routing table there are also device routes
2157
for directly connected networks. These routes are usually managed by OS itself
2158
(as a part of IP address configuration) and we don't want to touch that. They
2159
are completely ignored during the scan of the kernel tables and also the export
2160
of device routes from BIRD tables to kernel routing tables is restricted to
2161
prevent accidental interference. This restriction can be disabled using
2162
<cf/device routes/ switch.
2163

    
2164
<p>If your OS supports only a single routing table, you can configure only one
2165
instance of the Kernel protocol. If it supports multiple tables (in order to
2166
allow policy routing; such an OS is for example Linux), you can run as many
2167
instances as you want, but each of them must be connected to a different BIRD
2168
routing table and to a different kernel table.
2169

    
2170
<p>Because the kernel protocol is partially integrated with the connected
2171
routing table, there are two limitations - it is not possible to connect more
2172
kernel protocols to the same routing table and changing route destination
2173
(gateway) in an export filter of a kernel protocol does not work. Both
2174
limitations can be overcome using another routing table and the pipe protocol.
2175

    
2176
<sect1>Configuration
2177

    
2178
<p><descrip>
2179
	<tag>persist <m/switch/</tag>
2180
	Tell BIRD to leave all its routes in the routing tables when it exits
2181
	(instead of cleaning them up).
2182

    
2183
	<tag>scan time <m/number/</tag>
2184
	Time in seconds between two consecutive scans of the kernel routing
2185
	table.
2186

    
2187
	<tag>learn <m/switch/</tag>
2188
	Enable learning of routes added to the kernel routing tables by other
2189
	routing daemons or by the system administrator. This is possible only on
2190
	systems which support identification of route authorship.
2191

    
2192
	<tag>device routes <m/switch/</tag>
2193
	Enable export of device routes to the kernel routing table. By default,
2194
	such routes are rejected (with the exception of explicitly configured
2195
	device routes from the static protocol) regardless of the export filter
2196
	to protect device routes in kernel routing table (managed by OS itself)
2197
	from accidental overwriting or erasing.
2198

    
2199
	<tag>kernel table <m/number/</tag>
2200
	Select which kernel table should this particular instance of the Kernel
2201
	protocol work with. Available only on systems supporting multiple
2202
	routing tables.
2203

    
2204
	<tag>graceful restart <m/switch/</tag>
2205
	Participate in graceful restart recovery. If this option is enabled and
2206
	a graceful restart recovery is active, the Kernel protocol will defer
2207
	synchronization of routing tables until the end of the recovery. Note
2208
	that import of kernel routes to BIRD is not affected.
2209
</descrip>
2210

    
2211
<sect1>Attributes
2212

    
2213
<p>The Kernel protocol defines several attributes. These attributes are
2214
translated to appropriate system (and OS-specific) route attributes. We support
2215
these attributes:
2216

    
2217
<descrip>
2218
	<tag>int <cf/krt_source/</tag>
2219
	The original source of the imported kernel route. The value is
2220
	system-dependent. On Linux, it is a value of the protocol field of the
2221
	route. See /etc/iproute2/rt_protos for common values. On BSD, it is
2222
	based on STATIC and PROTOx flags. The attribute is read-only.
2223

    
2224
	<tag>int <cf/krt_metric/</tag>
2225
	The kernel metric of the route. When multiple same routes are in a
2226
	kernel routing table, the Linux kernel chooses one with lower metric.
2227

    
2228
	<tag>ip <cf/krt_prefsrc/</tag> (Linux)
2229
	The preferred source address. Used in source address selection for
2230
 	outgoing packets. Have to be one of IP addresses of the router.
2231

    
2232
	<tag>int <cf/krt_realm/</tag> (Linux)
2233
	The realm of the route. Can be used for traffic classification.
2234
</descrip>
2235

    
2236
<sect1>Example
2237

    
2238
<p>A simple configuration can look this way:
2239

    
2240
<p><code>
2241
protocol kernel {
2242
	export all;
2243
}
2244
</code>
2245

    
2246
<p>Or for a system with two routing tables:
2247

    
2248
<p><code>
2249
protocol kernel {		# Primary routing table
2250
	learn;			# Learn alien routes from the kernel
2251
	persist;		# Don't remove routes on bird shutdown
2252
	scan time 10;		# Scan kernel routing table every 10 seconds
2253
	import all;
2254
	export all;
2255
}
2256

    
2257
protocol kernel {		# Secondary routing table
2258
	table auxtable;
2259
	kernel table 100;
2260
	export all;
2261
}
2262
</code>
2263

    
2264

    
2265
<sect>OSPF
2266

    
2267
<sect1>Introduction
2268

    
2269
<p>Open Shortest Path First (OSPF) is a quite complex interior gateway
2270
protocol. The current IPv4 version (OSPFv2) is defined in RFC 2328
2271
<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc2328.txt">
2272
and the current IPv6 version (OSPFv3) is defined in RFC 5340
2273
<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc5340.txt">
2274
It's a link state (a.k.a. shortest path first) protocol -- each router maintains
2275
a database describing the autonomous system's topology. Each participating
2276
router has an identical copy of the database and all routers run the same
2277
algorithm calculating a shortest path tree with themselves as a root. OSPF
2278
chooses the least cost path as the best path.
2279

    
2280
<p>In OSPF, the autonomous system can be split to several areas in order to
2281
reduce the amount of resources consumed for exchanging the routing information
2282
and to protect the other areas from incorrect routing data. Topology of the area
2283
is hidden to the rest of the autonomous system.
2284

    
2285
<p>Another very important feature of OSPF is that it can keep routing information
2286
from other protocols (like Static or BGP) in its link state database as external
2287
routes. Each external route can be tagged by the advertising router, making it
2288
possible to pass additional information between routers on the boundary of the
2289
autonomous system.
2290

    
2291
<p>OSPF quickly detects topological changes in the autonomous system (such as
2292
router interface failures) and calculates new loop-free routes after a short
2293
period of convergence. Only a minimal amount of routing traffic is involved.
2294

    
2295
<p>Each router participating in OSPF routing periodically sends Hello messages
2296
to all its interfaces. This allows neighbors to be discovered dynamically. Then
2297
the neighbors exchange theirs parts of the link state database and keep it
2298
identical by flooding updates. The flooding process is reliable and ensures that
2299
each router detects all changes.
2300

    
2301
<sect1>Configuration
2302

    
2303
<p>In the main part of configuration, there can be multiple definitions of OSPF
2304
areas, each with a different id. These definitions includes many other switches
2305
and multiple definitions of interfaces. Definition of interface may contain many
2306
switches and constant definitions and list of neighbors on nonbroadcast
2307
networks.
2308

    
2309
<code>
2310
protocol ospf &lt;name&gt; {
2311
	rfc1583compat &lt;switch&gt;;
2312
	instance id &lt;num&gt;;
2313
	stub router &lt;switch&gt;;
2314
	tick &lt;num&gt;;
2315
	ecmp &lt;switch&gt; [limit &lt;num&gt;];
2316
	merge external &lt;switch&gt;;
2317
	area &lt;id&gt; {
2318
		stub;
2319
		nssa;
2320
		summary &lt;switch&gt;;
2321
		default nssa &lt;switch&gt;;
2322
		default cost &lt;num&gt;;
2323
		default cost2 &lt;num&gt;;
2324
		translator &lt;switch&gt;;
2325
		translator stability &lt;num&gt;;
2326

    
2327
                networks {
2328
			&lt;prefix&gt;;
2329
			&lt;prefix&gt; hidden;
2330
		}
2331
                external {
2332
			&lt;prefix&gt;;
2333
			&lt;prefix&gt; hidden;
2334
			&lt;prefix&gt; tag &lt;num&gt;;
2335
		}
2336
		stubnet &lt;prefix&gt;;
2337
		stubnet &lt;prefix&gt; {
2338
			hidden &lt;switch&gt;;
2339
			summary &lt;switch&gt;;
2340
			cost &lt;num&gt;;
2341
		}
2342
		interface &lt;interface pattern&gt; [instance &lt;num&gt;] {
2343
			cost &lt;num&gt;;
2344
			stub &lt;switch&gt;;
2345
			hello &lt;num&gt;;
2346
			poll &lt;num&gt;;
2347
			retransmit &lt;num&gt;;
2348
			priority &lt;num&gt;;
2349
			wait &lt;num&gt;;
2350
			dead count &lt;num&gt;;
2351
			dead &lt;num&gt;;
2352
			secondary &lt;switch&gt;;
2353
			rx buffer [normal|large|&lt;num&gt;];
2354
			tx length &lt;num&gt;;
2355
			type [broadcast|bcast|pointopoint|ptp|
2356
				nonbroadcast|nbma|pointomultipoint|ptmp];
2357
			link lsa suppression &lt;switch&gt;;
2358
			strict nonbroadcast &lt;switch&gt;;
2359
			real broadcast &lt;switch&gt;;
2360
			ptp netmask &lt;switch&gt;;
2361
			check link &lt;switch&gt;;
2362
			bfd &lt;switch&gt;;
2363
			ecmp weight &lt;num&gt;;
2364
			ttl security [&lt;switch&gt;; | tx only]
2365
			tx class|dscp &lt;num&gt;;
2366
			tx priority &lt;num&gt;;
2367
			authentication [none|simple|cryptographic];
2368
			password "&lt;text&gt;";
2369
			password "&lt;text&gt;" {
2370
				id &lt;num&gt;;
2371
				generate from "&lt;date&gt;";
2372
				generate to "&lt;date&gt;";
2373
				accept from "&lt;date&gt;";
2374
				accept to "&lt;date&gt;";
2375
			};
2376
			neighbors {
2377
				&lt;ip&gt;;
2378
				&lt;ip&gt; eligible;
2379
			};
2380
		};
2381
		virtual link &lt;id&gt; [instance &lt;num&gt;] {
2382
			hello &lt;num&gt;;
2383
			retransmit &lt;num&gt;;
2384
			wait &lt;num&gt;;
2385
			dead count &lt;num&gt;;
2386
			dead &lt;num&gt;;
2387
			authentication [none|simple|cryptographic];
2388
			password "&lt;text&gt;";
2389
		};
2390
	};
2391
}
2392
</code>
2393

    
2394
<descrip>
2395
	<tag>rfc1583compat <M>switch</M></tag>
2396
	This option controls compatibility of routing table calculation with
2397
	RFC 1583 <htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc1583.txt">.
2398
	Default	value is no.
2399

    
2400
	<tag>instance id <m/num/</tag>
2401
	When multiple OSPF protocol instances are active on the same links, they
2402
	should use different instance IDs to distinguish their packets. Although
2403
	it could be done on per-interface basis, it is often preferred to set
2404
	one instance ID to whole OSPF domain/topology (e.g., when multiple
2405
	instances are used to represent separate logical topologies on the same
2406
	physical network). This option specifies the default instance ID for all
2407
	interfaces of the OSPF instance. Note that this option, if used, must
2408
	precede interface definitions. Default value is 0.
2409

    
2410
	<tag>stub router <M>switch</M></tag>
2411
	This option configures the router to be a stub router, i.e., a router
2412
	that participates in the OSPF topology but does not allow transit
2413
	traffic. In OSPFv2, this is implemented by advertising maximum metric
2414
	for outgoing links. In OSPFv3, the stub router behavior is announced by
2415
	clearing the R-bit in the router LSA. See RFC 6987
2416
	<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc6987.txt"> for
2417
	details. Default value is no.
2418

    
2419
	<tag>tick <M>num</M></tag>
2420
	The routing table calculation and clean-up of areas' databases is not
2421
	performed when a single link state change arrives. To lower the CPU
2422
	utilization, it's processed later at periodical intervals of <m/num/
2423
	seconds. The default value is 1.
2424

    
2425
	<tag>ecmp <M>switch</M> [limit <M>number</M>]</tag>
2426
	This option specifies whether OSPF is allowed to generate ECMP
2427
	(equal-cost multipath) routes. Such routes are used when there are
2428
	several directions to the destination, each with the same (computed)
2429
	cost. This option also allows to specify a limit on maximal number of
2430
	nexthops in one route. By default, ECMP is disabled. If enabled,
2431
	default	value of the limit is 16.
2432

    
2433
	<tag>merge external <M>switch</M></tag>
2434
	This option specifies whether OSPF should merge external routes from
2435
	different routers/LSAs for the same destination. When enabled together
2436
	with <cf/ecmp/, equal-cost external routes will be combined to multipath
2437
	routes in the same way as regular routes. When disabled, external routes
2438
	from different LSAs are treated as separate even if they represents the
2439
	same destination. Default value is no.
2440

    
2441
	<tag>area <M>id</M></tag>
2442
	This defines an OSPF area with given area ID (an integer or an IPv4
2443
	address, similarly to a router ID). The most important area is the
2444
	backbone (ID 0) to which every other area must be connected.
2445

    
2446
	<tag>stub</tag>
2447
	This option configures the area to be a stub area. External routes are
2448
	not flooded into stub areas. Also summary LSAs can be limited in stub
2449
	areas (see option <cf/summary/). By default, the area is not a stub
2450
	area.
2451

    
2452
	<tag>nssa</tag>
2453
	This option configures the area to be a NSSA (Not-So-Stubby Area). NSSA
2454
	is a variant of a stub area which allows a limited way of external route
2455
	propagation. Global external routes are not propagated into a NSSA, but
2456
	an external route can be imported into NSSA as a (area-wide) NSSA-LSA
2457
	(and possibly translated and/or aggregated on area boundary). By
2458
	default, the area is not NSSA.
2459

    
2460
	<tag>summary <M>switch</M></tag>
2461
	This option controls propagation of summary LSAs into stub or NSSA
2462
	areas. If enabled, summary LSAs are propagated as usual, otherwise just
2463
	the default summary route (0.0.0.0/0) is propagated (this is sometimes
2464
	called totally stubby area). If a stub area has more area boundary
2465
	routers, propagating summary LSAs could lead to more efficient routing
2466
	at the cost of larger link state database. Default value is no.
2467

    
2468
	<tag>default nssa <M>switch</M></tag>
2469
	When <cf/summary/ option is enabled, default summary route is no longer
2470
	propagated to the NSSA. In that case, this option allows to originate
2471
	default route as NSSA-LSA to the NSSA. Default value is no.
2472

    
2473
	<tag>default cost <M>num</M></tag>
2474
	This option controls the cost of a default route propagated to stub and
2475
	NSSA areas. Default value is 1000.
2476

    
2477
	<tag>default cost2 <M>num</M></tag>
2478
	When a default route is originated as NSSA-LSA, its cost can use either
2479
	type 1 or type 2 metric. This option allows to specify the cost of a
2480
	default route in type 2 metric. By default, type 1 metric (option
2481
	<cf/default cost/) is used.
2482

    
2483
	<tag>translator <M>switch</M></tag>
2484
	This option controls translation of NSSA-LSAs into external LSAs. By
2485
	default, one translator per NSSA is automatically elected from area
2486
	boundary routers. If enabled, this area boundary router would
2487
	unconditionally translate all NSSA-LSAs regardless of translator
2488
	election. Default value is no.
2489

    
2490
	<tag>translator stability <M>num</M></tag>
2491
	This option controls the translator stability interval (in seconds).
2492
	When the new translator is elected, the old one keeps translating until
2493
	the interval is over. Default value is 40.
2494

    
2495
	<tag>networks { <m/set/ }</tag>
2496
	Definition of area IP ranges. This is used in summary LSA origination.
2497
	Hidden networks are not propagated into other areas.
2498

    
2499
	<tag>external { <m/set/ }</tag>
2500
	Definition of external area IP ranges for NSSAs. This is used for
2501
	NSSA-LSA translation. Hidden networks are not translated into external
2502
	LSAs. Networks can have configured route tag.
2503

    
2504
	<tag>stubnet <m/prefix/ { <m/options/ }</tag>
2505
	Stub networks are networks that are not transit networks between OSPF
2506
	routers. They are also propagated through an OSPF area as a part of a
2507
	link state database. By default, BIRD generates a stub network record
2508
	for each primary network address on each OSPF interface that does not
2509
	have any OSPF neighbors, and also for each non-primary network address
2510
	on each OSPF interface. This option allows to alter a set of stub
2511
	networks propagated by this router.
2512

    
2513
	Each instance of this option adds a stub network with given network
2514
	prefix to the set of propagated stub network, unless option <cf/hidden/
2515
	is used. It also suppresses default stub networks for given network
2516
	prefix. When option <cf/summary/ is used, also default stub networks
2517
	that are subnetworks of given stub network are suppressed. This might be
2518
	used, for example, to aggregate generated stub networks.
2519

    
2520
	<tag>interface <M>pattern</M> [instance <m/num/]</tag>
2521
	Defines that the specified interfaces belong to the area being defined.
2522
	See <ref id="dsc-iface" name="interface"> common option for detailed
2523
	description. In OSPFv2, extended interface clauses are used, because
2524
	each network prefix is handled as a separate virtual interface.
2525

    
2526
	You can specify alternative instance ID for the interface definition,
2527
	therefore it is possible to have several instances of that interface
2528
	with different options or even in different areas. For OSPFv2,
2529
	instance ID support is an extension (RFC 6549
2530
	<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc6549.txt">) and is
2531
	supposed to be set per-protocol. For OSPFv3, it is an integral feature.
2532

    
2533
	<tag>virtual link <M>id</M> [instance <m/num/]</tag>
2534
	Virtual link to router with the router id. Virtual link acts as a
2535
	point-to-point interface belonging to backbone. The actual area is used
2536
	as a transport area. This item cannot be in the backbone. Like with
2537
	<cf/interface/ option, you could also use several virtual links to one
2538
	destination with different instance IDs.
2539

    
2540
	<tag>cost <M>num</M></tag>
2541
	Specifies output cost (metric) of an interface. Default value is 10.
2542

    
2543
	<tag>stub <M>switch</M></tag>
2544
	If set to interface it does not listen to any packet and does not send
2545
	any hello. Default value is no.
2546

    
2547
	<tag>hello <M>num</M></tag>
2548
	Specifies interval in seconds between sending of Hello messages. Beware,
2549
	all routers on the same network need to have the same hello interval.
2550
	Default value is 10.
2551

    
2552
	<tag>poll <M>num</M></tag>
2553
	Specifies interval in seconds between sending of Hello messages for some
2554
	neighbors on NBMA network. Default value is 20.
2555

    
2556
	<tag>retransmit <M>num</M></tag>
2557
	Specifies interval in seconds between retransmissions of unacknowledged
2558
	updates. Default value is 5.
2559

    
2560
	<tag>priority <M>num</M></tag>
2561
	On every multiple access network (e.g., the Ethernet) Designed Router
2562
	and Backup Designed router are elected. These routers have some special
2563
	functions in the flooding process. Higher priority increases preferences
2564
	in this election. Routers with priority 0 are not eligible. Default
2565
	value is 1.
2566

    
2567
	<tag>wait <M>num</M></tag>
2568
	After start, router waits for the specified number of seconds between
2569
	starting election and building adjacency. Default value is 4*<m/hello/.
2570

    
2571
	<tag>dead count <M>num</M></tag>
2572
	When the router does not receive any messages from a neighbor in
2573
	<m/dead count/*<m/hello/ seconds, it will consider the neighbor down.
2574

    
2575
	<tag>dead <M>num</M></tag>
2576
	When the router does not receive any messages from a neighbor in
2577
	<m/dead/ seconds, it will consider the neighbor down. If both directives
2578
	<cf/dead count/ and <cf/dead/ are used, <cf/dead/ has precendence.
2579

    
2580
	<tag>secondary <M>switch</M></tag>
2581
	On BSD systems, older versions of BIRD supported OSPFv2 only for the
2582
	primary IP address of an interface, other IP ranges on the interface
2583
	were handled as stub networks. Since v1.4.1, regular operation on
2584
	secondary IP addresses is supported, but disabled by default for
2585
	compatibility. This option allows to enable it. The option is a
2586
	transitional measure, will be removed in the next major release as the
2587
	behavior will be changed. On Linux systems, the option is irrelevant, as
2588
	operation on non-primary addresses is already the regular behavior.
2589

    
2590
	<tag>rx buffer <M>num</M></tag>
2591
	This option allows to specify the size of buffers used for packet
2592
	processing. The buffer size should be bigger than maximal size of any
2593
	packets. By default, buffers are dynamically resized as needed, but a
2594
	fixed value could be specified. Value <cf/large/ means maximal allowed
2595
	packet size - 65535.
2596

    
2597
	<tag>tx length <M>num</M></tag>
2598
	Transmitted OSPF messages that contain large amount of information are
2599
	segmented to separate OSPF packets to avoid IP fragmentation. This
2600
	option specifies the soft ceiling for the length of generated OSPF
2601
	packets. Default value is the MTU of the network interface. Note that
2602
	larger OSPF packets may still be generated if underlying OSPF messages
2603
	cannot be splitted (e.g. when one large LSA is propagated).
2604

    
2605
	<tag>type broadcast|bcast</tag>
2606
	BIRD detects a type of a connected network automatically, but sometimes
2607
	it's convenient to force use of a different type manually. On broadcast
2608
	networks (like ethernet), flooding and Hello messages are sent using
2609
	multicasts (a single packet for all the neighbors). A designated router
2610
	is elected and it is responsible for synchronizing the link-state
2611
	databases and originating network LSAs. This network type cannot be used
2612
	on physically NBMA networks and on unnumbered networks (networks without
2613
	proper IP prefix).
2614

    
2615
	<tag>type pointopoint|ptp</tag>
2616
	Point-to-point networks connect just 2 routers together. No election is
2617
	performed and no network LSA is originated, which makes it simpler and
2618
	faster to establish. This network type is useful not only for physically
2619
	PtP ifaces (like PPP or tunnels), but also for broadcast networks used
2620
	as PtP links. This network type cannot be used on physically NBMA
2621
	networks.
2622

    
2623
	<tag>type nonbroadcast|nbma</tag>
2624
	On NBMA networks, the packets are sent to each neighbor separately
2625
	because of lack of multicast capabilities. Like on broadcast networks,
2626
	a designated router is elected, which plays a central role in propagation
2627
	of LSAs. This network type cannot be used on unnumbered networks.
2628

    
2629
	<tag>type pointomultipoint|ptmp</tag>
2630
	This is another network type designed to handle NBMA networks. In this
2631
	case the NBMA network is treated as a collection of PtP links. This is
2632
	useful if not every pair of routers on the NBMA network has direct
2633
	communication, or if the NBMA network is used as an (possibly
2634
	unnumbered) PtP link.
2635

    
2636
	<tag>link lsa suppression <m/switch/</tag>
2637
	In OSPFv3, link LSAs are generated for each link, announcing link-local
2638
	IPv6 address of the router to its local neighbors. These are useless on
2639
	PtP or PtMP networks and this option allows to suppress the link LSA
2640
	origination for such interfaces. The option is ignored on other than PtP
2641
	or PtMP interfaces. Default value is no.
2642

    
2643
	<tag>strict nonbroadcast <m/switch/</tag>
2644
	If set, don't send hello to any undefined neighbor. This switch is
2645
	ignored on other than NBMA or PtMP interfaces. Default value is no.
2646

    
2647
	<tag>real broadcast <m/switch/</tag>
2648
	In <cf/type broadcast/ or <cf/type ptp/ network configuration, OSPF
2649
	packets are sent as IP multicast packets. This option changes the
2650
	behavior to using old-fashioned IP broadcast packets. This may be useful
2651
	as a workaround if IP multicast for some reason does not work or does
2652
	not work reliably. This is a non-standard option and probably is not
2653
	interoperable with other OSPF implementations. Default value is no.
2654

    
2655
	<tag>ptp netmask <m/switch/</tag>
2656
	In <cf/type ptp/ network configurations, OSPFv2 implementations should
2657
	ignore received netmask field in hello packets and should send hello
2658
	packets with zero netmask field on unnumbered PtP links. But some OSPFv2
2659
	implementations perform netmask checking even for PtP links. This option
2660
	specifies whether real netmask will be used in hello packets on <cf/type
2661
 	ptp/ interfaces. You should ignore this option unless you meet some
2662
	compatibility problems related to this issue. Default value is no for
2663
	unnumbered PtP links, yes otherwise.
2664

    
2665
	<tag>check link <M>switch</M></tag>
2666
	If set, a hardware link state (reported by OS) is taken into consideration.
2667
	When a link disappears (e.g. an ethernet cable is unplugged), neighbors
2668
	are immediately considered unreachable and only the address of the iface
2669
	(instead of whole network prefix) is propagated. It is possible that
2670
	some hardware drivers or platforms do not implement this feature.
2671
	Default value is no.
2672

    
2673
	<tag>bfd <M>switch</M></tag>
2674
	OSPF could use BFD protocol as an advisory mechanism for neighbor
2675
	liveness and failure detection. If enabled, BIRD setups a BFD session
2676
	for each OSPF neighbor and tracks its liveness by it. This has an
2677
	advantage of an order of magnitude lower detection times in case of
2678
	failure. Note that BFD protocol also has to be configured, see
2679
	<ref id="sect-bfd" name="BFD"> section for details. Default value is no.
2680

    
2681
	<tag>ttl security [<m/switch/ | tx only]</tag>
2682
	TTL security is a feature that protects routing protocols from remote
2683
	spoofed packets by using TTL 255 instead of TTL 1 for protocol packets
2684
	destined to neighbors. Because TTL is decremented when packets are
2685
	forwarded, it is non-trivial to spoof packets with TTL 255 from remote
2686
	locations. Note that this option would interfere with OSPF virtual
2687
	links.
2688

    
2689
	If this option is enabled, the router will send OSPF packets with TTL
2690
	255 and drop received packets with TTL less than 255. If this option si
2691
	set to <cf/tx only/, TTL 255 is used for sent packets, but is not
2692
	checked for received packets. Default value is no.
2693

    
2694
	<tag>tx class|dscp|priority <m/num/</tag>
2695
	These options specify the ToS/DiffServ/Traffic class/Priority of the
2696
	outgoing OSPF packets. See <ref id="dsc-prio" name="tx class"> common
2697
	option for detailed description.
2698

    
2699
	<tag>ecmp weight <M>num</M></tag>
2700
	When ECMP (multipath) routes are allowed, this value specifies a
2701
	relative weight used for nexthops going through the iface. Allowed
2702
	values are 1-256. Default value is 1.
2703

    
2704
	<tag>authentication none</tag>
2705
	No passwords are sent in OSPF packets. This is the default value.
2706

    
2707
	<tag>authentication simple</tag>
2708
	Every packet carries 8 bytes of password. Received packets lacking this
2709
	password are ignored. This authentication mechanism is very weak.
2710

    
2711
	<tag>authentication cryptographic</tag>
2712
	16-byte long MD5 digest is appended to every packet. For the digest
2713
	generation 16-byte long passwords are used. Those passwords are not sent
2714
	via network, so this mechanism is quite secure. Packets can still be
2715
	read by an attacker.
2716

    
2717
	<tag>password "<M>text</M>"</tag>
2718
	An 8-byte or 16-byte password used for authentication. See
2719
	<ref id="dsc-pass" name="password"> common option for detailed
2720
	description.
2721

    
2722
	<tag>neighbors { <m/set/ } </tag>
2723
	A set of neighbors to which Hello messages on NBMA or PtMP networks are
2724
	to be sent. For NBMA networks, some of them could be marked as eligible.
2725
	In OSPFv3, link-local addresses should be used, using global ones is
2726
	possible, but it is nonstandard and might be problematic. And definitely,
2727
	link-local and global addresses should not be mixed.
2728
</descrip>
2729

    
2730
<sect1>Attributes
2731

    
2732
<p>OSPF defines four route attributes. Each internal route has a <cf/metric/.
2733

    
2734
<p>Metric is ranging from 1 to infinity (65535). External routes use
2735
<cf/metric type 1/ or <cf/metric type 2/. A <cf/metric of type 1/ is comparable
2736
with internal <cf/metric/, a <cf/metric of type 2/ is always longer than any
2737
<cf/metric of type 1/ or any <cf/internal metric/. <cf/Internal metric/ or
2738
<cf/metric of type 1/ is stored in attribute <cf/ospf_metric1/, <cf/metric type
2739
2/ is stored in attribute <cf/ospf_metric2/. If you specify both metrics only
2740
metric1 is used.
2741

    
2742
<p>Each external route can also carry attribute <cf/ospf_tag/ which is a 32-bit
2743
integer which is used when exporting routes to other protocols; otherwise, it
2744
doesn't affect routing inside the OSPF domain at all. The fourth attribute
2745
<cf/ospf_router_id/ is a router ID of the router advertising that route /
2746
network. This attribute is read-only. Default is <cf/ospf_metric2 = 10000/ and
2747
<cf/ospf_tag = 0/.
2748

    
2749
<sect1>Example
2750

    
2751
<p><code>
2752
protocol ospf MyOSPF {
2753
	rfc1583compat yes;
2754
	tick 2;
2755
	export filter {
2756
		if source = RTS_BGP then {
2757
			ospf_metric1 = 100;
2758
			accept;
2759
		}
2760
		reject;
2761
	};
2762
	area 0.0.0.0 {
2763
		interface "eth*" {
2764
			cost 11;
2765
			hello 15;
2766
			priority 100;
2767
			retransmit 7;
2768
			authentication simple;
2769
			password "aaa";
2770
		};
2771
		interface "ppp*" {
2772
			cost 100;
2773
			authentication cryptographic;
2774
			password "abc" {
2775
				id 1;
2776
				generate to "22-04-2003 11:00:06";
2777
				accept from "17-01-2001 12:01:05";
2778
			};
2779
			password "def" {
2780
				id 2;
2781
				generate to "22-07-2005 17:03:21";
2782
				accept from "22-02-2001 11:34:06";
2783
			};
2784
		};
2785
		interface "arc0" {
2786
			cost 10;
2787
			stub yes;
2788
		};
2789
		interface "arc1";
2790
	};
2791
	area 120 {
2792
		stub yes;
2793
		networks {
2794
			172.16.1.0/24;
2795
			172.16.2.0/24 hidden;
2796
		}
2797
		interface "-arc0" , "arc*" {
2798
			type nonbroadcast;
2799
			authentication none;
2800
			strict nonbroadcast yes;
2801
			wait 120;
2802
			poll 40;
2803
			dead count 8;
2804
			neighbors {
2805
				192.168.120.1 eligible;
2806
				192.168.120.2;
2807
				192.168.120.10;
2808
			};
2809
		};
2810
	};
2811
}
2812
</code>
2813

    
2814

    
2815
<sect>Pipe
2816

    
2817
<sect1>Introduction
2818

    
2819
<p>The Pipe protocol serves as a link between two routing tables, allowing
2820
routes to be passed from a table declared as primary (i.e., the one the pipe is
2821
connected to using the <cf/table/ configuration keyword) to the secondary one
2822
(declared using <cf/peer table/) and vice versa, depending on what's allowed by
2823
the filters. Export filters control export of routes from the primary table to
2824
the secondary one, import filters control the opposite direction.
2825

    
2826
<p>The Pipe protocol may work in the transparent mode mode or in the opaque
2827
mode. In the transparent mode, the Pipe protocol retransmits all routes from
2828
one table to the other table, retaining their original source and attributes.
2829
If import and export filters are set to accept, then both tables would have
2830
the same content. The transparent mode is the default mode.
2831

    
2832
<p>In the opaque mode, the Pipe protocol retransmits optimal route from one
2833
table to the other table in a similar way like other protocols send and receive
2834
routes. Retransmitted route will have the source set to the Pipe protocol, which
2835
may limit access to protocol specific route attributes. This mode is mainly for
2836
compatibility, it is not suggested for new configs. The mode can be changed by
2837
<tt/mode/ option.
2838

    
2839
<p>The primary use of multiple routing tables and the Pipe protocol is for
2840
policy routing, where handling of a single packet doesn't depend only on its
2841
destination address, but also on its source address, source interface, protocol
2842
type and other similar parameters. In many systems (Linux being a good example),
2843
the kernel allows to enforce routing policies by defining routing rules which
2844
choose one of several routing tables to be used for a packet according to its
2845
parameters. Setting of these rules is outside the scope of BIRD's work (on
2846
Linux, you can use the <tt/ip/ command), but you can create several routing
2847
tables in BIRD, connect them to the kernel ones, use filters to control which
2848
routes appear in which tables and also you can employ the Pipe protocol for
2849
exporting a selected subset of one table to another one.
2850

    
2851
<sect1>Configuration
2852

    
2853
<p><descrip>
2854
	<tag>peer table <m/table/</tag>
2855
	Defines secondary routing table to connect to. The primary one is
2856
	selected by the <cf/table/ keyword.
2857

    
2858
	<tag>mode opaque|transparent</tag>
2859
	Specifies the mode for the pipe to work in. Default is transparent.
2860
</descrip>
2861

    
2862
<sect1>Attributes
2863

    
2864
<p>The Pipe protocol doesn't define any route attributes.
2865

    
2866
<sect1>Example
2867

    
2868
<p>Let's consider a router which serves as a boundary router of two different
2869
autonomous systems, each of them connected to a subset of interfaces of the
2870
router, having its own exterior connectivity and wishing to use the other AS as
2871
a backup connectivity in case of outage of its own exterior line.
2872

    
2873
<p>Probably the simplest solution to this situation is to use two routing tables
2874
(we'll call them <cf/as1/ and <cf/as2/) and set up kernel routing rules, so that
2875
packets having arrived from interfaces belonging to the first AS will be routed
2876
according to <cf/as1/ and similarly for the second AS. Thus we have split our
2877
router to two logical routers, each one acting on its own routing table, having
2878
its own routing protocols on its own interfaces. In order to use the other AS's
2879
routes for backup purposes, we can pass the routes between the tables through a
2880
Pipe protocol while decreasing their preferences and correcting their BGP paths
2881
to reflect the AS boundary crossing.
2882

    
2883
<code>
2884
table as1;				# Define the tables
2885
table as2;
2886

    
2887
protocol kernel kern1 {			# Synchronize them with the kernel
2888
	table as1;
2889
	kernel table 1;
2890
}
2891

    
2892
protocol kernel kern2 {
2893
	table as2;
2894
	kernel table 2;
2895
}
2896

    
2897
protocol bgp bgp1 {			# The outside connections
2898
	table as1;
2899
	local as 1;
2900
	neighbor 192.168.0.1 as 1001;
2901
	export all;
2902
	import all;
2903
}
2904

    
2905
protocol bgp bgp2 {
2906
	table as2;
2907
	local as 2;
2908
	neighbor 10.0.0.1 as 1002;
2909
	export all;
2910
	import all;
2911
}
2912

    
2913
protocol pipe {				# The Pipe
2914
	table as1;
2915
	peer table as2;
2916
	export filter {
2917
		if net ~ [ 1.0.0.0/8+] then {	# Only AS1 networks
2918
			if preference>10 then preference = preference-10;
2919
			if source=RTS_BGP then bgp_path.prepend(1);
2920
			accept;
2921
		}
2922
		reject;
2923
	};
2924
	import filter {
2925
		if net ~ [ 2.0.0.0/8+] then {	# Only AS2 networks
2926
			if preference>10 then preference = preference-10;
2927
			if source=RTS_BGP then bgp_path.prepend(2);
2928
			accept;
2929
		}
2930
		reject;
2931
	};
2932
}
2933
</code>
2934

    
2935

    
2936
<sect>RAdv
2937

    
2938
<sect1>Introduction
2939

    
2940
<p>The RAdv protocol is an implementation of Router Advertisements, which are
2941
used in the IPv6 stateless autoconfiguration. IPv6 routers send (in irregular
2942
time intervals or as an answer to a request) advertisement packets to connected
2943
networks. These packets contain basic information about a local network (e.g. a
2944
list of network prefixes), which allows network hosts to autoconfigure network
2945
addresses and choose a default route. BIRD implements router behavior as defined
2946
in RFC 4861<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc4861.txt">
2947
and also the DNS extensions from
2948
RFC 6106<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc6106.txt">.
2949

    
2950
<sect1>Configuration
2951

    
2952
<p>There are several classes of definitions in RAdv configuration -- interface
2953
definitions, prefix definitions and DNS definitions:
2954

    
2955
<descrip>
2956
	<tag>interface <m/pattern [, ...]/ { <m/options/ }</tag>
2957
	Interface definitions specify a set of interfaces on which the
2958
	protocol is activated and contain interface specific options.
2959
	See <ref id="dsc-iface" name="interface"> common options for
2960
	detailed description.
2961

    
2962
	<tag>prefix <m/prefix/ { <m/options/ }</tag>
2963
	Prefix definitions allow to modify a list of advertised prefixes. By
2964
	default, the advertised prefixes are the same as the network prefixes
2965
	assigned to the interface. For each network prefix, the matching prefix
2966
	definition is found and its options are used. If no matching prefix
2967
	definition is found, the prefix is used with default options.
2968

    
2969
	Prefix definitions can be either global or interface-specific. The
2970
	second ones are part of interface options. The prefix definition
2971
	matching is done in the first-match style, when interface-specific
2972
	definitions are processed before global definitions. As expected, the
2973
	prefix definition is matching if the network prefix is a subnet of the
2974
	prefix in prefix definition.
2975

    
2976
	<tag>rdnss { <m/options/ }</tag>
2977
	RDNSS definitions allow to specify a list of advertised recursive DNS
2978
	servers together with their options. As options are seldom necessary,
2979
	there is also a short variant <cf>rdnss <m/address/</cf> that just
2980
	specifies one DNS server. Multiple definitions are cumulative. RDNSS
2981
	definitions may also be interface-specific when used inside interface
2982
	options. By default, interface uses both global and interface-specific
2983
	options, but that can be changed by <cf/rdnss local/ option.
2984

    
2985
	<tag>dnssl { <m/options/ }</tag>
2986
	DNSSL definitions allow to specify a list of advertised DNS search
2987
	domains together with their options. Like <cf/rdnss/ above, multiple
2988
	definitions are cumulative, they can be used also as interface-specific
2989
	options and there is a short variant <cf>dnssl <m/domain/</cf> that just
2990
	specifies one DNS search domain.
2991

    
2992
	<label id="dsc-trigger"> <tag>trigger <m/prefix/</tag>
2993
	RAdv protocol could be configured to change its behavior based on
2994
	availability of routes. When this option is used, the protocol waits in
2995
	suppressed state until a <it/trigger route/ (for the specified network)
2996
	is exported to the protocol, the protocol also returnsd to suppressed
2997
	state if the <it/trigger route/ disappears. Note that route export
2998
	depends on specified export filter, as usual. This option could be used,
2999
	e.g., for handling failover in multihoming scenarios.
3000

    
3001
	During suppressed state, router advertisements are generated, but with
3002
	some fields zeroed. Exact behavior depends on which fields are zeroed,
3003
	this can be configured by <cf/sensitive/ option for appropriate
3004
	fields. By default, just <cf/default lifetime/ (also called <cf/router
3005
	lifetime/) is zeroed, which means hosts cannot use the router as a
3006
	default router. <cf/preferred lifetime/ and <cf/valid lifetime/ could
3007
	also be configured as <cf/sensitive/ for a prefix, which would cause
3008
	autoconfigured IPs to be deprecated or even removed.
3009
</descrip>
3010

    
3011
<p>Interface specific options:
3012

    
3013
<descrip>
3014
	<tag>max ra interval <m/expr/</tag>
3015
	Unsolicited router advertisements are sent in irregular time intervals.
3016
	This option specifies the maximum length of these intervals, in seconds.
3017
	Valid values are 4-1800. Default: 600
3018

    
3019
	<tag>min ra interval <m/expr/</tag>
3020
	This option specifies the minimum length of that intervals, in seconds.
3021
	Must be at least 3 and at most 3/4 * <cf/max ra interval/. Default:
3022
	about 1/3 * <cf/max ra interval/.
3023

    
3024
	<tag>min delay <m/expr/</tag>
3025
	The minimum delay between two consecutive router advertisements, in
3026
	seconds. Default: 3
3027

    
3028
	<tag>managed <m/switch/</tag>
3029
	This option specifies whether hosts should use DHCPv6 for IP address
3030
	configuration. Default: no
3031

    
3032
	<tag>other config <m/switch/</tag>
3033
	This option specifies whether hosts should use DHCPv6 to receive other
3034
	configuration information. Default: no
3035

    
3036
	<tag>link mtu <m/expr/</tag>
3037
	This option specifies which value of MTU should be used by hosts. 0
3038
	means unspecified. Default: 0
3039

    
3040
	<tag>reachable time <m/expr/</tag>
3041
	This option specifies the time (in milliseconds) how long hosts should
3042
	assume a neighbor is reachable (from the last confirmation). Maximum is
3043
	3600000, 0 means unspecified. Default 0.
3044

    
3045
	<tag>retrans timer <m/expr/</tag>
3046
	This option specifies the time (in milliseconds) how long hosts should
3047
	wait before retransmitting Neighbor Solicitation messages. 0 means
3048
	unspecified. Default 0.
3049

    
3050
	<tag>current hop limit <m/expr/</tag>
3051
	This option specifies which value of Hop Limit should be used by
3052
	hosts. Valid values are 0-255, 0 means unspecified. Default: 64
3053

    
3054
	<tag>default lifetime <m/expr/ [sensitive <m/switch/]</tag>
3055
	This option specifies the time (in seconds) how long (after the receipt
3056
	of RA) hosts may use the router as a default router. 0 means do not use
3057
	as a default router. For <cf/sensitive/ option, see <ref id="dsc-trigger" name="trigger">.
3058
	Default: 3 * <cf/max ra	interval/, <cf/sensitive/ yes.
3059

    
3060
	<tag>default preference low|medium|high</tag>
3061
	This option specifies the Default Router Preference value to advertise
3062
	to hosts. Default: medium.
3063

    
3064
	<tag>rdnss local <m/switch/</tag>
3065
	Use only local (interface-specific) RDNSS definitions for this
3066
	interface. Otherwise, both global and local definitions are used. Could
3067
	also be used to disable RDNSS for given interface if no local definitons
3068
	are specified. Default: no.
3069

    
3070
	<tag>dnssl local <m/switch/</tag>
3071
	Use only local DNSSL definitions for this interface. See <cf/rdnss local/
3072
	option above. Default: no.
3073
</descrip>
3074

    
3075

    
3076
<p>Prefix specific options:
3077

    
3078
<descrip>
3079
	<tag>skip <m/switch/</tag>
3080
	This option allows to specify that given prefix should not be
3081
	advertised. This is useful for making exceptions from a default policy
3082
	of advertising all prefixes. Note that for withdrawing an already
3083
	advertised prefix it is more useful to advertise it with zero valid
3084
	lifetime. Default: no
3085

    
3086
	<tag>onlink <m/switch/</tag>
3087
	This option specifies whether hosts may use the advertised prefix for
3088
	onlink determination. Default: yes
3089

    
3090
	<tag>autonomous <m/switch/</tag>
3091
	This option specifies whether hosts may use the advertised prefix for
3092
	stateless autoconfiguration. Default: yes
3093

    
3094
	<tag>valid lifetime <m/expr/ [sensitive <m/switch/]</tag>
3095
	This option specifies the time (in seconds) how long (after the
3096
	receipt of RA) the prefix information is valid, i.e., autoconfigured
3097
	IP addresses can be assigned and hosts with that IP addresses are
3098
	considered directly reachable. 0 means the prefix is no longer
3099
	valid. For <cf/sensitive/ option, see <ref id="dsc-trigger" name="trigger">.
3100
	Default: 86400 (1 day), <cf/sensitive/ no.
3101

    
3102
	<tag>preferred lifetime <m/expr/ [sensitive <m/switch/]</tag>
3103
	This option specifies the time (in seconds) how long (after the
3104
	receipt of RA) IP addresses generated from the prefix using stateless
3105
	autoconfiguration remain preferred. For <cf/sensitive/ option,
3106
	see <ref id="dsc-trigger" name="trigger">. Default: 14400 (4 hours),
3107
	<cf/sensitive/ no.
3108
</descrip>
3109

    
3110

    
3111
<p>RDNSS specific options:
3112

    
3113
<descrip>
3114
	<tag>ns <m/address/</tag>
3115
	This option specifies one recursive DNS server. Can be used multiple
3116
	times for multiple servers. It is mandatory to have at least one
3117
	<cf/ns/ option in <cf/rdnss/ definition.
3118

    
3119
	<tag>lifetime [mult] <m/expr/</tag>
3120
	This option specifies the time how long the RDNSS information may be
3121
	used by clients after the receipt of RA. It is expressed either in
3122
	seconds or (when <cf/mult/ is used) in multiples of <cf/max ra
3123
	interval/. Note that RDNSS information is also invalidated when
3124
	<cf/default lifetime/ expires. 0 means these addresses are no longer
3125
	valid DNS servers. Default: 3 * <cf/max ra interval/.
3126
</descrip>
3127

    
3128

    
3129
<p>DNSSL specific options:
3130

    
3131
<descrip>
3132
	<tag>domain <m/address/</tag>
3133
	This option specifies one DNS search domain. Can be used multiple times
3134
	for multiple domains. It is mandatory to have at least one <cf/domain/
3135
	option in <cf/dnssl/ definition.
3136

    
3137
	<tag>lifetime [mult] <m/expr/</tag>
3138
	This option specifies the time how long the DNSSL information may be
3139
	used by clients after the receipt of RA. Details are the same as for
3140
	RDNSS <cf/lifetime/ option above. Default: 3 * <cf/max ra interval/.
3141
</descrip>
3142

    
3143

    
3144
<sect1>Example
3145

    
3146
<p><code>
3147
protocol radv {
3148
	interface "eth2" {
3149
		max ra interval 5;	# Fast failover with more routers
3150
		managed yes;		# Using DHCPv6 on eth2
3151
		prefix ::/0 {
3152
			autonomous off;	# So do not autoconfigure any IP
3153
		};
3154
	};
3155

    
3156
	interface "eth*";		# No need for any other options
3157

    
3158
	prefix 2001:0DB8:1234::/48 {
3159
		preferred lifetime 0;	# Deprecated address range
3160
	};
3161

    
3162
	prefix 2001:0DB8:2000::/48 {
3163
		autonomous off;		# Do not autoconfigure
3164
	};
3165

    
3166
	rdnss 2001:0DB8:1234::10;	# Short form of RDNSS
3167

    
3168
	rdnss {
3169
		lifetime mult 10;
3170
		ns 2001:0DB8:1234::11;
3171
		ns 2001:0DB8:1234::12;
3172
	};
3173

    
3174
	dnssl {
3175
		lifetime 3600;
3176
		domain "abc.com";
3177
		domain "xyz.com";
3178
	};
3179
}
3180
</code>
3181

    
3182

    
3183
<sect>RIP
3184

    
3185
<sect1>Introduction
3186

    
3187
<p>The RIP protocol (also sometimes called Rest In Pieces) is a simple protocol,
3188
where each router broadcasts (to all its neighbors) distances to all networks it
3189
can reach. When a router hears distance to another network, it increments it and
3190
broadcasts it back. Broadcasts are done in regular intervals. Therefore, if some
3191
network goes unreachable, routers keep telling each other that its distance is
3192
the original distance plus 1 (actually, plus interface metric, which is usually
3193
one). After some time, the distance reaches infinity (that's 15 in RIP) and all
3194
routers know that network is unreachable. RIP tries to minimize situations where
3195
counting to infinity is necessary, because it is slow. Due to infinity being 16,
3196
you can't use RIP on networks where maximal distance is higher than 15
3197
hosts. You can read more about RIP at
3198
<HTMLURL URL="http://www.ietf.org/html.charters/rip-charter.html"
3199
name="http://www.ietf.org/html.charters/rip-charter.html">. Both IPv4
3200
(RFC 1723 <htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc1723.txt">) and IPv6
3201
(RFC 2080 <htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc2080.txt">) versions
3202
of RIP are supported by BIRD, historical RIPv1
3203
(RFC 1058 <htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc1058.txt">) is not
3204
currently supported. RIPv4 MD5 authentication
3205
(RFC 2082 <htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc2082.txt">) is
3206
supported.
3207

    
3208
<p>RIP is a very simple protocol, and it has a lot of shortcomings. Slow
3209
convergence, big network load and inability to handle larger networks makes it
3210
pretty much obsolete. It is still usable on very small networks.
3211

    
3212
<sect1>Configuration
3213

    
3214
<p>In addition to options common for all to other protocols, RIP supports the
3215
following ones:
3216

    
3217
<descrip>
3218
	<tag>authentication none|plaintext|md5</tag>
3219
	Selects authentication method to be used. <cf/none/ means that packets
3220
	are not authenticated at all, <cf/plaintext/ means that a plaintext
3221
	password is embedded into each packet, and <cf/md5/ means that packets
3222
	are authenticated using a MD5 cryptographic hash. If you set
3223
	authentication to not-none, it is a good idea to add <cf>password</cf>
3224
	section. Default: none.
3225

    
3226
	<tag>honor always|neighbor|never</tag>
3227
	Specifies when should requests for dumping routing table be honored.
3228
	(Always, when sent from a host on a directly connected network or
3229
	never.) Routing table updates are honored only from neighbors, that is
3230
	not configurable. Default: never.
3231
</descrip>
3232

    
3233
<p>There are some options that can be specified per-interface:
3234

    
3235
<descrip>
3236
	<tag>metric <m/num/</tag>
3237
	This option specifies the metric of the interface. Valid
3238

    
3239
	<tag>mode multicast|broadcast|quiet|nolisten|version1</tag>
3240
	This option selects the mode for RIP to use on the interface. If nothing
3241
	is specified, RIP runs in multicast mode. <cf/version1/ is currently
3242
	equivalent to <cf/broadcast/, and it makes RIP talk to a broadcast
3243
	address even through multicast mode is possible. <cf/quiet/ option means
3244
	that RIP will not transmit any periodic messages to this interface and
3245
	<cf/nolisten/ means that RIP will send to this interface butnot listen
3246
	to it.
3247

    
3248
	<tag>ttl security [<m/switch/ | tx only]</tag>
3249
	TTL security is a feature that protects routing protocols from remote
3250
	spoofed packets by using TTL 255 instead of TTL 1 for protocol packets
3251
	destined to neighbors. Because TTL is decremented when packets are
3252
	forwarded, it is non-trivial to spoof packets with TTL 255 from remote
3253
	locations.
3254

    
3255
	If this option is enabled, the router will send RIP packets with TTL 255
3256
	and drop received packets with TTL less than 255. If this option si set
3257
	to <cf/tx only/, TTL 255 is used for sent packets, but is not checked
3258
	for received packets. Such setting does not offer protection, but offers
3259
	compatibility with neighbors regardless of whether they use ttl
3260
	security.
3261

    
3262
	Note that for RIPng, TTL security is a standard behavior (required by
3263
	RFC 2080), but BIRD uses <cf/tx only/ by default, for compatibility with
3264
	older versions. For IPv4 RIP, default value is no.
3265

    
3266
	<tag>tx class|dscp|priority <m/num/</tag>
3267
	These options specify the ToS/DiffServ/Traffic class/Priority of the
3268
	outgoing RIP packets. See <ref id="dsc-prio" name="tx class"> common
3269
	option for detailed description.
3270
</descrip>
3271

    
3272
<p>The following options generally override behavior specified in RFC. If you
3273
use any of these options, BIRD will no longer be RFC-compliant, which means it
3274
will not be able to talk to anything other than equally configured BIRD. I have
3275
warned you.
3276

    
3277
<descrip>
3278
	<tag>port <M>number</M></tag>
3279
	Selects IP port to operate on, default 520. (This is useful when testing
3280
	BIRD, if you set this to an address &gt;1024, you will not need to run
3281
	bird with UID==0).
3282

    
3283
	<tag>infinity <M>number</M></tag>
3284
	Selects the value of infinity, default is 16. Bigger values will make
3285
	protocol convergence even slower.
3286

    
3287
	<tag>period <M>number</M></tag>
3288
	Specifies the number of seconds between periodic updates. Default is 30
3289
	seconds. A lower number will mean faster convergence but bigger network
3290
	load. Do not use values lower than 12.
3291

    
3292
	<tag>timeout time <M>number</M></tag>
3293
	Specifies how old route has to be to be considered unreachable.
3294
	Default is 4*<cf/period/.
3295

    
3296
	<tag>garbage time <M>number</M></tag>
3297
	Specifies how old route has to be to be discarded. Default is
3298
	10*<cf/period/.
3299
</descrip>
3300

    
3301
<sect1>Attributes
3302

    
3303
<p>RIP defines two route attributes:
3304

    
3305
<descrip>
3306
	<tag>int <cf/rip_metric/</tag>
3307
	RIP metric of the route (ranging from 0 to <cf/infinity/).  When routes
3308
	from different RIP instances are available and all of them have the same
3309
	preference, BIRD prefers the route with lowest <cf/rip_metric/. When
3310
	importing a non-RIP route, the metric defaults to 5.
3311

    
3312
	<tag>int <cf/rip_tag/</tag>
3313
	RIP route tag: a 16-bit number which can be used to carry additional
3314
	information with the route (for example, an originating AS number in
3315
	case of external routes). When importing a non-RIP route, the tag
3316
	defaults to 0.
3317
</descrip>
3318

    
3319
<sect1>Example
3320

    
3321
<p><code>
3322
protocol rip MyRIP_test {
3323
        debug all;
3324
        port 1520;
3325
        period 12;
3326
        garbage time 60;
3327
        interface "eth0" { metric 3; mode multicast; };
3328
	interface "eth*" { metric 2; mode broadcast; };
3329
        honor neighbor;
3330
        authentication none;
3331
        import filter { print "importing"; accept; };
3332
        export filter { print "exporting"; accept; };
3333
}
3334
</code>
3335

    
3336

    
3337
<sect>Static
3338

    
3339
<p>The Static protocol doesn't communicate with other routers in the network,
3340
but instead it allows you to define routes manually. This is often used for
3341
specifying how to forward packets to parts of the network which don't use
3342
dynamic routing at all and also for defining sink routes (i.e., those telling to
3343
return packets as undeliverable if they are in your IP block, you don't have any
3344
specific destination for them and you don't want to send them out through the
3345
default route to prevent routing loops).
3346

    
3347
<p>There are five types of static routes: `classical' routes telling to forward
3348
packets to a neighboring router, multipath routes specifying several (possibly
3349
weighted) neighboring routers, device routes specifying forwarding to hosts on a
3350
directly connected network, recursive routes computing their nexthops by doing
3351
route table lookups for a given IP and special routes (sink, blackhole etc.)
3352
which specify a special action to be done instead of forwarding the packet.
3353

    
3354
<p>When the particular destination is not available (the interface is down or
3355
the next hop of the route is not a neighbor at the moment), Static just
3356
uninstalls the route from the table it is connected to and adds it again as soon
3357
as the destination becomes adjacent again.
3358

    
3359
<p>The Static protocol does not have many configuration options. The definition
3360
of the protocol contains mainly a list of static routes:
3361

    
3362
<descrip>
3363
	<tag>route <m/prefix/ via <m/ip/</tag>
3364
	Static route through a neighboring router.
3365

    
3366
	<tag>route <m/prefix/ multipath via <m/ip/ [weight <m/num/] [via ...]</tag>
3367
	Static multipath route. Contains several nexthops (gateways), possibly
3368
 	with their weights.
3369

    
3370
	<tag>route <m/prefix/ via <m/"interface"/</tag>
3371
	Static device route through an interface to hosts on a directly
3372
	connected network.
3373

    
3374
	<tag>route <m/prefix/ recursive <m/ip/</tag>
3375
	Static recursive route, its nexthop depends on a route table lookup for
3376
	given IP address.
3377

    
3378
	<tag>route <m/prefix/ blackhole|unreachable|prohibit</tag>
3379
	Special routes specifying to silently drop the packet, return it as
3380
	unreachable or return it as administratively prohibited. First two
3381
	targets are also known as <cf/drop/ and <cf/reject/.
3382

    
3383
	<tag>check link <m/switch/</tag>
3384
	If set, hardware link states of network interfaces are taken into
3385
	consideration.  When link disappears (e.g. ethernet cable is unplugged),
3386
	static routes directing to that interface are removed. It is possible
3387
	that some hardware drivers or platforms do not implement this feature.
3388
	Default: off.
3389

    
3390
	<tag>igp table <m/name/</tag>
3391
	Specifies a table that is used for route table lookups of recursive
3392
	routes. Default: the same table as the protocol is connected to.
3393
</descrip>
3394

    
3395
<p>Static routes have no specific attributes.
3396

    
3397
<p>Example static config might look like this:
3398

    
3399
<p><code>
3400
protocol static {
3401
	table testable;			 # Connect to a non-default routing table
3402
	route 0.0.0.0/0 via 198.51.100.130; # Default route
3403
	route 10.0.0.0/8 multipath	 # Multipath route
3404
		via 198.51.100.10 weight 2
3405
		via 198.51.100.20
3406
		via 192.0.2.1;
3407
	route 203.0.113.0/24 unreachable; # Sink route
3408
	route 10.2.0.0/24 via "arc0";	 # Secondary network
3409
}
3410
</code>
3411

    
3412

    
3413
<chapt>Conclusions
3414

    
3415
<sect>Future work
3416

    
3417
<p>Although BIRD supports all the commonly used routing protocols, there are
3418
still some features which would surely deserve to be implemented in future
3419
versions of BIRD:
3420

    
3421
<itemize>
3422
<item>Opaque LSA's
3423
<item>Route aggregation and flap dampening
3424
<item>Multipath routes
3425
<item>Multicast routing protocols
3426
<item>Ports to other systems
3427
</itemize>
3428

    
3429

    
3430
<sect>Getting more help
3431

    
3432
<p>If you use BIRD, you're welcome to join the bird-users mailing list
3433
(<HTMLURL URL="mailto:bird-users@network.cz" name="bird-users@network.cz">)
3434
where you can share your experiences with the other users and consult
3435
your problems with the authors. To subscribe to the list, visit
3436
<HTMLURL URL="http://bird.network.cz/?m_list" name="http://bird.network.cz/?m_list">.
3437
The home page of BIRD can be found at <HTMLURL URL="http://bird.network.cz/" name="http://bird.network.cz/">.
3438

    
3439
<p>BIRD is a relatively young system and it probably contains some bugs. You can
3440
report any problems to the bird-users list and the authors will be glad to solve
3441
them, but before you do so, please make sure you have read the available
3442
documentation and that you are running the latest version (available at
3443
<HTMLURL URL="ftp://bird.network.cz/pub/bird" name="bird.network.cz:/pub/bird">).
3444
(Of course, a patch which fixes the bug is always welcome as an attachment.)
3445

    
3446
<p>If you want to understand what is going inside, Internet standards are a good
3447
and interesting reading. You can get them from
3448
<HTMLURL URL="ftp://ftp.rfc-editor.org/" name="ftp.rfc-editor.org"> (or a
3449
nicely sorted version from <HTMLURL URL="ftp://atrey.karlin.mff.cuni.cz/pub/rfc"
3450
name="atrey.karlin.mff.cuni.cz:/pub/rfc">).
3451

    
3452
<p><it/Good luck!/
3453

    
3454
</book>
3455

    
3456
<!--
3457
LocalWords:  GPL IPv GateD BGPv RIPv OSPFv Linux sgml html dvi sgmltools Pavel
3458
LocalWords:  linuxdoc dtd descrip config conf syslog stderr auth ospf bgp Mbps
3459
LocalWords:  router's eval expr num birdc ctl UNIX if's enums bool int ip GCC
3460
LocalWords:  len ipaddress pxlen netmask enum bgppath bgpmask clist gw md eth
3461
LocalWords:  RTS printn quitbird iBGP AS'es eBGP RFC multiprotocol IGP Machek
3462
LocalWords:  EGP misconfigurations keepalive pref aggr aggregator BIRD's RTC
3463
LocalWords:  OS'es AS's multicast nolisten misconfigured UID blackhole MRTD MTU
3464
LocalWords:  uninstalls ethernets IP binutils ANYCAST anycast dest RTD ICMP rfc
3465
LocalWords:  compat multicasts nonbroadcast pointopoint loopback sym stats
3466
LocalWords:  Perl SIGHUP dd mm yy HH MM SS EXT IA UNICAST multihop Discriminator txt
3467
LocalWords:  proto wildcard Ondrej Filip
3468
-->