Statistics
| Branch: | Revision:

iof-bird-daemon / doc / bird.sgml @ cf3e3845

History | View | Annotate | Download (208 KB)

1
<!doctype birddoc system>
2

    
3
<!--
4
	BIRD 2.0 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 2.0 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
Jan Matejka <it/&lt;mq@jmq.cz&gt;/,
29
Ondrej Zajicek <it/&lt;santiago@crfreenet.org&gt;/
30
</author>
31

    
32
<abstract>
33
This document contains user documentation for the BIRD Internet Routing Daemon project.
34
</abstract>
35

    
36
<!-- Table of contents -->
37
<toc>
38

    
39
<!-- Begin the document -->
40

    
41

    
42
<chapt>Introduction
43
<label id="intro">
44

    
45
<sect>What is BIRD
46
<label id="what-is-bird">
47

    
48
<p>The name `BIRD' is actually an acronym standing for `BIRD Internet Routing
49
Daemon'. Let's take a closer look at the meaning of the name:
50

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

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

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

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

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

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

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

    
117
<p>BIRD 1.x supported either IPv4 or IPv6 protocol, but had to be compiled separately
118
for each one. BIRD~2 supports both of them with a possibility of further extension.
119
BIRD~2 supports Linux at least 3.16, FreeBSD 10, NetBSD 7.0, and OpenBSD 5.8.
120
Anyway, it will probably work well also on older systems.
121

    
122
<sect>Installing BIRD
123
<label id="install">
124

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

    
128
<code>
129
	./configure
130
	make
131
	make install
132
	vi /usr/local/etc/bird.conf
133
	bird
134
</code>
135

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

    
141

    
142
<sect>Running BIRD
143
<label id="argv">
144

    
145
<p>You can pass several command-line options to bird:
146

    
147
<descrip>
148
	<tag><label id="argv-config">-c <m/config name/</tag>
149
	use given configuration file instead of <it/prefix/<file>/etc/bird.conf</file>.
150

    
151
	<tag><label id="argv-debug">-d</tag>
152
	enable debug messages and run bird in foreground.
153

    
154
	<tag><label id="argv-log-file">-D <m/filename of debug log/</tag>
155
	log debugging information to given file instead of stderr.
156

    
157
	<tag><label id="argv-foreground">-f</tag>
158
	run bird in foreground.
159

    
160
	<tag><label id="argv-group">-g <m/group/</tag>
161
	use that group ID, see the next section for details.
162

    
163
	<tag><label id="argv-help">-h, --help</tag>
164
	display command-line options to bird.
165

    
166
	<tag><label id="argv-local">-l</tag>
167
	look for a configuration file and a communication socket in the current
168
	working directory instead of in default system locations. However, paths
169
	specified by options <cf/-c/, <cf/-s/ have higher priority.
170

    
171
	<tag><label id="argv-parse">-p</tag>
172
	just parse the config file and exit. Return value is zero if the config
173
	file is valid, nonzero if there are some errors.
174

    
175
	<tag><label id="argv-pid">-P <m/name of PID file/</tag>
176
	create a PID file with given filename.
177

    
178
	<tag><label id="argv-recovery">-R</tag>
179
	apply graceful restart recovery after start.
180

    
181
	<tag><label id="argv-socket">-s <m/name of communication socket/</tag>
182
	use given filename for a socket for communications with the client,
183
	default is <it/prefix/<file>/var/run/bird.ctl</file>.
184

    
185
	<tag><label id="argv-user">-u <m/user/</tag>
186
	drop privileges and use that user ID, see the next section for details.
187

    
188
	<tag><label id="argv-version">--version</tag>
189
	display bird version.
190
</descrip>
191

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

    
194

    
195
<sect>Privileges
196
<label id="privileges">
197

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

    
208
<p>An unprivileged user (as an argument to <cf/-u/ options) may be the user
209
<cf/nobody/, but it is suggested to use a new dedicated user account (like
210
<cf/bird/). The similar considerations apply for the group option, but there is
211
one more condition -- the users in the same group can use <file/birdc/ to
212
control BIRD.
213

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

    
219

    
220
<chapt>Architecture
221
<label id="architecture">
222

    
223
<sect>Routing tables
224
<label id="routing-tables">
225

    
226
<p>The heart of BIRD is a routing table. BIRD has several independent routing tables;
227
each of them contains routes of exactly one <m/nettype/ (see below). There are two
228
default tables -- <cf/master4/ for IPv4 routes and <cf/master6/ for IPv6 routes.
229
Other tables must be explicitly configured.
230

    
231
<p>
232
These routing tables are not kernel forwarding tables. No forwarding is done by
233
BIRD. If you want to forward packets using the routes in BIRD tables, you may
234
use the Kernel protocol (see below) to synchronize them with kernel FIBs.
235

    
236
<p>
237
Every nettype defines a (kind of) primary key on routes. Every route source can
238
supply one route for every possible primary key; new route announcement replaces
239
the old route from the same source, keeping other routes intact. BIRD always
240
chooses the best route for each primary key among the known routes and keeps the
241
others as suboptimal. When the best route is retracted, BIRD re-runs the best
242
route selection algorithm to find the current best route.
243

    
244
<p>
245
The global best route selection algorithm is (roughly) as follows:
246

    
247
<itemize>
248
	<item>Preferences of the routes are compared.
249
	<item>Source protocol instance preferences are compared.
250
	<item>If source protocols are the same (e.g. BGP vs. BGP), the protocol's route selection algorithm is invoked.
251
	<item>If source protocols are different (e.g. BGP vs. OSPF), result of the algorithm is undefined.
252
</itemize>
253

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

    
266
<sect>Routes and network types
267
<label id="routes">
268

    
269
<p>BIRD works with several types of routes. Some of them are typical IP routes,
270
others are better described as forwarding rules. We call them all routes,
271
regardless of this difference.
272

    
273
<p>Every route consists of several attributes (read more about them in the
274
<ref id="route-attributes" name="Route attributes"> section); the common for all
275
routes are:
276

    
277
<itemize>
278
	<item>IP address of router which told us about this route
279
	<item>Source protocol instance
280
	<item>Route preference
281
	<item>Optional attributes defined by protocols
282
</itemize>
283

    
284
<p>Other attributes depend on nettypes. Some of them are part of the primary key, these are marked (PK).
285

    
286
<sect1>IPv4 and IPv6 routes
287
<label id="ip-routes">
288

    
289
<p>The traditional routes. Configuration keywords are <cf/ipv4/ and <cf/ipv6/.
290

    
291
<itemize>
292
	<item>(PK) Route destination (IP prefix together with its length)
293
	<item>Route next hops (see below)
294
</itemize>
295

    
296
<sect1>VPN IPv4 and IPv6 routes
297
<label id="vpn-routes">
298

    
299
<p>Routes for IPv4 and IPv6 with VPN Route Distinguisher (<rfc id="4364">).
300
Configuration keywords are <cf/vpn4/ and <cf/vpn6/.
301

    
302
<itemize>
303
	<item>(PK) Route destination (IP prefix together with its length)
304
	<item>(PK) Route distinguisher (according to <rfc id="4364">)
305
	<item>Route next hops
306
</itemize>
307

    
308
<sect1>Route Origin Authorization for IPv4 and IPv6
309
<label id="roa-routes">
310

    
311
<p>These entries can be used to validate route origination of BGP routes.
312
A ROA entry specifies prefixes which could be originated by an AS number.
313
Their keywords are <cf/roa4/ and <cf/roa6/.
314

    
315
<itemize>
316
	<item>(PK) IP prefix together with its length
317
	<item>(PK) Matching prefix maximal length
318
	<item>(PK) AS number
319
</itemize>
320

    
321
<sect1>Flowspec for IPv4 and IPv6
322
<label id="flow-routes">
323

    
324
<p>Flowspec rules are a form of firewall and traffic flow control rules
325
distributed mostly via BGP. These rules may help the operators stop various
326
network attacks in the beginning before eating up the whole bandwidth.
327
Configuration keywords are <cf/flow4/ and <cf/flow6/.
328

    
329
<itemize>
330
	<item>(PK) IP prefix together with its length
331
	<item>(PK) Flow definition data
332
	<item>Flow action (encoded internally as BGP communities according to <rfc id="5575">)
333
</itemize>
334

    
335
<sect1>MPLS switching rules
336
<label id="mpls-routes">
337

    
338
<p>This nettype is currently a stub before implementing more support of <rfc id="3031">.
339
BIRD currently does not support any label distribution protocol nor any label assignment method.
340
Only the Kernel, Pipe and Static protocols can use MPLS tables.
341
Configuration keyword is <cf/mpls/.
342

    
343
<itemize>
344
	<item>(PK) MPLS label
345
	<item>Route next hops
346
</itemize>
347

    
348
<sect1>Route next hops
349
<label id="route-next-hop">
350

    
351
<p>This is not a nettype. The route next hop is a complex attribute common for many
352
nettypes as you can see before. Every next hop has its assigned device
353
(either assumed from its IP address or set explicitly). It may have also
354
an IP address and an MPLS stack (one or both independently).
355
Maximal MPLS stack depth is set (in compile time) to 8 labels.
356

    
357
<p>Every route (when eligible to have a next hop) can have more than one next hop.
358
In that case, every next hop has also its weight.
359

    
360
<sect>Protocols and channels
361
<label id="protocols-concept">
362

    
363
<p>BIRD protocol is an abstract class of producers and consumers of the routes.
364
Each protocol may run in multiple instances and bind on one side to route
365
tables via channels, on the other side to specified listen sockets (BGP),
366
interfaces (Babel, OSPF, RIP), APIs (Kernel, Direct), or nothing (Static, Pipe).
367

    
368
<p>There are also two protocols that do not have any channels -- BFD and Device.
369
Both of them are kind of service for other protocols.
370

    
371
<p>Each protocol is connected to a routing table through a channel. Some protocols
372
support only one channel (OSPF, RIP), some protocols support more channels (BGP, Direct).
373
Each channel has two filters which can accept, reject and modify the routes.
374
An <it/export/ filter is applied to routes passed from the routing table to the protocol,
375
an <it/import/ filter is applied to routes in the opposite direction.
376

    
377
<sect>Graceful restart
378
<label id="graceful-restart">
379

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

    
392

    
393
<chapt>Configuration
394
<label id="config">
395

    
396
<sect>Introduction
397
<label id="config-intro">
398

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

    
406
<p>In the config, everything on a line after <cf/#/ or inside <cf>/* */</cf> is
407
a comment, whitespace characters are treated as a single space. If there's a
408
variable number of options, they are grouped using the <cf/{ }/ brackets. Each
409
option is terminated by a <cf/;/. Configuration is case sensitive. There are two
410
ways how to name symbols (like protocol names, filter names, constants etc.). You
411
can either use a simple string starting with a letter followed by any
412
combination of letters and numbers (e.g. <cf/R123/, <cf/myfilter/, <cf/bgp5/) or you can
413
enclose the name into apostrophes (<cf/'/) and than you can use any combination
414
of numbers, letters. hyphens, dots and colons (e.g. <cf/'1:strange-name'/,
415
<cf/'-NAME-'/, <cf/'cool::name'/).
416

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

    
421
<code>
422
protocol kernel {
423
	persist;		# Don't remove routes on BIRD shutdown
424
	scan time 20;		# Scan kernel routing table every 20 seconds
425
	export all;		# Default is export none
426
}
427

    
428
protocol device {
429
	scan time 10;		# Scan interfaces every 10 seconds
430
}
431

    
432
protocol rip {
433
	export all;
434
	import all;
435
	interface "*";
436
}
437
</code>
438

    
439

    
440
<sect>Global options
441
<label id="global-opts">
442

    
443
<p><descrip>
444
	<tag><label id="opt-include">include "<m/filename/";</tag>
445
	This statement causes inclusion of a new file. The <m/filename/ could
446
	also be a wildcard, in that case matching files are included in
447
	alphabetic order. The maximal depth is 8. Note that this statement can
448
	be used anywhere in the config file, even inside other options, but
449
	always on the beginning of line. In the following example, the first
450
	semicolon belongs to the <cf/include/, the second to <cf/ipv6 table/.
451
	If the <file/tablename.conf/ contains exactly one token (the name of the
452
	table), this construction is correct:
453
<code>
454
ipv6 table
455
include "tablename.conf";;
456
</code>
457

    
458
	<tag><label id="opt-log">log "<m/filename/"|syslog [name <m/name/]|stderr all|{ <m/list of classes/ }</tag>
459
	Set logging of messages having the given class (either <cf/all/ or
460
	<cf/{ error|trace [, <m/.../] }/ etc.) into selected destination (a file specified
461
	as a filename string, syslog with optional name argument, or the stderr
462
	output). Classes are:
463
	<cf/info/, <cf/warning/, <cf/error/ and <cf/fatal/ for messages about local problems,
464
	<cf/debug/ for debugging messages,
465
	<cf/trace/ when you want to know what happens in the network,
466
	<cf/remote/ for messages about misbehavior of remote machines,
467
	<cf/auth/ about authentication failures,
468
	<cf/bug/ for internal BIRD bugs.
469
	You may specify more than one <cf/log/ line to establish logging to
470
	multiple destinations. Default: log everything to the system log.
471

    
472
	<tag><label id="opt-debug-protocols">debug protocols all|off|{ states|routes|filters|interfaces|events|packets [, <m/.../] }</tag>
473
	Set global defaults of protocol debugging options. See <cf/debug/ in the
474
	following section. Default: off.
475

    
476
	<tag><label id="opt-debug-commands">debug commands <m/number/</tag>
477
	Control logging of client connections (0 for no logging, 1 for logging
478
	of connects and disconnects, 2 and higher for logging of all client
479
	commands). Default: 0.
480

    
481
	<tag><label id="opt-debug-latency">debug latency <m/switch/</tag>
482
	Activate tracking of elapsed time for internal events. Recent events
483
	could be examined using <cf/dump events/ command. Default: off.
484

    
485
	<tag><label id="opt-debug-latency-limit">debug latency limit <m/time/</tag>
486
	If <cf/debug latency/ is enabled, this option allows to specify a limit
487
	for elapsed time. Events exceeding the limit are logged. Default: 1 s.
488

    
489
	<tag><label id="opt-watchdog-warn">watchdog warning <m/time/</tag>
490
	Set time limit for I/O loop cycle. If one iteration took more time to
491
	complete, a warning is logged. Default: 5 s.
492

    
493
	<tag><label id="opt-watchdog-timeout">watchdog timeout <m/time/</tag>
494
	Set time limit for I/O loop cycle. If the limit is breached, BIRD is
495
	killed by abort signal. The timeout has effective granularity of
496
	seconds, zero means disabled. Default: disabled (0).
497

    
498
	<tag><label id="opt-mrtdump">mrtdump "<m/filename/"</tag>
499
	Set MRTdump file name. This option must be specified to allow MRTdump
500
	feature. Default: no dump file.
501

    
502
	<tag><label id="opt-mrtdump-protocols">mrtdump protocols all|off|{ states|messages [, <m/.../] }</tag>
503
	Set global defaults of MRTdump options. See <cf/mrtdump/ in the
504
	following section. Default: off.
505

    
506
	<tag><label id="opt-filter">filter <m/name local variables/{ <m/commands/ }</tag>
507
	Define a filter. You can learn more about filters in the following
508
	chapter.
509

    
510
	<tag><label id="opt-function">function <m/name/ (<m/parameters/) <m/local variables/ { <m/commands/ }</tag>
511
	Define a function. You can learn more about functions in the following chapter.
512

    
513
	<tag><label id="opt-protocol">protocol rip|ospf|bgp|<m/.../ [<m/name/ [from <m/name2/]] { <m>protocol options</m> }</tag>
514
	Define a protocol instance called <cf><m/name/</cf> (or with a name like
515
	"rip5" generated automatically if you don't specify any
516
	<cf><m/name/</cf>). You can learn more about configuring protocols in
517
	their own chapters. When <cf>from <m/name2/</cf> expression is used,
518
	initial protocol options are taken from protocol or template
519
	<cf><m/name2/</cf> You can run more than one instance of most protocols
520
	(like RIP or BGP). By default, no instances are configured.
521

    
522
	<tag><label id="opt-template">template rip|ospf|bgp|<m/.../ [<m/name/ [from <m/name2/]] { <m>protocol options</m> }</tag>
523
	Define a protocol template instance called <m/name/ (or with a name like
524
	"bgp1" generated automatically if you don't specify any	<m/name/).
525
	Protocol templates can be used to group common options when many
526
	similarly configured protocol instances are to be defined. Protocol
527
	instances (and other templates) can use templates by using <cf/from/
528
	expression and the name of the template. At the moment templates (and
529
	<cf/from/ expression) are not implemented for OSPF protocol.
530

    
531
	<tag><label id="opt-define">define <m/constant/ = <m/expression/</tag>
532
	Define a constant. You can use it later in every place you could use a
533
	value of the same type. Besides, there are some predefined numeric
534
	constants based on /etc/iproute2/rt_* files. A list of defined constants
535
	can be seen (together with other symbols) using 'show symbols' command.
536

    
537
	<tag><label id="opt-router-id">router id <m/IPv4 address/</tag>
538
	Set BIRD's router ID. It's a world-wide unique identification of your
539
	router, usually one of router's IPv4 addresses. Default: the lowest
540
	IPv4 address of a non-loopback interface.
541

    
542
	<tag><label id="opt-router-id-from">router id from [-] [ "<m/mask/" ] [ <m/prefix/ ] [, <m/.../]</tag>
543
	Set BIRD's router ID based on an IPv4 address of an interface specified by
544
	an interface pattern.
545
	See <ref id="proto-iface" name="interface"> section for detailed
546
	description of interface patterns with extended clauses.
547

    
548
	<tag><label id="opt-graceful-restart">graceful restart wait <m/number/</tag>
549
	During graceful restart recovery, BIRD waits for convergence of routing
550
	protocols. This option allows to specify a timeout for the recovery to
551
	prevent waiting indefinitely if some protocols cannot converge. Default:
552
	240 seconds.
553

    
554
	<tag><label id="opt-timeformat">timeformat route|protocol|base|log "<m/format1/" [<m/limit/ "<m/format2/"]</tag>
555
	This option allows to specify a format of date/time used by BIRD. The
556
	first argument specifies for which purpose such format is used.
557
	<cf/route/ is a format used in 'show route' command output,
558
	<cf/protocol/ is used in 'show protocols' command output, <cf/base/ is
559
	used for other commands and <cf/log/ is used in a log file.
560

    
561
	"<m/format1/" is a format string using <it/strftime(3)/ notation (see
562
	<it/man strftime/ for details). It is extended to support sub-second
563
	time part with variable precision (up to microseconds) using "%f"
564
	conversion code (e.g., "%T.%3f" is hh:mm:ss.sss time). <m/limit/ and
565
	"<m/format2/" allow to specify the second format string for times in
566
	past deeper than <m/limit/ seconds.
567

    
568
	There are several shorthands: <cf/iso long/ is a ISO 8601 date/time
569
	format (YYYY-MM-DD hh:mm:ss) that can be also specified using <cf/"%F
570
	%T"/. Similarly, <cf/iso long ms/ and <cf/iso long us/ are ISO 8601
571
	date/time formats with millisecond or microsecond precision.
572
	<cf/iso short/ is a variant of ISO 8601 that uses just the time format
573
	(hh:mm:ss) for near times (up to 20 hours in the past) and the date
574
	format (YYYY-MM-DD) for far times. This is a shorthand for <cf/"%T"
575
	72000 "%F"/. And there are also <cf/iso short ms/ and <cf/iso short us/
576
	high-precision variants of that.
577

    
578
	By default, BIRD uses the <cf/iso short ms/ format for <cf/route/ and
579
	<cf/protocol/ times, and the <cf/iso long ms/ format for <cf/base/ and
580
	<cf/log/ times.
581

    
582
	<tag><label id="opt-table"><m/nettype/ table <m/name/ [sorted]</tag>
583
	Create a new routing table. The default routing tables <cf/master4/ and
584
	<cf/master6/ are created implicitly, other routing tables have to be
585
	added by this command.  Option <cf/sorted/ can be used to enable sorting
586
	of routes, see <ref id="dsc-table-sorted" name="sorted table">
587
	description for details.
588

    
589
	<tag><label id="opt-eval">eval <m/expr/</tag>
590
	Evaluates given filter expression. It is used by the developers for testing of filters.
591
</descrip>
592

    
593

    
594
<sect>Protocol options
595
<label id="protocol-opts">
596

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

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

    
607
<descrip>
608
	<tag><label id="proto-disabled">disabled <m/switch/</tag>
609
	Disables the protocol. You can change the disable/enable status from the
610
	command line interface without needing to touch the configuration.
611
	Disabled protocols are not activated. Default: protocol is enabled.
612

    
613
	<tag><label id="proto-debug">debug all|off|{ states|routes|filters|interfaces|events|packets [, <m/.../] }</tag>
614
	Set protocol debugging options. If asked, each protocol is capable of
615
	writing trace messages about its work to the log (with category
616
	<cf/trace/). You can either request printing of <cf/all/ trace messages
617
	or only of the types selected: <cf/states/ for protocol state changes
618
	(protocol going up, down, starting, stopping etc.), <cf/routes/ for
619
	routes exchanged with the routing table, <cf/filters/ for details on
620
	route filtering, <cf/interfaces/ for interface change events sent to the
621
	protocol, <cf/events/ for events internal to the protocol and <cf/packets/
622
	for packets sent and received by the protocol. Default: off.
623

    
624
	<tag><label id="proto-mrtdump">mrtdump all|off|{ states|messages [, <m/.../] }</tag>
625
	Set protocol MRTdump flags. MRTdump is a standard binary format for
626
	logging information from routing protocols and daemons. These flags
627
	control what kind of information is logged from the protocol to the
628
	MRTdump file (which must be specified by global <cf/mrtdump/ option, see
629
	the previous section). Although these flags are similar to flags of
630
	<cf/debug/ option, their meaning is different and protocol-specific. For
631
	BGP protocol, <cf/states/ logs BGP state changes and <cf/messages/ logs
632
	received BGP messages. Other protocols does not support MRTdump yet.
633

    
634
	<tag><label id="proto-router-id">router id <m/IPv4 address/</tag>
635
	This option can be used to override global router id for a given
636
	protocol. Default: uses global router id.
637

    
638
	<tag><label id="proto-description">description "<m/text/"</tag>
639
	This is an optional description of the protocol. It is displayed as a
640
	part of the output of 'show route all' command.
641

    
642
	<tag><label id="proto-vrf">vrf "<m/text/"</tag>
643
	Associate the protocol with specific VRF. The protocol will be
644
	restricted to interfaces assigned to the VRF and will use sockets bound
645
	to the VRF. Appropriate VRF interface must exist on OS level. For kernel
646
	protocol, an appropriate table still must be explicitly selected by
647
	<cf/table/ option. Note that the VRF support in BIRD and Linux kernel
648
	(4.11) is still in development and is currently problematic outside of
649
	multihop BGP.
650

    
651
	<tag><label id="proto-channel"><m/channel name/ [{<m/channel config/}]</tag>
652
	Every channel must be explicitly stated. See the protocol-specific
653
	configuration for the list of supported channel names. See the
654
	<ref id="channel-opts" name="channel configuration section"> for channel
655
	definition.
656
</descrip>
657

    
658
<p>There are several options that give sense only with certain protocols:
659

    
660
<descrip>
661
	<tag><label id="proto-iface">interface [-] [ "<m/mask/" ] [ <m/prefix/ ] [, <m/.../] [ { <m/option/; [<m/.../] } ]</tag>
662
	Specifies a set of interfaces on which the protocol is activated with
663
	given interface-specific options. A set of interfaces specified by one
664
	interface option is described using an interface pattern. The interface
665
	pattern consists of a sequence of clauses (separated by commas), each
666
	clause is a mask specified as a shell-like pattern. Interfaces are
667
	matched by their name.
668

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

    
674
	Some protocols (namely OSPFv2 and Direct) support extended clauses that
675
	may contain a mask, a prefix, or both of them. An interface matches such
676
	clause if its name matches the mask (if specified) and its address
677
	matches the prefix (if specified). Extended clauses are used when the
678
	protocol handles multiple addresses on an interface independently.
679

    
680
	An interface option can be used more times with different interface-specific
681
	options, in that case for given interface the first matching interface
682
	option is used.
683

    
684
	This option is allowed in Babel, BFD, Device, Direct, OSPF, RAdv and RIP
685
	protocols. In OSPF protocol it is used in the <cf/area/ subsection.
686

    
687
	Default: none.
688

    
689
	Examples:
690

    
691
	<cf>interface "*" { type broadcast; };</cf> - start the protocol on all
692
	interfaces with <cf>type broadcast</cf> option.
693

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

    
697
	<cf>interface -192.168.1.0/24, 192.168.0.0/16;</cf> - start the protocol
698
	on all interfaces that have address from 192.168.0.0/16, but not from
699
	192.168.1.0/24.
700

    
701
	<cf>interface -192.168.1.0/24, 192.168.0.0/16;</cf> - start the protocol
702
	on all interfaces that have address from 192.168.0.0/16, but not from
703
	192.168.1.0/24.
704

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

    
708
	<tag><label id="proto-tx-class">tx class|dscp <m/num/</tag>
709
	This option specifies the value of ToS/DS/Class field in IP headers of
710
	the outgoing protocol packets. This may affect how the protocol packets
711
	are processed by the network relative to the other network traffic. With
712
	<cf/class/ keyword, the value (0-255) is used for the whole ToS/Class
713
	octet (but two bits reserved for ECN are ignored). With	<cf/dscp/
714
	keyword, the value (0-63) is used just for the DS field in the octet.
715
	Default value is 0xc0 (DSCP 0x30 - CS6).
716

    
717
	<tag><label id="proto-tx-priority">tx priority <m/num/</tag>
718
	This option specifies the local packet priority. This may affect how the
719
	protocol packets are processed in the local TX queues. This option is
720
	Linux specific. Default value is 7 (highest priority, privileged traffic).
721

    
722
	<tag><label id="proto-pass">password "<m/password/" [ { <m>password options</m> } ]</tag>
723
	Specifies a password that can be used by the protocol as a shared secret
724
	key. Password option can be used more times to specify more passwords.
725
	If more passwords are specified, it is a protocol-dependent decision
726
	which one is really used. Specifying passwords does not mean that
727
	authentication is enabled, authentication can be enabled by separate,
728
	protocol-dependent <cf/authentication/ option.
729

    
730
	This option is allowed in BFD, OSPF and RIP protocols. BGP has also
731
	<cf/password/ option, but it is slightly different and described
732
	separately.
733
	Default: none.
734
</descrip>
735

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

    
738
<descrip>
739
	<tag><label id="proto-pass-id">id <M>num</M></tag>
740
	ID of the password, (1-255). If it is not used, BIRD will choose ID based
741
	on an order of the password item in the interface. For example, second
742
	password item in one interface will have default ID 2. ID is used by
743
	some routing protocols to identify which password was used to
744
	authenticate protocol packets.
745

    
746
	<tag><label id="proto-pass-gen-from">generate from "<m/time/"</tag>
747
	The start time of the usage of the password for packet signing.
748
	The format of <cf><m/time/</cf> is <tt>dd-mm-yyyy HH:MM:SS</tt>.
749

    
750
	<tag><label id="proto-pass-gen-to">generate to "<m/time/"</tag>
751
	The last time of the usage of the password for packet signing.
752

    
753
	<tag><label id="proto-pass-accept-from">accept from "<m/time/"</tag>
754
	The start time of the usage of the password for packet verification.
755

    
756
	<tag><label id="proto-pass-accept-to">accept to "<m/time/"</tag>
757
	The last time of the usage of the password for packet verification.
758

    
759
	<tag><label id="proto-pass-from">from "<m/time/"</tag>
760
	Shorthand for setting both <cf/generate from/ and <cf/accept from/.
761

    
762
	<tag><label id="proto-pass-to">to "<m/time/"</tag>
763
	Shorthand for setting both <cf/generate to/ and <cf/accept to/.
764

    
765
	<tag><label id="proto-pass-algorithm">algorithm ( keyed md5 | keyed sha1 | hmac sha1 | hmac sha256 | hmac sha384 | hmac sha512 )</tag>
766
	The message authentication algorithm for the password when cryptographic
767
	authentication is enabled. The default value depends on the protocol.
768
	For RIP and OSPFv2 it is Keyed-MD5 (for compatibility), for OSPFv3
769
	protocol it is HMAC-SHA-256.
770

    
771
</descrip>
772

    
773

    
774
<sect>Channel options
775
<label id="channel-opts">
776

    
777
<p>Every channel belongs to a protocol and is configured inside its block. The
778
minimal channel config is empty, then it uses the default values. The name of
779
the channel implies its nettype.
780

    
781
<descrip>
782
	<tag><label id="proto-table">table <m/name/</tag>
783
	Specify a table to which the channel is connected. Default: the first
784
	table of given nettype.
785

    
786
	<tag><label id="proto-preference">preference <m/expr/</tag>
787
	Sets the preference of routes generated by the protocol and imported
788
	through this channel. Default: protocol dependent.
789

    
790
	<tag><label id="proto-import">import all | none | filter <m/name/ | filter { <m/filter commands/ } | where <m/boolean filter expression/</tag>
791
	Specify a filter to be used for filtering routes coming from the
792
	protocol to the routing table. <cf/all/ is for keeping all routes,
793
	<cf/none/ is for dropping all routes. Default: <cf/all/.
794

    
795
	<tag><label id="proto-export">export <m/filter/</tag>
796
	This is similar to the <cf>import</cf> keyword, except that it works in
797
	the direction from the routing table to the protocol. Default: <cf/none/.
798

    
799
	<tag><label id="proto-import-keep-filtered">import keep filtered <m/switch/</tag>
800
	Usually, if an import filter rejects a route, the route is forgotten.
801
	When this option is active, these routes are kept in the routing table,
802
	but they are hidden and not propagated to other protocols. But it is
803
	possible to show them using <cf/show route filtered/. Note that this
804
	option does not work for the pipe protocol. Default: off.
805

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

    
815
	<tag><label id="proto-receive-limit">receive limit [<m/number/ | off ] [action warn | block | restart | disable]</tag>
816
	Specify an receive route limit (a maximum number of routes received from
817
	the protocol and remembered). It works almost identically to <cf>import
818
	limit</cf> option, the only difference is that if <cf/import keep
819
	filtered/ option is active, filtered routes are counted towards the
820
	limit and blocked routes are forgotten, as the main purpose of the
821
	receive limit is to protect routing tables from overflow. Import limit,
822
	on the contrary, counts accepted routes only and routes blocked by the
823
	limit are handled like filtered routes. Default: <cf/off/.
824

    
825
	<tag><label id="proto-export-limit">export limit [ <m/number/ | off ] [action warn | block | restart | disable]</tag>
826
	Specify an export route limit, works similarly to the <cf>import
827
	limit</cf> option, but for the routes exported to the protocol. This
828
	option is experimental, there are some problems in details of its
829
	behavior -- the number of exported routes can temporarily exceed the
830
	limit without triggering it during protocol reload, exported routes
831
	counter ignores route blocking and block action also blocks route
832
	updates of already accepted routes -- and these details will probably
833
	change in the future. Default: <cf/off/.
834
</descrip>
835

    
836
<p>This is a trivial example of RIP configured for IPv6 on all interfaces:
837
<code>
838
protocol rip ng {
839
	ipv6;
840
	interface "*";
841
}
842
</code>
843

    
844
<p>And this is a non-trivial example.
845
<code>
846
protocol rip ng {
847
	ipv6 {
848
		table mytable6;
849
		import filter { ... };
850
		export filter { ... };
851
		import limit 50;
852
	};
853
	interface "*";
854
}
855
</code>
856

    
857
<chapt>Remote control
858
<label id="remote-control">
859

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

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

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

    
881
<p>Here is a brief list of supported functions:
882

    
883
<descrip>
884
	<tag><label id="cli-show-status">show status</tag>
885
	Show router status, that is BIRD version, uptime and time from last
886
	reconfiguration.
887

    
888
	<tag><label id="cli-show-interfaces">show interfaces [summary]</tag>
889
	Show the list of interfaces. For each interface, print its type, state,
890
	MTU and addresses assigned.
891

    
892
	<tag><label id="cli-show-protocols">show protocols [all]</tag>
893
	Show list of protocol instances along with tables they are connected to
894
	and protocol status, possibly giving verbose information, if <cf/all/ is
895
	specified.
896

    
897
	<!-- TODO: Move these protocol-specific remote control commands to the protocol sections -->
898
	<tag><label id="cli-show-ospf-iface">show ospf interface [<m/name/] ["<m/interface/"]</tag>
899
	Show detailed information about OSPF interfaces.
900

    
901
	<tag><label id="cli-show-ospf-neighbors">show ospf neighbors [<m/name/] ["<m/interface/"]</tag>
902
	Show a list of OSPF neighbors and a state of adjacency to them.
903

    
904
	<tag><label id="cli-show-ospf-state">show ospf state [all] [<m/name/]</tag>
905
	Show detailed information about OSPF areas based on a content of the
906
	link-state database. It shows network topology, stub networks,
907
	aggregated networks and routers from other areas and external routes.
908
	The command shows information about reachable network nodes, use option
909
	<cf/all/ to show information about all network nodes in the link-state
910
	database.
911

    
912
	<tag><label id="cli-show-ospf-topology">show ospf topology [all] [<m/name/]</tag>
913
	Show a topology of OSPF areas based on a content of the link-state
914
	database. It is just a stripped-down version of 'show ospf state'.
915

    
916
	<tag><label id="cli-show-ospf-lsadb">show ospf lsadb [global | area <m/id/ | link] [type <m/num/] [lsid <m/id/] [self | router <m/id/] [<m/name/] </tag>
917
	Show contents of an OSPF LSA database. Options could be used to filter
918
	entries.
919

    
920
	<tag><label id="cli-show-rip-interfaces">show rip interfaces [<m/name/] ["<m/interface/"]</tag>
921
	Show detailed information about RIP interfaces.
922

    
923
	<tag><label id="cli-show-rip-neighbors">show rip neighbors [<m/name/] ["<m/interface/"]</tag>
924
	Show a list of RIP neighbors and associated state.
925

    
926
	<tag><label id="cli-show-static">show static [<m/name/]</tag>
927
	Show detailed information about static routes.
928

    
929
	<tag><label id="cli-show-bfd-sessions">show bfd sessions [<m/name/]</tag>
930
	Show information about BFD sessions.
931

    
932
	<tag><label id="cli-show-symbols">show symbols [table|filter|function|protocol|template|roa|<m/symbol/]</tag>
933
	Show the list of symbols defined in the configuration (names of
934
	protocols, routing tables etc.).
935

    
936
	<tag><label id="cli-show-route">show route [[for] <m/prefix/|<m/IP/] [table (<m/t/ | all)] [filter <m/f/|where <m/c/] [(export|preexport|noexport) <m/p/] [protocol <m/p/] [(stats|count)] [<m/options/]</tag>
937
	Show contents of specified routing tables, that is routes, their metrics
938
	and (in case the <cf/all/ switch is given) all their attributes.
939

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

    
947
	<p>The <cf/show route/ command can process one or multiple routing
948
	tables. The set of selected tables is determined on three levels: First,
949
	tables can be explicitly selected by <cf/table/ switch, which could be
950
	used multiple times, all tables are specified by <cf/table all/. Second,
951
	tables can be implicitly selected by channels or protocols that are
952
	arguments of several other switches (e.g., <cf/export/, <cf/protocol/).
953
	Last, the set of default tables is used: <cf/master4/, <cf/master6/ and
954
	each first table of any other network type.
955

    
956
	<p>You can also ask for printing only routes processed and accepted by
957
	a given filter (<cf>filter <m/name/</cf> or <cf>filter { <m/filter/ }
958
	</cf> or matching a given condition (<cf>where <m/condition/</cf>).
959

    
960
	The <cf/export/, <cf/preexport/ and <cf/noexport/ switches ask for
961
	printing of routes that are exported to the specified protocol or
962
	channel. With <cf/preexport/, the export filter of the channel is
963
	skipped. With <cf/noexport/, routes rejected by the export filter are
964
	printed instead. Note that routes not exported for other reasons
965
	(e.g. secondary routes or routes imported from that protocol) are not
966
	printed even with <cf/noexport/. These switches also imply that
967
	associated routing tables are selected instead of default ones.
968

    
969
	<p>You can also select just routes added by a specific protocol.
970
	<cf>protocol <m/p/</cf>. This switch also implies that associated
971
	routing tables are selected instead of default ones.
972

    
973
	<p>If BIRD is configured to keep filtered routes (see <cf/import keep
974
	filtered/ option), you can show them instead of routes by using
975
	<cf/filtered/ switch.
976

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

    
981
	<tag><label id="cli-configure">configure [soft] ["<m/config file/"] [timeout [<m/num/]]</tag>
982
	Reload configuration from a given file. BIRD will smoothly switch itself
983
	to the new configuration, protocols are reconfigured if possible,
984
	restarted otherwise. Changes in filters usually lead to restart of
985
	affected protocols.
986

    
987
	If <cf/soft/ option is used, changes in filters does not cause BIRD to
988
	restart affected protocols, therefore already accepted routes (according
989
	to old filters) would be still propagated, but new routes would be
990
	processed according to the new filters.
991

    
992
	If <cf/timeout/ option is used, config timer is activated. The new
993
	configuration could be either confirmed using <cf/configure confirm/
994
	command, or it will be reverted to the old one when the config timer
995
	expires. This is useful for cases when reconfiguration breaks current
996
	routing and a router becomes inaccessible for an administrator. The
997
	config timeout expiration is equivalent to <cf/configure undo/
998
	command. The timeout duration could be specified, default is 300 s.
999

    
1000
	<tag><label id="cli-configure-confirm">configure confirm</tag>
1001
	Deactivate the config undo timer and therefore confirm the current
1002
	configuration.
1003

    
1004
	<tag><label id="cli-configure-undo">configure undo</tag>
1005
	Undo the last configuration change and smoothly switch back to the
1006
	previous (stored) configuration. If the last configuration change was
1007
	soft, the undo change is also soft. There is only one level of undo, but
1008
	in some specific cases when several reconfiguration requests are given
1009
	immediately in a row and the intermediate ones are skipped then the undo
1010
	also skips them back.
1011

    
1012
	<tag><label id="cli-configure-check">configure check ["<m/config file/"]</tag>
1013
	Read and parse given config file, but do not use it. useful for checking
1014
	syntactic and some semantic validity of an config file.
1015

    
1016
	<tag><label id="cli-enable-disable-restart">enable|disable|restart <m/name/|"<m/pattern/"|all</tag>
1017
	Enable, disable or restart a given protocol instance, instances matching
1018
	the <cf><m/pattern/</cf> or <cf/all/ instances.
1019

    
1020
	<tag><label id="cli-reload">reload [in|out] <m/name/|"<m/pattern/"|all</tag>
1021
	Reload a given protocol instance, that means re-import routes from the
1022
	protocol instance and re-export preferred routes to the instance. If
1023
	<cf/in/ or <cf/out/ options are used, the command is restricted to one
1024
	direction (re-import or re-export).
1025

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

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

    
1037
	<tag><label id="cli-down">down</tag>
1038
	Shut BIRD down.
1039

    
1040
	<tag><label id="cli-debug">debug <m/protocol/|<m/pattern/|all all|off|{ states|routes|filters|events|packets [, <m/.../] }</tag>
1041
	Control protocol debugging.
1042

    
1043
	<tag><label id="cli-dump">dump resources|sockets|interfaces|neighbors|attributes|routes|protocols</tag>
1044
	Dump contents of internal data structures to the debugging output.
1045

    
1046
	<tag><label id="cli-echo">echo all|off|{ <m/list of log classes/ } [ <m/buffer-size/ ]</tag>
1047
	Control echoing of log messages to the command-line output.
1048
	See <ref id="opt-log" name="log option"> for a list of log classes.
1049

    
1050
	<tag><label id="cli-eval">eval <m/expr/</tag>
1051
	Evaluate given expression.
1052
</descrip>
1053

    
1054
<chapt>Filters
1055
<label id="filters">
1056

    
1057
<sect>Introduction
1058
<label id="filters-intro">
1059

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

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

    
1072
<code>
1073
filter not_too_far
1074
int var;
1075
{
1076
	if defined( rip_metric ) then
1077
		var = rip_metric;
1078
	else {
1079
		var = 1;
1080
		rip_metric = 1;
1081
	}
1082
	if rip_metric &gt; 10 then
1083
		reject "RIP metric is too big";
1084
	else
1085
		accept "ok";
1086
}
1087
</code>
1088

    
1089
<p>As you can see, a filter has a header, a list of local variables, and a body.
1090
The header consists of the <cf/filter/ keyword followed by a (unique) name of
1091
filter. The list of local variables consists of <cf><M>type name</M>;</cf>
1092
pairs where each pair defines one local variable. The body consists of <cf>
1093
{ <M>statements</M> }</cf>. Each <m/statement/ is terminated by a <cf/;/. You
1094
can group several statements to a single compound statement by using braces
1095
(<cf>{ <M>statements</M> }</cf>) which is useful if you want to make a bigger
1096
block of code conditional.
1097

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

    
1102
<code>
1103
function name ()
1104
int local_variable;
1105
{
1106
	local_variable = 5;
1107
}
1108

    
1109
function with_parameters (int parameter)
1110
{
1111
	print parameter;
1112
}
1113
</code>
1114

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

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

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

    
1130
<code>
1131
pavel@bug:~/bird$ ./birdc -s bird.ctl
1132
BIRD 0.0.0 ready.
1133
bird> show route
1134
10.0.0.0/8         dev eth0 [direct1 23:21] (240)
1135
195.113.30.2/32    dev tunl1 [direct1 23:21] (240)
1136
127.0.0.0/8        dev lo [direct1 23:21] (240)
1137
bird> show route ?
1138
show route [<prefix>] [table <t>] [filter <f>] [all] [primary]...
1139
bird> show route filter { if 127.0.0.5 &tilde; net then accept; }
1140
127.0.0.0/8        dev lo [direct1 23:21] (240)
1141
bird>
1142
</code>
1143

    
1144

    
1145
<sect>Data types
1146
<label id="data-types">
1147

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

    
1152
<descrip>
1153
	<tag><label id="type-bool">bool</tag>
1154
	This is a boolean type, it can have only two values, <cf/true/ and
1155
	<cf/false/. Boolean is the only type you can use in <cf/if/ statements.
1156

    
1157
	<tag><label id="type-int">int</tag>
1158
	This is a general integer type. It is an unsigned 32bit type; i.e., you
1159
	can expect it to store values from 0 to 4294967295. Overflows are not
1160
	checked. You can use <cf/0x1234/ syntax to write hexadecimal values.
1161

    
1162
	<tag><label id="type-pair">pair</tag>
1163
	This is a pair of two short integers. Each component can have values
1164
	from 0 to 65535. Literals of this type are written as <cf/(1234,5678)/.
1165
	The same syntax can also be used to construct a pair from two arbitrary
1166
	integer expressions (for example <cf/(1+2,a)/).
1167

    
1168
	<tag><label id="type-quad">quad</tag>
1169
	This is a dotted quad of numbers used to represent router IDs (and
1170
	others). Each component can have a value from 0 to 255. Literals of
1171
	this type are written like IPv4 addresses.
1172

    
1173
	<tag><label id="type-string">string</tag>
1174
	This is a string of characters. There are no ways to modify strings in
1175
	filters. You can pass them between functions, assign them to variables
1176
	of type <cf/string/, print such variables, use standard string
1177
	comparison operations (e.g. <cf/=, !=, &lt;, &gt;, &lt;=, &gt;=/), but
1178
	you can't concatenate two strings. String literals are written as
1179
	<cf/"This is a string constant"/. Additionally matching (<cf/&tilde;,
1180
	!&tilde;/) operators could be used to match a string value against
1181
	a shell pattern (represented also as a string).
1182

    
1183
	<tag><label id="type-ip">ip</tag>
1184
	This type can hold a single IP address. The IPv4 addresses are stored as
1185
	IPv4-Mapped IPv6 addresses so one data type for both of them is used.
1186
	Whether the address is IPv4 or not may be checked by <cf>.is_ip4</cf>
1187
	which returns <cf/bool/. IP addresses are written in the standard
1188
	notation (<cf/10.20.30.40/ or <cf/fec0:3:4::1/). You can apply special
1189
	operator <cf>.mask(<M>num</M>)</cf> on values of type ip. It masks out
1190
	all but first <cf><M>num</M></cf> bits from the IP address. So
1191
	<cf/1.2.3.4.mask(8) = 1.0.0.0/ is true.
1192

    
1193
	<tag><label id="type-prefix">prefix</tag>
1194
	This type can hold a network prefix consisting of IP address, prefix
1195
	length and several other values. This is the key in route tables.
1196

    
1197
	Prefixes may be of several types, which can be determined by the special
1198
	operator <cf/.type/. The type may be:
1199

    
1200
	<cf/NET_IP4/ and <cf/NET_IP6/ prefixes hold an IP prefix. The literals
1201
	are written as <cf><m/ipaddress//<m/pxlen/</cf>,
1202
	or <cf><m>ipaddress</m>/<m>netmask</m></cf>. There are two special
1203
	operators on these: <cf/.ip/ which extracts the IP address from the
1204
	pair, and <cf/.len/, which separates prefix length from the pair.
1205
	So <cf>1.2.0.0/16.len = 16</cf> is true.
1206

    
1207
	<cf/NET_VPN4/ and <cf/NET_VPN6/ prefixes hold an IP prefix with VPN
1208
	Route Distinguisher (<rfc id="4364">). They support the same special
1209
	operators as IP prefixes, and also <cf/.rd/ which extracts the Route
1210
	Distinguisher. Their literals are written
1211
	as <cf><m/vpnrd/ <m/ipprefix/</cf>
1212

    
1213
	<cf/NET_ROA4/ and <cf/NET_ROA6/ prefixes hold an IP prefix range
1214
	together with an ASN. They support the same special operators as IP
1215
	prefixes, and also <cf/.maxlen/ which extracts maximal prefix length,
1216
	and <cf/.asn/ which extracts the ASN.
1217

    
1218
	<cf/NET_FLOW4/ and <cf/NET_FLOW6/ hold an IP prefix together with a
1219
	flowspec rule. Filters currently don't support flowspec parsing.
1220

    
1221
	<cf/NET_MPLS/ holds a single MPLS label and its handling is currently
1222
	not implemented.
1223

    
1224
	<tag><label id="type-vpnrd">vpnrd</tag>
1225
	This is a route distinguisher according to <rfc id="4364">. There are
1226
	three kinds of RD's: <cf><m/asn/:<m/32bit int/</cf>, <cf><m/asn4/:<m/16bit int/</cf>
1227
	and <cf><m/IPv4 address/:<m/32bit int/</cf>
1228

    
1229
	<tag><label id="type-ec">ec</tag>
1230
	This is a specialized type used to represent BGP extended community
1231
	values. It is essentially a 64bit value, literals of this type are
1232
	usually written as <cf>(<m/kind/, <m/key/, <m/value/)</cf>, where
1233
	<cf/kind/ is a kind of extended community (e.g. <cf/rt/ / <cf/ro/ for a
1234
	route target / route origin communities), the format and possible values
1235
	of <cf/key/ and <cf/value/ are usually integers, but it depends on the
1236
	used kind. Similarly to pairs, ECs can be constructed using expressions
1237
	for <cf/key/ and <cf/value/ parts, (e.g. <cf/(ro, myas, 3*10)/, where
1238
	<cf/myas/ is an integer variable).
1239

    
1240
	<tag><label id="type-lc">lc</tag>
1241
	This is a specialized type used to represent BGP large community
1242
	values. It is essentially a triplet of 32bit values, where the first
1243
	value is reserved for the AS number of the issuer, while meaning of
1244
	remaining parts is defined by the issuer. Literals of this type are
1245
	written as <cf/(123, 456, 789)/, with any integer values. Similarly to
1246
	pairs, LCs can be constructed using expressions for its parts, (e.g.
1247
	<cf/(myas, 10+20, 3*10)/, where <cf/myas/ is an integer variable).
1248

    
1249
	<tag><label id="type-set">int|pair|quad|ip|prefix|ec|lc|enum set</tag>
1250
	Filters recognize four types of sets. Sets are similar to strings: you
1251
	can pass them around but you can't modify them. Literals of type <cf>int
1252
	set</cf> look like <cf> [ 1, 2, 5..7 ]</cf>. As you can see, both simple
1253
	values and ranges are permitted in sets.
1254

    
1255
	For pair sets, expressions like <cf/(123,*)/ can be used to denote
1256
	ranges (in that case <cf/(123,0)..(123,65535)/). You can also use
1257
	<cf/(123,5..100)/ for range <cf/(123,5)..(123,100)/. You can also use
1258
	<cf/*/ and <cf/a..b/ expressions in the first part of a pair, note that
1259
	such expressions are translated to a set of intervals, which may be
1260
	memory intensive. E.g. <cf/(*,4..20)/ is translated to <cf/(0,4..20),
1261
	(1,4..20), (2,4..20), ... (65535, 4..20)/.
1262

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

    
1268
	Also LC sets use similar expressions like pair sets. You can use ranges
1269
	and wildcards, but if one field uses that, more specific (later) fields
1270
	must be wildcards. E.g., <cf/(10, 20..30, *)/ or <cf/(10, 20, 30..40)/
1271
	is valid, while <cf/(10, *, 20..30)/ or <cf/(10, 20..30, 40)/ is not
1272
	valid.
1273

    
1274
	You can also use expressions for int, pair, EC and LC set values.
1275
	However, it must be possible to evaluate these expressions before daemon
1276
	boots. So you can use only constants inside them. E.g.
1277

    
1278
	<code>
1279
	 define one=1;
1280
	 define myas=64500;
1281
	 int set odds;
1282
	 pair set ps;
1283
	 ec set es;
1284

    
1285
	 odds = [ one, 2+1, 6-one, 2*2*2-1, 9, 11 ];
1286
	 ps = [ (1,one+one), (3,4)..(4,8), (5,*), (6,3..6), (7..9,*) ];
1287
	 es = [ (rt, myas, 3*10), (rt, myas+one, 0..16*16*16-1), (ro, myas+2, *) ];
1288
	</code>
1289

    
1290
	Sets of prefixes are special: their literals does not allow ranges, but
1291
	allows prefix patterns that are written
1292
	as <cf><M>ipaddress</M>/<M>pxlen</M>{<M>low</M>,<M>high</M>}</cf>.
1293
	Prefix <cf><m>ip1</m>/<m>len1</m></cf> matches prefix
1294
	pattern <cf><m>ip2</m>/<m>len2</m>{<m>l</m>,<m>h</m>}</cf> if the
1295
	first <cf>min(len1, len2)</cf> bits of <cf/ip1/ and <cf/ip2/ are
1296
	identical and <cf>len1 &lt;= ip1 &lt;= len2</cf>. A valid prefix pattern
1297
	has to satisfy <cf>low &lt;= high</cf>, but <cf/pxlen/ is not
1298
	constrained by <cf/low/ or <cf/high/. Obviously, a prefix matches a
1299
	prefix set literal if it matches any prefix pattern in the prefix set
1300
	literal.
1301

    
1302
	There are also two shorthands for prefix patterns: <cf><m/address//<m/len/+</cf>
1303
	is a shorthand for <cf><m/address//<m/len/{<m/len/,<m/maxlen/}</cf>
1304
	(where <cf><m/maxlen/</cf> is 32 for IPv4 and 128 for IPv6), that means
1305
	network prefix <cf><m/address//<m/len/</cf> and all its	subnets.
1306
	<cf><m/address//<m/len/-</cf> is a shorthand for
1307
	<cf><m/address//<m/len/{0,<m/len/}</cf>, that means network prefix
1308
	<cf><m/address//<m/len/</cf> and all its supernets (network prefixes
1309
	that contain it).
1310

    
1311
	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}
1312
	]</cf> matches prefix <cf>1.0.0.0/8</cf>, all subprefixes of
1313
	<cf>2.0.0.0/8</cf>, all superprefixes of <cf>3.0.0.0/8</cf> and prefixes
1314
	<cf/4.X.X.X/ whose prefix length is 16 to 24. <cf>[ 0.0.0.0/0{20,24} ]</cf>
1315
	matches all prefixes (regardless of IP address) whose prefix length is
1316
	20 to 24, <cf>[ 1.2.3.4/32- ]</cf> matches any prefix that contains IP
1317
	address <cf>1.2.3.4</cf>. <cf>1.2.0.0/16 &tilde; [ 1.0.0.0/8{15,17} ]</cf>
1318
	is true, but <cf>1.0.0.0/16 &tilde; [ 1.0.0.0/8- ]</cf> is false.
1319

    
1320
	Cisco-style patterns like <cf>10.0.0.0/8 ge 16 le 24</cf> can be expressed
1321
	in BIRD as <cf>10.0.0.0/8{16,24}</cf>, <cf>192.168.0.0/16 le 24</cf> as
1322
	<cf>192.168.0.0/16{16,24}</cf> and <cf>192.168.0.0/16 ge 24</cf> as
1323
	<cf>192.168.0.0/16{24,32}</cf>.
1324

    
1325
	It is possible to mix IPv4 and IPv6 prefixes/addresses in a prefix/ip set
1326
	but its behavior may change between versions without any warning; don't do
1327
	it unless you are more than sure what you are doing. (Really, don't do it.)
1328

    
1329
	<tag><label id="type-enum">enum</tag>
1330
	Enumeration types are fixed sets of possibilities. You can't define your
1331
	own variables of such type, but some route attributes are of enumeration
1332
	type. Enumeration types are incompatible with each other.
1333

    
1334
	<tag><label id="type-bgppath">bgppath</tag>
1335
	BGP path is a list of autonomous system numbers. You can't write
1336
	literals of this type. There are several special operators on bgppaths:
1337

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

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

    
1342
	<cf><m/P/.last_nonaggregated</cf> returns the last ASN in the non-aggregated part of the path <m/P/.
1343

    
1344
	Both <cf/first/ and <cf/last/ return zero if there is no appropriate
1345
	ASN, for example if the path contains an AS set element as the first (or
1346
	the last) part. If the path ends with an AS set, <cf/last_nonaggregated/
1347
	may be used to get last ASN before any AS set.
1348

    
1349
	<cf><m/P/.len</cf> returns the length of path <m/P/.
1350

    
1351
	<cf><m/P/.empty()</cf> makes the path <m/P/ empty.
1352

    
1353
	<cf>prepend(<m/P/,<m/A/)</cf> prepends ASN <m/A/ to path <m/P/ and
1354
	returns the result.
1355

    
1356
	<cf>delete(<m/P/,<m/A/)</cf> deletes all instances of ASN <m/A/ from
1357
	from path <m/P/ and returns the result. <m/A/ may also be an integer
1358
	set, in that case the operator deletes all ASNs from path <m/P/ that are
1359
	also members of set <m/A/.
1360

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

    
1365
	Statement <cf><m/P/ = prepend(<m/P/, <m/A/);</cf> can be shortened to
1366
	<cf><m/P/.prepend(<m/A/);</cf> if <m/P/ is appropriate route attribute
1367
	(for example <cf/bgp_path/). Similarly for <cf/delete/ and <cf/filter/.
1368

    
1369
	<tag><label id="type-bgpmask">bgpmask</tag>
1370
	BGP masks are patterns used for BGP path matching (using <cf>path
1371
	&tilde; [= 2 3 5 * =]</cf> syntax). The masks resemble wildcard patterns
1372
	as used by UNIX shells. Autonomous system numbers match themselves,
1373
	<cf/*/ matches any (even empty) sequence of arbitrary AS numbers and
1374
	<cf/?/ matches one arbitrary AS number. For example, if <cf>bgp_path</cf>
1375
 	is 4 3 2 1, then: <tt>bgp_path &tilde; [= * 4 3 * =]</tt> is true,
1376
	but <tt>bgp_path &tilde; [= * 4 5 * =]</tt> is false. BGP mask
1377
	expressions can also contain integer expressions enclosed in parenthesis
1378
	and integer variables, for example <tt>[= * 4 (1+2) a =]</tt>. You can
1379
        also use ranges, for example <tt>[= * 3..5 2 100..200 * =]</tt>.
1380

    
1381
	<tag><label id="type-clist">clist</tag>
1382
	Clist is similar to a set, except that unlike other sets, it can be
1383
	modified. The type is used for community list (a set of pairs) and for
1384
	cluster list (a set of quads). There exist no literals of this type.
1385
	There are three special operators on clists:
1386

    
1387
	<cf><m/C/.len</cf> returns the length of clist <m/C/.
1388

    
1389
	<cf><m/C/.empty</cf> makes the list <m/C/ empty.
1390

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

    
1396
	<cf>delete(<m/C/,<m/P/)</cf> deletes pair (or quad) <m/P/ from clist
1397
	<m/C/ and returns the result. If clist <m/C/ does not contain item
1398
	<m/P/, it does nothing. <m/P/ may also be a pair (or quad) set, in that
1399
	case the operator deletes all items from clist <m/C/ that are also
1400
	members of set <m/P/. Moreover, <m/P/ may also be a clist, which works
1401
	analogously; i.e., it works as clist difference.
1402

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

    
1408
	Statement <cf><m/C/ = add(<m/C/, <m/P/);</cf> can be shortened to
1409
	<cf><m/C/.add(<m/P/);</cf> if <m/C/ is appropriate route attribute (for
1410
	example <cf/bgp_community/). Similarly for <cf/delete/ and <cf/filter/.
1411

    
1412
	<tag><label id="type-eclist">eclist</tag>
1413
	Eclist is a data type used for BGP extended community lists. Eclists
1414
	are very similar to clists, but they are sets of ECs instead of pairs.
1415
	The same operations (like <cf/add/, <cf/delete/ or <cf/&tilde;/ and
1416
	<cf/!&tilde;/ membership operators) can be used to modify or test
1417
	eclists, with ECs instead of pairs as arguments.
1418

    
1419
	<tag><label id="type-lclist">lclist/</tag>
1420
	Lclist is a data type used for BGP large community lists. Like eclists,
1421
	lclists are very similar to clists, but they are sets of LCs instead of
1422
	pairs. The same operations (like <cf/add/, <cf/delete/ or <cf/&tilde;/
1423
	and <cf/!&tilde;/ membership operators) can be used to modify or test
1424
	lclists, with LCs instead of pairs as arguments.
1425
</descrip>
1426

    
1427
<sect>Operators
1428
<label id="operators">
1429

    
1430
<p>The filter language supports common integer operators <cf>(+,-,*,/)</cf>,
1431
parentheses <cf/(a*(b+c))/, comparison <cf/(a=b, a!=b, a&lt;b, a&gt;=b)/.
1432
Logical operations include unary not (<cf/!/), and (<cf/&amp;&amp;/), and or
1433
(<cf/&verbar;&verbar;/). Special operators include (<cf/&tilde;/,
1434
<cf/!&tilde;/) for "is (not) element of a set" operation - it can be used on
1435
element and set of elements of the same type (returning true if element is
1436
contained in the given set), or on two strings (returning true if first string
1437
matches a shell-like pattern stored in second string) or on IP and prefix
1438
(returning true if IP is within the range defined by that prefix), or on prefix
1439
and prefix (returning true if first prefix is more specific than second one) or
1440
on bgppath and bgpmask (returning true if the path matches the mask) or on
1441
number and bgppath (returning true if the number is in the path) or on bgppath
1442
and int (number) set (returning true if any ASN from the path is in the set) or
1443
on pair/quad and clist (returning true if the pair/quad is element of the
1444
clist) or on clist and pair/quad set (returning true if there is an element of
1445
the clist that is also a member of the pair/quad set).
1446

    
1447
<p>There is one operator related to ROA infrastructure - <cf/roa_check()/. It
1448
examines a ROA table and does <rfc id="6483"> route origin validation for a
1449
given network prefix. The basic usage is <cf>roa_check(<m/table/)</cf>, which
1450
checks current route (which should be from BGP to have AS_PATH argument) in the
1451
specified ROA table and returns ROA_UNKNOWN if there is no relevant ROA,
1452
ROA_VALID if there is a matching ROA, or ROA_INVALID if there are some relevant
1453
ROAs but none of them match. There is also an extended variant
1454
<cf>roa_check(<m/table/, <m/prefix/, <m/asn/)</cf>, which allows to specify a
1455
prefix and an ASN as arguments.
1456

    
1457

    
1458
<sect>Control structures
1459
<label id="control-structures">
1460

    
1461
<p>Filters support two control structures: conditions and case switches.
1462

    
1463
<p>Syntax of a condition is: <cf>if <M>boolean expression</M> then <m/commandT/;
1464
else <m/commandF/;</cf> and you can use <cf>{ <m/command1/; <m/command2/;
1465
<M>...</M> }</cf> instead of either command. The <cf>else</cf> clause may be
1466
omitted. If the <cf><m>boolean expression</m></cf> is true, <m/commandT/ is
1467
executed, otherwise <m/commandF/ is executed.
1468

    
1469
<p>The <cf>case</cf> is similar to case from Pascal. Syntax is <cf>case
1470
<m/expr/ { else: | <m/num_or_prefix [ .. num_or_prefix]/: <m/statement/ ; [
1471
... ] }</cf>. The expression after <cf>case</cf> can be of any type which can be
1472
on the left side of the &tilde; operator and anything that could be a member of
1473
a set is allowed before <cf/:/. Multiple commands are allowed without <cf/{}/
1474
grouping. If <cf><m/expr/</cf> matches one of the <cf/:/ clauses, statements
1475
between it and next <cf/:/ statement are executed. If <cf><m/expr/</cf> matches
1476
neither of the <cf/:/ clauses, the statements after <cf/else:/ are executed.
1477

    
1478
<p>Here is example that uses <cf/if/ and <cf/case/ structures:
1479

    
1480
<code>
1481
case arg1 {
1482
	2: print "two"; print "I can do more commands without {}";
1483
	3 .. 5: print "three to five";
1484
	else: print "something else";
1485
}
1486

    
1487
if 1234 = i then printn "."; else {
1488
  print "not 1234";
1489
  print "You need {} around multiple commands";
1490
}
1491
</code>
1492

    
1493

    
1494
<sect>Route attributes
1495
<label id="route-attributes">
1496

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

    
1504
<descrip>
1505
	<tag><label id="rta-net"><m/prefix/ net</tag>
1506
	The network prefix or anything else the route is talking about. The
1507
	primary key of the routing table. Read-only. (See the <ref id="routes"
1508
	name="chapter about routes">.)
1509

    
1510
	<tag><label id="rta-scope"><m/enum/ scope</tag>
1511
	The scope of the route. Possible values: <cf/SCOPE_HOST/ for routes
1512
	local to this host, <cf/SCOPE_LINK/ for those specific for a physical
1513
	link, <cf/SCOPE_SITE/ and <cf/SCOPE_ORGANIZATION/ for private routes and
1514
	<cf/SCOPE_UNIVERSE/ for globally visible routes. This attribute is not
1515
	interpreted by BIRD and can be used to mark routes in filters. The
1516
	default value for new routes is <cf/SCOPE_UNIVERSE/.
1517

    
1518
	<tag><label id="rta-preference"><m/int/ preference</tag>
1519
	Preference of the route. Valid values are 0-65535. (See the chapter
1520
	about routing tables.)
1521

    
1522
	<tag><label id="rta-from"><m/ip/ from</tag>
1523
	The router which the route has originated from.
1524

    
1525
	<tag><label id="rta-gw"><m/ip/ gw</tag>
1526
	Next hop packets routed using this route should be forwarded to.
1527

    
1528
	<tag><label id="rta-proto"><m/string/ proto</tag>
1529
	The name of the protocol which the route has been imported from.
1530
	Read-only.
1531

    
1532
	<tag><label id="rta-source"><m/enum/ source</tag>
1533
	what protocol has told me about this route. Possible values:
1534
	<cf/RTS_DUMMY/, <cf/RTS_STATIC/, <cf/RTS_INHERIT/, <cf/RTS_DEVICE/,
1535
	<cf/RTS_STATIC_DEVICE/, <cf/RTS_REDIRECT/, <cf/RTS_RIP/, <cf/RTS_OSPF/,
1536
	<cf/RTS_OSPF_IA/, <cf/RTS_OSPF_EXT1/, <cf/RTS_OSPF_EXT2/, <cf/RTS_BGP/,
1537
	<cf/RTS_PIPE/, <cf/RTS_BABEL/.
1538

    
1539
	<tag><label id="rta-dest"><m/enum/ dest</tag>
1540
	Type of destination the packets should be sent to
1541
	(<cf/RTD_ROUTER/ for forwarding to a neighboring router,
1542
	<cf/RTD_DEVICE/ for routing to a directly-connected network,
1543
	<cf/RTD_MULTIPATH/ for multipath destinations,
1544
	<cf/RTD_BLACKHOLE/ for packets to be silently discarded,
1545
	<cf/RTD_UNREACHABLE/, <cf/RTD_PROHIBIT/ for packets that should be
1546
	returned with ICMP host unreachable / ICMP administratively prohibited
1547
	messages). Can be changed, but only to <cf/RTD_BLACKHOLE/,
1548
	<cf/RTD_UNREACHABLE/ or <cf/RTD_PROHIBIT/.
1549

    
1550
	<tag><label id="rta-ifname"><m/string/ ifname</tag>
1551
	Name of the outgoing interface. Sink routes (like blackhole, unreachable
1552
	or prohibit) and multipath routes have no interface associated with
1553
	them, so <cf/ifname/ returns an empty string for such routes. Read-only.
1554

    
1555
	<tag><label id="rta-ifindex"><m/int/ ifindex</tag>
1556
	Index of the outgoing interface. System wide index of the interface. May
1557
	be used for interface matching, however indexes might change on interface
1558
	creation/removal. Zero is returned for routes with undefined outgoing
1559
	interfaces. Read-only.
1560

    
1561
	<tag><label id="rta-igp-metric"><m/int/ igp_metric</tag>
1562
	The optional attribute that can be used to specify a distance to the
1563
	network for routes that do not have a native protocol metric attribute
1564
	(like <cf/ospf_metric1/ for OSPF routes). It is used mainly by BGP to
1565
	compare internal distances to boundary routers (see below). It is also
1566
	used when the route is exported to OSPF as a default value for OSPF type
1567
	1 metric.
1568
</descrip>
1569

    
1570
<p>There also exist protocol-specific attributes which are described in the
1571
corresponding protocol sections.
1572

    
1573

    
1574
<sect>Other statements
1575
<label id="other-statements">
1576

    
1577
<p>The following statements are available:
1578

    
1579
<descrip>
1580
	<tag><label id="assignment"><m/variable/ = <m/expr/</tag>
1581
	Set variable to a given value.
1582

    
1583
	<tag><label id="filter-accept-reject">accept|reject [ <m/expr/ ]</tag>
1584
	Accept or reject the route, possibly printing <cf><m>expr</m></cf>.
1585

    
1586
	<tag><label id="return">return <m/expr/</tag>
1587
	Return <cf><m>expr</m></cf> from the current function, the function ends
1588
	at this point.
1589

    
1590
	<tag><label id="print">print|printn <m/expr/ [<m/, expr.../]</tag>
1591
	Prints given expressions; useful mainly while debugging filters. The
1592
	<cf/printn/ variant does not terminate the line.
1593

    
1594
	<tag><label id="quitbird">quitbird</tag>
1595
	Terminates BIRD. Useful when debugging the filter interpreter.
1596
</descrip>
1597

    
1598

    
1599
<chapt>Protocols
1600
<label id="protocols">
1601

    
1602
<sect>Babel
1603
<label id="babel">
1604

    
1605
<sect1>Introduction
1606
<label id="babel-intro">
1607

    
1608
<p>The Babel protocol
1609
(<rfc id="6126">) is a loop-avoiding distance-vector routing protocol that is
1610
robust and efficient both in ordinary wired networks and in wireless mesh
1611
networks. Babel is conceptually very simple in its operation and "just works"
1612
in its default configuration, though some configuration is possible and in some
1613
cases desirable.
1614

    
1615
<p>The Babel protocol is dual stack; i.e., it can carry both IPv4 and IPv6
1616
routes over the same IPv6 transport. For sending and receiving Babel packets,
1617
only a link-local IPv6 address is needed.
1618

    
1619
<p>BIRD does not implement any Babel extensions, but will coexist with
1620
implementations using extensions (and will just ignore extension messages).
1621

    
1622
<sect1>Configuration
1623
<label id="babel-config">
1624

    
1625
<p>Babel supports no global configuration options apart from those common to all
1626
other protocols, but supports the following per-interface configuration options:
1627

    
1628
<code>
1629
protocol babel [<name>] {
1630
	ipv4 { <channel config> };
1631
	ipv6 { <channel config> };
1632
	interface <interface pattern> {
1633
		type <wired|wireless>;
1634
		rxcost <number>;
1635
		limit <number>;
1636
		hello interval <time>;
1637
		update interval <time>;
1638
		port <number>;
1639
		tx class|dscp <number>;
1640
		tx priority <number>;
1641
		rx buffer <number>;
1642
		tx length <number>;
1643
		check link <switch>;
1644
		next hop ipv4 <address>;
1645
		next hop ipv6 <address>;
1646
	};
1647
}
1648
</code>
1649

    
1650
<descrip>
1651
      <tag><label id="babel-channel">ipv4|ipv6 <m/channel config/</tag>
1652
      The supported channels are IPv4 and IPv6.
1653

    
1654
      <tag><label id="babel-type">type wired|wireless </tag>
1655
      This option specifies the interface type: Wired or wireless. On wired
1656
      interfaces a neighbor is considered unreachable after a small number of
1657
      Hello packets are lost, as described by <cf/limit/ option. On wireless
1658
      interfaces the ETX link quality estimation technique is used to compute
1659
      the metrics of routes discovered over this interface. This technique will
1660
      gradually degrade the metric of routes when packets are lost rather than
1661
      the more binary up/down mechanism of wired type links. Default:
1662
      <cf/wired/.
1663

    
1664
      <tag><label id="babel-rxcost">rxcost <m/num/</tag>
1665
      This option specifies the nominal RX cost of the interface. The effective
1666
      neighbor costs for route metrics will be computed from this value with a
1667
      mechanism determined by the interface <cf/type/. Note that in contrast to
1668
      other routing protocols like RIP or OSPF, the <cf/rxcost/ specifies the
1669
      cost of RX instead of TX, so it affects primarily neighbors' route
1670
      selection and not local route selection. Default: 96 for wired interfaces,
1671
      256 for wireless.
1672

    
1673
      <tag><label id="babel-limit">limit <m/num/</tag>
1674
      BIRD keeps track of received Hello messages from each neighbor to
1675
      establish neighbor reachability. For wired type interfaces, this option
1676
      specifies how many of last 16 hellos have to be correctly received in
1677
      order to neighbor is assumed to be up. The option is ignored on wireless
1678
      type interfaces, where gradual cost degradation is used instead of sharp
1679
      limit. Default: 12.
1680

    
1681
      <tag><label id="babel-hello">hello interval <m/time/ s|ms</tag>
1682
      Interval at which periodic Hello messages are sent on this interface,
1683
      with time units. Default: 4 seconds.
1684

    
1685
      <tag><label id="babel-update">update interval <m/time/ s|ms</tag>
1686
      Interval at which periodic (full) updates are sent, with time
1687
      units. Default: 4 times the hello interval.
1688

    
1689
      <tag><label id="babel-port">port <m/number/</tag>
1690
      This option selects an UDP port to operate on. The default is to operate
1691
      on port 6696 as specified in the Babel RFC.
1692

    
1693
      <tag><label id="babel-tx-class">tx class|dscp|priority <m/number/</tag>
1694
      These options specify the ToS/DiffServ/Traffic class/Priority of the
1695
      outgoing Babel packets. See <ref id="proto-tx-class" name="tx class"> common
1696
      option for detailed description.
1697

    
1698
      <tag><label id="babel-rx-buffer">rx buffer <m/number/</tag>
1699
      This option specifies the size of buffers used for packet processing.
1700
      The buffer size should be bigger than maximal size of received packets.
1701
      The default value is the interface MTU, and the value will be clamped to a
1702
      minimum of 512 bytes + IP packet overhead.
1703

    
1704
      <tag><label id="babel-tx-length">tx length <m/number/</tag>
1705
      This option specifies the maximum length of generated Babel packets. To
1706
      avoid IP fragmentation, it should not exceed the interface MTU value.
1707
      The default value is the interface MTU value, and the value will be
1708
      clamped to a minimum of 512 bytes + IP packet overhead.
1709

    
1710
      <tag><label id="babel-check-link">check link <m/switch/</tag>
1711
      If set, the hardware link state (as reported by OS) is taken into
1712
      consideration. When the link disappears (e.g. an ethernet cable is
1713
      unplugged), neighbors are immediately considered unreachable and all
1714
      routes received from them are withdrawn. It is possible that some
1715
      hardware drivers or platforms do not implement this feature. Default:
1716
      yes.
1717

    
1718
      <tag><label id="babel-next-hop-ipv4">next hop ipv4 <m/address/</tag>
1719
      Set the next hop address advertised for IPv4 routes advertised on this
1720
      interface. Default: the preferred IPv4 address of the interface.
1721

    
1722
      <tag><label id="babel-next-hop-ipv6">next hop ipv6 <m/address/</tag>
1723
      Set the next hop address advertised for IPv6 routes advertised on this
1724
      interface. If not set, the same link-local address that is used as the
1725
      source for Babel packets will be used. In normal operation, it should not
1726
      be necessary to set this option.
1727
</descrip>
1728

    
1729
<sect1>Attributes
1730
<label id="babel-attr">
1731

    
1732
<p>Babel defines just one attribute: the internal babel metric of the route. It
1733
is exposed as the <cf/babel_metric/ attribute and has range from 1 to infinity
1734
(65535).
1735

    
1736
<sect1>Example
1737
<label id="babel-exam">
1738

    
1739
<p><code>
1740
protocol babel {
1741
	interface "eth*" {
1742
		type wired;
1743
	};
1744
	interface "wlan0", "wlan1" {
1745
		type wireless;
1746
		hello interval 1;
1747
		rxcost 512;
1748
	};
1749
	interface "tap0";
1750

    
1751
	# This matches the default of babeld: redistribute all addresses
1752
	# configured on local interfaces, plus re-distribute all routes received
1753
	# from other babel peers.
1754

    
1755
	ipv4 {
1756
		export where (source = RTS_DEVICE) || (source = RTS_BABEL);
1757
	};
1758
	ipv6 {
1759
		export where (source = RTS_DEVICE) || (source = RTS_BABEL);
1760
	};
1761
}
1762
</code>
1763

    
1764
<sect1>Known issues
1765
<label id="babel-issues">
1766

    
1767
<p>When retracting a route, Babel generates an unreachable route for a little
1768
while (according to RFC). The interaction of this behavior with other protocols
1769
is not well tested and strange things may happen.
1770

    
1771

    
1772
<sect>BFD
1773
<label id="bfd">
1774

    
1775
<sect1>Introduction
1776
<label id="bfd-intro">
1777

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

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

    
1795
<p>BIRD implements basic BFD behavior as defined in <rfc id="5880"> (some
1796
advanced features like the echo mode or authentication are not implemented), IP
1797
transport for BFD as defined in <rfc id="5881"> and <rfc id="5883"> and
1798
interaction with client protocols as defined in <rfc id="5882">.
1799
We currently support at most one protocol instance.
1800

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

    
1806
<sect1>Configuration
1807
<label id="bfd-config">
1808

    
1809
<p>BFD configuration consists mainly of multiple definitions of interfaces.
1810
Most BFD config options are session specific. When a new session is requested
1811
and dynamically created, it is configured from one of these definitions. For
1812
sessions to directly connected neighbors, <cf/interface/ definitions are chosen
1813
based on the interface associated with the session, while <cf/multihop/
1814
definition is used for multihop sessions. If no definition is relevant, the
1815
session is just created with the default configuration. Therefore, an empty BFD
1816
configuration is often sufficient.
1817

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

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

    
1826
<code>
1827
protocol bfd [&lt;name&gt;] {
1828
	interface &lt;interface pattern&gt; {
1829
		interval &lt;time&gt;;
1830
		min rx interval &lt;time&gt;;
1831
		min tx interval &lt;time&gt;;
1832
		idle tx interval &lt;time&gt;;
1833
		multiplier &lt;num&gt;;
1834
		passive &lt;switch&gt;;
1835
		authentication none;
1836
		authentication simple;
1837
		authentication [meticulous] keyed md5|sha1;
1838
		password "&lt;text&gt;";
1839
		password "&lt;text&gt;" {
1840
			id &lt;num&gt;;
1841
			generate from "&lt;date&gt;";
1842
			generate to "&lt;date&gt;";
1843
			accept from "&lt;date&gt;";
1844
			accept to "&lt;date&gt;";
1845
			from "&lt;date&gt;";
1846
			to "&lt;date&gt;";
1847
		};
1848
	};
1849
	multihop {
1850
		interval &lt;time&gt;;
1851
		min rx interval &lt;time&gt;;
1852
		min tx interval &lt;time&gt;;
1853
		idle tx interval &lt;time&gt;;
1854
		multiplier &lt;num&gt;;
1855
		passive &lt;switch&gt;;
1856
	};
1857
	neighbor &lt;ip&gt; [dev "&lt;interface&gt;"] [local &lt;ip&gt;] [multihop &lt;switch&gt;];
1858
}
1859
</code>
1860

    
1861
<descrip>
1862
	<tag><label id="bfd-iface">interface <m/pattern/ [, <m/.../] { <m/options/ }</tag>
1863
	Interface definitions allow to specify options for sessions associated
1864
	with such interfaces and also may contain interface specific options.
1865
	See <ref id="proto-iface" name="interface"> common option for a detailed
1866
	description of interface patterns. Note that contrary to the behavior of
1867
	<cf/interface/ definitions of other protocols, BFD protocol would accept
1868
	sessions (in default configuration) even on interfaces not covered by
1869
	such definitions.
1870

    
1871
	<tag><label id="bfd-multihop">multihop { <m/options/ }</tag>
1872
	Multihop definitions allow to specify options for multihop BFD sessions,
1873
	in the same manner as <cf/interface/ definitions are used for directly
1874
	connected sessions. Currently only one such definition (for all multihop
1875
	sessions) could be used.
1876

    
1877
	<tag><label id="bfd-neighbor">neighbor <m/ip/ [dev "<m/interface/"] [local <m/ip/] [multihop <m/switch/]</tag>
1878
	BFD sessions are usually created on demand as requested by other
1879
	protocols (like OSPF or BGP). This option allows to explicitly add
1880
	a BFD session to the specified neighbor regardless of such requests.
1881

    
1882
	The session is identified by the IP address of the neighbor, with
1883
	optional specification of used interface and local IP. By default
1884
	the neighbor must be directly connected, unless the session is
1885
	configured as multihop. Note that local IP must be specified for
1886
	multihop sessions.
1887
</descrip>
1888

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

    
1891
<descrip>
1892
	<tag><label id="bfd-interval">interval <m/time/</tag>
1893
	BFD ensures availability of the forwarding path associated with the
1894
	session by periodically sending BFD control packets in both
1895
	directions. The rate of such packets is controlled by two options,
1896
	<cf/min rx interval/ and <cf/min tx interval/ (see below). This option
1897
	is just a shorthand to set both of these options together.
1898

    
1899
	<tag><label id="bfd-min-rx-interval">min rx interval <m/time/</tag>
1900
	This option specifies the minimum RX interval, which is announced to the
1901
	neighbor and used there to limit the neighbor's rate of generated BFD
1902
	control packets. Default: 10 ms.
1903

    
1904
	<tag><label id="bfd-min-tx-interval">min tx interval <m/time/</tag>
1905
	This option specifies the desired TX interval, which controls the rate
1906
	of generated BFD control packets (together with <cf/min rx interval/
1907
	announced by the neighbor). Note that this value is used only if the BFD
1908
	session is up, otherwise the value of <cf/idle tx interval/ is used
1909
	instead. Default: 100 ms.
1910

    
1911
	<tag><label id="bfd-idle-tx-interval">idle tx interval <m/time/</tag>
1912
	In order to limit unnecessary traffic in cases where a neighbor is not
1913
	available or not running BFD, the rate of generated BFD control packets
1914
	is lower when the BFD session is not up. This option specifies the
1915
	desired TX interval in such cases instead of <cf/min tx interval/.
1916
	Default: 1 s.
1917

    
1918
	<tag><label id="bfd-multiplier">multiplier <m/num/</tag>
1919
	Failure detection time for BFD sessions is based on established rate of
1920
	BFD control packets (<cf>min rx/tx interval</cf>) multiplied by this
1921
	multiplier, which is essentially (ignoring jitter) a number of missed
1922
	packets after which the session is declared down. Note that rates and
1923
	multipliers could be different in each direction of a BFD session.
1924
	Default: 5.
1925

    
1926
	<tag><label id="bfd-passive">passive <m/switch/</tag>
1927
	Generally, both BFD session endpoints try to establish the session by
1928
	sending control packets to the other side. This option allows to enable
1929
	passive mode, which means that the router does not send BFD packets
1930
	until it has received one from the other side. Default: disabled.
1931

    
1932
	<tag>authentication none</tag>
1933
	No passwords are sent in BFD packets. This is the default value.
1934

    
1935
	<tag>authentication simple</tag>
1936
	Every packet carries 16 bytes of password. Received packets lacking this
1937
	password are ignored. This authentication mechanism is very weak.
1938

    
1939
	<tag>authentication [meticulous] keyed md5|sha1</tag>
1940
	An authentication code is appended to each packet. The cryptographic
1941
	algorithm is keyed MD5 or keyed SHA-1. Note that the algorithm is common
1942
	for all keys (on one interface), in contrast to OSPF or RIP, where it
1943
	is a per-key option. Passwords (keys) are not sent open via network.
1944

    
1945
	The <cf/meticulous/ variant means that cryptographic sequence numbers
1946
	are increased for each sent packet, while in the basic variant they are
1947
	increased about once per second. Generally, the <cf/meticulous/ variant
1948
	offers better resistance to replay attacks but may require more
1949
	computation.
1950

    
1951
	<tag>password "<M>text</M>"</tag>
1952
	Specifies a password used for authentication. See <ref id="proto-pass"
1953
	name="password"> common option for detailed description. Note that
1954
	password option <cf/algorithm/ is not available in BFD protocol. The
1955
	algorithm is selected by <cf/authentication/ option for all passwords.
1956

    
1957
</descrip>
1958

    
1959
<sect1>Example
1960
<label id="bfd-exam">
1961

    
1962
<p><code>
1963
protocol bfd {
1964
	interface "eth*" {
1965
		min rx interval 20 ms;
1966
		min tx interval 50 ms;
1967
		idle tx interval 300 ms;
1968
	};
1969
	interface "gre*" {
1970
		interval 200 ms;
1971
		multiplier 10;
1972
		passive;
1973
	};
1974
	multihop {
1975
		interval 200 ms;
1976
		multiplier 10;
1977
	};
1978

    
1979
	neighbor 192.168.1.10;
1980
	neighbor 192.168.2.2 dev "eth2";
1981
	neighbor 192.168.10.1 local 192.168.1.1 multihop;
1982
}
1983
</code>
1984

    
1985

    
1986
<sect>BGP
1987
<label id="bgp">
1988

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

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

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

    
2010
<sect1>Supported standards:
2011
<label id="bgp-standards">
2012

    
2013
<itemize>
2014
<item> <rfc id="4271"> - Border Gateway Protocol 4 (BGP)
2015
<item> <rfc id="1997"> - BGP Communities Attribute
2016
<item> <rfc id="2385"> - Protection of BGP Sessions via TCP MD5 Signature
2017
<item> <rfc id="2545"> - Use of BGP Multiprotocol Extensions for IPv6
2018
<item> <rfc id="2918"> - Route Refresh Capability
2019
<item> <rfc id="3107"> - Carrying Label Information in BGP
2020
<item> <rfc id="4360"> - BGP Extended Communities Attribute
2021
<item> <rfc id="4364"> - BGP/MPLS IPv4 Virtual Private Networks
2022
<item> <rfc id="4456"> - BGP Route Reflection
2023
<item> <rfc id="4486"> - Subcodes for BGP Cease Notification Message
2024
<item> <rfc id="4659"> - BGP/MPLS IPv6 Virtual Private Networks
2025
<item> <rfc id="4724"> - Graceful Restart Mechanism for BGP
2026
<item> <rfc id="4760"> - Multiprotocol extensions for BGP
2027
<item> <rfc id="4798"> - Connecting IPv6 Islands over IPv4 MPLS
2028
<item> <rfc id="5065"> - AS confederations for BGP
2029
<item> <rfc id="5082"> - Generalized TTL Security Mechanism
2030
<item> <rfc id="5492"> - Capabilities Advertisement with BGP
2031
<item> <rfc id="5549"> - Advertising IPv4 NLRI with an IPv6 Next Hop
2032
<item> <rfc id="5575"> - Dissemination of Flow Specification Rules
2033
<item> <rfc id="5668"> - 4-Octet AS Specific BGP Extended Community
2034
<item> <rfc id="6286"> - AS-Wide Unique BGP Identifier
2035
<item> <rfc id="6608"> - Subcodes for BGP Finite State Machine Error
2036
<item> <rfc id="6793"> - BGP Support for 4-Octet AS Numbers
2037
<item> <rfc id="7313"> - Enhanced Route Refresh Capability for BGP
2038
<item> <rfc id="7606"> - Revised Error Handling for BGP UPDATE Messages
2039
<item> <rfc id="7911"> - Advertisement of Multiple Paths in BGP
2040
<item> <rfc id="7947"> - Internet Exchange BGP Route Server
2041
<item> <rfc id="8092"> - BGP Large Communities Attribute
2042
<item> <rfc id="8203"> - BGP Administrative Shutdown Communication
2043
</itemize>
2044

    
2045
<sect1>Route selection rules
2046
<label id="bgp-route-select-rules">
2047

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

    
2054
<itemize>
2055
	<item>Prefer route with the highest Local Preference attribute.
2056
	<item>Prefer route with the shortest AS path.
2057
	<item>Prefer IGP origin over EGP and EGP origin over incomplete.
2058
	<item>Prefer the lowest value of the Multiple Exit Discriminator.
2059
	<item>Prefer routes received via eBGP over ones received via iBGP.
2060
	<item>Prefer routes with lower internal distance to a boundary router.
2061
	<item>Prefer the route with the lowest value of router ID of the
2062
	advertising router.
2063
</itemize>
2064

    
2065
<sect1>IGP routing table
2066
<label id="bgp-igp-routing-table">
2067

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

    
2076
<sect1>Protocol configuration
2077
<label id="bgp-proto-config">
2078

    
2079
<p>Each instance of the BGP corresponds to one neighboring router. This allows
2080
to set routing policy and all the other parameters differently for each neighbor
2081
using the following configuration parameters:
2082

    
2083
<descrip>
2084
	<tag><label id="bgp-local">local [<m/ip/] as <m/number/</tag>
2085
	Define which AS we are part of. (Note that contrary to other IP routers,
2086
	BIRD is able to act as a router located in multiple AS'es simultaneously,
2087
	but in such cases you need to tweak the BGP paths manually in the filters
2088
	to get consistent behavior.) Optional <cf/ip/ argument specifies a source
2089
	address, equivalent to the <cf/source address/ option (see below). This
2090
	parameter is mandatory.
2091

    
2092
	<tag><label id="bgp-neighbor">neighbor [<m/ip/] [port <m/number/] [as <m/number/]</tag>
2093
	Define neighboring router this instance will be talking to and what AS
2094
	it is located in. In case the neighbor is in the same AS as we are, we
2095
	automatically switch to iBGP. Optionally, the remote port may also be
2096
	specified. The parameter may be used multiple times with different
2097
	sub-options (e.g., both <cf/neighbor 10.0.0.1 as 65000;/ and
2098
	<cf/neighbor 10.0.0.1; neighbor as 65000;/ are valid). This parameter is
2099
	mandatory.
2100

    
2101
	<tag><label id="bgp-iface">interface <m/string/</tag>
2102
	Define interface we should use for link-local BGP IPv6 sessions.
2103
	Interface can also be specified as a part of <cf/neighbor address/
2104
	(e.g., <cf/neighbor fe80::1234%eth0 as 65000;/). The option may also be
2105
	used for non link-local sessions when it is necessary to explicitly
2106
	specify an interface, but only for direct (not multihop) sessions.
2107

    
2108
	<tag><label id="bgp-direct">direct</tag>
2109
	Specify that the neighbor is directly connected. The IP address of the
2110
	neighbor must be from a directly reachable IP range (i.e. associated
2111
	with one of your router's interfaces), otherwise the BGP session
2112
	wouldn't start but it would wait for such interface to appear. The
2113
	alternative is the <cf/multihop/ option. Default: enabled for eBGP.
2114

    
2115
	<tag><label id="bgp-multihop">multihop [<m/number/]</tag>
2116
	Configure multihop BGP session to a neighbor that isn't directly
2117
	connected. Accurately, this option should be used if the configured
2118
	neighbor IP address does not match with any local network subnets. Such
2119
	IP address have to be reachable through system routing table. The
2120
	alternative is the <cf/direct/ option. For multihop BGP it is
2121
	recommended to explicitly configure the source address to have it
2122
	stable. Optional <cf/number/ argument can be used to specify the number
2123
	of hops (used for TTL). Note that the number of networks (edges) in a
2124
	path is counted; i.e., if two BGP speakers are separated by one router,
2125
	the number of hops is 2. Default: enabled for iBGP.
2126

    
2127
	<tag><label id="bgp-source-address">source address <m/ip/</tag>
2128
	Define local address we should use for next hop calculation and as a
2129
	source address for the BGP session. Default: the address of the local
2130
	end of the interface our neighbor is connected to.
2131

    
2132
	<tag><label id="bgp-strict-bind">strict bind <m/switch/</tag>
2133
	Specify whether BGP listening socket should be bound to a specific local
2134
	address (the same as the <cf/source address/) and associated interface,
2135
	or to all addresses. Binding to a specific address could be useful in
2136
	cases like running multiple BIRD instances on a machine, each using its
2137
	IP address. Note that listening sockets bound to a specific address and
2138
	to all addresses collide, therefore either all BGP protocols (of the
2139
	same address family and using the same local port) should have set
2140
	<cf/strict bind/, or none of them. Default: disabled.
2141

    
2142
	<tag><label id="bgp-check-link">check link <M>switch</M></tag>
2143
	BGP could use hardware link state into consideration.  If enabled,
2144
	BIRD tracks the link state of the associated interface and when link
2145
	disappears (e.g. an ethernet cable is unplugged), the BGP session is
2146
	immediately shut down. Note that this option cannot be used with
2147
	multihop BGP. Default: enabled for direct BGP, disabled otherwise.
2148

    
2149
	<tag><label id="bgp-bfd">bfd <M>switch</M></tag>
2150
	BGP could use BFD protocol as an advisory mechanism for neighbor
2151
	liveness and failure detection. If enabled, BIRD setups a BFD session
2152
	for the BGP neighbor and tracks its liveness by it. This has an
2153
	advantage of an order of magnitude lower detection times in case of
2154
	failure. Note that BFD protocol also has to be configured, see
2155
	<ref id="bfd" name="BFD"> section for details. Default: disabled.
2156

    
2157
	<tag><label id="bgp-ttl-security">ttl security <m/switch/</tag>
2158
	Use GTSM (<rfc id="5082"> - the generalized TTL security mechanism). GTSM
2159
	protects against spoofed packets by ignoring received packets with a
2160
	smaller than expected TTL. To work properly, GTSM have to be enabled on
2161
	both sides of a BGP session. If both <cf/ttl security/ and
2162
	<cf/multihop/ options are enabled, <cf/multihop/ option should specify
2163
	proper hop value to compute expected TTL. Kernel support required:
2164
	Linux: 2.6.34+ (IPv4), 2.6.35+ (IPv6), BSD: since long ago, IPv4 only.
2165
	Note that full (ICMP protection, for example) <rfc id="5082"> support is
2166
	provided by Linux only. Default: disabled.
2167

    
2168
	<tag><label id="bgp-password">password <m/string/</tag>
2169
	Use this password for MD5 authentication of BGP sessions (<rfc id="2385">). When
2170
	used on BSD systems, see also <cf/setkey/ option below. Default: no
2171
	authentication.
2172

    
2173
	<tag><label id="bgp-setkey">setkey <m/switch/</tag>
2174
	On BSD systems, keys for TCP MD5 authentication are stored in the global
2175
	SA/SP database, which can be accessed by external utilities (e.g.
2176
	setkey(8)). BIRD configures security associations in the SA/SP database
2177
	automatically based on <cf/password/ options (see above), this option
2178
	allows to disable automatic updates by BIRD when manual configuration by
2179
	external utilities is preferred. Note that automatic SA/SP database
2180
	updates are currently implemented only for FreeBSD. Passwords have to be
2181
	set manually by an external utility on NetBSD and OpenBSD. Default:
2182
	enabled (ignored on non-FreeBSD).
2183

    
2184
	<tag><label id="bgp-passive">passive <m/switch/</tag>
2185
	Standard BGP behavior is both initiating outgoing connections and
2186
	accepting incoming connections. In passive mode, outgoing connections
2187
	are not initiated. Default: off.
2188

    
2189
	<tag><label id="bgp-confederation">confederation <m/number/</tag>
2190
	BGP confederations (<rfc id="5065">) are collections of autonomous
2191
	systems that act as one entity to external systems, represented by one
2192
	confederation identifier (instead of AS numbers). This option allows to
2193
	enable BGP confederation behavior and to specify the local confederation
2194
	identifier. When BGP confederations are used, all BGP speakers that are
2195
	members of the BGP confederation should have the same confederation
2196
	identifier configured. Default: 0 (no confederation).
2197

    
2198
	<tag><label id="bgp-confederation-member">confederation member <m/switch/</tag>
2199
	When BGP confederations are used, this option allows to specify whether
2200
	the BGP neighbor is a member of the same confederation as the local BGP
2201
	speaker. The option is unnecessary (and ignored) for IBGP sessions, as
2202
	the same AS number implies the same confederation. Default: no.
2203

    
2204
	<tag><label id="bgp-rr-client">rr client</tag>
2205
	Be a route reflector and treat the neighbor as a route reflection
2206
	client. Default: disabled.
2207

    
2208
	<tag><label id="bgp-rr-cluster-id">rr cluster id <m/IPv4 address/</tag>
2209
	Route reflectors use cluster id to avoid route reflection loops. When
2210
	there is one route reflector in a cluster it usually uses its router id
2211
	as a cluster id, but when there are more route reflectors in a cluster,
2212
	these need to be configured (using this option) to use a common cluster
2213
	id. Clients in a cluster need not know their cluster id and this option
2214
	is not allowed for them. Default: the same as router id.
2215

    
2216
	<tag><label id="bgp-rs-client">rs client</tag>
2217
	Be a route server and treat the neighbor as a route server client.
2218
	A route server is used as a replacement for full mesh EBGP routing in
2219
	Internet exchange points in a similar way to route reflectors used in
2220
	IBGP routing. BIRD does not implement obsoleted <rfc id="1863">, but
2221
	uses ad-hoc implementation, which behaves like plain EBGP but reduces
2222
	modifications to advertised route attributes to be transparent (for
2223
	example does not prepend its AS number to AS PATH attribute and
2224
	keeps MED attribute). Default: disabled.
2225

    
2226
	<tag><label id="bgp-allow-local-pref">allow bgp_local_pref <m/switch/</tag>
2227
	A standard BGP implementation do not send the Local Preference attribute
2228
	to eBGP neighbors and ignore this attribute if received from eBGP
2229
	neighbors, as per <rfc id="4271">.  When this option is enabled on an
2230
	eBGP session, this attribute will be sent to and accepted from the peer,
2231
	which is useful for example if you have a setup like in <rfc id="7938">.
2232
	The option does not affect iBGP sessions. Default: off.
2233

    
2234
	<tag><label id="bgp-allow-local-as">allow local as [<m/number/]</tag>
2235
	BGP prevents routing loops by rejecting received routes with the local
2236
	AS number in the AS path. This option allows to loose or disable the
2237
	check. Optional <cf/number/ argument can be used to specify the maximum
2238
	number of local ASNs in the AS path that is allowed for received
2239
	routes. When the option is used without the argument, the check is
2240
	completely disabled and you should ensure loop-free behavior by some
2241
	other means. Default: 0 (no local AS number allowed).
2242

    
2243
	<tag><label id="bgp-enable-route-refresh">enable route refresh <m/switch/</tag>
2244
	After the initial route exchange, BGP protocol uses incremental updates
2245
	to keep BGP speakers synchronized. Sometimes (e.g., if BGP speaker
2246
	changes its import filter, or if there is suspicion of inconsistency) it
2247
	is necessary to do a new complete route exchange. BGP protocol extension
2248
	Route Refresh (<rfc id="2918">) allows BGP speaker to request
2249
	re-advertisement of all routes from its neighbor. BGP protocol
2250
	extension Enhanced Route Refresh (<rfc id="7313">) specifies explicit
2251
	begin and end for such exchanges, therefore the receiver can remove
2252
	stale routes that were not advertised during the exchange. This option
2253
	specifies whether BIRD advertises these capabilities and supports
2254
	related procedures. Note that even when disabled, BIRD can send route
2255
	refresh requests.  Default: on.
2256

    
2257
	<tag><label id="bgp-graceful-restart">graceful restart <m/switch/|aware</tag>
2258
	When a BGP speaker restarts or crashes, neighbors will discard all
2259
	received paths from the speaker, which disrupts packet forwarding even
2260
	when the forwarding plane of the speaker remains intact. <rfc id="4724">
2261
	specifies an optional graceful restart mechanism to alleviate this
2262
	issue. This option controls the mechanism. It has three states:
2263
	Disabled, when no support is provided. Aware, when the graceful restart
2264
	support is announced and the support for restarting neighbors is
2265
	provided, but no local graceful restart is allowed (i.e. receiving-only
2266
	role). Enabled, when the full graceful restart support is provided
2267
	(i.e. both restarting and receiving role). Restarting role could be also
2268
	configured per-channel. Note that proper support for local graceful
2269
	restart requires also configuration of other protocols. Default: aware.
2270

    
2271
	<tag><label id="bgp-graceful-restart-time">graceful restart time <m/number/</tag>
2272
	The restart time is announced in the BGP graceful restart capability
2273
	and specifies how long the neighbor would wait for the BGP session to
2274
	re-establish after a restart before deleting stale routes. Default:
2275
	120 seconds.
2276

    
2277
	<tag><label id="bgp-interpret-communities">interpret communities <m/switch/</tag>
2278
	<rfc id="1997"> demands that BGP speaker should process well-known
2279
	communities like no-export (65535, 65281) or no-advertise (65535,
2280
	65282). For example, received route carrying a no-adverise community
2281
	should not be advertised to any of its neighbors. If this option is
2282
	enabled (which is by default), BIRD has such behavior automatically (it
2283
	is evaluated when a route is exported to the BGP protocol just before
2284
	the export filter).  Otherwise, this integrated processing of
2285
	well-known communities is disabled. In that case, similar behavior can
2286
	be implemented in the export filter.  Default: on.
2287

    
2288
	<tag><label id="bgp-enable-as4">enable as4 <m/switch/</tag>
2289
	BGP protocol was designed to use 2B AS numbers and was extended later to
2290
	allow 4B AS number. BIRD supports 4B AS extension, but by disabling this
2291
	option it can be persuaded not to advertise it and to maintain old-style
2292
	sessions with its neighbors. This might be useful for circumventing bugs
2293
	in neighbor's implementation of 4B AS extension. Even when disabled
2294
	(off), BIRD behaves internally as AS4-aware BGP router. Default: on.
2295

    
2296
	<tag><label id="bgp-enable-extended-messages">enable extended messages <m/switch/</tag>
2297
	The BGP protocol uses maximum message length of 4096 bytes. This option
2298
	provides an extension to allow extended messages with length up
2299
	to 65535 bytes. Default: off.
2300

    
2301
	<tag><label id="bgp-capabilities">capabilities <m/switch/</tag>
2302
	Use capability advertisement to advertise optional capabilities. This is
2303
	standard behavior for newer BGP implementations, but there might be some
2304
	older BGP implementations that reject such connection attempts. When
2305
	disabled (off), features that request it (4B AS support) are also
2306
	disabled. Default: on, with automatic fallback to off when received
2307
	capability-related error.
2308

    
2309
	<tag><label id="bgp-advertise-ipv4">advertise ipv4 <m/switch/</tag>
2310
	Advertise IPv4 multiprotocol capability. This is not a correct behavior
2311
	according to the strict interpretation of <rfc id="4760">, but it is
2312
	widespread and required by some BGP implementations (Cisco and Quagga).
2313
	This option is relevant to IPv4 mode with enabled capability
2314
	advertisement only. Default: on.
2315

    
2316
	<tag><label id="bgp-disable-after-error">disable after error <m/switch/</tag>
2317
	When an error is encountered (either locally or by the other side),
2318
	disable the instance automatically and wait for an administrator to fix
2319
	the problem manually. Default: off.
2320

    
2321
	<tag><label id="bgp-hold-time">hold time <m/number/</tag>
2322
	Time in seconds to wait for a Keepalive message from the other side
2323
	before considering the connection stale. Default: depends on agreement
2324
	with the neighboring router, we prefer 240 seconds if the other side is
2325
	willing to accept it.
2326

    
2327
	<tag><label id="bgp-startup-hold-time">startup hold time <m/number/</tag>
2328
	Value of the hold timer used before the routers have a chance to exchange
2329
	open messages and agree on the real value. Default: 240	seconds.
2330

    
2331
	<tag><label id="bgp-keepalive-time">keepalive time <m/number/</tag>
2332
	Delay in seconds between sending of two consecutive Keepalive messages.
2333
	Default: One third of the hold time.
2334

    
2335
	<tag><label id="bgp-connect-delay-time">connect delay time <m/number/</tag>
2336
	Delay in seconds between protocol startup and the first attempt to
2337
	connect. Default: 5 seconds.
2338

    
2339
	<tag><label id="bgp-connect-retry-time">connect retry time <m/number/</tag>
2340
	Time in seconds to wait before retrying a failed attempt to connect.
2341
	Default: 120 seconds.
2342

    
2343
	<tag><label id="bgp-error-wait-time">error wait time <m/number/,<m/number/</tag>
2344
	Minimum and maximum delay in seconds between a protocol failure (either
2345
	local or reported by the peer) and automatic restart. Doesn't apply
2346
	when <cf/disable after error/ is configured. If consecutive errors
2347
	happen, the delay is increased exponentially until it reaches the
2348
	maximum. Default: 60, 300.
2349

    
2350
	<tag><label id="bgp-error-forget-time">error forget time <m/number/</tag>
2351
	Maximum time in seconds between two protocol failures to treat them as a
2352
	error sequence which makes <cf/error wait time/ increase exponentially.
2353
	Default: 300 seconds.
2354

    
2355
	<tag><label id="bgp-path-metric">path metric <m/switch/</tag>
2356
	Enable comparison of path lengths when deciding which BGP route is the
2357
	best one. Default: on.
2358

    
2359
	<tag><label id="bgp-med-metric">med metric <m/switch/</tag>
2360
	Enable comparison of MED attributes (during best route selection) even
2361
	between routes received from different ASes. This may be useful if all
2362
	MED attributes contain some consistent metric, perhaps enforced in
2363
	import filters of AS boundary routers. If this option is disabled, MED
2364
	attributes are compared only if routes are received from the same AS
2365
	(which is the standard behavior). Default: off.
2366

    
2367
	<tag><label id="bgp-deterministic-med">deterministic med <m/switch/</tag>
2368
	BGP route selection algorithm is often viewed as a comparison between
2369
	individual routes (e.g. if a new route appears and is better than the
2370
	current best one, it is chosen as the new best one). But the proper
2371
	route selection, as specified by <rfc id="4271">, cannot be fully
2372
	implemented in that way. The problem is mainly in handling the MED
2373
	attribute. BIRD, by default, uses an simplification based on individual
2374
	route comparison, which in some cases may lead to temporally dependent
2375
	behavior (i.e. the selection is dependent on the order in which routes
2376
	appeared). This option enables a different (and slower) algorithm
2377
	implementing proper <rfc id="4271"> route selection, which is
2378
	deterministic. Alternative way how to get deterministic behavior is to
2379
	use <cf/med metric/ option. This option is incompatible with <ref
2380
	id="dsc-table-sorted" name="sorted tables">.  Default: off.
2381

    
2382
	<tag><label id="bgp-igp-metric">igp metric <m/switch/</tag>
2383
	Enable comparison of internal distances to boundary routers during best
2384
	route selection. Default: on.
2385

    
2386
	<tag><label id="bgp-prefer-older">prefer older <m/switch/</tag>
2387
	Standard route selection algorithm breaks ties by comparing router IDs.
2388
	This changes the behavior to prefer older routes (when both are external
2389
	and from different peer). For details, see <rfc id="5004">. Default: off.
2390

    
2391
	<tag><label id="bgp-default-med">default bgp_med <m/number/</tag>
2392
	Value of the Multiple Exit Discriminator to be used during route
2393
	selection when the MED attribute is missing. Default: 0.
2394

    
2395
	<tag><label id="bgp-default-local-pref">default bgp_local_pref <m/number/</tag>
2396
	A default value for the Local Preference attribute. It is used when
2397
	a new Local Preference attribute is attached to a route by the BGP
2398
	protocol itself (for example, if a route is received through eBGP and
2399
	therefore does not have such attribute). Default: 100 (0 in pre-1.2.0
2400
	versions of BIRD).
2401
</descrip>
2402

    
2403
<sect1>Channel configuration
2404
<label id="bgp-channel-config">
2405

    
2406
<p>BGP supports several AFIs and SAFIs over one connection. Every AFI/SAFI
2407
announced to the peer corresponds to one channel. The table of supported AFI/SAFIs
2408
together with their appropriate channels follows.
2409

    
2410
<tabular ca="l|l|l|r|r">
2411
  <bf/Channel name/   | <bf/Table nettype/ | <bf/IGP table allowed/  | <bf/AFI/ | <bf/SAFI/
2412
@ <hline>
2413
  <cf/ipv4/	      | <cf/ipv4/          | <cf/ipv4/ and <cf/ipv6/ | 1        | 1
2414
@ <cf/ipv6/           | <cf/ipv6/          | <cf/ipv4/ and <cf/ipv6/ | 2        | 1
2415
@ <cf/ipv4 multicast/ | <cf/ipv4/          | <cf/ipv4/ and <cf/ipv6/ | 1        | 2
2416
@ <cf/ipv6 multicast/ | <cf/ipv6/          | <cf/ipv4/ and <cf/ipv6/ | 2        | 2
2417
@ <cf/ipv4 mpls/      | <cf/ipv4/          | <cf/ipv4/ and <cf/ipv6/ | 1        | 4
2418
@ <cf/ipv6 mpls/      | <cf/ipv6/          | <cf/ipv4/ and <cf/ipv6/ | 2        | 4
2419
@ <cf/vpn4 mpls/      | <cf/vpn4/          | <cf/ipv4/ and <cf/ipv6/ | 1        | 128
2420
@ <cf/vpn6 mpls/      | <cf/vpn6/          | <cf/ipv4/ and <cf/ipv6/ | 2        | 128
2421
@ <cf/vpn4 multicast/ | <cf/vpn4/          | <cf/ipv4/ and <cf/ipv6/ | 1        | 129
2422
@ <cf/vpn6 multicast/ | <cf/vpn6/          | <cf/ipv4/ and <cf/ipv6/ | 2        | 129
2423
@ <cf/flow4/	      | <cf/flow4/         | ---                     | 1        | 133
2424
@ <cf/flow6/          | <cf/flow6/         | ---                     | 2        | 133
2425
</tabular>
2426

    
2427
<p>BGP's channels have additional config options (together with the common ones):
2428

    
2429
<descrip>
2430
	<tag><label id="bgp-next-hop-keep">next hop keep</tag>
2431
	Forward the received Next Hop attribute even in situations where the
2432
	local address should be used instead, like when the route is sent to an
2433
	interface with a different subnet. Default: disabled.
2434

    
2435
	<tag><label id="bgp-next-hop-self">next hop self</tag>
2436
	Avoid calculation of the Next Hop attribute and always advertise our own
2437
	source address as a next hop. This needs to be used only occasionally to
2438
	circumvent misconfigurations of other routers. Default: disabled.
2439

    
2440
	<tag><label id="bgp-next-hop-address">next hop address <m/ip/</tag>
2441
	Avoid calculation of the Next Hop attribute and always advertise this address
2442
	as a next hop.
2443

    
2444
	<tag><label id="bgp-missing-lladdr">missing lladdr self|drop|ignore</tag>
2445
	Next Hop attribute in BGP-IPv6 sometimes contains just the global IPv6
2446
	address, but sometimes it has to contain both global and link-local IPv6
2447
	addresses. This option specifies what to do if BIRD have to send both
2448
	addresses but does not know link-local address. This situation might
2449
	happen when routes from other protocols are exported to BGP, or when
2450
	improper updates are received from BGP peers. <cf/self/ means that BIRD
2451
	advertises its own local address instead. <cf/drop/ means that BIRD
2452
	skips that prefixes and logs error. <cf/ignore/ means that BIRD ignores
2453
	the problem and sends just the global address (and therefore forms
2454
	improper BGP update). Default: <cf/self/, unless BIRD is configured as a
2455
	route server (option <cf/rs client/), in that case default is <cf/ignore/,
2456
	because route servers usually do not forward packets themselves.
2457

    
2458
	<tag><label id="bgp-gateway">gateway direct|recursive</tag>
2459
	For received routes, their <cf/gw/ (immediate next hop) attribute is
2460
	computed from received <cf/bgp_next_hop/ attribute. This option
2461
	specifies how it is computed. Direct mode means that the IP address from
2462
	<cf/bgp_next_hop/ is used if it is directly reachable, otherwise the
2463
	neighbor IP address is used. Recursive mode means that the gateway is
2464
	computed by an IGP routing table lookup for the IP address from
2465
	<cf/bgp_next_hop/. Note that there is just one level of indirection in
2466
	recursive mode - the route obtained by the lookup must not be recursive
2467
	itself, to prevent mutually recursive routes.
2468

    
2469
	Recursive mode is the behavior specified by the BGP
2470
	standard. Direct mode is simpler, does not require any routes in a
2471
	routing table, and was used in older versions of BIRD, but does not
2472
	handle well nontrivial iBGP setups and multihop. Recursive mode is
2473
	incompatible with <ref id="dsc-table-sorted" name="sorted tables">. Default:
2474
	<cf/direct/ for direct sessions, <cf/recursive/ for multihop sessions.
2475

    
2476
	<tag><label id="bgp-igp-table">igp table <m/name/</tag>
2477
	Specifies a table that is used as an IGP routing table. The type of this
2478
	table must be as allowed in the table above. This option is allowed once
2479
	for every allowed table type. Default: the same as the main table
2480
	the channel is connected to (if eligible).
2481

    
2482
	<tag><label id="bgp-secondary">secondary <m/switch/</tag>
2483
	Usually, if an export filter rejects a selected route, no other route is
2484
	propagated for that network. This option allows to try the next route in
2485
	order until one that is accepted is found or all routes for that network
2486
	are rejected. This can be used for route servers that need to propagate
2487
	different tables to each client but do not want to have these tables
2488
	explicitly (to conserve memory). This option requires that the connected
2489
	routing table is <ref id="dsc-table-sorted" name="sorted">. Default: off.
2490

    
2491
	<tag><label id="bgp-add-paths">add paths <m/switch/|rx|tx</tag>
2492
	Standard BGP can propagate only one path (route) per destination network
2493
	(usually the selected one). This option controls the add-path protocol
2494
	extension, which allows to advertise any number of paths to a
2495
	destination. Note that to be active, add-path has to be enabled on both
2496
	sides of the BGP session, but it could be enabled separately for RX and
2497
	TX direction. When active, all available routes accepted by the export
2498
	filter are advertised to the neighbor. Default: off.
2499

    
2500
	<tag><label id="bgp-graceful-restart-c">graceful restart <m/switch/</tag>
2501
	Although BGP graceful restart is configured mainly by protocol-wide
2502
	<ref id="bgp-graceful-restart" name="options">, it is possible to
2503
	configure restarting role per AFI/SAFI pair by this channel option.
2504
	The option is ignored if graceful restart is disabled by protocol-wide
2505
	option. Default: off in aware mode, on in full mode.
2506
</descrip>
2507

    
2508
<sect1>Attributes
2509
<label id="bgp-attr">
2510

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

    
2515
<descrip>
2516
	<tag><label id="rta-bgp-path">bgppath bgp_path/</tag>
2517
	Sequence of AS numbers describing the AS path the packet will travel
2518
	through when forwarded according to the particular route. In case of
2519
	internal BGP it doesn't contain the number of the local AS.
2520

    
2521
	<tag><label id="rta-bgp-local-pref">int bgp_local_pref/ [I]</tag>
2522
	Local preference value used for selection among multiple BGP routes (see
2523
	the selection rules above). It's used as an additional metric which is
2524
	propagated through the whole local AS.
2525

    
2526
	<tag><label id="rta-bgp-med">int bgp_med/ [O]</tag>
2527
	The Multiple Exit Discriminator of the route is an optional attribute
2528
	which is used on external (inter-AS) links to convey to an adjacent AS
2529
	the optimal entry point into the local AS. The received attribute is
2530
	also propagated over internal BGP links. The attribute value is zeroed
2531
	when a route is exported to an external BGP instance to ensure that the
2532
	attribute received from a neighboring AS is not propagated to other
2533
	neighboring ASes. A new value might be set in the export filter of an
2534
	external BGP instance. See <rfc id="4451"> for further discussion of
2535
	BGP MED attribute.
2536

    
2537
	<tag><label id="rta-bgp-origin">enum bgp_origin/</tag>
2538
	Origin of the route: either <cf/ORIGIN_IGP/ if the route has originated
2539
	in an interior routing protocol or <cf/ORIGIN_EGP/ if it's been imported
2540
	from the <tt>EGP</tt> protocol (nowadays it seems to be obsolete) or
2541
	<cf/ORIGIN_INCOMPLETE/ if the origin is unknown.
2542

    
2543
	<tag><label id="rta-bgp-next-hop">ip bgp_next_hop/</tag>
2544
	Next hop to be used for forwarding of packets to this destination. On
2545
	internal BGP connections, it's an address of the originating router if
2546
	it's inside the local AS or a boundary router the packet will leave the
2547
	AS through if it's an exterior route, so each BGP speaker within the AS
2548
	has a chance to use the shortest interior path possible to this point.
2549

    
2550
	<tag><label id="rta-bgp-atomic-aggr">void bgp_atomic_aggr/ [O]</tag>
2551
	This is an optional attribute which carries no value, but the sole
2552
	presence of which indicates that the route has been aggregated from
2553
	multiple routes by some router on the path from the originator.
2554

    
2555
<!-- we don't handle aggregators right since they are of a very obscure type
2556
	<tag>bgp_aggregator</tag>
2557
-->
2558
	<tag><label id="rta-bgp-community">clist bgp_community/ [O]</tag>
2559
	List of community values associated with the route. Each such value is a
2560
	pair (represented as a <cf/pair/ data type inside the filters) of 16-bit
2561
	integers, the first of them containing the number of the AS which
2562
	defines the community and the second one being a per-AS identifier.
2563
	There are lots of uses of the community mechanism, but generally they
2564
	are used to carry policy information like "don't export to USA peers".
2565
	As each AS can define its own routing policy, it also has a complete
2566
	freedom about which community attributes it defines and what will their
2567
	semantics be.
2568

    
2569
	<tag><label id="rta-bgp-ext-community">eclist bgp_ext_community/ [O]</tag>
2570
	List of extended community values associated with the route. Extended
2571
	communities have similar usage as plain communities, but they have an
2572
	extended range (to allow 4B ASNs) and a nontrivial structure with a type
2573
	field. Individual community values are represented using an <cf/ec/ data
2574
	type inside the filters.
2575

    
2576
	<tag><label id="rta-bgp-large-community">lclist <cf/bgp_large_community/ [O]</tag>
2577
	List of large community values associated with the route. Large BGP
2578
	communities is another variant of communities, but contrary to extended
2579
	communities they behave very much the same way as regular communities,
2580
	just larger -- they are uniform untyped triplets of 32bit numbers.
2581
	Individual community values are represented using an <cf/lc/ data type
2582
	inside the filters.
2583

    
2584
	<tag><label id="rta-bgp-originator-id">quad bgp_originator_id/ [I, O]</tag>
2585
	This attribute is created by the route reflector when reflecting the
2586
	route and contains the router ID of the originator of the route in the
2587
	local AS.
2588

    
2589
	<tag><label id="rta-bgp-cluster-list">clist bgp_cluster_list/ [I, O]</tag>
2590
	This attribute contains a list of cluster IDs of route reflectors. Each
2591
	route reflector prepends its cluster ID when reflecting the route.
2592
</descrip>
2593

    
2594
<sect1>Example
2595
<label id="bgp-exam">
2596

    
2597
<p><code>
2598
protocol bgp {
2599
	local 198.51.100.14 as 65000;	     # Use a private AS number
2600
	neighbor 198.51.100.130 as 64496;    # Our neighbor ...
2601
	multihop;			     # ... which is connected indirectly
2602
	ipv4 {
2603
		export filter {			     # We use non-trivial export rules
2604
			if source = RTS_STATIC then { # Export only static routes
2605
				# Assign our community
2606
				bgp_community.add((65000,64501));
2607
				# Artificially increase path length
2608
				# by advertising local AS number twice
2609
				if bgp_path ~ [= 65000 =] then
2610
					bgp_path.prepend(65000);
2611
				accept;
2612
			}
2613
			reject;
2614
		};
2615
		import all;
2616
		next hop self; # advertise this router as next hop
2617
		igp table myigptable4; # IGP table for routes with IPv4 nexthops
2618
		igp table myigptable6; # IGP table for routes with IPv6 nexthops
2619
	};
2620
	ipv6 {
2621
		export filter mylargefilter; # We use a named filter
2622
		import all;
2623
		missing lladdr self;
2624
		igp table myigptable4; # IGP table for routes with IPv4 nexthops
2625
		igp table myigptable6; # IGP table for routes with IPv6 nexthops
2626
	};
2627
	ipv4 multicast {
2628
		import all;
2629
		export filter someotherfilter;
2630
		table mymulticasttable4; # Another IPv4 table, dedicated for multicast
2631
		igp table myigptable4;
2632
	};
2633
}
2634
</code>
2635

    
2636

    
2637
<sect>Device
2638
<label id="device">
2639

    
2640
<p>The Device protocol is not a real routing protocol. It doesn't generate any
2641
routes and it only serves as a module for getting information about network
2642
interfaces from the kernel. This protocol supports no channel.
2643

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

    
2648
<sect1>Configuration
2649
<label id="device-config">
2650

    
2651
<p><descrip>
2652
	<tag><label id="device-scan-time">scan time <m/number/</tag>
2653
	Time in seconds between two scans of the network interface list. On
2654
	systems where we are notified about interface status changes
2655
	asynchronously (such as newer versions of Linux), we need to scan the
2656
	list only in order to avoid confusion by lost notification messages,
2657
	so the default time is set to a large value.
2658

    
2659
	<tag><label id="device-iface">interface <m/pattern/ [, <m/.../]</tag>
2660

    
2661
	By default, the Device protocol handles all interfaces without any
2662
	configuration. Interface definitions allow to specify optional
2663
	parameters for specific interfaces. See <ref id="proto-iface"
2664
	name="interface"> common option for detailed description. Currently only
2665
	one interface option is available:
2666

    
2667
	<tag><label id="device-preferred">preferred <m/ip/</tag>
2668
	If a network interface has more than one IP address, BIRD chooses one of
2669
	them as a preferred one. Preferred IP address is used as source address
2670
	for packets or announced next hop by routing protocols. Precisely, BIRD
2671
	chooses one preferred IPv4 address, one preferred IPv6 address and one
2672
	preferred link-local IPv6 address. By default, BIRD chooses the first
2673
	found IP address as the preferred one.
2674

    
2675
	This option allows to specify which IP address should be preferred. May
2676
	be used multiple times for different address classes (IPv4, IPv6, IPv6
2677
	link-local). In all cases, an address marked by operating system as
2678
	secondary cannot be chosen as the primary one.
2679
</descrip>
2680

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

    
2684
<p><code>
2685
protocol device {
2686
	scan time 10;		# Scan the interfaces often
2687
	interface "eth0" {
2688
		preferred 192.168.1.1;
2689
		preferred 2001:db8:1:10::1;
2690
	};
2691
}
2692
</code>
2693

    
2694

    
2695
<sect>Direct
2696
<label id="direct">
2697

    
2698
<p>The Direct protocol is a simple generator of device routes for all the
2699
directly connected networks according to the list of interfaces provided by the
2700
kernel via the Device protocol. The Direct protocol supports both IPv4 and IPv6
2701
channels.
2702

    
2703
<p>The question is whether it is a good idea to have such device routes in BIRD
2704
routing table. OS kernel usually handles device routes for directly connected
2705
networks by itself so we don't need (and don't want) to export these routes to
2706
the kernel protocol. OSPF protocol creates device routes for its interfaces
2707
itself and BGP protocol is usually used for exporting aggregate routes. Although
2708
there are some use cases that use the direct protocol (like abusing eBGP as an
2709
IGP routing protocol), in most cases it is not needed to have these device
2710
routes in BIRD routing table and to use the direct protocol.
2711

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

    
2720
<p>There are just few configuration options for the Direct protocol:
2721

    
2722
<p><descrip>
2723
	<tag><label id="direct-iface">interface <m/pattern/ [, <m/.../]</tag>
2724
	By default, the Direct protocol will generate device routes for all the
2725
	interfaces available. If you want to restrict it to some subset of
2726
	interfaces or addresses (e.g. if you're using multiple routing tables
2727
	for policy routing and some of the policy domains don't contain all
2728
	interfaces), just use this clause. See <ref id="proto-iface" name="interface">
2729
	common option for detailed description. The Direct protocol uses
2730
	extended interface clauses.
2731

    
2732
	<tag><label id="direct-check-link">check link <m/switch/</tag>
2733
	If enabled, a hardware link state (reported by OS) is taken into
2734
	consideration. Routes for directly connected networks are generated only
2735
	if link up is reported and they are withdrawn when link disappears
2736
	(e.g., an ethernet cable is unplugged). Default value is no.
2737
</descrip>
2738

    
2739
<p>Direct device routes don't contain any specific attributes.
2740

    
2741
<p>Example config might look like this:
2742

    
2743
<p><code>
2744
protocol direct {
2745
	ipv4;
2746
	ipv6;
2747
	interface "-arc*", "*";		# Exclude the ARCnets
2748
}
2749
</code>
2750

    
2751

    
2752
<sect>Kernel
2753
<label id="krt">
2754

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

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

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

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

    
2785
<p>The Kernel protocol supports both IPv4 and IPv6 channels; only one of them
2786
can be configured in each protocol instance.
2787

    
2788
<sect1>Configuration
2789
<label id="krt-config">
2790

    
2791
<p><descrip>
2792
	<tag><label id="krt-persist">persist <m/switch/</tag>
2793
	Tell BIRD to leave all its routes in the routing tables when it exits
2794
	(instead of cleaning them up).
2795

    
2796
	<tag><label id="krt-scan-time">scan time <m/number/</tag>
2797
	Time in seconds between two consecutive scans of the kernel routing
2798
	table.
2799

    
2800
	<tag><label id="krt-learn">learn <m/switch/</tag>
2801
	Enable learning of routes added to the kernel routing tables by other
2802
	routing daemons or by the system administrator. This is possible only on
2803
	systems which support identification of route authorship.
2804

    
2805
	<tag><label id="krt-kernel-table">kernel table <m/number/</tag>
2806
	Select which kernel table should this particular instance of the Kernel
2807
	protocol work with. Available only on systems supporting multiple
2808
	routing tables.
2809

    
2810
	<tag><label id="krt-metric">metric <m/number/</tag> (Linux)
2811
	Use specified value as a kernel metric (priority) for all routes sent to
2812
	the kernel. When multiple routes for the same network are in the kernel
2813
	routing table, the Linux kernel chooses one with lower metric. Also,
2814
	routes with different metrics do not clash with each other, therefore
2815
	using dedicated metric value is a reliable way to avoid overwriting
2816
	routes from other sources (e.g. kernel device routes). Metric 0 has a
2817
	special meaning of undefined metric, in which either OS default is used,
2818
	or per-route metric can be set using <cf/krt_metric/ attribute. Default:
2819
	32.
2820

    
2821
	<tag><label id="krt-graceful-restart">graceful restart <m/switch/</tag>
2822
	Participate in graceful restart recovery. If this option is enabled and
2823
	a graceful restart recovery is active, the Kernel protocol will defer
2824
	synchronization of routing tables until the end of the recovery. Note
2825
	that import of kernel routes to BIRD is not affected.
2826

    
2827
	<tag><label id="krt-merge-paths">merge paths <M>switch</M> [limit <M>number</M>]</tag>
2828
	Usually, only best routes are exported to the kernel protocol. With path
2829
	merging enabled, both best routes and equivalent non-best routes are
2830
	merged during export to generate one ECMP (equal-cost multipath) route
2831
	for each network. This is useful e.g. for BGP multipath. Note that best
2832
	routes are still pivotal for route export (responsible for most
2833
	properties of resulting ECMP routes), while exported non-best routes are
2834
	responsible just for additional multipath next hops. This option also
2835
	allows to specify a limit on maximal number of nexthops in one route. By
2836
	default, multipath merging is disabled. If enabled, default value of the
2837
	limit is 16.
2838
</descrip>
2839

    
2840
<sect1>Attributes
2841
<label id="krt-attr">
2842

    
2843
<p>The Kernel protocol defines several attributes. These attributes are
2844
translated to appropriate system (and OS-specific) route attributes. We support
2845
these attributes:
2846

    
2847
<descrip>
2848
	<tag><label id="rta-krt-source">int krt_source/</tag>
2849
	The original source of the imported kernel route. The value is
2850
	system-dependent. On Linux, it is a value of the protocol field of the
2851
	route. See /etc/iproute2/rt_protos for common values. On BSD, it is
2852
	based on STATIC and PROTOx flags. The attribute is read-only.
2853

    
2854
	<tag><label id="rta-krt-metric">int krt_metric/</tag> (Linux)
2855
	The kernel metric of the route. When multiple same routes are in a
2856
	kernel routing table, the Linux kernel chooses one with lower metric.
2857
	Note that preferred way to set kernel metric is to use protocol option
2858
	<cf/metric/, unless per-route metric values are needed.
2859

    
2860
	<tag><label id="rta-krt-prefsrc">ip krt_prefsrc/</tag> (Linux)
2861
	The preferred source address. Used in source address selection for
2862
	outgoing packets. Has to be one of the IP addresses of the router.
2863

    
2864
	<tag><label id="rta-krt-realm">int krt_realm/</tag> (Linux)
2865
	The realm of the route. Can be used for traffic classification.
2866

    
2867
	<tag><label id="rta-krt-scope">int krt_scope/</tag> (Linux IPv4)
2868
	The scope of the route. Valid values are 0-254, although Linux kernel
2869
	may reject some values depending on route type and nexthop. It is
2870
	supposed to represent `indirectness' of the route, where nexthops of
2871
	routes are resolved through routes with a higher scope, but in current
2872
	kernels anything below <it/link/ (253) is treated as <it/global/ (0).
2873
	When not present, global scope is implied for all routes except device
2874
	routes, where link scope is used by default.
2875
</descrip>
2876

    
2877
<p>In Linux, there is also a plenty of obscure route attributes mostly focused
2878
on tuning TCP performance of local connections. BIRD supports most of these
2879
attributes, see Linux or iproute2 documentation for their meaning. Attributes
2880
<cf/krt_lock_*/ and <cf/krt_feature_*/ have type bool, others have type int.
2881
Supported attributes are:
2882

    
2883
<cf/krt_mtu/, <cf/krt_lock_mtu/, <cf/krt_window/, <cf/krt_lock_window/,
2884
<cf/krt_rtt/, <cf/krt_lock_rtt/, <cf/krt_rttvar/, <cf/krt_lock_rttvar/,
2885
<cf/krt_sstresh/, <cf/krt_lock_sstresh/, <cf/krt_cwnd/, <cf/krt_lock_cwnd/,
2886
<cf/krt_advmss/, <cf/krt_lock_advmss/, <cf/krt_reordering/, <cf/krt_lock_reordering/,
2887
<cf/krt_hoplimit/, <cf/krt_lock_hoplimit/, <cf/krt_rto_min/, <cf/krt_lock_rto_min/,
2888
<cf/krt_initcwnd/, <cf/krt_initrwnd/, <cf/krt_quickack/,
2889
<cf/krt_feature_ecn/, <cf/krt_feature_allfrag/
2890

    
2891
<sect1>Example
2892
<label id="krt-exam">
2893

    
2894
<p>A simple configuration can look this way:
2895

    
2896
<p><code>
2897
protocol kernel {
2898
	export all;
2899
}
2900
</code>
2901

    
2902
<p>Or for a system with two routing tables:
2903

    
2904
<p><code>
2905
protocol kernel {		# Primary routing table
2906
	learn;			# Learn alien routes from the kernel
2907
	persist;		# Don't remove routes on bird shutdown
2908
	scan time 10;		# Scan kernel routing table every 10 seconds
2909
	ipv4 {
2910
		import all;
2911
		export all;
2912
	};
2913
}
2914

    
2915
protocol kernel {		# Secondary routing table
2916
	kernel table 100;
2917
	ipv4 {
2918
		table auxtable;
2919
		export all;
2920
	};
2921
}
2922
</code>
2923

    
2924

    
2925
<sect>OSPF
2926
<label id="ospf">
2927

    
2928
<sect1>Introduction
2929
<label id="ospf-intro">
2930

    
2931
<p>Open Shortest Path First (OSPF) is a quite complex interior gateway
2932
protocol. The current IPv4 version (OSPFv2) is defined in <rfc id="2328"> and
2933
the current IPv6 version (OSPFv3) is defined in <rfc id="5340"> It's a link
2934
state (a.k.a. shortest path first) protocol -- each router maintains a database
2935
describing the autonomous system's topology. Each participating router has an
2936
identical copy of the database and all routers run the same algorithm
2937
calculating a shortest path tree with themselves as a root. OSPF chooses the
2938
least cost path as the best path.
2939

    
2940
<p>In OSPF, the autonomous system can be split to several areas in order to
2941
reduce the amount of resources consumed for exchanging the routing information
2942
and to protect the other areas from incorrect routing data. Topology of the area
2943
is hidden to the rest of the autonomous system.
2944

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

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

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

    
2961
<sect1>Configuration
2962
<label id="ospf-config">
2963

    
2964
<p>First, the desired OSPF version can be specified by using <cf/ospf v2/ or
2965
<cf/ospf v3/ as a protocol type. By default, OSPFv2 is used. In the main part of
2966
configuration, there can be multiple definitions of OSPF areas, each with a
2967
different id. These definitions includes many other switches and multiple
2968
definitions of interfaces. Definition of interface may contain many switches and
2969
constant definitions and list of neighbors on nonbroadcast networks.
2970

    
2971
<p>OSPFv2 needs one IPv4 channel. OSPFv3 needs either one IPv6 channel, or one
2972
IPv4 channel (<rfc id="5838">). Therefore, it is possible to use OSPFv3 for both
2973
IPv4 and Pv6 routing, but it is necessary to have two protocol instances anyway.
2974
If no channel is configured, appropriate channel is defined with default
2975
parameters.
2976

    
2977
<code>
2978
protocol ospf [v2|v3] &lt;name&gt; {
2979
	rfc1583compat &lt;switch&gt;;
2980
	rfc5838 &lt;switch&gt;;
2981
	instance id &lt;num&gt;;
2982
	stub router &lt;switch&gt;;
2983
	tick &lt;num&gt;;
2984
	ecmp &lt;switch&gt; [limit &lt;num&gt;];
2985
	merge external &lt;switch&gt;;
2986
	area &lt;id&gt; {
2987
		stub;
2988
		nssa;
2989
		summary &lt;switch&gt;;
2990
		default nssa &lt;switch&gt;;
2991
		default cost &lt;num&gt;;
2992
		default cost2 &lt;num&gt;;
2993
		translator &lt;switch&gt;;
2994
		translator stability &lt;num&gt;;
2995

    
2996
                networks {
2997
			&lt;prefix&gt;;
2998
			&lt;prefix&gt; hidden;
2999
		}
3000
                external {
3001
			&lt;prefix&gt;;
3002
			&lt;prefix&gt; hidden;
3003
			&lt;prefix&gt; tag &lt;num&gt;;
3004
		}
3005
		stubnet &lt;prefix&gt;;
3006
		stubnet &lt;prefix&gt; {
3007
			hidden &lt;switch&gt;;
3008
			summary &lt;switch&gt;;
3009
			cost &lt;num&gt;;
3010
		}
3011
		interface &lt;interface pattern&gt; [instance &lt;num&gt;] {
3012
			cost &lt;num&gt;;
3013
			stub &lt;switch&gt;;
3014
			hello &lt;num&gt;;
3015
			poll &lt;num&gt;;
3016
			retransmit &lt;num&gt;;
3017
			priority &lt;num&gt;;
3018
			wait &lt;num&gt;;
3019
			dead count &lt;num&gt;;
3020
			dead &lt;num&gt;;
3021
			secondary &lt;switch&gt;;
3022
			rx buffer [normal|large|&lt;num&gt;];
3023
			tx length &lt;num&gt;;
3024
			type [broadcast|bcast|pointopoint|ptp|
3025
				nonbroadcast|nbma|pointomultipoint|ptmp];
3026
			link lsa suppression &lt;switch&gt;;
3027
			strict nonbroadcast &lt;switch&gt;;
3028
			real broadcast &lt;switch&gt;;
3029
			ptp netmask &lt;switch&gt;;
3030
			check link &lt;switch&gt;;
3031
			bfd &lt;switch&gt;;
3032
			ecmp weight &lt;num&gt;;
3033
			ttl security [&lt;switch&gt;; | tx only]
3034
			tx class|dscp &lt;num&gt;;
3035
			tx priority &lt;num&gt;;
3036
			authentication none|simple|cryptographic;
3037
			password "&lt;text&gt;";
3038
			password "&lt;text&gt;" {
3039
				id &lt;num&gt;;
3040
				generate from "&lt;date&gt;";
3041
				generate to "&lt;date&gt;";
3042
				accept from "&lt;date&gt;";
3043
				accept to "&lt;date&gt;";
3044
				from "&lt;date&gt;";
3045
				to "&lt;date&gt;";
3046
				algorithm ( keyed md5 | keyed sha1 | hmac sha1 | hmac sha256 | hmac sha384 | hmac sha512 );
3047
			};
3048
			neighbors {
3049
				&lt;ip&gt;;
3050
				&lt;ip&gt; eligible;
3051
			};
3052
		};
3053
		virtual link &lt;id&gt; [instance &lt;num&gt;] {
3054
			hello &lt;num&gt;;
3055
			retransmit &lt;num&gt;;
3056
			wait &lt;num&gt;;
3057
			dead count &lt;num&gt;;
3058
			dead &lt;num&gt;;
3059
			authentication none|simple|cryptographic;
3060
			password "&lt;text&gt;";
3061
			password "&lt;text&gt;" {
3062
				id &lt;num&gt;;
3063
				generate from "&lt;date&gt;";
3064
				generate to "&lt;date&gt;";
3065
				accept from "&lt;date&gt;";
3066
				accept to "&lt;date&gt;";
3067
				from "&lt;date&gt;";
3068
				to "&lt;date&gt;";
3069
				algorithm ( keyed md5 | keyed sha1 | hmac sha1 | hmac sha256 | hmac sha384 | hmac sha512 );
3070
			};
3071
		};
3072
	};
3073
}
3074
</code>
3075

    
3076
<descrip>
3077
	<tag><label id="ospf-rfc1583compat">rfc1583compat <M>switch</M></tag>
3078
	This option controls compatibility of routing table calculation with
3079
	<rfc id="1583">. Default value is no.
3080

    
3081
	<tag><label id="ospf-rfc5838">rfc5838 <m/switch/</tag>
3082
	Basic OSPFv3 is limited to IPv6 unicast routing. The <rfc id="5838">
3083
	extension defines support for more address families (IPv4, IPv6, both
3084
	unicast and multicast). The extension is enabled by default, but can be
3085
	disabled if necessary, as it restricts the range of available instance
3086
	IDs. Default value is yes.
3087

    
3088
	<tag><label id="ospf-instance-id">instance id <m/num/</tag>
3089
	When multiple OSPF protocol instances are active on the same links, they
3090
	should use different instance IDs to distinguish their packets. Although
3091
	it could be done on per-interface basis, it is often preferred to set
3092
	one instance ID to whole OSPF domain/topology (e.g., when multiple
3093
	instances are used to represent separate logical topologies on the same
3094
	physical network). This option specifies the instance ID for all
3095
	interfaces of the OSPF instance, but can be overridden by
3096
	<cf/interface/ option. Default value is 0 unless OSPFv3-AF extended
3097
	address families are used, see <rfc id="5838"> for that case.
3098

    
3099
	<tag><label id="ospf-stub-router">stub router <M>switch</M></tag>
3100
	This option configures the router to be a stub router, i.e., a router
3101
	that participates in the OSPF topology but does not allow transit
3102
	traffic. In OSPFv2, this is implemented by advertising maximum metric
3103
	for outgoing links. In OSPFv3, the stub router behavior is announced by
3104
	clearing the R-bit in the router LSA. See <rfc id="6987"> for details.
3105
	Default value is no.
3106

    
3107
	<tag><label id="ospf-tick">tick <M>num</M></tag>
3108
	The routing table calculation and clean-up of areas' databases is not
3109
	performed when a single link state change arrives. To lower the CPU
3110
	utilization, it's processed later at periodical intervals of <m/num/
3111
	seconds. The default value is 1.
3112

    
3113
	<tag><label id="ospf-ecmp">ecmp <M>switch</M> [limit <M>number</M>]</tag>
3114
	This option specifies whether OSPF is allowed to generate ECMP
3115
	(equal-cost multipath) routes. Such routes are used when there are
3116
	several directions to the destination, each with the same (computed)
3117
	cost. This option also allows to specify a limit on maximum number of
3118
	nexthops in one route. By default, ECMP is enabled if supported by
3119
	Kernel. Default value of the limit is 16.
3120

    
3121
	<tag><label id="ospf-merge-external">merge external <M>switch</M></tag>
3122
	This option specifies whether OSPF should merge external routes from
3123
	different routers/LSAs for the same destination. When enabled together
3124
	with <cf/ecmp/, equal-cost external routes will be combined to multipath
3125
	routes in the same way as regular routes. When disabled, external routes
3126
	from different LSAs are treated as separate even if they represents the
3127
	same destination. Default value is no.
3128

    
3129
	<tag><label id="ospf-area">area <M>id</M></tag>
3130
	This defines an OSPF area with given area ID (an integer or an IPv4
3131
	address, similarly to a router ID). The most important area is the
3132
	backbone (ID 0) to which every other area must be connected.
3133

    
3134
	<tag><label id="ospf-stub">stub</tag>
3135
	This option configures the area to be a stub area. External routes are
3136
	not flooded into stub areas. Also summary LSAs can be limited in stub
3137
	areas (see option <cf/summary/). By default, the area is not a stub
3138
	area.
3139

    
3140
	<tag><label id="ospf-nssa">nssa</tag>
3141
	This option configures the area to be a NSSA (Not-So-Stubby Area). NSSA
3142
	is a variant of a stub area which allows a limited way of external route
3143
	propagation. Global external routes are not propagated into a NSSA, but
3144
	an external route can be imported into NSSA as a (area-wide) NSSA-LSA
3145
	(and possibly translated and/or aggregated on area boundary). By
3146
	default, the area is not NSSA.
3147

    
3148
	<tag><label id="ospf-summary">summary <M>switch</M></tag>
3149
	This option controls propagation of summary LSAs into stub or NSSA
3150
	areas. If enabled, summary LSAs are propagated as usual, otherwise just
3151
	the default summary route (0.0.0.0/0) is propagated (this is sometimes
3152
	called totally stubby area). If a stub area has more area boundary
3153
	routers, propagating summary LSAs could lead to more efficient routing
3154
	at the cost of larger link state database. Default value is no.
3155

    
3156
	<tag><label id="ospf-default-nssa">default nssa <M>switch</M></tag>
3157
	When <cf/summary/ option is enabled, default summary route is no longer
3158
	propagated to the NSSA. In that case, this option allows to originate
3159
	default route as NSSA-LSA to the NSSA. Default value is no.
3160

    
3161
	<tag><label id="ospf-default-cost">default cost <M>num</M></tag>
3162
	This option controls the cost of a default route propagated to stub and
3163
	NSSA areas. Default value is 1000.
3164

    
3165
	<tag><label id="ospf-default-cost2">default cost2 <M>num</M></tag>
3166
	When a default route is originated as NSSA-LSA, its cost can use either
3167
	type 1 or type 2 metric. This option allows to specify the cost of a
3168
	default route in type 2 metric. By default, type 1 metric (option
3169
	<cf/default cost/) is used.
3170

    
3171
	<tag><label id="ospf-translator">translator <M>switch</M></tag>
3172
	This option controls translation of NSSA-LSAs into external LSAs. By
3173
	default, one translator per NSSA is automatically elected from area
3174
	boundary routers. If enabled, this area boundary router would
3175
	unconditionally translate all NSSA-LSAs regardless of translator
3176
	election. Default value is no.
3177

    
3178
	<tag><label id="ospf-translator-stability">translator stability <M>num</M></tag>
3179
	This option controls the translator stability interval (in seconds).
3180
	When the new translator is elected, the old one keeps translating until
3181
	the interval is over. Default value is 40.
3182

    
3183
	<tag><label id="ospf-networks">networks { <m/set/ }</tag>
3184
	Definition of area IP ranges. This is used in summary LSA origination.
3185
	Hidden networks are not propagated into other areas.
3186

    
3187
	<tag><label id="ospf-external">external { <m/set/ }</tag>
3188
	Definition of external area IP ranges for NSSAs. This is used for
3189
	NSSA-LSA translation. Hidden networks are not translated into external
3190
	LSAs. Networks can have configured route tag.
3191

    
3192
	<tag><label id="ospf-stubnet">stubnet <m/prefix/ { <m/options/ }</tag>
3193
	Stub networks are networks that are not transit networks between OSPF
3194
	routers. They are also propagated through an OSPF area as a part of a
3195
	link state database. By default, BIRD generates a stub network record
3196
	for each primary network address on each OSPF interface that does not
3197
	have any OSPF neighbors, and also for each non-primary network address
3198
	on each OSPF interface. This option allows to alter a set of stub
3199
	networks propagated by this router.
3200

    
3201
	Each instance of this option adds a stub network with given network
3202
	prefix to the set of propagated stub network, unless option <cf/hidden/
3203
	is used. It also suppresses default stub networks for given network
3204
	prefix. When option <cf/summary/ is used, also default stub networks
3205
	that are subnetworks of given stub network are suppressed. This might be
3206
	used, for example, to aggregate generated stub networks.
3207

    
3208
	<tag><label id="ospf-iface">interface <M>pattern</M> [instance <m/num/]</tag>
3209
	Defines that the specified interfaces belong to the area being defined.
3210
	See <ref id="proto-iface" name="interface"> common option for detailed
3211
	description. In OSPFv2, extended interface clauses are used, because
3212
	each network prefix is handled as a separate virtual interface.
3213

    
3214
	You can specify alternative instance ID for the interface definition,
3215
	therefore it is possible to have several instances of that interface
3216
	with different options or even in different areas. For OSPFv2, instance
3217
	ID support is an extension (<rfc id="6549">) and is supposed to be set
3218
	per-protocol. For OSPFv3, it is an integral feature.
3219

    
3220
	<tag><label id="ospf-virtual-link">virtual link <M>id</M> [instance <m/num/]</tag>
3221
	Virtual link to router with the router id. Virtual link acts as a
3222
	point-to-point interface belonging to backbone. The actual area is used
3223
	as a transport area. This item cannot be in the backbone. Like with
3224
	<cf/interface/ option, you could also use several virtual links to one
3225
	destination with different instance IDs.
3226

    
3227
	<tag><label id="ospf-cost">cost <M>num</M></tag>
3228
	Specifies output cost (metric) of an interface. Default value is 10.
3229

    
3230
	<tag><label id="ospf-stub-iface">stub <M>switch</M></tag>
3231
	If set to interface it does not listen to any packet and does not send
3232
	any hello. Default value is no.
3233

    
3234
	<tag><label id="ospf-hello">hello <M>num</M></tag>
3235
	Specifies interval in seconds between sending of Hello messages. Beware,
3236
	all routers on the same network need to have the same hello interval.
3237
	Default value is 10.
3238

    
3239
	<tag><label id="ospf-poll">poll <M>num</M></tag>
3240
	Specifies interval in seconds between sending of Hello messages for some
3241
	neighbors on NBMA network. Default value is 20.
3242

    
3243
	<tag><label id="ospf-retransmit">retransmit <M>num</M></tag>
3244
	Specifies interval in seconds between retransmissions of unacknowledged
3245
	updates. Default value is 5.
3246

    
3247
	<tag><label id="ospf-priority">priority <M>num</M></tag>
3248
	On every multiple access network (e.g., the Ethernet) Designated Router
3249
	and Backup Designated router are elected. These routers have some special
3250
	functions in the flooding process. Higher priority increases preferences
3251
	in this election. Routers with priority 0 are not eligible. Default
3252
	value is 1.
3253

    
3254
	<tag><label id="ospf-wait">wait <M>num</M></tag>
3255
	After start, router waits for the specified number of seconds between
3256
	starting election and building adjacency. Default value is 4*<m/hello/.
3257

    
3258
	<tag><label id="ospf-dead-count">dead count <M>num</M></tag>
3259
	When the router does not receive any messages from a neighbor in
3260
	<m/dead count/*<m/hello/ seconds, it will consider the neighbor down.
3261

    
3262
	<tag><label id="ospf-dead">dead <M>num</M></tag>
3263
	When the router does not receive any messages from a neighbor in
3264
	<m/dead/ seconds, it will consider the neighbor down. If both directives
3265
	<cf/dead count/ and <cf/dead/ are used, <cf/dead/ has precedence.
3266

    
3267
	<tag><label id="ospf-secondary">secondary <M>switch</M></tag>
3268
	On BSD systems, older versions of BIRD supported OSPFv2 only for the
3269
	primary IP address of an interface, other IP ranges on the interface
3270
	were handled as stub networks. Since v1.4.1, regular operation on
3271
	secondary IP addresses is supported, but disabled by default for
3272
	compatibility. This option allows to enable it. The option is a
3273
	transitional measure, will be removed in the next major release as the
3274
	behavior will be changed. On Linux systems, the option is irrelevant, as
3275
	operation on non-primary addresses is already the regular behavior.
3276

    
3277
	<tag><label id="ospf-rx-buffer">rx buffer <M>num</M></tag>
3278
	This option allows to specify the size of buffers used for packet
3279
	processing. The buffer size should be bigger than maximal size of any
3280
	packets. By default, buffers are dynamically resized as needed, but a
3281
	fixed value could be specified. Value <cf/large/ means maximal allowed
3282
	packet size - 65535.
3283

    
3284
	<tag><label id="ospf-tx-length">tx length <M>num</M></tag>
3285
	Transmitted OSPF messages that contain large amount of information are
3286
	segmented to separate OSPF packets to avoid IP fragmentation. This
3287
	option specifies the soft ceiling for the length of generated OSPF
3288
	packets. Default value is the MTU of the network interface. Note that
3289
	larger OSPF packets may still be generated if underlying OSPF messages
3290
	cannot be splitted (e.g. when one large LSA is propagated).
3291

    
3292
	<tag><label id="ospf-type-bcast">type broadcast|bcast</tag>
3293
	BIRD detects a type of a connected network automatically, but sometimes
3294
	it's convenient to force use of a different type manually. On broadcast
3295
	networks (like ethernet), flooding and Hello messages are sent using
3296
	multicasts (a single packet for all the neighbors). A designated router
3297
	is elected and it is responsible for synchronizing the link-state
3298
	databases and originating network LSAs. This network type cannot be used
3299
	on physically NBMA networks and on unnumbered networks (networks without
3300
	proper IP prefix).
3301

    
3302
	<tag><label id="ospf-type-ptp">type pointopoint|ptp</tag>
3303
	Point-to-point networks connect just 2 routers together. No election is
3304
	performed and no network LSA is originated, which makes it simpler and
3305
	faster to establish. This network type is useful not only for physically
3306
	PtP ifaces (like PPP or tunnels), but also for broadcast networks used
3307
	as PtP links. This network type cannot be used on physically NBMA
3308
	networks.
3309

    
3310
	<tag><label id="ospf-type-nbma">type nonbroadcast|nbma</tag>
3311
	On NBMA networks, the packets are sent to each neighbor separately
3312
	because of lack of multicast capabilities. Like on broadcast networks,
3313
	a designated router is elected, which plays a central role in propagation
3314
	of LSAs. This network type cannot be used on unnumbered networks.
3315

    
3316
	<tag><label id="ospf-type-ptmp">type pointomultipoint|ptmp</tag>
3317
	This is another network type designed to handle NBMA networks. In this
3318
	case the NBMA network is treated as a collection of PtP links. This is
3319
	useful if not every pair of routers on the NBMA network has direct
3320
	communication, or if the NBMA network is used as an (possibly
3321
	unnumbered) PtP link.
3322

    
3323
	<tag><label id="ospf-link-lsa-suppression">link lsa suppression <m/switch/</tag>
3324
	In OSPFv3, link LSAs are generated for each link, announcing link-local
3325
	IPv6 address of the router to its local neighbors. These are useless on
3326
	PtP or PtMP networks and this option allows to suppress the link LSA
3327
	origination for such interfaces. The option is ignored on other than PtP
3328
	or PtMP interfaces. Default value is no.
3329

    
3330
	<tag><label id="ospf-strict-nonbroadcast">strict nonbroadcast <m/switch/</tag>
3331
	If set, don't send hello to any undefined neighbor. This switch is
3332
	ignored on other than NBMA or PtMP interfaces. Default value is no.
3333

    
3334
	<tag><label id="ospf-real-broadcast">real broadcast <m/switch/</tag>
3335
	In <cf/type broadcast/ or <cf/type ptp/ network configuration, OSPF
3336
	packets are sent as IP multicast packets. This option changes the
3337
	behavior to using old-fashioned IP broadcast packets. This may be useful
3338
	as a workaround if IP multicast for some reason does not work or does
3339
	not work reliably. This is a non-standard option and probably is not
3340
	interoperable with other OSPF implementations. Default value is no.
3341

    
3342
	<tag><label id="ospf-ptp-netmask">ptp netmask <m/switch/</tag>
3343
	In <cf/type ptp/ network configurations, OSPFv2 implementations should
3344
	ignore received netmask field in hello packets and should send hello
3345
	packets with zero netmask field on unnumbered PtP links. But some OSPFv2
3346
	implementations perform netmask checking even for PtP links. This option
3347
	specifies whether real netmask will be used in hello packets on <cf/type
3348
 	ptp/ interfaces. You should ignore this option unless you meet some
3349
	compatibility problems related to this issue. Default value is no for
3350
	unnumbered PtP links, yes otherwise.
3351

    
3352
	<tag><label id="ospf-check-link">check link <M>switch</M></tag>
3353
	If set, a hardware link state (reported by OS) is taken into consideration.
3354
	When a link disappears (e.g. an ethernet cable is unplugged), neighbors
3355
	are immediately considered unreachable and only the address of the iface
3356
	(instead of whole network prefix) is propagated. It is possible that
3357
	some hardware drivers or platforms do not implement this feature.
3358
	Default value is yes.
3359

    
3360
	<tag><label id="ospf-bfd">bfd <M>switch</M></tag>
3361
	OSPF could use BFD protocol as an advisory mechanism for neighbor
3362
	liveness and failure detection. If enabled, BIRD setups a BFD session
3363
	for each OSPF neighbor and tracks its liveness by it. This has an
3364
	advantage of an order of magnitude lower detection times in case of
3365
	failure. Note that BFD protocol also has to be configured, see
3366
	<ref id="bfd" name="BFD"> section for details. Default value is no.
3367

    
3368
	<tag><label id="ospf-ttl-security">ttl security [<m/switch/ | tx only]</tag>
3369
	TTL security is a feature that protects routing protocols from remote
3370
	spoofed packets by using TTL 255 instead of TTL 1 for protocol packets
3371
	destined to neighbors. Because TTL is decremented when packets are
3372
	forwarded, it is non-trivial to spoof packets with TTL 255 from remote
3373
	locations. Note that this option would interfere with OSPF virtual
3374
	links.
3375

    
3376
	If this option is enabled, the router will send OSPF packets with TTL
3377
	255 and drop received packets with TTL less than 255. If this option si
3378
	set to <cf/tx only/, TTL 255 is used for sent packets, but is not
3379
	checked for received packets. Default value is no.
3380

    
3381
	<tag><label id="ospf-tx-class">tx class|dscp|priority <m/num/</tag>
3382
	These options specify the ToS/DiffServ/Traffic class/Priority of the
3383
	outgoing OSPF packets. See <ref id="proto-tx-class" name="tx class"> common
3384
	option for detailed description.
3385

    
3386
	<tag><label id="ospf-ecmp-weight">ecmp weight <M>num</M></tag>
3387
	When ECMP (multipath) routes are allowed, this value specifies a
3388
	relative weight used for nexthops going through the iface. Allowed
3389
	values are 1-256. Default value is 1.
3390

    
3391
	<tag><label id="ospf-auth-none">authentication none</tag>
3392
	No passwords are sent in OSPF packets. This is the default value.
3393

    
3394
	<tag><label id="ospf-auth-simple">authentication simple</tag>
3395
	Every packet carries 8 bytes of password. Received packets lacking this
3396
	password are ignored. This authentication mechanism is very weak.
3397
	This option is not available in OSPFv3.
3398

    
3399
	<tag><label id="ospf-auth-cryptographic">authentication cryptographic</tag>
3400
	An authentication code is appended to every packet. The specific
3401
	cryptographic algorithm is selected by option <cf/algorithm/ for each
3402
	key. The default cryptographic algorithm for OSPFv2 keys is Keyed-MD5
3403
	and for OSPFv3 keys is HMAC-SHA-256. Passwords are not sent open via
3404
	network, so this mechanism is quite secure. Packets can still be read by
3405
	an attacker.
3406

    
3407
	<tag><label id="ospf-pass">password "<M>text</M>"</tag>
3408
	Specifies a password used for authentication. See
3409
	<ref id="proto-pass" name="password"> common option for detailed
3410
	description.
3411

    
3412
	<tag><label id="ospf-neighbors">neighbors { <m/set/ } </tag>
3413
	A set of neighbors to which Hello messages on NBMA or PtMP networks are
3414
	to be sent. For NBMA networks, some of them could be marked as eligible.
3415
	In OSPFv3, link-local addresses should be used, using global ones is
3416
	possible, but it is nonstandard and might be problematic. And definitely,
3417
	link-local and global addresses should not be mixed.
3418
</descrip>
3419

    
3420
<sect1>Attributes
3421
<label id="ospf-attr">
3422

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

    
3425
<p>Metric is ranging from 1 to infinity (65535). External routes use
3426
<cf/metric type 1/ or <cf/metric type 2/. A <cf/metric of type 1/ is comparable
3427
with internal <cf/metric/, a <cf/metric of type 2/ is always longer than any
3428
<cf/metric of type 1/ or any <cf/internal metric/. <cf/Internal metric/ or
3429
<cf/metric of type 1/ is stored in attribute <cf/ospf_metric1/, <cf/metric type
3430
2/ is stored in attribute <cf/ospf_metric2/. If you specify both metrics only
3431
metric1 is used.
3432

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

    
3440
<sect1>Example
3441
<label id="ospf-exam">
3442

    
3443
<p><code>
3444
protocol ospf MyOSPF {
3445
	ipv4 {
3446
		export filter {
3447
			if source = RTS_BGP then {
3448
				ospf_metric1 = 100;
3449
				accept;
3450
			}
3451
			reject;
3452
		};
3453
	};
3454
	area 0.0.0.0 {
3455
		interface "eth*" {
3456
			cost 11;
3457
			hello 15;
3458
			priority 100;
3459
			retransmit 7;
3460
			authentication simple;
3461
			password "aaa";
3462
		};
3463
		interface "ppp*" {
3464
			cost 100;
3465
			authentication cryptographic;
3466
			password "abc" {
3467
				id 1;
3468
				generate to "22-04-2003 11:00:06";
3469
				accept from "17-01-2001 12:01:05";
3470
				algorithm hmac sha384;
3471
			};
3472
			password "def" {
3473
				id 2;
3474
				generate to "22-07-2005 17:03:21";
3475
				accept from "22-02-2001 11:34:06";
3476
				algorithm hmac sha512;
3477
			};
3478
		};
3479
		interface "arc0" {
3480
			cost 10;
3481
			stub yes;
3482
		};
3483
		interface "arc1";
3484
	};
3485
	area 120 {
3486
		stub yes;
3487
		networks {
3488
			172.16.1.0/24;
3489
			172.16.2.0/24 hidden;
3490
		}
3491
		interface "-arc0" , "arc*" {
3492
			type nonbroadcast;
3493
			authentication none;
3494
			strict nonbroadcast yes;
3495
			wait 120;
3496
			poll 40;
3497
			dead count 8;
3498
			neighbors {
3499
				192.168.120.1 eligible;
3500
				192.168.120.2;
3501
				192.168.120.10;
3502
			};
3503
		};
3504
	};
3505
}
3506
</code>
3507

    
3508

    
3509
<sect>Pipe
3510
<label id="pipe">
3511

    
3512
<sect1>Introduction
3513
<label id="pipe-intro">
3514

    
3515
<p>The Pipe protocol serves as a link between two routing tables, allowing
3516
routes to be passed from a table declared as primary (i.e., the one the pipe is
3517
connected to using the <cf/table/ configuration keyword) to the secondary one
3518
(declared using <cf/peer table/) and vice versa, depending on what's allowed by
3519
the filters. Export filters control export of routes from the primary table to
3520
the secondary one, import filters control the opposite direction. Both tables
3521
must be of the same nettype.
3522

    
3523
<p>The Pipe protocol may work in the transparent mode mode or in the opaque
3524
mode. In the transparent mode, the Pipe protocol retransmits all routes from
3525
one table to the other table, retaining their original source and attributes.
3526
If import and export filters are set to accept, then both tables would have
3527
the same content. The transparent mode is the default mode.
3528

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

    
3536
<p>The primary use of multiple routing tables and the Pipe protocol is for
3537
policy routing, where handling of a single packet doesn't depend only on its
3538
destination address, but also on its source address, source interface, protocol
3539
type and other similar parameters. In many systems (Linux being a good example),
3540
the kernel allows to enforce routing policies by defining routing rules which
3541
choose one of several routing tables to be used for a packet according to its
3542
parameters. Setting of these rules is outside the scope of BIRD's work (on
3543
Linux, you can use the <tt/ip/ command), but you can create several routing
3544
tables in BIRD, connect them to the kernel ones, use filters to control which
3545
routes appear in which tables and also you can employ the Pipe protocol for
3546
exporting a selected subset of one table to another one.
3547

    
3548
<sect1>Configuration
3549
<label id="pipe-config">
3550

    
3551
<p>Essentially, the Pipe protocol is just a channel connected to a table on both
3552
sides. Therefore, the configuration block for <cf/protocol pipe/ shall directly
3553
include standard channel config options; see the example below.
3554

    
3555
<p><descrip>
3556
	<tag><label id="pipe-peer-table">peer table <m/table/</tag>
3557
	Defines secondary routing table to connect to. The primary one is
3558
	selected by the <cf/table/ keyword.
3559
</descrip>
3560

    
3561
<sect1>Attributes
3562
<label id="pipe-attr">
3563

    
3564
<p>The Pipe protocol doesn't define any route attributes.
3565

    
3566
<sect1>Example
3567
<label id="pipe-exam">
3568

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

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

    
3584
<code>
3585
ipv4 table as1;				# Define the tables
3586
ipv4 table as2;
3587

    
3588
protocol kernel kern1 {			# Synchronize them with the kernel
3589
	ipv4 { table as1; export all; };
3590
	kernel table 1;
3591
}
3592

    
3593
protocol kernel kern2 {
3594
	ipv4 { table as2; export all; };
3595
	kernel table 2;
3596
}
3597

    
3598
protocol bgp bgp1 {			# The outside connections
3599
	ipv4 { table as1; export all; };
3600
	local as 1;
3601
	neighbor 192.168.0.1 as 1001;
3602
}
3603

    
3604
protocol bgp bgp2 {
3605
	ipv4 { table as2; export all; };
3606
	local as 2;
3607
	neighbor 10.0.0.1 as 1002;
3608
}
3609

    
3610
protocol pipe {				# The Pipe
3611
	table as1;
3612
	peer table as2;
3613
	export filter {
3614
		if net ~ [ 1.0.0.0/8+] then {	# Only AS1 networks
3615
			if preference>10 then preference = preference-10;
3616
			if source=RTS_BGP then bgp_path.prepend(1);
3617
			accept;
3618
		}
3619
		reject;
3620
	};
3621
	import filter {
3622
		if net ~ [ 2.0.0.0/8+] then {	# Only AS2 networks
3623
			if preference>10 then preference = preference-10;
3624
			if source=RTS_BGP then bgp_path.prepend(2);
3625
			accept;
3626
		}
3627
		reject;
3628
	};
3629
}
3630
</code>
3631

    
3632

    
3633
<sect>RAdv
3634
<label id="radv">
3635

    
3636
<sect1>Introduction
3637
<label id="radv-intro">
3638

    
3639
<p>The RAdv protocol is an implementation of Router Advertisements, which are
3640
used in the IPv6 stateless autoconfiguration. IPv6 routers send (in irregular
3641
time intervals or as an answer to a request) advertisement packets to connected
3642
networks. These packets contain basic information about a local network (e.g. a
3643
list of network prefixes), which allows network hosts to autoconfigure network
3644
addresses and choose a default route. BIRD implements router behavior as defined
3645
in <rfc id="4861">, router preferences and specific routes (<rfc id="4191">),
3646
and DNS extensions (<rfc id="6106">).
3647

    
3648
<p>The RAdv protocols supports just IPv6 channel.
3649

    
3650
<sect1>Configuration
3651
<label id="radv-config">
3652

    
3653
<p>There are several classes of definitions in RAdv configuration -- interface
3654
definitions, prefix definitions and DNS definitions:
3655

    
3656
<descrip>
3657
	<tag><label id="radv-iface">interface <m/pattern/ [, <m/.../] { <m/options/ }</tag>
3658
	Interface definitions specify a set of interfaces on which the
3659
	protocol is activated and contain interface specific options.
3660
	See <ref id="proto-iface" name="interface"> common options for
3661
	detailed description.
3662

    
3663
	<tag><label id="radv-prefix">prefix <m/prefix/ { <m/options/ }</tag>
3664
	Prefix definitions allow to modify a list of advertised prefixes. By
3665
	default, the advertised prefixes are the same as the network prefixes
3666
	assigned to the interface. For each network prefix, the matching prefix
3667
	definition is found and its options are used. If no matching prefix
3668
	definition is found, the prefix is used with default options.
3669

    
3670
	Prefix definitions can be either global or interface-specific. The
3671
	second ones are part of interface options. The prefix definition
3672
	matching is done in the first-match style, when interface-specific
3673
	definitions are processed before global definitions. As expected, the
3674
	prefix definition is matching if the network prefix is a subnet of the
3675
	prefix in prefix definition.
3676

    
3677
	<tag><label id="radv-rdnss">rdnss { <m/options/ }</tag>
3678
	RDNSS definitions allow to specify a list of advertised recursive DNS
3679
	servers together with their options. As options are seldom necessary,
3680
	there is also a short variant <cf>rdnss <m/address/</cf> that just
3681
	specifies one DNS server. Multiple definitions are cumulative. RDNSS
3682
	definitions may also be interface-specific when used inside interface
3683
	options. By default, interface uses both global and interface-specific
3684
	options, but that can be changed by <cf/rdnss local/ option.
3685

    
3686
	<tag><label id="radv-dnssl">dnssl { <m/options/ }</tag>
3687
	DNSSL definitions allow to specify a list of advertised DNS search
3688
	domains together with their options. Like <cf/rdnss/ above, multiple
3689
	definitions are cumulative, they can be used also as interface-specific
3690
	options and there is a short variant <cf>dnssl <m/domain/</cf> that just
3691
	specifies one DNS search domain.
3692

    
3693
	<tag><label id="radv-trigger">trigger <m/prefix/</tag>
3694
	RAdv protocol could be configured to change its behavior based on
3695
	availability of routes. When this option is used, the protocol waits in
3696
	suppressed state until a <it/trigger route/ (for the specified network)
3697
	is exported to the protocol, the protocol also returnsd to suppressed
3698
	state if the <it/trigger route/ disappears. Note that route export
3699
	depends on specified export filter, as usual. This option could be used,
3700
	e.g., for handling failover in multihoming scenarios.
3701

    
3702
	During suppressed state, router advertisements are generated, but with
3703
	some fields zeroed. Exact behavior depends on which fields are zeroed,
3704
	this can be configured by <cf/sensitive/ option for appropriate
3705
	fields. By default, just <cf/default lifetime/ (also called <cf/router
3706
	lifetime/) is zeroed, which means hosts cannot use the router as a
3707
	default router. <cf/preferred lifetime/ and <cf/valid lifetime/ could
3708
	also be configured as <cf/sensitive/ for a prefix, which would cause
3709
	autoconfigured IPs to be deprecated or even removed.
3710

    
3711
	<tag><label id="radv-propagate-routes">propagate routes <m/switch/</tag>
3712
	This option controls propagation of more specific routes, as defined in
3713
	<rfc id="4191">. If enabled, all routes exported to the RAdv protocol,
3714
	with the exception of the trigger prefix, are added to advertisments as
3715
	additional options. The lifetime and preference of advertised routes can
3716
	be set individually by <cf/ra_lifetime/ and <cf/ra_preference/ route
3717
	attributes, or per interface by <cf/route lifetime/ and
3718
	<cf/route preference/ options. Default: disabled.
3719

    
3720
	Note that the RFC discourages from sending more than 17 routes and
3721
	recommends the routes to be configured manually.
3722
</descrip>
3723

    
3724
<p>Interface specific options:
3725

    
3726
<descrip>
3727
	<tag><label id="radv-iface-max-ra-interval">max ra interval <m/expr/</tag>
3728
	Unsolicited router advertisements are sent in irregular time intervals.
3729
	This option specifies the maximum length of these intervals, in seconds.
3730
	Valid values are 4-1800. Default: 600
3731

    
3732
	<tag><label id="radv-iface-min-ra-interval">min ra interval <m/expr/</tag>
3733
	This option specifies the minimum length of that intervals, in seconds.
3734
	Must be at least 3 and at most 3/4 * <cf/max ra interval/. Default:
3735
	about 1/3 * <cf/max ra interval/.
3736

    
3737
	<tag><label id="radv-iface-min-delay">min delay <m/expr/</tag>
3738
	The minimum delay between two consecutive router advertisements, in
3739
	seconds. Default: 3
3740

    
3741
	<tag><label id="radv-iface-managed">managed <m/switch/</tag>
3742
	This option specifies whether hosts should use DHCPv6 for IP address
3743
	configuration. Default: no
3744

    
3745
	<tag><label id="radv-iface-other-config">other config <m/switch/</tag>
3746
	This option specifies whether hosts should use DHCPv6 to receive other
3747
	configuration information. Default: no
3748

    
3749
	<tag><label id="radv-iface-link-mtu">link mtu <m/expr/</tag>
3750
	This option specifies which value of MTU should be used by hosts. 0
3751
	means unspecified. Default: 0
3752

    
3753
	<tag><label id="radv-iface-reachable-time">reachable time <m/expr/</tag>
3754
	This option specifies the time (in milliseconds) how long hosts should
3755
	assume a neighbor is reachable (from the last confirmation). Maximum is
3756
	3600000, 0 means unspecified. Default 0.
3757

    
3758
	<tag><label id="radv-iface-retrans-timer">retrans timer <m/expr/</tag>
3759
	This option specifies the time (in milliseconds) how long hosts should
3760
	wait before retransmitting Neighbor Solicitation messages. 0 means
3761
	unspecified. Default 0.
3762

    
3763
	<tag><label id="radv-iface-current-hop-limit">current hop limit <m/expr/</tag>
3764
	This option specifies which value of Hop Limit should be used by
3765
	hosts. Valid values are 0-255, 0 means unspecified. Default: 64
3766

    
3767
	<tag><label id="radv-iface-default-lifetime">default lifetime <m/expr/ [sensitive <m/switch/]</tag>
3768
	This option specifies the time (in seconds) how long (since the receipt
3769
	of RA) hosts may use the router as a default router. 0 means do not use
3770
	as a default router. For <cf/sensitive/ option, see <ref id="radv-trigger" name="trigger">.
3771
	Default: 3 * <cf/max ra	interval/, <cf/sensitive/ yes.
3772

    
3773
	<tag><label id="radv-iface-default-preference">default preference low|medium|high</tag>
3774
	This option specifies the Default Router Preference value to advertise
3775
	to hosts. Default: medium.
3776

    
3777
	<tag><label id="radv-iface-route-lifetime">route lifetime <m/expr/ [sensitive <m/switch/]</tag>
3778
	This option specifies the default value of advertised lifetime for
3779
	specific routes; i.e., the time (in seconds) for how long (since the
3780
	receipt of RA) hosts should consider these routes valid. A special value
3781
	0xffffffff represents infinity. The lifetime can be overriden on a per
3782
	route basis by the <ref id="rta-ra-lifetime" name="ra_lifetime"> route
3783
	attribute. Default: 3 * <cf/max ra interval/, <cf/sensitive/ no.
3784

    
3785
	For the <cf/sensitive/ option, see <ref id="radv-trigger" name="trigger">.
3786
	If <cf/sensitive/ is enabled, even the routes with the <cf/ra_lifetime/
3787
	attribute become sensitive to the trigger.
3788

    
3789
	<tag><label id="radv-iface-route-preference">route preference low|medium|high</tag>
3790
	This option specifies the default value of advertised route preference
3791
	for specific routes. The value can be overriden on a per route basis by
3792
	the <ref id="rta-ra-preference" name="ra_preference"> route attribute.
3793
	Default: medium.
3794

    
3795
	<tag><label id="radv-prefix-linger-time">prefix linger time <m/expr/</tag>
3796
	When a prefix or a route disappears, it is advertised for some time with
3797
	zero lifetime, to inform clients it is no longer valid. This option
3798
	specifies the time (in seconds) for how long prefixes are advertised
3799
	that way. Default: 3 * <cf/max ra interval/.
3800

    
3801
	<tag><label id="radv-route-linger-time">route linger time <m/expr/</tag>
3802
	When a prefix or a route disappears, it is advertised for some time with
3803
	zero lifetime, to inform clients it is no longer valid. This option
3804
	specifies the time (in seconds) for how long routes are advertised
3805
	that way. Default: 3 * <cf/max ra interval/.
3806

    
3807
	<tag><label id="radv-iface-rdnss-local">rdnss local <m/switch/</tag>
3808
	Use only local (interface-specific) RDNSS definitions for this
3809
	interface. Otherwise, both global and local definitions are used. Could
3810
	also be used to disable RDNSS for given interface if no local definitons
3811
	are specified. Default: no.
3812

    
3813
	<tag><label id="radv-iface-dnssl-local">dnssl local <m/switch/</tag>
3814
	Use only local DNSSL definitions for this interface. See <cf/rdnss local/
3815
	option above. Default: no.
3816
</descrip>
3817

    
3818
<p>Prefix specific options
3819

    
3820
<descrip>
3821
	<tag><label id="radv-prefix-skip">skip <m/switch/</tag>
3822
	This option allows to specify that given prefix should not be
3823
	advertised. This is useful for making exceptions from a default policy
3824
	of advertising all prefixes. Note that for withdrawing an already
3825
	advertised prefix it is more useful to advertise it with zero valid
3826
	lifetime. Default: no
3827

    
3828
	<tag><label id="radv-prefix-onlink">onlink <m/switch/</tag>
3829
	This option specifies whether hosts may use the advertised prefix for
3830
	onlink determination. Default: yes
3831

    
3832
	<tag><label id="radv-prefix-autonomous">autonomous <m/switch/</tag>
3833
	This option specifies whether hosts may use the advertised prefix for
3834
	stateless autoconfiguration. Default: yes
3835

    
3836
	<tag><label id="radv-prefix-valid-lifetime">valid lifetime <m/expr/ [sensitive <m/switch/]</tag>
3837
	This option specifies the time (in seconds) how long (after the
3838
	receipt of RA) the prefix information is valid, i.e., autoconfigured
3839
	IP addresses can be assigned and hosts with that IP addresses are
3840
	considered directly reachable. 0 means the prefix is no longer
3841
	valid. For <cf/sensitive/ option, see <ref id="radv-trigger" name="trigger">.
3842
	Default: 86400 (1 day), <cf/sensitive/ no.
3843

    
3844
	<tag><label id="radv-prefix-preferred-lifetime">preferred lifetime <m/expr/ [sensitive <m/switch/]</tag>
3845
	This option specifies the time (in seconds) how long (after the
3846
	receipt of RA) IP addresses generated from the prefix using stateless
3847
	autoconfiguration remain preferred. For <cf/sensitive/ option,
3848
	see <ref id="radv-trigger" name="trigger">. Default: 14400 (4 hours),
3849
	<cf/sensitive/ no.
3850
</descrip>
3851

    
3852
<p>RDNSS specific options:
3853

    
3854
<descrip>
3855
	<tag><label id="radv-rdnss-ns">ns <m/address/</tag>
3856
	This option specifies one recursive DNS server. Can be used multiple
3857
	times for multiple servers. It is mandatory to have at least one
3858
	<cf/ns/ option in <cf/rdnss/ definition.
3859

    
3860
	<tag><label id="radv-rdnss-lifetime">lifetime [mult] <m/expr/</tag>
3861
	This option specifies the time how long the RDNSS information may be
3862
	used by clients after the receipt of RA. It is expressed either in
3863
	seconds or (when <cf/mult/ is used) in multiples of <cf/max ra
3864
	interval/. Note that RDNSS information is also invalidated when
3865
	<cf/default lifetime/ expires. 0 means these addresses are no longer
3866
	valid DNS servers. Default: 3 * <cf/max ra interval/.
3867
</descrip>
3868

    
3869
<p>DNSSL specific options:
3870

    
3871
<descrip>
3872
	<tag><label id="radv-dnssl-domain">domain <m/address/</tag>
3873
	This option specifies one DNS search domain. Can be used multiple times
3874
	for multiple domains. It is mandatory to have at least one <cf/domain/
3875
	option in <cf/dnssl/ definition.
3876

    
3877
	<tag><label id="radv-dnssl-lifetime">lifetime [mult] <m/expr/</tag>
3878
	This option specifies the time how long the DNSSL information may be
3879
	used by clients after the receipt of RA. Details are the same as for
3880
	RDNSS <cf/lifetime/ option above. Default: 3 * <cf/max ra interval/.
3881
</descrip>
3882

    
3883
<sect1>Attributes
3884
<label id="radv-attr">
3885

    
3886
<p>RAdv defines two route attributes:
3887

    
3888
<descrip>
3889
	<tag><label id="rta-ra-preference">enum ra_preference/</tag>
3890
	The preference of the route. The value can be <it/RA_PREF_LOW/,
3891
	<it/RA_PREF_MEDIUM/ or <it/RA_PREF_HIGH/. If the attribute is not set,
3892
	the <ref id="radv-iface-route-preference" name="route preference">
3893
	option is used.
3894

    
3895
	<tag><label id="rta-ra-lifetime">int ra_lifetime/</tag>
3896
	The advertised lifetime of the route, in seconds. The special value of
3897
	0xffffffff represents infinity. If the attribute is not set, the
3898
	<ref id="radv-iface-route-lifetime" name="route lifetime">
3899
	option is used.
3900
</descrip>
3901

    
3902
<sect1>Example
3903
<label id="radv-exam">
3904

    
3905
<p><code>
3906
ipv6 table radv_routes;			# Manually configured routes go here
3907

    
3908
protocol static {
3909
	ipv6 { table radv_routes; };
3910

    
3911
	route 2001:0DB8:4000::/48 unreachable;
3912
	route 2001:0DB8:4010::/48 unreachable;
3913

    
3914
	route 2001:0DB8:4020::/48 unreachable {
3915
		ra_preference = RA_PREF_HIGH;
3916
		ra_lifetime = 3600;
3917
	};
3918
}
3919

    
3920
protocol radv {
3921
	propagate routes yes;		# Propagate the routes from the radv_routes table
3922
	ipv6 { table radv_routes; export all; };
3923

    
3924
	interface "eth2" {
3925
		max ra interval 5;	# Fast failover with more routers
3926
		managed yes;		# Using DHCPv6 on eth2
3927
		prefix ::/0 {
3928
			autonomous off;	# So do not autoconfigure any IP
3929
		};
3930
	};
3931

    
3932
	interface "eth*";		# No need for any other options
3933

    
3934
	prefix 2001:0DB8:1234::/48 {
3935
		preferred lifetime 0;	# Deprecated address range
3936
	};
3937

    
3938
	prefix 2001:0DB8:2000::/48 {
3939
		autonomous off;		# Do not autoconfigure
3940
	};
3941

    
3942
	rdnss 2001:0DB8:1234::10;	# Short form of RDNSS
3943

    
3944
	rdnss {
3945
		lifetime mult 10;
3946
		ns 2001:0DB8:1234::11;
3947
		ns 2001:0DB8:1234::12;
3948
	};
3949

    
3950
	dnssl {
3951
		lifetime 3600;
3952
		domain "abc.com";
3953
		domain "xyz.com";
3954
	};
3955
}
3956
</code>
3957

    
3958

    
3959
<sect>RIP
3960
<label id="rip">
3961

    
3962
<sect1>Introduction
3963
<label id="rip-intro">
3964

    
3965
<p>The RIP protocol (also sometimes called Rest In Pieces) is a simple protocol,
3966
where each router broadcasts (to all its neighbors) distances to all networks it
3967
can reach. When a router hears distance to another network, it increments it and
3968
broadcasts it back. Broadcasts are done in regular intervals. Therefore, if some
3969
network goes unreachable, routers keep telling each other that its distance is
3970
the original distance plus 1 (actually, plus interface metric, which is usually
3971
one). After some time, the distance reaches infinity (that's 15 in RIP) and all
3972
routers know that network is unreachable. RIP tries to minimize situations where
3973
counting to infinity is necessary, because it is slow. Due to infinity being 16,
3974
you can't use RIP on networks where maximal distance is higher than 15
3975
hosts.
3976

    
3977
<p>BIRD supports RIPv1 (<rfc id="1058">), RIPv2 (<rfc id="2453">), RIPng (<rfc
3978
id="2080">), and RIP cryptographic authentication (<rfc id="4822">).
3979

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

    
3984
<sect1>Configuration
3985
<label id="rip-config">
3986

    
3987
<p>RIP configuration consists mainly of common protocol options and interface
3988
definitions, most RIP options are interface specific. RIPng (RIP for IPv6)
3989
protocol instance can be configured by using <cf/rip ng/ instead of just
3990
<cf/rip/ as a protocol type.
3991

    
3992
<p>RIP needs one IPv4 channel. RIPng needs one IPv6 channel. If no channel is
3993
configured, appropriate channel is defined with default parameters.
3994

    
3995
<code>
3996
protocol rip [ng] [&lt;name&gt;] {
3997
	infinity &lt;number&gt;;
3998
	ecmp &lt;switch&gt; [limit &lt;number&gt;];
3999
	interface &lt;interface pattern&gt; {
4000
		metric &lt;number&gt;;
4001
		mode multicast|broadcast;
4002
		passive &lt;switch&gt;;
4003
		address &lt;ip&gt;;
4004
		port &lt;number&gt;;
4005
		version 1|2;
4006
		split horizon &lt;switch&gt;;
4007
		poison reverse &lt;switch&gt;;
4008
		check zero &lt;switch&gt;;
4009
		update time &lt;number&gt;;
4010
		timeout time &lt;number&gt;;
4011
		garbage time &lt;number&gt;;
4012
		ecmp weight &lt;number&gt;;
4013
		ttl security &lt;switch&gt;; | tx only;
4014
		tx class|dscp &lt;number&gt;;
4015
		tx priority &lt;number&gt;;
4016
		rx buffer &lt;number&gt;;
4017
		tx length &lt;number&gt;;
4018
		check link &lt;switch&gt;;
4019
		authentication none|plaintext|cryptographic;
4020
		password "&lt;text&gt;";
4021
		password "&lt;text&gt;" {
4022
			id &lt;num&gt;;
4023
			generate from "&lt;date&gt;";
4024
			generate to "&lt;date&gt;";
4025
			accept from "&lt;date&gt;";
4026
			accept to "&lt;date&gt;";
4027
			from "&lt;date&gt;";
4028
			to "&lt;date&gt;";
4029
			algorithm ( keyed md5 | keyed sha1 | hmac sha1 | hmac sha256 | hmac sha384 | hmac sha512 );
4030
		};
4031
	};
4032
}
4033
</code>
4034

    
4035
<descrip>
4036
	<tag><label id="rip-infinity">infinity <M>number</M></tag>
4037
	Selects the distance of infinity. Bigger values will make
4038
	protocol convergence even slower. The default value is 16.
4039

    
4040
	<tag><label id="rip-ecmp">ecmp <M>switch</M> [limit <M>number</M>]</tag>
4041
	This option specifies whether RIP is allowed to generate ECMP
4042
	(equal-cost multipath) routes. Such routes are used when there are
4043
	several directions to the destination, each with the same (computed)
4044
	cost. This option also allows to specify a limit on maximum number of
4045
	nexthops in one route. By default, ECMP is enabled if supported by
4046
	Kernel. Default value of the limit is 16.
4047

    
4048
	<tag><label id="rip-iface">interface <m/pattern/ [, <m/.../] { <m/options/ }</tag>
4049
	Interface definitions specify a set of interfaces on which the
4050
	protocol is activated and contain interface specific options.
4051
	See <ref id="proto-iface" name="interface"> common options for
4052
	detailed description.
4053
</descrip>
4054

    
4055
<p>Interface specific options:
4056

    
4057
<descrip>
4058
	<tag><label id="rip-iface-metric">metric <m/num/</tag>
4059
	This option specifies the metric of the interface. When a route is
4060
	received from the interface, its metric is increased by this value
4061
	before further processing. Valid values are 1-255, but values higher
4062
	than infinity has no further meaning. Default: 1.
4063

    
4064
	<tag><label id="rip-iface-mode">mode multicast|broadcast</tag>
4065
	This option selects the mode for RIP to use on the interface. The
4066
	default is multicast mode for RIPv2 and broadcast mode for RIPv1.
4067
	RIPng always uses the multicast mode.
4068

    
4069
	<tag><label id="rip-iface-passive">passive <m/switch/</tag>
4070
	Passive interfaces receive routing updates but do not transmit any
4071
	messages. Default: no.
4072

    
4073
	<tag><label id="rip-iface-address">address <m/ip/</tag>
4074
	This option specifies a destination address used for multicast or
4075
	broadcast messages, the default is the official RIP (224.0.0.9) or RIPng
4076
	(ff02::9) multicast address, or an appropriate broadcast address in the
4077
	broadcast mode.
4078

    
4079
	<tag><label id="rip-iface-port">port <m/number/</tag>
4080
	This option selects an UDP port to operate on, the default is the
4081
	official RIP (520) or RIPng (521) port.
4082

    
4083
	<tag><label id="rip-iface-version">version 1|2</tag>
4084
	This option selects the version of RIP used on the interface. For RIPv1,
4085
	automatic subnet aggregation is not implemented, only classful network
4086
	routes and host routes are propagated. Note that BIRD allows RIPv1 to be
4087
	configured with features that are defined for RIPv2 only, like
4088
	authentication or using multicast sockets. The default is RIPv2 for IPv4
4089
	RIP, the option is not supported for RIPng, as no further versions are
4090
	defined.
4091

    
4092
	<tag><label id="rip-iface-version-only">version only <m/switch/</tag>
4093
	Regardless of RIP version configured for the interface, BIRD accepts
4094
	incoming packets of any RIP version. This option restrict accepted
4095
	packets to the configured version. Default: no.
4096

    
4097
	<tag><label id="rip-iface-split-horizon">split horizon <m/switch/</tag>
4098
	Split horizon is a scheme for preventing routing loops. When split
4099
	horizon is active, routes are not regularly propagated back to the
4100
	interface from which they were received. They are either not propagated
4101
	back at all (plain split horizon) or propagated back with an infinity
4102
	metric (split horizon with poisoned reverse). Therefore, other routers
4103
	on the interface will not consider the router as a part of an
4104
	independent path to the destination of the route. Default: yes.
4105

    
4106
	<tag><label id="rip-iface-poison-reverse">poison reverse <m/switch/</tag>
4107
	When split horizon is active, this option specifies whether the poisoned
4108
	reverse variant (propagating routes back with an infinity metric) is
4109
	used. The poisoned reverse has some advantages in faster convergence,
4110
	but uses more network traffic. Default: yes.
4111

    
4112
	<tag><label id="rip-iface-check-zero">check zero <m/switch/</tag>
4113
	Received RIPv1 packets with non-zero values in reserved fields should
4114
	be discarded. This option specifies whether the check is performed or
4115
	such packets are just processed as usual. Default: yes.
4116

    
4117
	<tag><label id="rip-iface-update-time">update time <m/number/</tag>
4118
	Specifies the number of seconds between periodic updates. A lower number
4119
	will mean faster convergence but bigger network load. Default: 30.
4120

    
4121
	<tag><label id="rip-iface-timeout-time">timeout time <m/number/</tag>
4122
	Specifies the time interval (in seconds) between the last received route
4123
	announcement and the route expiration. After that, the network is
4124
	considered unreachable, but still is propagated with infinity distance.
4125
	Default: 180.
4126

    
4127
	<tag><label id="rip-iface-garbage-time">garbage time <m/number/</tag>
4128
	Specifies the time interval (in seconds) between the route expiration
4129
	and the removal of the unreachable network entry. The garbage interval,
4130
	when a route with infinity metric is propagated, is used for both
4131
	internal (after expiration) and external (after withdrawal) routes.
4132
	Default: 120.
4133

    
4134
	<tag><label id="rip-iface-ecmp-weight">ecmp weight <m/number/</tag>
4135
	When ECMP (multipath) routes are allowed, this value specifies a
4136
	relative weight used for nexthops going through the iface. Valid
4137
	values are 1-256. Default value is 1.
4138

    
4139
	<tag><label id="rip-iface-auth">authentication none|plaintext|cryptographic</tag>
4140
	Selects authentication method to be used. <cf/none/ means that packets
4141
	are not authenticated at all, <cf/plaintext/ means that a plaintext
4142
	password is embedded into each packet, and <cf/cryptographic/ means that
4143
	packets are authenticated using some cryptographic hash function
4144
	selected by option <cf/algorithm/ for each key. The default
4145
	cryptographic algorithm for RIP keys is Keyed-MD5. If you set
4146
	authentication to not-none, it is a good idea to add <cf>password</cf>
4147
	section. Default: none.
4148

    
4149
	<tag><label id="rip-iface-pass">password "<m/text/"</tag>
4150
	Specifies a password used for authentication. See <ref id="proto-pass"
4151
	name="password"> common option for detailed description.
4152

    
4153
	<tag><label id="rip-iface-ttl-security">ttl security [<m/switch/ | tx only]</tag>
4154
	TTL security is a feature that protects routing protocols from remote
4155
	spoofed packets by using TTL 255 instead of TTL 1 for protocol packets
4156
	destined to neighbors. Because TTL is decremented when packets are
4157
	forwarded, it is non-trivial to spoof packets with TTL 255 from remote
4158
	locations.
4159

    
4160
	If this option is enabled, the router will send RIP packets with TTL 255
4161
	and drop received packets with TTL less than 255. If this option si set
4162
	to <cf/tx only/, TTL 255 is used for sent packets, but is not checked
4163
	for received packets. Such setting does not offer protection, but offers
4164
	compatibility with neighbors regardless of whether they use ttl
4165
	security.
4166

    
4167
	For RIPng, TTL security is a standard behavior (required by <rfc
4168
	id="2080">) and therefore default value is yes. For IPv4 RIP, default
4169
	value is no.
4170

    
4171
	<tag><label id="rip-iface-tx-class">tx class|dscp|priority <m/number/</tag>
4172
	These options specify the ToS/DiffServ/Traffic class/Priority of the
4173
	outgoing RIP packets. See <ref id="proto-tx-class" name="tx class"> common
4174
	option for detailed description.
4175

    
4176
	<tag><label id="rip-iface-rx-buffer">rx buffer <m/number/</tag>
4177
	This option specifies the size of buffers used for packet processing.
4178
	The buffer size should be bigger than maximal size of received packets.
4179
	The default value is 532 for IPv4 RIP and interface MTU value for RIPng.
4180

    
4181
	<tag><label id="rip-iface-tx-length">tx length <m/number/</tag>
4182
	This option specifies the maximum length of generated RIP packets. To
4183
	avoid IP fragmentation, it should not exceed the interface MTU value.
4184
	The default value is 532 for IPv4 RIP and interface MTU value for RIPng.
4185

    
4186
	<tag><label id="rip-iface-check-link">check link <m/switch/</tag>
4187
	If set, the hardware link state (as reported by OS) is taken into
4188
	consideration. When the link disappears (e.g. an ethernet cable is
4189
	unplugged), neighbors are immediately considered unreachable and all
4190
	routes received from them are withdrawn. It is possible that some
4191
	hardware drivers or platforms do not implement this feature.
4192
	Default: yes.
4193
</descrip>
4194

    
4195
<sect1>Attributes
4196
<label id="rip-attr">
4197

    
4198
<p>RIP defines two route attributes:
4199

    
4200
<descrip>
4201
	<tag>int <cf/rip_metric/</tag>
4202
	RIP metric of the route (ranging from 0 to <cf/infinity/). When routes
4203
	from different RIP instances are available and all of them have the same
4204
	preference, BIRD prefers the route with lowest <cf/rip_metric/. When a
4205
	non-RIP route is exported to RIP, the default metric is 1.
4206

    
4207
	<tag><label id="rta-rip-tag">int rip_tag/</tag>
4208
	RIP route tag: a 16-bit number which can be used to carry additional
4209
	information with the route (for example, an originating AS number in
4210
	case of external routes). When a non-RIP route is exported to RIP, the
4211
	default tag is 0.
4212
</descrip>
4213

    
4214
<sect1>Example
4215
<label id="rip-exam">
4216

    
4217
<p><code>
4218
protocol rip {
4219
	ipv4 {
4220
		import all;
4221
		export all;
4222
	};
4223
	interface "eth*" {
4224
		metric 2;
4225
		port 1520;
4226
		mode multicast;
4227
		update time 12;
4228
		timeout time 60;
4229
		authentication cryptographic;
4230
		password "secret" { algorithm hmac sha256; };
4231
	};
4232
}
4233
</code>
4234

    
4235

    
4236
<sect>RPKI
4237

    
4238
<sect1>Introduction
4239

    
4240
<p>The Resource Public Key Infrastructure (RPKI) is mechanism for origin
4241
validation of BGP routes (RFC 6480). BIRD supports only so-called RPKI-based
4242
origin validation. There is implemented RPKI to Router (RPKI-RTR) protocol (RFC
4243
6810). It uses some of the RPKI data to allow a router to verify that the
4244
autonomous system announcing an IP address prefix is in fact authorized to do
4245
so. This is not crypto checked so can be violated. But it should prevent the
4246
vast majority of accidental hijackings on the Internet today, e.g. the famous
4247
Pakastani accidental announcement of YouTube's address space.
4248

    
4249
<p>The RPKI-RTR protocol receives and maintains a set of ROAs from a cache
4250
server (also called validator). You can validate routes (RFC 6483) using
4251
function <cf/roa_check()/ in filter and set it as import filter at the BGP
4252
protocol. BIRD should re-validate all of affected routes after RPKI update by
4253
RFC 6811, but we don't support it yet! You can use a BIRD's client command
4254
<cf>reload in <m/bgp_protocol_name/</cf> for manual call of revalidation of all
4255
routes.
4256

    
4257
<sect1>Supported transports
4258
<itemize>
4259
        <item>Unprotected transport over TCP uses a port 323. The cache server
4260
        and BIRD router should be on the same trusted and controlled network
4261
        for security reasons.
4262
        <item>SSHv2 encrypted transport connection uses the normal SSH port
4263
        22.
4264
</itemize>
4265

    
4266
<sect1>Configuration
4267

    
4268
<p>We currently support just one cache server per protocol. However you can
4269
define more RPKI protocols generally.
4270

    
4271
<code>
4272
protocol rpki [&lt;name&gt;] {
4273
        roa4 { table &lt;tab&gt;; };
4274
        roa6 { table &lt;tab&gt;; };
4275
        remote &lt;ip&gt; | "&lt;domain&gt;" [port &lt;num&gt;];
4276
        port &lt;num&gt;;
4277
        refresh [keep] &lt;num&gt;;
4278
        retry [keep] &lt;num&gt;;
4279
        expire [keep] &lt;num&gt;;
4280
        transport tcp;
4281
        transport ssh {
4282
                bird private key "&lt;/path/to/id_rsa&gt;";
4283
                remote public key "&lt;/path/to/known_host&gt;";
4284
                user "&lt;name&gt;";
4285
        };
4286
}
4287
</code>
4288

    
4289
<p>Alse note that you have to specify the ROA channel. If you want to import
4290
only IPv4 prefixes you have to specify only roa4 channel. Similarly with IPv6
4291
prefixes only. If you want to fetch both IPv4 and even IPv6 ROAs you have to
4292
specify both channels.
4293

    
4294
<sect2>RPKI protocol options
4295

    
4296
<descrip>
4297
        <tag>remote <m/ip/ | "<m/hostname/" [port <m/num/]</tag> Specifies
4298
        a destination address of the cache server.  Can be specified by an IP
4299
        address or by full domain name string.  Only one cache can be specified
4300
        per protocol. This option is required.
4301

    
4302
        <tag>port <m/num/</tag> Specifies the port number. The default port
4303
        number is 323 for transport without any encryption and 22 for transport
4304
        with SSH encryption.
4305

    
4306
        <tag>refresh [keep] <m/num/</tag> Time period in seconds. Tells how
4307
        long to wait before next attempting to poll the cache using a Serial
4308
        Query or a Reset Query packet. Must be lower than 86400 seconds (one
4309
        day). Too low value can caused a false positive detection of
4310
        network connection problems.  A keyword <cf/keep/ suppresses updating
4311
        this value by a cache server.
4312
        Default: 3600 seconds
4313

    
4314
        <tag>retry [keep] <m/num/</tag> Time period in seconds between a failed
4315
        Serial/Reset Query and a next attempt.  Maximum allowed value is 7200
4316
        seconds (two hours). Too low value can caused a false positive
4317
        detection of network connection problems.  A keyword <cf/keep/
4318
        suppresses updating this value by a cache server.
4319
        Default: 600 seconds
4320

    
4321
        <tag>expire [keep] <m/num/</tag> Time period in seconds. Received
4322
        records are deleted if the client was unable to successfully refresh
4323
        data for this time period.  Must be in range from 600 seconds (ten
4324
        minutes) to 172800 seconds (two days).  A keyword <cf/keep/
4325
        suppresses updating this value by a cache server.
4326
        Default: 7200 seconds
4327

    
4328
        <tag>transport tcp</tag> Unprotected transport over TCP. It's a default
4329
        transport. Should be used only on secure private networks.
4330
        Default: tcp
4331

    
4332
        <tag>transport ssh { <m/SSH transport options.../ }</tag> It enables a
4333
        SSHv2 transport encryption. Cannot be combined with a TCP transport.
4334
        Default: off
4335
</descrip>
4336

    
4337
<sect3>SSH transport options
4338
<descrip>
4339
	<tag>bird private key "<m>/path/to/id_rsa</m>"</tag>
4340
	A path to the BIRD's private SSH key for authentication.
4341
	It can be a <cf><m>id_rsa</m></cf> file.
4342

    
4343
	<tag>remote public key "<m>/path/to/known_host</m>"</tag>
4344
	A path to the cache's public SSH key for verification identity
4345
	of the cache server. It could be a path to <cf><m>known_host</m></cf> file.
4346

    
4347
	<tag>user "<m/name/"</tag>
4348
	A SSH user name for authentication. This option is a required.
4349
</descrip>
4350

    
4351
<sect1>Examples
4352
<sect2>BGP origin validation
4353
<p>Policy: Don't import <cf/ROA_INVALID/ routes.
4354
<code>
4355
roa4 table r4;
4356
roa6 table r6;
4357

    
4358
protocol rpki {
4359
	debug all;
4360

    
4361
	roa4 { table r4; };
4362
	roa6 { table r6; };
4363

    
4364
	# Please, do not use rpki-validator.realmv6.org in production
4365
	remote "rpki-validator.realmv6.org" port 8282;
4366

    
4367
	retry keep 5;
4368
	refresh keep 30;
4369
	expire 600;
4370
}
4371

    
4372
filter peer_in_v4 {
4373
	if (roa_check(r4, net, bgp_path.last) = ROA_INVALID) then
4374
	{
4375
		print "Ignore invalid ROA ", net, " for ASN ", bgp_path.last;
4376
		reject;
4377
	}
4378
	accept;
4379
}
4380

    
4381
protocol bgp {
4382
	debug all;
4383
	local as 65000;
4384
	neighbor 192.168.2.1 as 65001;
4385
	ipv4 { import filter peer_in_v4; };
4386
}
4387
</code>
4388

    
4389
<sect2>SSHv2 transport encryption
4390
<code>
4391
roa4 table r4;
4392
roa6 table r6;
4393

    
4394
protocol rpki {
4395
	debug all;
4396

    
4397
	roa4 { table r4; };
4398
	roa6 { table r6; };
4399

    
4400
	remote 127.0.0.1 port 2345;
4401
	transport ssh {
4402
		bird private key "/home/birdgeek/.ssh/id_rsa";
4403
		remote public key "/home/birdgeek/.ssh/known_hosts";
4404
		user "birdgeek";
4405
	};
4406

    
4407
	# Default interval values
4408
}
4409
</code>
4410

    
4411

    
4412
<sect>Static
4413
<label id="static">
4414

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

    
4423
<p>There are three classes of definitions in Static protocol configuration --
4424
global options, static route definitions, and per-route options. Usually, the
4425
definition of the protocol contains mainly a list of static routes.
4426
Static routes have no specific attributes.
4427

    
4428
<p>Global options:
4429

    
4430
<descrip>
4431
	<tag><label id="static-check-link">check link <m/switch/</tag>
4432
	If set, hardware link states of network interfaces are taken into
4433
	consideration.  When link disappears (e.g. ethernet cable is unplugged),
4434
	static routes directing to that interface are removed. It is possible
4435
	that some hardware drivers or platforms do not implement this feature.
4436
	Default: off.
4437

    
4438
	<tag><label id="static-igp-table">igp table <m/name/</tag>
4439
	Specifies a table that is used for route table lookups of recursive
4440
	routes. Default: the same table as the protocol is connected to.
4441
</descrip>
4442

    
4443
<p>Route definitions (each may also contain a block of per-route options):
4444

    
4445
<sect1>Regular routes; MPLS switching rules</sect1>
4446

    
4447
There exist several types of routes; keep in mind that <m/prefix/ syntax is
4448
<ref id="type-prefix" name="dependent on network type">.
4449

    
4450
<descrip>
4451
	<tag>route <m/prefix/ via <m/ip/|<m/"interface"/ [mpls <m/num/[/<m/num/[/<m/num/[...]]]]</tag>
4452
	Next hop routes may bear one or more <ref id="route-next-hop" name="next hops">.
4453
	Every next hop is preceded by <cf/via/ and configured as shown.
4454

    
4455
	<tag>route <m/prefix/ recursive <m/ip/ [mpls <m/num/[/<m/num/[/<m/num/[...]]]]</tag>
4456
	Recursive nexthop resolves the given IP in the configured IGP table and
4457
	uses that route's next hop. The MPLS stacks are concatenated; on top is
4458
	the IGP's nexthop stack and on bottom is this route's stack.
4459

    
4460
	<tag>route <m/prefix/ blackhole|unreachable|prohibit</tag>
4461
	Special routes specifying to silently drop the packet, return it as
4462
	unreachable or return it as administratively prohibited. First two
4463
	targets are also known as <cf/drop/ and <cf/reject/.
4464
</descrip>
4465

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

    
4471
<sect1>Route Origin Authorization
4472

    
4473
<p>The ROA config is just <cf>route <m/prefix/ max <m/int/ as <m/int/</cf> with no nexthop.
4474

    
4475
<sect1>Flowspec
4476
<label id="flowspec-network-type">
4477

    
4478
<p>The flow specification are rules for routers and firewalls for filtering
4479
purpose. It is described by <rfc id="5575">. There are 3 types of arguments:
4480
<m/inet4/ or <m/inet6/ prefixes, bitmasks matching expressions and numbers
4481
matching expressions.
4482

    
4483
Bitmasks matching is written using <m/value/<cf>/</cf><m/mask/ or
4484
<cf/!/<m/value/<cf>/</cf><m/mask/ pairs. It means that <cf/(/<m/data/ <cf/&/
4485
<m/mask/<cf/)/ is or is not equal to <m/value/.
4486

    
4487
Numbers matching is a matching sequence of numbers and ranges separeted by a
4488
commas (<cf/,/) (e.g. <cf/10,20,30/). Ranges can be written using double dots
4489
<cf/../ notation (e.g. <cf/80..90,120..124/). An alternative notation are
4490
sequence of one or more pairs of relational operators and values separated by
4491
logical operators <cf/&&/ or <cf/||/. Allowed relational operators are <cf/=/,
4492
<cf/!=/, <cf/</, <cf/<=/, <cf/>/, <cf/>=/, <cf/true/ and <cf/false/.
4493

    
4494
<sect2>IPv4 Flowspec
4495

    
4496
<p><descrip>
4497
	<tag><label id="flow-dst">dst <m/inet4/</tag>
4498
	Set a matching destination prefix (e.g. <cf>dst 192.168.0.0/16</cf>).
4499
	Only this option is mandatory in IPv4 Flowspec.
4500

    
4501
	<tag><label id="flow-src">src <m/inet4/</tag>
4502
	Set a matching source prefix (e.g. <cf>src 10.0.0.0/8</cf>).
4503

    
4504
	<tag><label id="flow-proto">proto <m/numbers-match/</tag>
4505
	Set a matching IP protocol numbers (e.g.  <cf/proto 6/).
4506

    
4507
	<tag><label id="flow-port">port <m/numbers-match/</tag>
4508
	Set a matching source or destination TCP/UDP port numbers (e.g.
4509
	<cf>port 1..1023,1194,3306</cf>).
4510

    
4511
	<tag><label id="flow-dport">dport <m/numbers-match/</tag>
4512
	Set a mating destination port numbers (e.g. <cf>dport 49151</cf>).
4513

    
4514
	<tag><label id="flow-sport">sport <m/numbers-match/</tag>
4515
	Set a matching source port numbers (e.g. <cf>sport = 0</cf>).
4516

    
4517
	<tag><label id="flow-icmp-type">icmp type <m/numbers-match/</tag>
4518
	Set a matching type field number of an ICMP packet (e.g. <cf>icmp type
4519
	3</cf>)
4520

    
4521
	<tag><label id="flow-icmp-code">icmp code <m/numbers-match/</tag>
4522
	Set a matching code field number of an ICMP packet (e.g. <cf>icmp code
4523
	1</cf>)
4524

    
4525
	<tag><label id="flow-tcp-flags">tcp flags <m/bitmask-match/</tag>
4526
	Set a matching bitmask for TCP header flags (aka control bits) (e.g.
4527
	<cf>tcp flags 0x03/0x0f;</cf>). The maximum length of mask is 12 bits
4528
	(0xfff).
4529

    
4530
	<tag><label id="flow-length">length <m/numbers-match/</tag>
4531
	Set a matching packet length (e.g. <cf>length > 1500;</cf>)
4532

    
4533
	<tag><label id="flow-dscp">dscp <m/numbers-match/</tag>
4534
	Set a matching DiffServ Code Point number (e.g. <cf>length > 1500;</cf>).
4535

    
4536
	<tag><label id="flow-fragment">fragment <m/fragmentation-type/</tag>
4537
	Set a matching type of packet fragmentation. Allowed fragmentation
4538
	types are <cf/dont_fragment/, <cf/is_fragment/, <cf/first_fragment/,
4539
	<cf/last_fragment/ (e.g. <cf>fragment is_fragment &&
4540
	!dont_fragment</cf>).
4541
</descrip>
4542

    
4543
<p><code>
4544
protocol static {
4545
	flow4;
4546

    
4547
	route flow4 {
4548
		dst 10.0.0.0/8;
4549
		port > 24 && < 30 || 40..50,60..70,80 && >= 90;
4550
		tcp flags 0x03/0x0f;
4551
		length > 1024;
4552
		dscp = 63;
4553
		fragment dont_fragment, is_fragment || !first_fragment;
4554
	};
4555
}
4556
</code>
4557

    
4558
<sect2>Differences for IPv6 Flowspec
4559

    
4560
<p>Flowspec IPv6 are same as Flowspec IPv4 with a few exceptions.
4561
<itemize>
4562
	<item>Prefixes <m/inet6/ can be specified not only with prefix length,
4563
	but with prefix <cf/offset/ <m/num/ too (e.g.
4564
	<cf>::1234:5678:9800:0000/101 offset 64</cf>). Offset means to don't
4565
	care of <m/num/ first bits.
4566
	<item>IPv6 Flowspec hasn't mandatory any flowspec component.
4567
	<item>In IPv6 packets, there is a matching the last next header value
4568
	for a matching IP protocol number (e.g. <cf>next header 6</cf>).
4569
	<item>It is not possible to set <cf>dont_fragment</cf> as a type of
4570
	packet fragmentation.
4571
</itemize>
4572

    
4573
<p><descrip>
4574
	<tag><label id="flow6-dst">dst <m/inet6/ [offset <m/num/]</tag>
4575
	Set a matching destination IPv6 prefix (e.g. <cf>dst
4576
	::1c77:3769:27ad:a11a/128 offset 64</cf>).
4577

    
4578
	<tag><label id="flow6-src">src <m/inet6/ [offset <m/num/]</tag>
4579
	Set a matching source IPv6 prefix (e.g. <cf>src fe80::/64</cf>).
4580

    
4581
	<tag><label id="flow6-next-header">next header <m/numbers-match/</tag>
4582
	Set a matching IP protocol numbers (e.g. <cf>next header != 6</cf>).
4583

    
4584
	<tag><label id="flow6-label">label <m/bitmask-match/</tag>
4585
	Set a 20-bit bitmask for matching Flow Label field in IPv6 packets
4586
	(e.g. <cf>label 0x8e5/0x8e5</cf>).
4587
</descrip>
4588

    
4589
<p><code>
4590
protocol static {
4591
	flow6 { table myflow6; };
4592

    
4593
	route flow6 {
4594
		dst fec0:1122:3344:5566:7788:99aa:bbcc:ddee/128;
4595
		src 0000:0000:0000:0001:1234:5678:9800:0000/101 offset 63;
4596
		next header = 23;
4597
		sport > 24 && < 30 || = 40 || 50,60,70..80;
4598
		dport = 50;
4599
		tcp flags 0x03/0x0f, !0/0xff || 0x33/0x33;
4600
		fragment !is_fragment || !first_fragment;
4601
		label 0xaaaa/0xaaaa && 0x33/0x33;
4602
	};
4603
}
4604
</code>
4605

    
4606
<sect1>Per-route options
4607
<descrip>
4608
	<tag><label id="static-route-bfd">bfd <m/switch/</tag>
4609
	The Static protocol could use BFD protocol for next hop liveness
4610
	detection. If enabled, a BFD session to the route next hop is created
4611
	and the static route is BFD-controlled -- the static route is announced
4612
	only if the next hop liveness is confirmed by BFD. If the BFD session
4613
	fails, the static route is removed. Note that this is a bit different
4614
	compared to other protocols, which may use BFD as an advisory mechanism
4615
	for fast failure detection but ignores it if a BFD session is not even
4616
	established.
4617

    
4618
	This option can be used for static routes with a direct next hop, or
4619
	also for for individual next hops in a static multipath route (see
4620
	above). Note that BFD protocol also has to be configured, see
4621
	<ref id="bfd" name="BFD"> section for details. Default value is no.
4622

    
4623
	<tag><label id="static-route-filter"><m/filter expression/</tag>
4624
	This is a special option that allows filter expressions to be configured
4625
	on per-route basis. Can be used multiple times. These expressions are
4626
	evaluated when the route is originated, similarly to the import filter
4627
	of the static protocol. This is especially useful for configuring route
4628
	attributes, e.g., <cf/ospf_metric1 = 100;/ for a route that will be
4629
	exported to the OSPF protocol.
4630
</descrip>
4631

    
4632
<sect1>Example static config
4633

    
4634
<p><code>
4635
protocol static {
4636
	ipv4 { table testable; };	# Connect to a non-default routing table
4637
	check link;			# Advertise routes only if link is up
4638
	route 0.0.0.0/0 via 198.51.100.130; # Default route
4639
	route 10.0.0.0/8		# Multipath route
4640
		via 198.51.100.10 weight 2
4641
		via 198.51.100.20 bfd	# BFD-controlled next hop
4642
		via 192.0.2.1;
4643
	route 203.0.113.0/24 unreachable; # Sink route
4644
	route 10.2.0.0/24 via "arc0";	# Secondary network
4645
	route 192.168.10.0/24 via 198.51.100.100 {
4646
		ospf_metric1 = 20;	# Set extended attribute
4647
	}
4648
	route 192.168.10.0/24 via 198.51.100.100 {
4649
		ospf_metric2 = 100;	# Set extended attribute
4650
		ospf_tag = 2;		# Set extended attribute
4651
		bfd;			# BFD-controlled route
4652
	}
4653
}
4654
</code>
4655

    
4656

    
4657
<chapt>Conclusions
4658
<label id="conclusion">
4659

    
4660
<sect>Future work
4661
<label id="future-work">
4662

    
4663
<p>Although BIRD supports all the commonly used routing protocols, there are
4664
still some features which would surely deserve to be implemented in future
4665
versions of BIRD:
4666

    
4667
<itemize>
4668
<item>Opaque LSA's
4669
<item>Route aggregation and flap dampening
4670
<item>Multicast routing protocols
4671
<item>Ports to other systems
4672
</itemize>
4673

    
4674

    
4675
<sect>Getting more help
4676
<label id="help">
4677

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

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

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

    
4698
<p><it/Good luck!/
4699

    
4700
</book>
4701

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