Statistics
| Branch: | Revision:

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

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.
57

    
58
<p>There already exist some such routing daemons (routed, GateD <HTMLURL URL="http://www.gated.org/">
59
and Zebra <HTMLURL URL="http://www.zebra.org">), but their capabilities are very limited and
60
they are very hard to configure and maintain.
61

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

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

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

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

    
92
<sect1>About this documentation
93

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

    
100
<sect1>Installing BIRD
101

    
102
<p>On UNIX system, installing BIRD should be as easy as:
103

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

    
111
<sect1>About routing tables
112

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

    
123
<sect>Configuration
124

    
125
<sect1>Introduction
126

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

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

    
140
<p>Really simple configuration file might look like this:
141

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

    
149
protocol device {
150
	scan time 10;		# Scan interfaces every 10 seconds
151
}
152

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

    
159
<sect1>Global options
160

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

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

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

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

    
191
	<tag>table <m/name/</tag> create new routing table.
192

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

    
196
<sect1>Protocol options
197

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

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

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

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

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

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

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

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

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

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

    
236
<sect>Filters
237

    
238
<sect1>Introduction
239

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

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

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

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

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

    
279

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

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

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

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

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

    
308
<sect1>Data types
309

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

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

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

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

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

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

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

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

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

    
357
	<tag/bgppath/
358
	  bgp path is list of autonomous systems.
359

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

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

    
371
	  
372
</descrip>
373

    
374
<sect1>Operations
375

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

    
383
<sect1>Control structures
384

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

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

    
397
<p>Here is example that uses if and case structures:
398

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

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

    
409
<sect1>Route attributes
410

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

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

    
417
	<tag/<m/prefix/ network/
418
	network this route is talking about.
419

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

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

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

    
432
<sect1>Utility functions
433

    
434
<p>There are few functions you might find convenient to use:
435

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

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

    
445
<sect>Protocols
446

    
447
<sect1>BGP
448

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

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

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

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

    
482
<sect2>Route selection rules
483

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

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

    
500
<sect2>Configuration
501

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

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

    
561
<sect2>Attributes
562

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

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

    
606
<sect2>Example
607

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

    
627
<sect1>Device
628

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

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

    
637
<p>The only configurable thing is interface scan time:
638

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

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

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

    
656
<sect1>Direct
657

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

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

    
667
<p>Only configurable thing about direct is what interfaces it watches:
668

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

    
678
<p>Direct device routes don't contain any specific attributes.
679

    
680
<p>Example config might look like this:
681

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

    
688
<sect1>Kernel
689

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

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

    
703
<sect2>Configuration
704

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

    
719
<p>A default simple configuration can look this way:
720

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

    
728
<p>Or for a system with two routing tables:
729

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

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

    
745
<p>The Kernel protocol doesn't define any route attributes.
746

    
747
<sect1>OSPF
748

    
749
<sect1>Pipe
750

    
751
<sect1>Rip
752

    
753
<sect2>Introduction
754

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

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

    
771
<sect2>Configuration
772

    
773
<p>In addition to options generic to other protocols, rip supports following options:
774

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

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

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

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

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

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

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

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

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

    
820
<sect2>Attributes
821

    
822
<p>RIP defines two route attributes:
823

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

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

    
834
<sect2>Example
835

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

    
853
<sect1>Static
854

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

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

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

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

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

    
888
<p>Static routes have no specific attributes.
889

    
890
<p>Example static config might look like this:
891

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

    
901
<sect>Getting more help
902

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

    
906

    
907
</article>
908

    
909

    
910
<!--
911
# 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 
912
-->