Statistics
| Branch: | Revision:

iof-bird-daemon / doc / bird.sgml @ 068b4127

History | View | Annotate | Download (38.5 KB)

1
<!doctype birddoc system>
2

    
3
<!--
4
	BIRD documentation
5

    
6
    Look for "about this documentation" section to learn more.
7

    
8
    (set-fill-column 100)
9

    
10
    Copyright 1999,2000 Pavel Machek <pavel@ucw.cz>, distribute under GPL version 2 or later.
11

    
12
 -->
13

    
14
<article>
15

    
16
<title>BIRD
17
<author>
18
Pavel Machek <tt/pavel@ucw.cz/
19

    
20
<abstract>
21
This document contains documentation for BIRD Internet Routing Daemon
22
</abstract>
23

    
24
<!-- Table of contents -->
25
<toc>
26

    
27
<!-- Begin the document -->
28

    
29
<sect>Introduction
30

    
31
<sect1>What is BIRD
32

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

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

    
40
<p><em/Internet Routing/: It's a program (well, a daemon, as you are going to discover in a moment)
41
which works as a dynamic router in an Internet type network (that is, in a network running either
42
the IPv4 or the IPv6 protocol). Routers are devices which forward packets between interconnected
43
networks in order to allow hosts not connected directly to the same local area network to
44
communicate with each other. They also communicate with other routers in the Internet to discover
45
the topology of the network which allows them to find optimal (in terms of some metric) rules for
46
forwarding of packets (which will be called routes in the rest of this document) and to adapt to the
47
changing conditions such as outages of network links, building of new connections and so on. Most of
48
these routers are costly dedicated devices running obscure firmware which is hard to configure and
49
not open to any changes.  Fortunately, most operating systems of the UNIX family allow an ordinary
50
computer to act as a router and forward packets belonging to the other hosts, but only according to
51
a statically configured table.
52

    
53
<p>A <em/Routing Daemon/ is in UNIX terminology a non-interactive program running on
54
background which does the dynamic part of Internet routing, that is it communicates
55
with the other routers, calculates routing tables and sends them to the OS kernel
56
which does the actual packet forwarding. There are other such routing daemons: routed (rip only), GateD <HTMLURL URL="http://www.gated.org/">
57
 (non free) and Zebra <HTMLURL URL="http://www.zebra.org">, but their capabilities are limited and
58
they are relatively hard to configure and maintain.
59

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

    
65
<itemize>
66
	<item>both IPv4 and IPv6 protocols
67
	<item>multiple routing tables
68
	<item>the Border Gateway Protocol (BGPv4)
69
	<item>the Routing Interchange Protocol (RIPv2)
70
	<item>the Open Shortest Path First protocol (OSPFv2)
71
	<item>a virtual protocol for exchange of routes between internal routing tables
72
	<item>a command-line interface allowing on-line control and inspection
73
		of status of the daemon
74
	<item>soft reconfiguration (no need to use complex online commands
75
		to change the configuration, just edit the configuration file
76
		and notify BIRD to re-read it and it will smoothly switch
77
		to the new configuration, not disturbing routing protocols
78
		unless they are affected by the configuration changes)
79
	<item>powerful language for route filtering
80
</itemize>
81

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

    
86
<p>BIRD has been designed to work on all UNIX-like systems. It has been developed and
87
tested under Linux 2.0 to 2.3, but porting to other systems (even non-UNIX ones) should
88
be relatively easy due to its highly modular architecture.
89

    
90
<sect1>About this documentation
91

    
92
<p>This documentation can have 4 forms: sgml (this is master copy), html, ASCII text (generated from
93
html) and dvi/postscript (generated from sgml using sgmltools). You should always edit master copy,
94
it is slightly modified linuxdoc dtd.  Anything in &lt;descrip&gt; tags is considered definition of
95
configuration primitives, &lt;cf&gt; is fragment of configuration within normal text, &lt;m&gt; is
96
"meta" information within fragment of configuration -- something in config which is not keyword.
97

    
98
<sect1>Installing BIRD
99

    
100
<p>On UNIX system, installing BIRD should be as easy as:
101

    
102
<code>
103
        ./configure
104
        make
105
        make install
106
        vi /usr/local/etc/bird.conf
107
</code>
108

    
109
<sect1>About routing tables
110

    
111
<p>Bird has one or more routing tables. Each routing table contains
112
list of known routes. Each route has certain attributes, most
113
important is prefix of network this route is for. Routing table
114
maintains more than one entry for network, but at most one entry for
115
one network and one protocol. The entry with biggest preference is
116
used for routing. If there are more entries with same preference and
117
they are from same protocol, protocol decides (typically according to
118
metrics). You can get list of route attributes in "Route attributes"
119
section in filters.
120

    
121
<sect>Configuration
122

    
123
<sect1>Introduction
124

    
125
<p>BIRD is configured using text configuration file. At startup, BIRD reads <file/bird.conf/ (unless
126
-c command line parameter is given). Configuration may be changed on user request: if you modify
127
config file and then signal BIRD with SIGHUP, it will adjust to new config. There's BIRD client,
128
which allows you to talk with BIRD in more extensive way than just telling it to reconfigure. BIRD
129
writes messages about its work to log files or syslog (according to config).
130

    
131
<p>Bird is configured using text configuration file. At startup, bird
132
reads <file/bird.conf/ (unless -c command line parameter is
133
given). Everything on a line after <cf/#/ is a comment, whitespace is
134
ignored, C-style comments <cf>/* comment */</cf> are also
135
recognized. If there's variable number of options, it is grouped using
136
<cf/{ }/ brackets. Each option is terminated by <cf/;/.
137

    
138
<p>Really simple configuration file might look like this:
139

    
140
<code>
141
protocol kernel {
142
	persist;		# Don't remove routes on BIRD shutdown
143
	scan time 20;		# Scan kernel routing table every 20 seconds
144
	export all;		# Default is export none
145
}
146

    
147
protocol device {
148
	scan time 10;		# Scan interfaces every 10 seconds
149
}
150

    
151
protocol rip {
152
	export all;
153
	import all;
154
}
155
</code>
156

    
157
<sect1>Global options
158

    
159
<p><descrip>
160
	<tag>log "<m/filename/"|syslog|stderr all|{ <m/list of classes/ }</tag> 
161
	set logging of classes (either all or <cf/{
162
	error, trace }/ etc.) into selected destination. Classes are:
163
	<cf/info/, <cf/warning/, <cf/error/, <cf/fatal/ for messages about local problems
164
	<cf/debug/ for debugging messages, 
165
	<cf/trace/ when you want to know what happens on network, 
166
	<cf/remote/ for messages about misbehavior of remote side, 
167
	<cf/auth/ about authentication failures,  
168
	<cf/bug/ for internal bugs
169
	of BIRD. You may specify more than one <cf/log/ line to log to multiple
170
	destinations.
171
				  
172
	<tag>debug protocols all|off|{ states, routes, filters, interfaces, events, packets }</tag>
173
	sets global default of protocol debugging options.
174

    
175
	<tag>filter <m/name/{ <m/commands/ }</tag> define filter. You can learn more about filters
176
	in next chapter.
177
 
178
	<tag>protocol rip|ospf|bgp|... <m/[name]/ { <m>protocol options</m> }</tag> define protocol
179
	instance, called name (or called something like rip5 if you omit name). You can learn more
180
	about configuring protocols in their own chapters. You can run more than one instance of
181
	most protocols (like rip or bgp).
182

    
183
	<tag>define constant = expression</tag> define constant. You can use it later in every place
184
	you could use simple integer.
185

    
186
	<tag>router id <m/IPv4 address/</tag> set router id. Router id needs to be world-wide
187
	unique. It is usually one of router's IPv4 addresses.
188

    
189
	<tag>table <m/name/</tag> create new routing table.
190

    
191
	<tag>eval <m/expr/</tag> evaluates given filter expression. It is used for testing.
192
</descrip>
193

    
194
<sect1>Protocol options
195

    
196
<p>Several options are per-protocol, but all protocols support them. They are described here.
197

    
198
<descrip>
199
	<tag>preference <m/expr/</tag> sets preference of routes generated by this protocol.
200

    
201
	<tag>disabled</tag> disables given protocol. You can disable/enable protocol from command
202
	line interface without needing to touch config.
203

    
204
	<tag>debug <m/setting/</tag> this is similar to global debug setting, except that it only
205
	affects one protocol. Only messages in selected debugging categories will be written to
206
	logs.
207

    
208
	<tag>import <m/filter/</tag> filter can be either either <cf> { <m>filter commands</m>
209
	}</cf> or <cf>filter <m/name/</cf>. Import filter works in direction from protocol to main
210
	routing table.
211

    
212
	<tag>export <m/filter/</tag> This is similar to <cf>export</cf> keyword, except that it
213
	works in direction from main routing table to protocol.
214

    
215
	<tag>table <m/name/</tag> Connect this protocol to non-default table.
216
</descrip>
217

    
218
<p>There are per-protocol options that give sense only with certain protocols.
219

    
220
<descrip>
221
	<tag>passwords { password "<m/password/" from <m/time/ to <m/time/ passive <m/time/ id
222
	<m/num/ [...] }</tag> specifies passwords to be used with this protocol. Passive time is
223
	time from which password is not announced but is allowed. id is password id, as needed by
224
	certain protocols.
225

    
226
	<tag>interface "<m/mask/"|<m/prefix/ [ { <m/option/ ; [ ... ] } ]</tag> specifies, which
227
	interfaces this protocol is active at, and allows you to set options on
228
	interface-by-interface basis. Mask is specified in shell-like patters, thus <cf>interface
229
	"*" { mode broadcast; };</cf> will start given protocol on all interfaces, with <cf>mode
230
	broadcast;</cf> option.
231
						  
232
</descrip>
233

    
234
<sect>Filters
235

    
236
<sect1>Introduction
237

    
238
<p>BIRD contains rather simple programming language. (No, it can not yet read mail :-). There are
239
two objects in this language: filters and functions. Filters are called by BIRD core when route is
240
being passed between protocol and main routing table, and filters may call functions. Functions may
241
call other functions, but recursion is not allowed. Filter language contains control structures such
242
as if's and switches, but it allows no loops. Filters are
243
interpreted. Filter using many features can be found in <file>filter/test.conf</file>. 
244

    
245
<p>Filter basically gets the route, looks at its attributes and
246
modifies some of them if it wishes. At the end, it decides, whether to
247
pass change route through (using <cf/accept/), or whether to <cf/reject/ given route. It looks
248
like this:
249

    
250
<code>
251
filter not_too_far
252
int var;
253
{
254
	if defined( rip_metric ) then
255
		var = rip_metric;
256
	else {
257
		var = 1;
258
		rip_metric = 1;
259
	}
260
	if rip_metric &gt; 10 then
261
		reject "RIP metric is too big";
262
	else
263
		accept "ok";
264
}
265
</code>
266

    
267
<p>As you can see, filter has a header, list of local variables, and body. Header consists of
268
<cf/filter/ keyword, followed by (unique) name of filter. List of local variables consists of
269
pairs <cf><M>type name</M>;</cf>, where each pair defines one local variable. Body consists of
270
<cf> { <M>statements</M> }</cf>. Statements are terminated by <cf/;/. You can group
271
several statements into one by <cf>{ <M>statements</M> }</cf> construction, that is useful if
272
you want to make bigger block of code conditional.
273

    
274
<p>There are two special filters, <cf/all/ (which accepts all routes) and <cf/none/ (which rejects
275
all routes).
276

    
277

    
278
<p>Bird supports functions, so that you don't have to repeat same blocks of code over and
279
over. Functions can have zero or more parameters, and can have local variables. Function basically
280
looks like this:
281

    
282
<code>
283
function name ()
284
int local_variable;
285
{
286
	local_variable = 5;
287
}
288

    
289
function with_parameters (int parameter)
290
{
291
	print parameter;
292
}
293
</code>
294

    
295
<p>Unlike C, variables are declared after function line but before first {. You can not declare
296
variables in nested blocks. Functions are called like in C: <cf>name();
297
with_parameters(5);</cf>. Function may return value using <cf>return <m/[expr]/</cf>
298
syntax. Returning value exits from current function (this is similar to C).
299

    
300
<p>Filters are declared in similar way to functions, except they can not have explicit
301
parameters. They get route table entry as implicit parameter. Route table entry is passed implicitly
302
to any functions being called. Filter must terminate with either
303
accept or reject statement. If there's runtime error in filter, route
304
is rejected. 
305

    
306
<sect1>Data types
307

    
308
<p>Each variable and each value has certain type. Unlike C, filters distinguish between integers and
309
booleans (that is to prevent you from shooting in the foot).
310

    
311
<descrip>
312
	<tag/bool/ this is boolean type, it can have only two values, <cf/TRUE/ and
313
	  <cf/FALSE/. Boolean is not compatible with integer and is the only type you can use in if
314
	  statements.
315

    
316
	<tag/int/ this is common integer, you can expect it to store signed values from -2000000000
317
	  to +2000000000.
318

    
319
	<tag/pair/ this is pair of two short integers. Each component can have values from 0 to
320
	  65535. Constant of this type is written as <cf/(1234,5678)/.
321

    
322
	<tag/string/ this is string of characters. There are no ways to modify strings in
323
	  filters. You can pass them between functions, assign to variable of type string, print
324
	  such variables, but you can not concatenate two strings (for example). String constants
325
	  are written as <cf/"This is a string constant"/.
326

    
327
	<tag/ip/ this type can hold single ip address. Depending on version of BIRD you are using, it
328
	  can be IPv4 or IPv6 address. IPv4 addresses are written (as you would expect) as
329
	  <cf/1.2.3.4/. You can apply special operator <cf>.mask(<M>num</M>)</cf>
330
	  on values of type ip. It masks out all but first <cf><M>num</M></cf> bits from ip
331
	  address. So <cf/1.2.3.4.mask(8) = 1.0.0.0/ is true.
332

    
333
	<tag/prefix/ this type can hold ip address, prefix len pair. Prefixes are written as
334
	  <cf><M>ipaddress</M>/<M>pxlen</M></cf>, or
335
	  <cf><m>ipaddress</m>/<m>netmask</m></cf> There are two special
336
	  operators on prefix:
337
	  <cf/.ip/, which separates ip address from the pair, and <cf/.len/, which separates prefix
338
	  len from the pair.
339

    
340
	<tag/int|ip|prefix|pair set/
341
	  filters know four types of sets. Sets are similar to strings: you can pass them around
342
	  but you can not modify them. Constant of type <cf>set int</cf> looks like <cf>
343
	  [ 1, 2, 5..7 ]</cf>. As you can see, both simple values and ranges are permitted in
344
	  sets. Sets of prefixes are special: you can specify which prefixes should match them by
345
	  using <cf>[ 1.0.0.0/8+, 2.0.0.0/8-, 3.0.0.0/8{5,6} ]</cf>. 3.0.0.0/8{5,6} matches
346
	  prefixes 3.X.X.X, whose prefix length is 5 to 6. 3.0.0.0/8+ is shorthand for 3.0.0.0/{0,8},
347
	  3.0.0.0/8- is shorthand for 3.0.0.0/{0,7}.
348

    
349
	<tag/enum/
350
	  enumeration types are halfway-internal in the BIRD. You can not define your own
351
	  variable of enumeration type, but some predefined variables are of enumeration
352
	  type. Enumeration types are incompatible with each other, again, for your
353
	  protection.
354

    
355
	<tag/bgppath/
356
	  bgp path is list of autonomous systems.
357

    
358
	<tag/bgpmask/ 
359
	  bgp mask is mask used for matching bgp paths
360
	  (using <cf>path ~ / 2 3 5 ? / syntax </cf>). <cf/?/ is
361
	  really serving in "any number of autonomous systems", but we
362
	  did not want to use * because then it becomes too easy to
363
	  write <cf>/*</cf> which is start of comment.
364

    
365
	<tag/clist/ 
366
	  community list. This is similar to set of pairs,
367
	  except that unlike other sets, it can be modified.
368

    
369
	  
370
</descrip>
371

    
372
<sect1>Operations
373

    
374
<p>Filter language supports common integer operations <cf>(+,-,*,/)</cf>, parentheses <cf/(a*(b+c))/, comparison
375
<cf/(a=b, a!=b, a&lt;b, a&gt;=b)/. Special operators include <cf/&tilde;/ for "in" operation. In operation can be
376
used on element and set of that elements, or on ip and prefix, or on
377
prefix and prefix or on bgppath and bgpmask or on pair and clist. Its result
378
is true if element is in given set or if ip address is inside given prefix. Operator <cf/=/ is used to assign value
379
to variable.
380

    
381
<sect1>Control structures
382

    
383
<p>Filters support two control structures: if/then/else and case. Syntax of if/then/else is <cf>if
384
<M>expression</M> then <M>command</M>; else <M>command</M>;</cf> and you can use <cf>{
385
<M>command_1</M>; <M>command_2</M>; <M>...</M> }</cf> instead of one or both commands. <cf>else</cf>
386
clause may be omitted.
387

    
388
<p><cf>case</cf> is similar to case from Pascal. Syntax is <cf>case <m/expr/ { else |
389
<m/num_or_prefix [ .. num_or_prefix]/ : <m/statement/ ; [ ... ] }</cf>. Expression after
390
<cf>case</cf> can be of any type that can be on the left side of &tilde; operator, and anything that could
391
be member of set is allowed before :. Multiple commands are allowed without {} grouping. If argument
392
matches neither of : clauses, else: clause is used. (Case is actually implemented as set matching,
393
internally.)
394

    
395
<p>Here is example that uses if and case structures:
396

    
397
<code>
398
case arg1 {
399
	2: print "two"; print "I can do more commands without {}";
400
	3 .. 5: print "three to five";
401
	else: print "something else";
402
	}
403

    
404
if 1234 = i then printn "."; else { print "*** FAIL: if 1 else"; }
405
</code>
406

    
407
<sect1>Route attributes
408

    
409
<p>Filter is implicitly passed route, and it can access its attributes, just like it accesses variables.
410

    
411
<descrip>
412
	<tag>defined( <m>attribute</m> )</tag>
413
	returns TRUE if given attribute is defined. Access to undefined attribute results in runtime error.
414

    
415
	<tag/<m/prefix/ network/
416
	network this route is talking about.
417

    
418
	<tag/<m/ip/ from/
419
	who told me about this route.
420
	
421
	<tag/<m/ip/ gw/
422
	what is next hop packets routed using this route should be forwarded to.
423

    
424
	<tag/<m/enum/ source/
425
	what protocol told me about this route. This can have values such as <cf/RTS_RIP/ or <cf/RTS_OSPF_EXT/.
426
</descrip>
427

    
428
<p>Plus, there are protocol-specific attributes, which are described in protocol sections.
429

    
430
<sect1>Utility functions
431

    
432
<p>There are few functions you might find convenient to use:
433

    
434
<descrip>
435
	<tag>print|printn <m/expr/ [ <m/, expr .../ ]</tag>
436
	prints given expressions, useful mainly while debugging
437
	filters. Printn variant does not go to new line.
438

    
439
	<tag>quitbird</tag>
440
	terminates bird. Useful while debugging filter interpreter.
441
</descrip>
442

    
443
<sect>Protocols
444

    
445
<sect1>BGP
446

    
447
<p>The Border Gateway Protocol is the routing protocol used for backbone
448
level routing in the today's Internet. Contrary to other protocols, its convergence
449
doesn't rely on all routers following the same rules for route selection,
450
making it possible to implement any routing policy at any router in the
451
network, the only restriction being that if a router advertises a route,
452
it must accept and forward packets according to it.
453

    
454
<p>BGP works in terms of autonomous systems (often abbreviated as AS). Each
455
AS is a part of the network with common management and common routing policy.
456
Routers within each AS usually communicate using either a interior routing
457
protocol (such as OSPF or RIP) or an interior variant of BGP (called iBGP).
458
Boundary routers at the border of the AS communicate with their peers
459
in the neighboring AS'es via exterior BGP (eBGP).
460

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

    
466
<p>BIRD supports all requirements of the BGP4 standard as defined in
467
RFC 1771<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc1771.txt">
468
including several enhancements from the
469
latest draft<htmlurl url="ftp://ftp.rfc-editor.org/internet-drafts/draft-ietf-idr-bgp4-09.txt">.
470
It also supports the community attributes as per
471
RFC 1997<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc1997.txt">,
472
capability negotiation draft<htmlurl url="ftp://ftp.rfc-editor.org/internet-drafts/draft-ietf-idr-bgp4-cap-neg-06.txt">.
473
For IPv6, it uses the standard multiprotocol extensions defined in
474
RFC 2283<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc2283.txt">
475
including changes described in the
476
latest draft <htmlurl url="ftp://ftp.rfc-editor.org/internet-drafts/draft-ietf-idr-bgp4-multiprotocol-v2-05.txt">
477
and applied to IPv6 according to
478
RFC 2545<htmlurl url="ftp://ftp.rfc-editor.org/in-notes/rfc2545.txt">.
479

    
480
<sect2>Route selection rules
481

    
482
<p>BGP doesn't have any simple metric, so the rules for selection of an optimal
483
route among multiple BGP routes with the same preference are a bit more complex
484
and are implemented according to the following algorithm. First it uses the first
485
rule, if there are more "best" routes, then it uses the second rule to choose
486
among them and so on.
487

    
488
<itemize>
489
	<item>Prefer route with the highest local preference attribute.
490
	<item>Prefer route with the shortest AS path.
491
	<item>Prefer IGP origin over EGP and EGP over incomplete.
492
	<item>Prefer the lowest value of the Multiple Exit Discriminator.
493
	<item>Prefer internal routes over external routes.
494
	<item>Prefer route with the lowest value of router ID of the
495
	advertising router.
496
</itemize>
497

    
498
<sect2>Configuration
499

    
500
<p>Each instance of the BGP corresponds to one neighboring router.
501
This allows to set routing policy and all other parameters differently
502
for each neighbor using the following protocol parameters:
503

    
504
<descrip>
505
	<tag>local as <m/number/</tag> Define which AS we are part of. (Note that
506
	contrary to other IP routers, BIRD is able to act as a router located
507
	in multiple AS'es simultaneously, but in such cases you need to tweak
508
	the BGP paths manually in the filters to get consistent behavior.)
509
	This parameter is mandatory.
510
	<tag>neighbor <m/ip/ as <m/number/</tag> Define neighboring router
511
	this instance will be talking to and what AS it's located in. Unless
512
	you use the <cf/multihop/ clause, it must be directly connected to one
513
	of your router's interfaces. This parameter is mandatory.
514
	<tag>multihop <m/number/ via <m/ip/</tag> Configure multihop BGP to a
515
	neighbor which is connected at most <m/number/ hops far and to which
516
	we should route via our direct neighbor with address <m/ip/.
517
	Default: switched off.
518
	<tag>next hop self</tag> Avoid calculation of the Next Hop attribute
519
	and always advertise our own source address (see below) as a next hop.
520
	This needs to be used only
521
	occasionally to circumvent misconfigurations of other routers.
522
	Default: disabled.
523
	<tag>source address <m/ip/</tag> Define local address we should use
524
	for next hop calculation. Default: the address of the local end
525
	of the interface our neighbor is connected to.
526
	<tag>disable after error <m/switch/</tag> When an error is encountered (either
527
	locally or by the other side), disable the instance automatically
528
	and wait for an administrator to solve the problem manually. Default: off.
529
	<tag>hold time <m/number/</tag> Time in seconds to wait for a keepalive
530
	message from the other side before considering the connection stale.
531
	Default: depends on agreement with the neighboring router, we prefer
532
	240 seconds if the other side is willing to accept it.
533
	<tag>startup hold time <m/number/</tag> Value of the hold timer used
534
	before the routers have a chance to exchange OPEN messages and agree
535
	on the real value. Default: 240 seconds.
536
	<tag>keepalive time <m/number/</tag> Delay in seconds between sending
537
	of two consecutive keepalive messages. Default: One third of the hold time.
538
	<tag>connect retry time <m/number/</tag> Time in seconds to wait before
539
	retrying a failed connect attempt. Default: 120 seconds.
540
	<tag>start delay time <m/number/</tag> Delay in seconds between protocol
541
	startup and first attempt to connect. Default: 5 seconds.
542
	<tag>error wait time <m/number/, <m/number/</tag> Minimum and maximum delay in seconds between protocol
543
	failure (either local or reported by the peer) and automatic startup.
544
	Doesn't apply when <cf/disable after error/ is configured. If consecutive
545
	errors happen, the delay is increased exponentially until it reaches the maximum. Default: 60, 300.
546
	<tag>error forget time <m/number/</tag> Maximum time in seconds between two protocol
547
	failures to treat them as a error sequence which makes the <cf/error wait time/
548
	increase exponentially. Default: 300 seconds.
549
	<tag>path metric <m/switch/</tag> Enable comparison of path lengths
550
	when deciding which BGP route is the best one. Default: on.
551
	<tag>default bgp_med <m/number/</tag> Value of the Multiple Exit
552
	Discriminator to be used during route selection when the MED attribute
553
	is missing. Default: infinite.
554
	<tag>default bgp_local_pref <m/number/</tag> Value of the Local Preference
555
	to be used during route selection when the Local Preference attribute
556
	is missing. Default: 0.
557
</descrip>
558

    
559
<sect2>Attributes
560

    
561
<p>BGP defines several route attributes. Some of them (those marked with `I' in the
562
table below) are available on internal BGP connections only, some of them (marked
563
with `O') are optional.
564

    
565
<descrip>
566
	<tag>path <cf/bgp_path/</tag> Sequence of AS numbers describing the AS path
567
	the packet will travel through when forwarded according to this route. On
568
	internal BGP connections it doesn't contain the number of the local AS.
569
	<tag>int <cf/bgp_local_pref/ [I]</tag> Local preference value used for
570
	selection among multiple BGP routes (see the selection rules above). It's
571
	used as an additional metric which is propagated through the whole local AS.
572
	<tag>int <cf/bgp_med/ [IO]</tag> The Multiple Exit Discriminator of the route
573
	which is an optional attribute which is often used within the local AS to
574
	reflect interior distances to various boundary routers. See the route selection
575
	rules above for exact semantics.
576
	<tag>enum <cf/bgp_origin/</tag> Origin of the route: either <cf/ORIGIN_IGP/
577
	if the route has originated in interior routing protocol of an AS or
578
	<cf/ORIGIN_EGP/ if it's been imported from the <tt>EGP</tt> protocol
579
	(nowadays it seems to be obsolete) or <cf/ORIGIN_INCOMPLETE/ if the origin
580
	is unknown.
581
	<tag>ip <cf/bgp_next_hop/</tag> Next hop to be used for forwarding of packets
582
	to this destination. On internal BGP connections, it's an address of the
583
	originating router if it's inside the local AS or a boundary router the
584
	packet will leave the AS through if it's an exterior route, so each BGP
585
	speaker within the AS has a chance to use the shortest interior path
586
	possible to this point.
587
	<tag>void <cf/bgp_atomic_aggr/ [O]</tag> This is an optional attribute
588
	which carries no value, but which sole presence indicates that the route
589
	has been aggregated from multiple routes by some AS on the path from
590
	the originator.
591
<!-- we don't handle aggregators right since they are of a very obscure type
592
	<tag>bgp_aggregator</tag>
593
-->
594
	<tag>clist <cf/bgp_community/ [O]</tag> List of community values associated
595
	with the route. Each such value is a pair (represented as a <cf/pair/ data
596
	type inside the filters) of 16-bit integers, the first of them containing a number of the AS which defines
597
	the community and the second one is a per-AS identifier. There are lots
598
	of uses of the community mechanism, but generally they are used to carry
599
	policy information like "don't export to USA peers". As each AS can define
600
	its own routing policy, it's also has a complete freedom about which community
601
	attributes it defines and what their semantics will be.
602
</descrip>
603

    
604
<sect2>Example
605

    
606
<p><code>
607
protocol bgp {
608
	local as 65000;				# Use a private AS number
609
	neighbor 62.168.0.130 as 5588;		# Our neighbor
610
	multihop 20 via 62.168.0.13;		# Which is connected indirectly
611
	export filter {				# We use non-trivial export rules
612
		if source = RTS_STATIC then {	# Export only static routes
613
			bgp_community.add((65000,5678));  # Assign our community
614
			if bgp_path ~ / 65000 / then	  # Artificially increase path length
615
				bgp_path.prepend(65000);  # by prepending local AS number twice
616
			accept;
617
		}
618
		reject;
619
	};
620
	import all;
621
	source address 62.168.0.1;		# Use non-standard source address
622
}
623
</code>
624

    
625
<sect1>Device
626

    
627
<p>The Device protocol is not a real routing protocol as it doesn't generate
628
any routes and only serves as a module for getting information about network
629
interfaces from the kernel.
630

    
631
<p>Except for very unusual circumstances, you probably should include
632
this protocol in the configuration since almost all other protocol
633
require network interfaces to be defined in order to work.
634

    
635
<p>The only configurable thing is interface scan time:
636

    
637
<p><descrip>
638
	<tag>scan time <m/number/</tag> Time in seconds between two scans
639
	of the network interface list. On systems where we are notified about
640
	interface status changes asynchronously (such as newer versions of
641
	Linux), we need to scan the list only to avoid confusion by lost
642
	notifications, so the default time is set to a large value.
643
</descrip>
644

    
645
<p>As the Device protocol doesn't generate any routes, it cannot have
646
any attributes. Example configuration looks really simple:
647

    
648
<p><code>
649
protocol device {
650
	scan time 10;		# Scan the interfaces often
651
}
652
</code>
653

    
654
<sect1>Direct
655

    
656
<p>The Direct protocol is a simple generator of device routes for all the
657
directly connected networks according to the list of interfaces provided
658
by the kernel via the Device protocol.
659

    
660
<p>It's highly recommended to include this protocol in your configuration
661
unless you want to use BIRD as a route server or a route reflector, that is
662
on a machine which doesn't forward packets and only participates in
663
distribution of routing information.
664

    
665
<p>Only configurable thing about direct is what interfaces it watches:
666

    
667
<p><descrip>
668
	<tag>interface <m/pattern [, ...]/</tag> By default, the Direct
669
	protocol will generate device routes for all the interfaces
670
	available. If you want to restrict it to some subset of interfaces
671
	(for example if you're using multiple routing tables for policy
672
	routing and some of the policy domains don't contain all interfaces),
673
	just use this clause.
674
</descrip>
675

    
676
<p>Direct device routes don't contain any specific attributes.
677

    
678
<p>Example config might look like this:
679

    
680
<p><code>
681
protocol direct {
682
	interface "-arc*", "*";		# Exclude the ARCnets
683
}
684
</code>
685

    
686
<sect1>Kernel
687

    
688
<p>The Kernel protocol is not a real routing protocol. Instead of communicating
689
with other routers in the network, it performs synchronization of BIRD's routing
690
tables with OS kernel. Basically, it sends all routing table updates to the kernel
691
and from time to time it scans the kernel tables to see whether some routes have
692
disappeared (for example due to unnoticed up/down transition of an interface)
693
or whether an `alien' route has been added by someone else.
694

    
695
<p>If your OS supports only a single routing table, you can configure only one
696
instance of the Kernel protocol. If it supports multiple tables (in order to
697
allow policy routing), you can run as many instances as you want, but each of
698
them must be connected to a different BIRD routing table and to a different
699
kernel table.
700

    
701
<sect2>Configuration
702

    
703
<p><descrip>
704
	<tag>persist <m/switch/</tag> Tell BIRD to leave all its routes in the
705
	routing tables when it exits instead of cleaning them up.
706
	<tag>scan time <m/number/</tag> Time in seconds between two scans of the
707
	kernel routing table.
708
	<tag>learn <m/switch/</tag> Enable learning of routes added to the kernel
709
	routing tables by other routing daemons or by the system administrator.
710
	This is possible only on systems which support identification of route
711
	authorship.
712
	<tag>kernel table <m/number/</tag> Select which kernel table should
713
	this particular instance of the Kernel protocol work with. Available
714
	only on systems supporting multiple routing tables.
715
</descrip>
716

    
717
<p>A default simple configuration can look this way:
718

    
719
<p><code>
720
protocol kernel {
721
	import all;
722
	export all;
723
}
724
</code>
725

    
726
<p>Or for a system with two routing tables:
727

    
728
<p><code>
729
protocol kernel {		# Primary routing table
730
	learn;			# Learn alien routes from the kernel
731
	persist;		# Don't remove routes on bird shutdown
732
	scan time 10;		# Scan kernel routing table every 10 seconds
733
	import all;
734
	export all;
735
}
736

    
737
protocol kernel {		# Secondary routing table
738
	table auxtable;
739
	kernel table 100;
740
	export all;
741
</code>
742

    
743
<p>The Kernel protocol doesn't define any route attributes.
744

    
745
<sect1>OSPF
746

    
747
<sect1>Pipe
748

    
749
<sect1>Rip
750

    
751
<sect2>Introduction
752

    
753
<p>Rip protocol (sometimes called Rest In Pieces) is simple protocol, where each router broadcasts
754
distances to all networks he can reach. When router hears distance to other network, it increments
755
it and broadcasts it back. Broadcasts are done in regular intervals. Therefore, if some network goes
756
unreachable, routers keep telling each other that distance is old distance plus 1 (actually, plus
757
interface metric, which is usually one). After some time, distance reaches infinity (that's 15 in
758
rip) and all routers know that network is unreachable. Rip tries to minimize situations where
759
counting to infinity is necessary, because it is slow. Due to infinity being 16, you can not use
760
rip on networks where maximal distance is bigger than 15 hosts. You can read more about rip at <HTMLURL
761
URL="http://www.ietf.org/html.charters/rip-charter.html">. Both IPv4 and IPv6 versions of rip are supported by BIRD.
762

    
763
<p>Rip is very simple protocol, and it is not too good. Slow
764
convergence, big network load and inability to handle bigger networks
765
makes it pretty much obsolete in IPv4 world. (It is still usable on
766
very small networks, through.) It is widely used in IPv6 world,
767
because they are no good implementations of OSPFv3.
768

    
769
<sect2>Configuration
770

    
771
<p>In addition to options generic to other protocols, rip supports following options:
772

    
773
<descrip>
774
	<tag/authentication none|password|md5/ selects authentication method to use. None means that
775
	  packets are not authenticated at all, password means that plaintext password is embedded
776
	  into each packet, and md5 means that packets are authenticated using md5 cryptographic
777
	  hash. If you set authentication to non-none, it is good idea to add <cf>passwords { }</cf>
778
	  section.
779

    
780
	<tag>honor always|neighbor|never </tag>specifies, when should be requests for dumping routing table
781
	  honored. (Always, when sent from host on directly connected
782
	  network, or never.) Routing table updates are honored only from
783
	  neighbors, that is not configurable.
784
</descrip>
785

    
786
<p>There are two options that can be specified per-interface. First is <cf>metric</cf>, with
787
default one.  Second is <cf>mode multicast|broadcast|quiet|nolisten|version1</cf>, it selects mode for
788
rip to work in. If nothing is specified, rip runs in multicast mode. <cf>version1</cf> is
789
currently equivalent to <cf>broadcast</cf>, and it makes rip talk at broadcast address even
790
through multicast mode is possible. <cf>quiet</cf> option means that rip will not transmit
791
periodic messages onto this interface and <cf>nolisten</cf> means that rip will talk to this
792
interface but not listen on it.
793

    
794
<p>Following options generally override specified behavior from RFC. If you use any of these
795
options, BIRD will no longer be RFC-compatible, which means it will not be able to talk to anything
796
other than equally misconfigured BIRD. I warned you.
797

    
798
<descrip>
799
	<tag>port <M>number</M></tag>
800
	  selects IP port to operate on, default 520. (This is useful when testing BIRD, if you
801
	  set this to address &gt;1024, you will not need to run bird with UID==0).
802

    
803
	<tag>infinity <M>number</M></tag>
804
	  select value of infinity, default 16. Bigger values will make protocol convergence
805
	  even slower.
806

    
807
	<tag>period <M>number</M>
808
	  </tag>specifies number of seconds between periodic updates. Default is 30 seconds. Lower
809
	  number will mean faster convergence but bigger network load.
810

    
811
	<tag>timeout time <M>number</M>
812
	  </tag>specifies how old route has to be to be considered unreachable. Default is 4*period.
813

    
814
	<tag>garbage time <M>number</M>
815
	  </tag>specifies how old route has to be to be discarded. Default is 10*period.
816
</descrip>
817

    
818
<sect2>Attributes
819

    
820
<p>RIP defines two route attributes:
821

    
822
<descrip>
823
	<tag>int <cf/rip_metric/</tag> RIP metric of the route (ranging from 0 to <cf/infinity/).
824
	When routes from different RIP instances are available and all of them have the same
825
	preference, BIRD prefers the route with lowest <cf/rip_metric/.
826

    
827
	<tag>int <cf/rip_tag/</tag> RIP route tag: a 16-bit number which can be used
828
	to carry additional information with the route (for example, an originating AS number
829
	in case of external routes).
830
</descrip>
831

    
832
<sect2>Example
833

    
834
<p><code>
835
protocol rip MyRIP_test {
836
        debug all;
837
        port 1520;
838
        period 7;
839
        garbagetime 60;
840
        interface "eth0" { metric 3; mode multicast; } "eth1" { metric 2; mode broadcast; };
841
        honor neighbour;
842
        passwords { password "ahoj" from 0 to 10;
843
                password "nazdar" from 10;
844
        }
845
        authentication none;
846
        import filter { print "importing"; accept; };
847
        export filter { print "exporting"; accept; };
848
}
849
</code>
850

    
851
<sect1>Static
852

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

    
861
<p>There are three types of static routes: `classical' routes telling to
862
forward packets to a neighboring router, device routes specifying forwarding
863
to hosts on a directly connected network and special routes (sink, blackhole
864
etc.) which specify a special action to be done instead of forwarding the
865
packet.
866

    
867
<p>When the particular destination is not available (the interface is down or
868
the next hop of the route is not a neighbor at the moment), Static just
869
uninstalls the route from the table its connected to and adds it again as soon
870
as the destinations becomes adjacent again.
871

    
872
<p>The Static protocol has no configuration options. Instead, the
873
definition of the protocol contains a list of static routes which
874
can contain:
875

    
876
<descrip>
877
	<tag>route <m/prefix/ via <m/ip/</tag> Static route through
878
	a neighboring router.
879
	<tag>route <m/prefix/ via <m/"interface"/</tag> Static device
880
	route through an interface to hosts on a directly connected network.
881
	<tag>route <m/prefix/ drop|reject|prohibit</tag> Special routes
882
	specifying to drop the packet, return it as unreachable or return
883
	it as administratively prohibited.
884
</descrip>
885

    
886
<p>Static routes have no specific attributes.
887

    
888
<p>Example static config might look like this:
889

    
890
<p><code>
891
protocol static {
892
	table testable;				# Connect to non-default routing table
893
	route 0.0.0.0/0 via 62.168.0.13;	# Default route
894
	route 62.168.0.0/25 reject;		# Sink route
895
	route 10.2.0.0/24 via "arc0";		# Secondary network
896
}
897
</code>
898

    
899
<sect>Getting more help
900

    
901
<p>This is really last section of this file, should give pointers to
902
programmers documentation, web pages mailing lists and similar stuff.
903

    
904

    
905
</article>
906

    
907

    
908
<!--
909
# LocalWords: IPv doctype verb GPL sgml html unix dvi sgmltools linuxdoc dtd descrip config conf syslog stderr auth ospf bgp router's IP expr num inst bool int ip px len enum cf md eval ipaddress pxlen netmask bgppath bgpmask clist gw RTS EXT quitbird nolisten UID timeouttime garbagetime RFC doc 
910
-->