]> git.proxmox.com Git - mirror_frr.git/blob - doc/user/bgp.rst
doc: fixup bgpd.rst
[mirror_frr.git] / doc / user / bgp.rst
1 .. _BGP:
2
3 ***
4 BGP
5 ***
6
7 :abbr:`BGP` stands for a Border Gateway Protocol. The lastest BGP version is 4.
8 It is referred as BGP-4. BGP-4 is one of the Exterior Gateway Protocols and
9 de-fact standard of Inter Domain routing protocol. BGP-4 is described in
10 :t:`RFC1771, A Border Gateway Protocol 4 (BGP-4)`.
11
12 Many extensions have been added to :t:`RFC1771`. :t:`RFC2858, Multiprotocol
13 Extensions for BGP-4` provides multiprotocol support to BGP-4.
14
15 .. _Starting_BGP:
16
17 Starting BGP
18 ============
19
20 Default configuration file of *bgpd* is :file:`bgpd.conf`.
21 *bgpd* searches the current directory first then
22 |INSTALL_PREFIX_ETC|/bgpd.conf. All of bgpd's command must be
23 configured in :file:`bgpd.conf`.
24
25 *bgpd* specific invocation options are described below. Common
26 options may also be specified (:ref:`Common_Invocation_Options`).
27
28
29
30 *-p `PORT`*
31
32 *--bgp_port=`PORT`*
33 Set the bgp protocol's port number.
34
35
36 *-r*
37
38 *--retain*
39 When program terminates, retain BGP routes added by zebra.
40
41
42 *-l*
43
44 *--listenon*
45 Specify a specific IP address for bgpd to listen on, rather than its
46 default of INADDR_ANY / IN6ADDR_ANY. This can be useful to constrain bgpd
47 to an internal address, or to run multiple bgpd processes on one host.
48
49
50 .. _BGP_router:
51
52 BGP router
53 ==========
54
55 First of all you must configure BGP router with *router bgp*
56 command. To configure BGP router, you need AS number. AS number is an
57 identification of autonomous system. BGP protocol uses the AS number
58 for detecting whether the BGP connection is internal one or external one.
59
60 .. index:: router bgp ASN
61
62 ``router bgp ASN``
63 Enable a BGP protocol process with the specified `asn`. After
64 this statement you can input any `BGP Commands`. You can not
65 create different BGP process under different `asn` without
66 specifying `multiple-instance` (:ref:`Multiple_instance`).
67
68 .. index:: no router bgp ASN
69
70 ``no router bgp ASN``
71 Destroy a BGP protocol process with the specified `asn`.
72
73 .. index:: bgp router-id `A.B.C.D`
74
75 ``bgp router-id `A.B.C.D```
76
77 This command specifies the router-ID. If *bgpd* connects to *zebra* it gets
78 interface and address information. In that case default router ID value
79 is selected as the largest IP Address of the interfaces. When
80 `router zebra` is not enabled *bgpd* can't get interface information
81 so `router-id` is set to 0.0.0.0. So please set router-id by hand.
82
83 .. _BGP_distance:
84
85 BGP distance
86 ------------
87
88 .. index:: distance bgp <1-255> <1-255> <1-255>
89
90 ``distance bgp <1-255> <1-255> <1-255>``
91
92 This command change distance value of BGP. Each argument is distance
93 value for external routes, internal routes and local routes.
94
95 .. index:: distance <1-255> `A.B.C.D/M`
96
97 ``distance <1-255> `A.B.C.D/M```
98
99 .. index:: distance <1-255> `A.B.C.D/M` `word`
100
101 ``distance <1-255> `A.B.C.D/M` `word```
102
103 This command set distance value to
104
105 .. _BGP_decision_process:
106
107 BGP decision process
108 --------------------
109
110 The decision process Frr BGP uses to select routes is as follows:
111
112
113
114 *1. Weight check*
115 prefer higher local weight routes to lower routes.
116
117
118 *2. Local preference check*
119 prefer higher local preference routes to lower.
120
121
122 *3. Local route check*
123 Prefer local routes (statics, aggregates, redistributed) to received routes.
124
125
126 *4. AS path length check*
127 Prefer shortest hop-count AS_PATHs.
128
129
130 *5. Origin check*
131 Prefer the lowest origin type route. That is, prefer IGP origin routes to
132 EGP, to Incomplete routes.
133
134
135 *6. MED check*
136 Where routes with a MED were received from the same AS,
137 prefer the route with the lowest MED. :ref:`BGP_MED`.
138
139
140 *7. External check*
141 Prefer the route received from an external, eBGP peer
142 over routes received from other types of peers.
143
144
145 *8. IGP cost check*
146 Prefer the route with the lower IGP cost.
147
148
149 *9. Multi-path check*
150 If multi-pathing is enabled, then check whether
151 the routes not yet distinguished in preference may be considered equal. If
152 :ref:`bgp_bestpath_as-path_multipath-relax` is set, all such routes are
153 considered equal, otherwise routes received via iBGP with identical AS_PATHs
154 or routes received from eBGP neighbours in the same AS are considered equal.
155
156
157 *10 Already-selected external check*
158 Where both routes were received from eBGP peers, then prefer the route which
159 is already selected. Note that this check is not applied if :ref:`bgp_bestpath_compare-routerid` is configured. This check can prevent some cases
160 of oscillation.
161
162
163 *11. Router-ID check*
164 Prefer the route with the lowest `router-ID`. If the
165 route has an `ORIGINATOR_ID` attribute, through iBGP reflection, then that
166 router ID is used, otherwise the `router-ID` of the peer the route was
167 received from is used.
168
169
170 *12. Cluster-List length check*
171 The route with the shortest cluster-list
172 length is used. The cluster-list reflects the iBGP reflection path the
173 route has taken.
174
175
176 *13. Peer address*
177 Prefer the route received from the peer with the higher
178 transport layer address, as a last-resort tie-breaker.
179
180
181 .. index:: bgp bestpath as-path confed
182
183 ``bgp bestpath as-path confed``
184
185 This command specifies that the length of confederation path sets and
186 sequences should should be taken into account during the BGP best path
187 decision process.
188
189 .. index:: bgp bestpath as-path multipath-relax
190
191 ``bgp bestpath as-path multipath-relax``
192
193 .. _bgp_bestpath_as-path_multipath-relax:
194
195 This command specifies that BGP decision process should consider paths
196 of equal AS_PATH length candidates for multipath computation. Without
197 the knob, the entire AS_PATH must match for multipath computation.
198
199 .. index:: bgp bestpath compare-routerid
200
201 ``bgp bestpath compare-routerid``
202
203 .. _bgp_bestpath_compare-routerid:
204
205 Ensure that when comparing routes where both are equal on most metrics,
206 including local-pref, AS_PATH length, IGP cost, MED, that the tie is broken
207 based on router-ID.
208
209 If this option is enabled, then the already-selected check, where
210 already selected eBGP routes are preferred, is skipped.
211
212 If a route has an `ORIGINATOR_ID` attribute because it has been reflected,
213 that `ORIGINATOR_ID` will be used. Otherwise, the router-ID of the peer the
214 route was received from will be used.
215
216 The advantage of this is that the route-selection (at this point) will be
217 more deterministic. The disadvantage is that a few or even one lowest-ID
218 router may attract all trafic to otherwise-equal paths because of this
219 check. It may increase the possibility of MED or IGP oscillation, unless
220 other measures were taken to avoid these. The exact behaviour will be
221 sensitive to the iBGP and reflection topology.
222
223
224 .. _BGP_route_flap_dampening:
225
226 BGP route flap dampening
227 ------------------------
228
229 .. index:: bgp dampening `<1-45>` `<1-20000>` `<1-20000>` `<1-255>`
230
231 ``bgp dampening `<1-45>` `<1-20000>` `<1-20000>` `<1-255>```
232
233 This command enables BGP route-flap dampening and specifies dampening parameters.
234
235
236
237 *@asis{half-life}*
238 Half-life time for the penalty
239
240 *@asis{reuse-threshold}*
241 Value to start reusing a route
242
243 *@asis{suppress-threshold}*
244 Value to start suppressing a route
245
246 *@asis{max-suppress}*
247 Maximum duration to suppress a stable route
248
249 The route-flap damping algorithm is compatible with :t:`RFC2439`. The use of this command
250 is not recommended nowadays, see `http://www.ripe.net/ripe/docs/ripe-378,,RIPE-378 <http://www.ripe.net/ripe/docs/ripe-378,,RIPE-378>`_.
251
252 .. _BGP_MED:
253
254 BGP MED
255 =======
256
257 The BGP MED (Multi_Exit_Discriminator) attribute has properties which can
258 cause subtle convergence problems in BGP. These properties and problems
259 have proven to be hard to understand, at least historically, and may still
260 not be widely understood. The following attempts to collect together and
261 present what is known about MED, to help operators and Frr users in
262 designing and configuring their networks.
263
264 The BGP :abbr:`MED ( Multi_Exit_Discriminator)` attribute is intended to
265 allow one AS to indicate its preferences for its ingress points to another
266 AS. The MED attribute will not be propagated on to another AS by the
267 receiving AS - it is 'non-transitive' in the BGP sense.
268
269 E.g., if AS X and AS Y have 2 different BGP peering points, then AS X
270 might set a MED of 100 on routes advertised at one and a MED of 200 at the
271 other. When AS Y selects between otherwise equal routes to or via
272 AS X, AS Y should prefer to take the path via the lower MED peering of 100 with
273 AS X. Setting the MED allows an AS to influence the routing taken to it
274 within another, neighbouring AS.
275
276 In this use of MED it is not really meaningful to compare the MED value on
277 routes where the next AS on the paths differs. E.g., if AS Y also had a
278 route for some destination via AS Z in addition to the routes from AS X, and
279 AS Z had also set a MED, it wouldn't make sense for AS Y to compare AS Z's
280 MED values to those of AS X. The MED values have been set by different
281 administrators, with different frames of reference.
282
283 The default behaviour of BGP therefore is to not compare MED values across
284 routes received from different neighbouring ASes. In Frr this is done by
285 comparing the neighbouring, left-most AS in the received AS_PATHs of the
286 routes and only comparing MED if those are the same.
287
288 @ifnottex
289 @macro mprec{}
290 @math{<}
291 @end macro
292 @end ifnottex
293
294 Unfortunately, this behaviour of MED, of sometimes being compared across
295 routes and sometimes not, depending on the properties of those other routes,
296 means MED can cause the order of preference over all the routes to be
297 undefined. That is, given routes A, B, and C, if A is preferred to B, and B
298 is preferred to C, then a well-defined order should mean the preference is
299 transitive (in the sense of orders @footnote{For some set of objects to have
300 an order, there *must* be some binary ordering relation that is defined
301 for *every* combination of those objects, and that relation *must*
302 be transitive. I.e.@:, if the relation operator is @mprec{}, and if
303 a @mprec{} b and b @mprec{} c then that relation must carry over
304 and it *must* be that a @mprec{} c for the objects to have an
305 order. The ordering relation may allow for equality, i.e.
306 a @mprec{} b and b @mprec{} a may both be true amd imply that
307 a and b are equal in the order and not distinguished by it, in
308 which case the set has a partial order. Otherwise, if there is an order,
309 all the objects have a distinct place in the order and the set has a total
310 order.}) and that A would be preferred to C.
311
312 However, when MED is involved this need not be the case. With MED it is
313 possible that C is actually preferred over A. So A is preferred to B, B is
314 preferred to C, but C is preferred to A. This can be true even where BGP
315 defines a deterministic 'most preferred' route out of the full set of
316 A,B,C. With MED, for any given set of routes there may be a
317 deterministically preferred route, but there need not be any way to arrange
318 them into any order of preference. With unmodified MED, the order of
319 preference of routes literally becomes undefined.
320
321 That MED can induce non-transitive preferences over routes can cause issues.
322 Firstly, it may be perceived to cause routing table churn locally at
323 speakers; secondly, and more seriously, it may cause routing instability in
324 iBGP topologies, where sets of speakers continually oscillate between
325 different paths.
326
327 The first issue arises from how speakers often implement routing decisions.
328 Though BGP defines a selection process that will deterministically select
329 the same route as best at any given speaker, even with MED, that process
330 requires evaluating all routes together. For performance and ease of
331 implementation reasons, many implementations evaluate route preferences in a
332 pair-wise fashion instead. Given there is no well-defined order when MED is
333 involved, the best route that will be chosen becomes subject to
334 implementation details, such as the order the routes are stored in. That
335 may be (locally) non-deterministic, e.g.@: it may be the order the routes
336 were received in.
337
338 This indeterminism may be considered undesirable, though it need not cause
339 problems. It may mean additional routing churn is perceived, as sometimes
340 more updates may be produced than at other times in reaction to some event .
341
342 This first issue can be fixed with a more deterministic route selection that
343 ensures routes are ordered by the neighbouring AS during selection.
344 :ref:`bgp_deterministic-med`. This may reduce the number of updates as
345 routes are received, and may in some cases reduce routing churn. Though, it
346 could equally deterministically produce the largest possible set of updates
347 in response to the most common sequence of received updates.
348
349 A deterministic order of evaluation tends to imply an additional overhead of
350 sorting over any set of n routes to a destination. The implementation of
351 deterministic MED in Frr scales significantly worse than most sorting
352 algorithms at present, with the number of paths to a given destination.
353 That number is often low enough to not cause any issues, but where there are
354 many paths, the deterministic comparison may quickly become increasingly
355 expensive in terms of CPU.
356
357 Deterministic local evaluation can *not* fix the second, more major,
358 issue of MED however. Which is that the non-transitive preference of routes
359 MED can cause may lead to routing instability or oscillation across multiple
360 speakers in iBGP topologies. This can occur with full-mesh iBGP, but is
361 particularly problematic in non-full-mesh iBGP topologies that further
362 reduce the routing information known to each speaker. This has primarily
363 been documented with iBGP route-reflection topologies. However, any
364 route-hiding technologies potentially could also exacerbate oscillation with
365 MED.
366
367 This second issue occurs where speakers each have only a subset of routes,
368 and there are cycles in the preferences between different combinations of
369 routes - as the undefined order of preference of MED allows - and the routes
370 are distributed in a way that causes the BGP speakers to 'chase' those
371 cycles. This can occur even if all speakers use a deterministic order of
372 evaluation in route selection.
373
374 E.g., speaker 4 in AS A might receive a route from speaker 2 in AS X, and
375 from speaker 3 in AS Y; while speaker 5 in AS A might receive that route
376 from speaker 1 in AS Y. AS Y might set a MED of 200 at speaker 1, and 100
377 at speaker 3. I.e, using ASN:ID:MED to label the speakers:
378
379 ::
380
381 /---------------\\
382 X:2------|--A:4-------A:5--|-Y:1:200
383 Y:3:100--|-/ |
384 \\---------------/
385
386
387
388 Assuming all other metrics are equal (AS_PATH, ORIGIN, 0 IGP costs), then
389 based on the RFC4271 decision process speaker 4 will choose X:2 over
390 Y:3:100, based on the lower ID of 2. Speaker 4 advertises X:2 to speaker 5.
391 Speaker 5 will continue to prefer Y:1:200 based on the ID, and advertise
392 this to speaker 4. Speaker 4 will now have the full set of routes, and the
393 Y:1:200 it receives from 5 will beat X:2, but when speaker 4 compares
394 Y:1:200 to Y:3:100 the MED check now becomes active as the ASes match, and
395 now Y:3:100 is preferred. Speaker 4 therefore now advertises Y:3:100 to 5,
396 which will also agrees that Y:3:100 is preferred to Y:1:200, and so
397 withdraws the latter route from 4. Speaker 4 now has only X:2 and Y:3:100,
398 and X:2 beats Y:3:100, and so speaker 4 implicitly updates its route to
399 speaker 5 to X:2. Speaker 5 sees that Y:1:200 beats X:2 based on the ID,
400 and advertises Y:1:200 to speaker 4, and the cycle continues.
401
402 The root cause is the lack of a clear order of preference caused by how MED
403 sometimes is and sometimes is not compared, leading to this cycle in the
404 preferences between the routes:
405
406 ::
407
408 /---> X:2 ---beats---> Y:3:100 --\\
409 | |
410 | |
411 \\---beats--- Y:1:200 <---beats---/
412
413
414
415 This particular type of oscillation in full-mesh iBGP topologies can be
416 avoided by speakers preferring already selected, external routes rather than
417 choosing to update to new a route based on a post-MED metric (e.g.
418 router-ID), at the cost of a non-deterministic selection process. Frr
419 implements this, as do many other implementations, so long as it is not
420 overridden by setting :ref:`bgp_bestpath_compare-routerid`, and see also
421 :ref:`BGP_decision_process`, .
422
423 However, more complex and insidious cycles of oscillation are possible with
424 iBGP route-reflection, which are not so easily avoided. These have been
425 documented in various places. See, e.g., @cite{McPherson, D. and Gill, V.
426 and Walton, D., "Border Gateway Protocol (BGP) Persistent Route Oscillation
427 Condition", IETF RFC3345}, and @cite{Flavel, A. and M. Roughan, "Stable
428 and flexible iBGP", ACM SIGCOMM 2009}, and @cite{Griffin, T. and G. Wilfong,
429 "On the correctness of IBGP configuration", ACM SIGCOMM 2002} for concrete
430 examples and further references.
431
432 There is as of this writing *no* known way to use MED for its original
433 purpose; *and* reduce routing information in iBGP topologies;
434 *and* be sure to avoid the instability problems of MED due the
435 non-transitive routing preferences it can induce; in general on arbitrary
436 networks.
437
438 There may be iBGP topology specific ways to reduce the instability risks,
439 even while using MED, e.g.@: by constraining the reflection topology and by
440 tuning IGP costs between route-reflector clusters, see RFC3345 for details.
441 In the near future, the Add-Path extension to BGP may also solve MED
442 oscillation while still allowing MED to be used as intended, by distributing
443 "best-paths per neighbour AS". This would be at the cost of distributing at
444 least as many routes to all speakers as a full-mesh iBGP would, if not more,
445 while also imposing similar CPU overheads as the "Deterministic MED" feature
446 at each Add-Path reflector.
447
448 More generally, the instability problems that MED can introduce on more
449 complex, non-full-mesh, iBGP topologies may be avoided either by:
450
451
452 *
453 Setting :ref:`bgp_always-compare-med`, however this allows MED to be compared
454 across values set by different neighbour ASes, which may not produce
455 coherent desirable results, of itself.
456
457 *
458 Effectively ignoring MED by setting MED to the same value (e.g.@: 0) using
459 :ref:`routemap_set_metric` on all received routes, in combination with
460 setting :ref:`bgp_always-compare-med` on all speakers. This is the simplest
461 and most performant way to avoid MED oscillation issues, where an AS is happy
462 not to allow neighbours to inject this problematic metric.
463
464
465 As MED is evaluated after the AS_PATH length check, another possible use for
466 MED is for intra-AS steering of routes with equal AS_PATH length, as an
467 extension of the last case above. As MED is evaluated before IGP metric,
468 this can allow cold-potato routing to be implemented to send traffic to
469 preferred hand-offs with neighbours, rather than the closest hand-off
470 according to the IGP metric.
471
472 Note that even if action is taken to address the MED non-transitivity
473 issues, other oscillations may still be possible. E.g., on IGP cost if
474 iBGP and IGP topologies are at cross-purposes with each other - see the
475 Flavel and Roughan paper above for an example. Hence the guideline that the
476 iBGP topology should follow the IGP topology.
477
478 .. index:: bgp deterministic-med
479
480 ``bgp deterministic-med``
481
482 .. _bgp_deterministic-med:
483
484 Carry out route-selection in way that produces deterministic answers
485 locally, even in the face of MED and the lack of a well-defined order of
486 preference it can induce on routes. Without this option the preferred route
487 with MED may be determined largely by the order that routes were received
488 in.
489
490 Setting this option will have a performance cost that may be noticeable when
491 there are many routes for each destination. Currently in Frr it is
492 implemented in a way that scales poorly as the number of routes per
493 destination increases.
494
495 The default is that this option is not set.
496
497 Note that there are other sources of indeterminism in the route selection
498 process, specifically, the preference for older and already selected routes
499 from eBGP peers, :ref:`BGP_decision_process`.
500
501 .. index:: bgp always-compare-med
502
503 ``bgp always-compare-med``
504
505 .. _bgp_always-compare-med:
506
507 Always compare the MED on routes, even when they were received from
508 different neighbouring ASes. Setting this option makes the order of
509 preference of routes more defined, and should eliminate MED induced
510 oscillations.
511
512 If using this option, it may also be desirable to use :ref:`routemap_set_metric` to set MED to 0 on routes received from external neighbours.
513
514 This option can be used, together with :ref:`routemap_set_metric` to use MED
515 as an intra-AS metric to steer equal-length AS_PATH routes to, e.g., desired
516 exit points.
517
518 .. _BGP_network:
519
520 BGP network
521 ===========
522
523
524 .. _BGP_route:
525
526 BGP route
527 ---------
528
529 .. index:: network `A.B.C.D/M`
530
531 ``network `A.B.C.D/M```
532
533 This command adds the announcement network.::
534
535 router bgp 1
536 address-family ipv4 unicast
537 network 10.0.0.0/8
538 exit-address-family
539
540 This configuration example says that network 10.0.0.0/8 will be
541 announced to all neighbors. Some vendors' routers don't advertise
542 routes if they aren't present in their IGP routing tables; `bgpd`
543 doesn't care about IGP routes when announcing its routes.
544
545 .. index:: no network `A.B.C.D/M`
546
547 ``no network `A.B.C.D/M```
548
549
550 .. _Route_Aggregation:
551
552 Route Aggregation
553 -----------------
554
555 .. index:: aggregate-address `A.B.C.D/M`
556
557 ``aggregate-address `A.B.C.D/M```
558
559 This command specifies an aggregate address.
560
561 .. index:: aggregate-address `A.B.C.D/M` as-set
562
563 ``aggregate-address `A.B.C.D/M` as-set``
564
565 This command specifies an aggregate address. Resulting routes include
566 AS set.
567
568 .. index:: aggregate-address `A.B.C.D/M` summary-only
569
570 ``aggregate-address `A.B.C.D/M` summary-only``
571
572 This command specifies an aggregate address. Aggreated routes will
573 not be announce.
574
575 .. index:: no aggregate-address `A.B.C.D/M`
576
577 ``no aggregate-address `A.B.C.D/M```
578
579
580 .. _Redistribute_to_BGP:
581
582 Redistribute to BGP
583 -------------------
584
585 .. index:: redistribute kernel
586
587 ``redistribute kernel``
588
589 Redistribute kernel route to BGP process.
590
591 .. index:: redistribute static
592
593 ``redistribute static``
594
595 Redistribute static route to BGP process.
596
597 .. index:: redistribute connected
598
599 ``redistribute connected``
600
601 Redistribute connected route to BGP process.
602
603 .. index:: redistribute rip
604
605 ``redistribute rip``
606
607 Redistribute RIP route to BGP process.
608
609 .. index:: redistribute ospf
610
611 ``redistribute ospf``
612
613 Redistribute OSPF route to BGP process.
614
615 .. index:: redistribute vpn
616
617 ``redistribute vpn``
618
619 Redistribute VNC routes to BGP process.
620
621 .. index:: update-delay `max-delay`
622
623 ``update-delay `max-delay```
624
625 .. index:: update-delay `max-delay` `establish-wait`
626
627 ``update-delay `max-delay` `establish-wait```
628
629 This feature is used to enable read-only mode on BGP process restart or when
630 BGP process is cleared using 'clear ip bgp \*'. When applicable, read-only mode
631 would begin as soon as the first peer reaches Established status and a timer
632 for max-delay seconds is started.
633
634 During this mode BGP doesn't run any best-path or generate any updates to its
635 peers. This mode continues until:
636 1. All the configured peers, except the shutdown peers, have sent explicit EOR
637 (End-Of-RIB) or an implicit-EOR. The first keep-alive after BGP has reached
638 Established is considered an implicit-EOR.
639 If the establish-wait optional value is given, then BGP will wait for
640 peers to reach established from the begining of the update-delay till the
641 establish-wait period is over, i.e. the minimum set of established peers for
642 which EOR is expected would be peers established during the establish-wait
643 window, not necessarily all the configured neighbors.
644 2. max-delay period is over.
645 On hitting any of the above two conditions, BGP resumes the decision process
646 and generates updates to its peers.
647
648 Default max-delay is 0, i.e. the feature is off by default.
649
650 .. index:: table-map `route-map-name`
651
652 ``table-map `route-map-name```
653
654 This feature is used to apply a route-map on route updates from BGP to Zebra.
655 All the applicable match operations are allowed, such as match on prefix,
656 next-hop, communities, etc. Set operations for this attach-point are limited
657 to metric and next-hop only. Any operation of this feature does not affect
658 BGPs internal RIB.
659
660 Supported for ipv4 and ipv6 address families. It works on multi-paths as well,
661 however, metric setting is based on the best-path only.
662
663 .. _BGP_Peer:
664
665 BGP Peer
666 ========
667
668
669 .. _Defining_Peer:
670
671 Defining Peer
672 -------------
673
674 .. index:: neighbor `peer` remote-as `asn`
675
676 ``neighbor `peer` remote-as `asn```
677
678 Creates a new neighbor whose remote-as is `asn`. `peer`
679 can be an IPv4 address or an IPv6 address.::
680
681 router bgp 1
682 neighbor 10.0.0.1 remote-as 2
683
684 In this case my router, in AS-1, is trying to peer with AS-2 at
685 10.0.0.1.
686
687 This command must be the first command used when configuring a neighbor.
688 If the remote-as is not specified, *bgpd* will complain like this:::
689
690 can't find neighbor 10.0.0.1
691
692
693 .. _BGP_Peer_commands:
694
695 BGP Peer commands
696 -----------------
697
698 In a `router bgp` clause there are neighbor specific configurations
699 required.
700
701 .. index:: neighbor `peer` shutdown
702
703 ``neighbor `peer` shutdown``
704
705 .. index:: no neighbor `peer` shutdown
706
707 ``no neighbor `peer` shutdown``
708
709 Shutdown the peer. We can delete the neighbor's configuration by
710 `no neighbor `peer` remote-as @var{as-number`} but all
711 configuration of the neighbor will be deleted. When you want to
712 preserve the configuration, but want to drop the BGP peer, use this
713 syntax.
714
715 .. index:: neighbor `peer` ebgp-multihop
716
717 ``neighbor `peer` ebgp-multihop``
718
719 .. index:: no neighbor `peer` ebgp-multihop
720
721 ``no neighbor `peer` ebgp-multihop``
722
723 .. index:: neighbor `peer` description ...
724
725 ``neighbor `peer` description ...``
726
727 .. index:: no neighbor `peer` description ...
728
729 ``no neighbor `peer` description ...``
730
731 Set description of the peer.
732
733 .. index:: neighbor `peer` version `version`
734
735 ``neighbor `peer` version `version```
736
737 Set up the neighbor's BGP version. `version` can be `4`,
738 `4+` or `4-`. BGP version `4` is the default value used for
739 BGP peering. BGP version `4+` means that the neighbor supports
740 Multiprotocol Extensions for BGP-4. BGP version `4-` is similar but
741 the neighbor speaks the old Internet-Draft revision 00's Multiprotocol
742 Extensions for BGP-4. Some routing software is still using this
743 version.
744
745 .. index:: neighbor `peer` interface `ifname`
746
747 ``neighbor `peer` interface `ifname```
748
749 .. index:: no neighbor `peer` interface `ifname`
750
751 ``no neighbor `peer` interface `ifname```
752
753 When you connect to a BGP peer over an IPv6 link-local address, you
754 have to specify the `ifname` of the interface used for the
755 connection. To specify IPv4 session addresses, see the
756 `neighbor `peer` update-source` command below.
757
758 This command is deprecated and may be removed in a future release. Its
759 use should be avoided.
760
761 .. index:: neighbor `peer` next-hop-self [all]
762
763 ``neighbor `peer` next-hop-self [all]``
764
765 .. index:: no neighbor `peer` next-hop-self [all]
766
767 ``no neighbor `peer` next-hop-self [all]``
768
769 This command specifies an announced route's nexthop as being equivalent
770 to the address of the bgp router if it is learned via eBGP.
771 If the optional keyword `all` is specified the modifiation is done
772 also for routes learned via iBGP.
773
774 .. index:: neighbor `peer` update-source `<ifname|address>`
775
776 ``neighbor `peer` update-source `<ifname|address>```
777
778 .. index:: no neighbor `peer` update-source
779
780 ``no neighbor `peer` update-source``
781
782 Specify the IPv4 source address to use for the :abbr:`BGP` session to this
783 neighbour, may be specified as either an IPv4 address directly or
784 as an interface name (in which case the *zebra* daemon MUST be running
785 in order for *bgpd* to be able to retrieve interface state).::
786
787 router bgp 64555
788 neighbor foo update-source 192.168.0.1
789 neighbor bar update-source lo0
790
791
792 .. index:: neighbor `peer` default-originate
793
794 ``neighbor `peer` default-originate``
795
796 .. index:: no neighbor `peer` default-originate
797
798 ``no neighbor `peer` default-originate``
799
800 *bgpd*'s default is to not announce the default route (0.0.0.0/0) even it
801 is in routing table. When you want to announce default routes to the
802 peer, use this command.
803
804 .. index:: neighbor `peer` port `port`
805
806 ``neighbor `peer` port `port```
807
808 .. index:: neighbor `peer` port `port`
809
810 ``neighbor `peer` port `port```
811
812 .. index:: neighbor `peer` send-community
813
814 ``neighbor `peer` send-community``
815
816 .. index:: neighbor `peer` send-community
817
818 ``neighbor `peer` send-community``
819
820 .. index:: neighbor `peer` weight `weight`
821
822 ``neighbor `peer` weight `weight```
823
824 .. index:: no neighbor `peer` weight `weight`
825
826 ``no neighbor `peer` weight `weight```
827
828 This command specifies a default `weight` value for the neighbor's
829 routes.
830
831 .. index:: neighbor `peer` maximum-prefix `number`
832
833 ``neighbor `peer` maximum-prefix `number```
834
835 .. index:: no neighbor `peer` maximum-prefix `number`
836
837 ``no neighbor `peer` maximum-prefix `number```
838
839 .. index:: neighbor `peer` local-as `as-number`
840
841 ``neighbor `peer` local-as `as-number```
842
843 .. index:: neighbor `peer` local-as `as-number` no-prepend
844
845 ``neighbor `peer` local-as `as-number` no-prepend``
846
847 .. index:: neighbor `peer` local-as `as-number` no-prepend replace-as
848
849 ``neighbor `peer` local-as `as-number` no-prepend replace-as``
850
851 .. index:: no neighbor `peer` local-as
852
853 ``no neighbor `peer` local-as``
854
855 Specify an alternate AS for this BGP process when interacting with the
856 specified peer. With no modifiers, the specified local-as is prepended to
857 the received AS_PATH when receiving routing updates from the peer, and
858 prepended to the outgoing AS_PATH (after the process local AS) when
859 transmitting local routes to the peer.
860
861 If the no-prepend attribute is specified, then the supplied local-as is not
862 prepended to the received AS_PATH.
863
864 If the replace-as attribute is specified, then only the supplied local-as is
865 prepended to the AS_PATH when transmitting local-route updates to this peer.
866
867 Note that replace-as can only be specified if no-prepend is.
868
869 This command is only allowed for eBGP peers.
870
871 .. index:: neighbor `peer` ttl-security hops `number`
872
873 ``neighbor `peer` ttl-security hops `number```
874
875 .. index:: no neighbor `peer` ttl-security hops `number`
876
877 ``no neighbor `peer` ttl-security hops `number```
878
879 This command enforces Generalized TTL Security Mechanism (GTSM), as
880 specified in RFC 5082. With this command, only neighbors that are the
881 specified number of hops away will be allowed to become neighbors. This
882 command is mututally exclusive with *ebgp-multihop*.
883
884 .. _Peer_filtering:
885
886 Peer filtering
887 --------------
888
889 .. index:: neighbor `peer` distribute-list `name` [in|out]
890
891 ``neighbor `peer` distribute-list `name` [in|out]``
892
893 This command specifies a distribute-list for the peer. `direct` is
894 @samp{in} or @samp{out}.
895
896 .. index:: neighbor PEER prefix-list NAME [in|out]
897
898 ``neighbor PEER prefix-list NAME [in|out]``
899 .. index:: neighbor PEER filter-list NAME [in|out]
900
901 ``neighbor PEER filter-list NAME [in|out]``
902 .. index:: neighbor `peer` route-map `name` [in|out]
903
904 ``neighbor `peer` route-map `name` [in|out]``
905
906 Apply a route-map on the neighbor. `direct` must be `in` or
907 `out`.
908
909 .. index:: bgp route-reflector allow-outbound-policy
910
911 ``bgp route-reflector allow-outbound-policy``
912
913 By default, attribute modification via route-map policy out is not reflected
914 on reflected routes. This option allows the modifications to be reflected as
915 well. Once enabled, it affects all reflected routes.
916
917 .. _BGP_Peer_Group:
918
919 BGP Peer Group
920 ==============
921
922 .. index:: neighbor `word` peer-group
923
924 ``neighbor `word` peer-group``
925
926 This command defines a new peer group.
927
928 .. index:: neighbor `peer` peer-group `word`
929
930 ``neighbor `peer` peer-group `word```
931
932 This command bind specific peer to peer group `word`.
933
934 .. _BGP_Address_Family:
935
936 BGP Address Family
937 ==================
938
939 Multiprotocol BGP enables BGP to carry routing information for multiple
940 Network Layer protocols. BGP supports multiple Address Family
941 Identifier (AFI), namely IPv4 and IPv6. Support is also provided for
942 multiple sets of per-AFI information via Subsequent Address Family
943 Identifiers (SAFI). In addition to unicast information, VPN information
944 :t:`RFC4364` and :t:`RFC4659`, and Encapsulation information
945 :t:`RFC5512` is supported.
946
947 .. index:: show ip bgp vpnv4 all
948
949 ``show ip bgp vpnv4 all``
950 .. index:: show ipv6 bgp vpn all
951
952 ``show ipv6 bgp vpn all``
953 Print active IPV4 or IPV6 routes advertised via the VPN SAFI.
954
955 .. index:: show ip bgp encap all
956
957 ``show ip bgp encap all``
958 .. index:: show ipv6 bgp encap all
959
960 ``show ipv6 bgp encap all``
961 Print active IPV4 or IPV6 routes advertised via the Encapsulation SAFI.
962
963 .. index:: show bgp ipv4 encap summary
964
965 ``show bgp ipv4 encap summary``
966 .. index:: show bgp ipv4 vpn summary
967
968 ``show bgp ipv4 vpn summary``
969 .. index:: show bgp ipv6 encap summary
970
971 ``show bgp ipv6 encap summary``
972 .. index:: show bgp ipv6 vpn summary
973
974 ``show bgp ipv6 vpn summary``
975 Print a summary of neighbor connections for the specified AFI/SAFI combination.
976
977 .. _Autonomous_System:
978
979 Autonomous System
980 =================
981
982 The :abbr:`AS (Autonomous System)` number is one of the essential
983 element of BGP. BGP is a distance vector routing protocol, and the
984 AS-Path framework provides distance vector metric and loop detection to
985 BGP. @cite{RFC1930, Guidelines for creation, selection, and
986 registration of an Autonomous System (AS)} provides some background on
987 the concepts of an AS.
988
989 The AS number is a two octet value, ranging in value from 1 to 65535.
990 The AS numbers 64512 through 65535 are defined as private AS numbers.
991 Private AS numbers must not to be advertised in the global Internet.
992
993 .. _Display_BGP_Routes_by_AS_Path:
994
995 Display BGP Routes by AS Path
996 -----------------------------
997
998 To show BGP routes which has specific AS path information `show ip bgp` command can be used.
999
1000 .. index:: show bgp ipv4|ipv6 regexp LINE
1001
1002 ``show bgp ipv4|ipv6 regexp LINE``
1003 This commands displays BGP routes that matches a regular
1004 expression `line` (:ref:`BGP_Regular_Expressions`).
1005
1006 .. _AS_Path_Access_List:
1007
1008 AS Path Access List
1009 -------------------
1010
1011 AS path access list is user defined AS path.
1012
1013 .. index:: ip as-path access-list WORD permit|deny LINE
1014
1015 ``ip as-path access-list WORD permit|deny LINE``
1016 This command defines a new AS path access list.
1017
1018 .. index:: no ip as-path access-list WORD
1019
1020 ``no ip as-path access-list WORD``
1021 .. index:: no ip as-path access-list WORD permit|deny LINE
1022
1023 ``no ip as-path access-list WORD permit|deny LINE``
1024
1025 .. _Using_AS_Path_in_Route_Map:
1026
1027 Using AS Path in Route Map
1028 --------------------------
1029
1030 .. index:: match as-path WORD
1031
1032 ``match as-path WORD``
1033
1034 .. index:: set as-path prepend AS-PATH
1035
1036 ``set as-path prepend AS-PATH``
1037 Prepend the given string of AS numbers to the AS_PATH.
1038
1039 .. index:: set as-path prepend last-as NUM
1040
1041 ``set as-path prepend last-as NUM``
1042 Prepend the existing last AS number (the leftmost ASN) to the AS_PATH.
1043
1044 .. _Private_AS_Numbers:
1045
1046 Private AS Numbers
1047 ------------------
1048
1049
1050 .. _BGP_Communities_Attribute:
1051
1052 BGP Communities Attribute
1053 =========================
1054
1055 BGP communities attribute is widely used for implementing policy
1056 routing. Network operators can manipulate BGP communities attribute
1057 based on their network policy. BGP communities attribute is defined
1058 in :t:`RFC1997, BGP Communities Attribute` and
1059 @cite{RFC1998, An Application of the BGP Community Attribute
1060 in Multi-home Routing}. It is an optional transitive attribute,
1061 therefore local policy can travel through different autonomous system.
1062
1063 Communities attribute is a set of communities values. Each
1064 communities value is 4 octet long. The following format is used to
1065 define communities value.
1066
1067
1068
1069 *AS:VAL*
1070 This format represents 4 octet communities value. `AS` is high
1071 order 2 octet in digit format. `VAL` is low order 2 octet in
1072 digit format. This format is useful to define AS oriented policy
1073 value. For example, `7675:80` can be used when AS 7675 wants to
1074 pass local policy value 80 to neighboring peer.
1075
1076 *internet*
1077 `internet` represents well-known communities value 0.
1078
1079 *no-export*
1080 ``no-export`` represents well-known communities value ``NO_EXPORT`` @\*
1081 @r{(0xFFFFFF01)}. All routes carry this value must not be advertised
1082 to outside a BGP confederation boundary. If neighboring BGP peer is
1083 part of BGP confederation, the peer is considered as inside a BGP
1084 confederation boundary, so the route will be announced to the peer.
1085
1086 *no-advertise*
1087 ``no-advertise`` represents well-known communities value
1088 ``NO_ADVERTISE`` @*@r{(0xFFFFFF02)}. All routes carry this value
1089 must not be advertise to other BGP peers.
1090
1091 *local-AS*
1092 ``local-AS`` represents well-known communities value
1093 ``NO_EXPORT_SUBCONFED`` @r{(0xFFFFFF03)}. All routes carry this
1094 value must not be advertised to external BGP peers. Even if the
1095 neighboring router is part of confederation, it is considered as
1096 external BGP peer, so the route will not be announced to the peer.
1097
1098 When BGP communities attribute is received, duplicated communities
1099 value in the communities attribute is ignored and each communities
1100 values are sorted in numerical order.
1101
1102 .. _BGP_Community_Lists:
1103
1104 BGP Community Lists
1105 -------------------
1106
1107 BGP community list is a user defined BGP communites attribute list.
1108 BGP community list can be used for matching or manipulating BGP
1109 communities attribute in updates.
1110
1111 There are two types of community list. One is standard community
1112 list and another is expanded community list. Standard community list
1113 defines communities attribute. Expanded community list defines
1114 communities attribute string with regular expression. Standard
1115 community list is compiled into binary format when user define it.
1116 Standard community list will be directly compared to BGP communities
1117 attribute in BGP updates. Therefore the comparison is faster than
1118 expanded community list.
1119
1120 .. index:: ip community-list standard NAME permit|deny COMMUNITY
1121
1122 ``ip community-list standard NAME permit|deny COMMUNITY``
1123 This command defines a new standard community list. `community`
1124 is communities value. The `community` is compiled into community
1125 structure. We can define multiple community list under same name. In
1126 that case match will happen user defined order. Once the
1127 community list matches to communities attribute in BGP updates it
1128 return permit or deny by the community list definition. When there is
1129 no matched entry, deny will be returned. When `community` is
1130 empty it matches to any routes.
1131
1132 .. index:: ip community-list expanded NAME permit|deny LINE
1133
1134 ``ip community-list expanded NAME permit|deny LINE``
1135 This command defines a new expanded community list. `line` is a
1136 string expression of communities attribute. `line` can be a
1137 regular expression (:ref:`BGP_Regular_Expressions`) to match
1138 the communities attribute in BGP updates.
1139
1140 .. index:: no ip community-list NAME
1141
1142 ``no ip community-list NAME``
1143 .. index:: no ip community-list standard NAME
1144
1145 ``no ip community-list standard NAME``
1146 .. index:: no ip community-list expanded NAME
1147
1148 ``no ip community-list expanded NAME``
1149 These commands delete community lists specified by `name`. All of
1150 community lists shares a single name space. So community lists can be
1151 removed simpley specifying community lists name.
1152
1153 .. index:: show ip community-list
1154
1155 ``show ip community-list``
1156 .. index:: show ip community-list NAME
1157
1158 ``show ip community-list NAME``
1159 This command displays current community list information. When
1160 `name` is specified the specified community list's information is
1161 shown.
1162
1163 ::
1164
1165 # show ip community-list
1166 Named Community standard list CLIST
1167 permit 7675:80 7675:100 no-export
1168 deny internet
1169 Named Community expanded list EXPAND
1170 permit :
1171
1172 # show ip community-list CLIST
1173 Named Community standard list CLIST
1174 permit 7675:80 7675:100 no-export
1175 deny internet
1176
1177
1178 .. _Numbered_BGP_Community_Lists:
1179
1180 Numbered BGP Community Lists
1181 ----------------------------
1182
1183 When number is used for BGP community list name, the number has
1184 special meanings. Community list number in the range from 1 and 99 is
1185 standard community list. Community list number in the range from 100
1186 to 199 is expanded community list. These community lists are called
1187 as numbered community lists. On the other hand normal community lists
1188 is called as named community lists.
1189
1190 .. index:: ip community-list <1-99> permit|deny COMMUNITY
1191
1192 ``ip community-list <1-99> permit|deny COMMUNITY``
1193 This command defines a new community list. <1-99> is standard
1194 community list number. Community list name within this range defines
1195 standard community list. When `community` is empty it matches to
1196 any routes.
1197
1198 .. index:: ip community-list <100-199> permit|deny COMMUNITY
1199
1200 ``ip community-list <100-199> permit|deny COMMUNITY``
1201 This command defines a new community list. <100-199> is expanded
1202 community list number. Community list name within this range defines
1203 expanded community list.
1204
1205 .. index:: ip community-list NAME permit|deny COMMUNITY
1206
1207 ``ip community-list NAME permit|deny COMMUNITY``
1208 When community list type is not specifed, the community list type is
1209 automatically detected. If `community` can be compiled into
1210 communities attribute, the community list is defined as a standard
1211 community list. Otherwise it is defined as an expanded community
1212 list. This feature is left for backward compability. Use of this
1213 feature is not recommended.
1214
1215 .. _BGP_Community_in_Route_Map:
1216
1217 BGP Community in Route Map
1218 --------------------------
1219
1220 In Route Map (:ref:`Route_Map`), we can match or set BGP
1221 communities attribute. Using this feature network operator can
1222 implement their network policy based on BGP communities attribute.
1223
1224 Following commands can be used in Route Map.
1225
1226 .. index:: match community WORD
1227
1228 ``match community WORD``
1229 .. index:: match community WORD exact-match
1230
1231 ``match community WORD exact-match``
1232 This command perform match to BGP updates using community list
1233 `word`. When the one of BGP communities value match to the one of
1234 communities value in community list, it is match. When
1235 `exact-match` keyword is spcified, match happen only when BGP
1236 updates have completely same communities value specified in the
1237 community list.
1238
1239 .. index:: set community none
1240
1241 ``set community none``
1242 .. index:: set community COMMUNITY
1243
1244 ``set community COMMUNITY``
1245 .. index:: set community COMMUNITY additive
1246
1247 ``set community COMMUNITY additive``
1248 This command manipulate communities value in BGP updates. When
1249 `none` is specified as communities value, it removes entire
1250 communities attribute from BGP updates. When `community` is not
1251 `none`, specified communities value is set to BGP updates. If
1252 BGP updates already has BGP communities value, the existing BGP
1253 communities value is replaced with specified `community` value.
1254 When `additive` keyword is specified, `community` is appended
1255 to the existing communities value.
1256
1257 .. index:: set comm-list WORD delete
1258
1259 ``set comm-list WORD delete``
1260 This command remove communities value from BGP communities attribute.
1261 The `word` is community list name. When BGP route's communities
1262 value matches to the community list `word`, the communities value
1263 is removed. When all of communities value is removed eventually, the
1264 BGP update's communities attribute is completely removed.
1265
1266 .. _Display_BGP_Routes_by_Community:
1267
1268 Display BGP Routes by Community
1269 -------------------------------
1270
1271 To show BGP routes which has specific BGP communities attribute,
1272 `show bgp {ipv4|ipv6}` command can be used. The
1273 `community` and `community-list` subcommand can be used.
1274
1275 .. index:: show bgp ipv4|ipv6 community
1276
1277 ``show bgp ipv4|ipv6 community``
1278 .. index:: show bgp ipv4|ipv6 community COMMUNITY
1279
1280 ``show bgp ipv4|ipv6 community COMMUNITY``
1281 .. index:: show bgp ipv4|ipv6 community COMMUNITY exact-match
1282
1283 ``show bgp ipv4|ipv6 community COMMUNITY exact-match``
1284 `show bgp {ipv4|ipv6} community` displays BGP routes which has communities
1285 attribute. Where the address family can be IPv4 or IPv6 among others. When
1286 `community` is specified, BGP routes that matches `community` value is
1287 displayed. For this command, `internet` keyword can't be used for
1288 `community` value. When `exact-match` is specified, it display only
1289 routes that have an exact match.
1290
1291 .. index:: show bgp ipv4|ipv6 community-list WORD
1292
1293 ``show bgp ipv4|ipv6 community-list WORD``
1294 .. index:: show bgp ipv4|ipv6 community-list WORD exact-match
1295
1296 ``show bgp ipv4|ipv6 community-list WORD exact-match``
1297 This commands display BGP routes for the address family specified that matches
1298 community list `word`. When `exact-match` is specified, display only
1299 routes that have an exact match.
1300
1301 .. _Using_BGP_Communities_Attribute:
1302
1303 Using BGP Communities Attribute
1304 -------------------------------
1305
1306 Following configuration is the most typical usage of BGP communities
1307 attribute. AS 7675 provides upstream Internet connection to AS 100.
1308 When following configuration exists in AS 7675, AS 100 networks
1309 operator can set local preference in AS 7675 network by setting BGP
1310 communities attribute to the updates.
1311
1312 ::
1313
1314 router bgp 7675
1315 neighbor 192.168.0.1 remote-as 100
1316 address-family ipv4 unicast
1317 neighbor 192.168.0.1 route-map RMAP in
1318 exit-address-family
1319 !
1320 ip community-list 70 permit 7675:70
1321 ip community-list 70 deny
1322 ip community-list 80 permit 7675:80
1323 ip community-list 80 deny
1324 ip community-list 90 permit 7675:90
1325 ip community-list 90 deny
1326 !
1327 route-map RMAP permit 10
1328 match community 70
1329 set local-preference 70
1330 !
1331 route-map RMAP permit 20
1332 match community 80
1333 set local-preference 80
1334 !
1335 route-map RMAP permit 30
1336 match community 90
1337 set local-preference 90
1338
1339
1340 Following configuration announce 10.0.0.0/8 from AS 100 to AS 7675.
1341 The route has communities value 7675:80 so when above configuration
1342 exists in AS 7675, announced route's local preference will be set to
1343 value 80.
1344
1345 ::
1346
1347 router bgp 100
1348 network 10.0.0.0/8
1349 neighbor 192.168.0.2 remote-as 7675
1350 address-family ipv4 unicast
1351 neighbor 192.168.0.2 route-map RMAP out
1352 exit-address-family
1353 !
1354 ip prefix-list PLIST permit 10.0.0.0/8
1355 !
1356 route-map RMAP permit 10
1357 match ip address prefix-list PLIST
1358 set community 7675:80
1359
1360
1361 Following configuration is an example of BGP route filtering using
1362 communities attribute. This configuration only permit BGP routes
1363 which has BGP communities value 0:80 or 0:90. Network operator can
1364 put special internal communities value at BGP border router, then
1365 limit the BGP routes announcement into the internal network.
1366
1367 ::
1368
1369 router bgp 7675
1370 neighbor 192.168.0.1 remote-as 100
1371 address-family ipv4 unicast
1372 neighbor 192.168.0.1 route-map RMAP in
1373 exit-address-family
1374 !
1375 ip community-list 1 permit 0:80 0:90
1376 !
1377 route-map RMAP permit in
1378 match community 1
1379
1380
1381 Following exmaple filter BGP routes which has communities value 1:1.
1382 When there is no match community-list returns deny. To avoid
1383 filtering all of routes, we need to define permit any at last.
1384
1385 ::
1386
1387 router bgp 7675
1388 neighbor 192.168.0.1 remote-as 100
1389 address-family ipv4 unicast
1390 neighbor 192.168.0.1 route-map RMAP in
1391 exit-address-family
1392 !
1393 ip community-list standard FILTER deny 1:1
1394 ip community-list standard FILTER permit
1395 !
1396 route-map RMAP permit 10
1397 match community FILTER
1398
1399
1400 Communities value keyword `internet` has special meanings in
1401 standard community lists. In below example `internet` act as
1402 match any. It matches all of BGP routes even if the route does not
1403 have communities attribute at all. So community list `INTERNET`
1404 is same as above example's `FILTER`.
1405
1406 ::
1407
1408 ip community-list standard INTERNET deny 1:1
1409 ip community-list standard INTERNET permit internet
1410
1411
1412 Following configuration is an example of communities value deletion.
1413 With this configuration communities value 100:1 and 100:2 is removed
1414 from BGP updates. For communities value deletion, only `permit`
1415 community-list is used. `deny` community-list is ignored.
1416
1417 ::
1418
1419 router bgp 7675
1420 neighbor 192.168.0.1 remote-as 100
1421 address-family ipv4 unicast
1422 neighbor 192.168.0.1 route-map RMAP in
1423 exit-address-family
1424 !
1425 ip community-list standard DEL permit 100:1 100:2
1426 !
1427 route-map RMAP permit 10
1428 set comm-list DEL delete
1429
1430
1431 .. _BGP_Extended_Communities_Attribute:
1432
1433 BGP Extended Communities Attribute
1434 ==================================
1435
1436 BGP extended communities attribute is introduced with MPLS VPN/BGP
1437 technology. MPLS VPN/BGP expands capability of network infrastructure
1438 to provide VPN functionality. At the same time it requires a new
1439 framework for policy routing. With BGP Extended Communities Attribute
1440 we can use Route Target or Site of Origin for implementing network
1441 policy for MPLS VPN/BGP.
1442
1443 BGP Extended Communities Attribute is similar to BGP Communities
1444 Attribute. It is an optional transitive attribute. BGP Extended
1445 Communities Attribute can carry multiple Extended Community value.
1446 Each Extended Community value is eight octet length.
1447
1448 BGP Extended Communities Attribute provides an extended range
1449 compared with BGP Communities Attribute. Adding to that there is a
1450 type field in each value to provides community space structure.
1451
1452 There are two format to define Extended Community value. One is AS
1453 based format the other is IP address based format.
1454
1455
1456
1457 *AS:VAL*
1458 This is a format to define AS based Extended Community value.
1459 `AS` part is 2 octets Global Administrator subfield in Extended
1460 Community value. `VAL` part is 4 octets Local Administrator
1461 subfield. `7675:100` represents AS 7675 policy value 100.
1462
1463 *IP-Address:VAL*
1464 This is a format to define IP address based Extended Community value.
1465 `IP-Address` part is 4 octets Global Administrator subfield.
1466 `VAL` part is 2 octets Local Administrator subfield.
1467 `10.0.0.1:100` represents
1468
1469 .. _BGP_Extended_Community_Lists:
1470
1471 BGP Extended Community Lists
1472 ----------------------------
1473
1474 Expanded Community Lists is a user defined BGP Expanded Community
1475 Lists.
1476
1477 .. index:: ip extcommunity-list standard NAME permit|deny EXTCOMMUNITY
1478
1479 ``ip extcommunity-list standard NAME permit|deny EXTCOMMUNITY``
1480 This command defines a new standard extcommunity-list.
1481 `extcommunity` is extended communities value. The
1482 `extcommunity` is compiled into extended community structure. We
1483 can define multiple extcommunity-list under same name. In that case
1484 match will happen user defined order. Once the extcommunity-list
1485 matches to extended communities attribute in BGP updates it return
1486 permit or deny based upon the extcommunity-list definition. When
1487 there is no matched entry, deny will be returned. When
1488 `extcommunity` is empty it matches to any routes.
1489
1490 .. index:: ip extcommunity-list expanded NAME permit|deny LINE
1491
1492 ``ip extcommunity-list expanded NAME permit|deny LINE``
1493 This command defines a new expanded extcommunity-list. `line` is
1494 a string expression of extended communities attribute. `line` can
1495 be a regular expression (:ref:`BGP_Regular_Expressions`) to match an
1496 extended communities attribute in BGP updates.
1497
1498 .. index:: no ip extcommunity-list NAME
1499
1500 ``no ip extcommunity-list NAME``
1501 .. index:: no ip extcommunity-list standard NAME
1502
1503 ``no ip extcommunity-list standard NAME``
1504 .. index:: no ip extcommunity-list expanded NAME
1505
1506 ``no ip extcommunity-list expanded NAME``
1507 These commands delete extended community lists specified by
1508 `name`. All of extended community lists shares a single name
1509 space. So extended community lists can be removed simpley specifying
1510 the name.
1511
1512 .. index:: show ip extcommunity-list
1513
1514 ``show ip extcommunity-list``
1515 .. index:: show ip extcommunity-list NAME
1516
1517 ``show ip extcommunity-list NAME``
1518 This command displays current extcommunity-list information. When
1519 `name` is specified the community list's information is shown.
1520
1521 ::
1522
1523 # show ip extcommunity-list
1524
1525
1526 .. _BGP_Extended_Communities_in_Route_Map:
1527
1528 BGP Extended Communities in Route Map
1529 -------------------------------------
1530
1531 .. index:: match extcommunity WORD
1532
1533 ``match extcommunity WORD``
1534
1535 .. index:: set extcommunity rt EXTCOMMUNITY
1536
1537 ``set extcommunity rt EXTCOMMUNITY``
1538 This command set Route Target value.
1539
1540 .. index:: set extcommunity soo EXTCOMMUNITY
1541
1542 ``set extcommunity soo EXTCOMMUNITY``
1543 This command set Site of Origin value.
1544
1545 .. _BGP_Large_Communities_Attribute:
1546
1547 BGP Large Communities Attribute
1548 ===============================
1549
1550 The BGP Large Communities attribute was introduced in Feb 2017 with
1551 :t:`RFC8092, BGP Large Communities Attribute`.
1552
1553 The BGP Large Communities Attribute is similar to the BGP Communities
1554 Attribute except that it has 3 components instead of two and each of
1555 which are 4 octets in length. Large Communities bring additional
1556 functionality and convenience over traditional communities, specifically
1557 the fact that the `GLOBAL` part below is now 4 octets wide allowing
1558 AS4 operators seamless use.
1559
1560
1561
1562 *GLOBAL:LOCAL1:LOCAL2*
1563 This is the format to define Large Community values. Referencing
1564 :t:`RFC8195, Use of BGP Large Communities` the values are commonly
1565 referred to as follows.
1566 The `GLOBAL` part is a 4 octet Global Administrator field, common
1567 use of this field is the operators AS number.
1568 The `LOCAL1` part is a 4 octet Local Data Part 1 subfield referred
1569 to as a function.
1570 The `LOCAL2` part is a 4 octet Local Data Part 2 field and referred
1571 to as the parameter subfield. `65551:1:10` represents AS 65551
1572 function 1 and parameter 10.
1573 The referenced RFC above gives some guidelines on recommended usage.
1574
1575 .. _BGP_Large_Community_Lists:
1576
1577 BGP Large Community Lists
1578 -------------------------
1579
1580 Two types of large community lists are supported, namely `standard` and
1581 `expanded`.
1582
1583 .. index:: ip large-community-list standard NAME permit|deny LARGE-COMMUNITY
1584
1585 ``ip large-community-list standard NAME permit|deny LARGE-COMMUNITY``
1586 This command defines a new standard large-community-list.
1587 `large-community` is the Large Community value. We
1588 can add multiple large communities under same name. In that case
1589 the match will happen in the user defined order. Once the large-community-list
1590 matches the Large Communities attribute in BGP updates it will return
1591 permit or deny based upon the large-community-list definition. When
1592 there is no matched entry, a deny will be returned. When `large-community`
1593 is empty it matches any routes.
1594
1595 .. index:: ip large-community-list expanded NAME permit|deny LINE
1596
1597 ``ip large-community-list expanded NAME permit|deny LINE``
1598 This command defines a new expanded large-community-list. Where `line` is
1599 a string matching expression, it will be compared to the entire Large Communities
1600 attribute as a string, with each large-community in order from lowest to highest.
1601 `line` can also be a regular expression which matches this Large
1602 Community attribute.
1603
1604 .. index:: no ip large-community-list NAME
1605
1606 ``no ip large-community-list NAME``
1607 .. index:: no ip large-community-list standard NAME
1608
1609 ``no ip large-community-list standard NAME``
1610 .. index:: no ip large-community-list expanded NAME
1611
1612 ``no ip large-community-list expanded NAME``
1613 These commands delete Large Community lists specified by
1614 `name`. All Large Community lists share a single namespace.
1615 This means Large Community lists can be removed by simply specifying the name.
1616
1617 .. index:: show ip large-community-list
1618
1619 ``show ip large-community-list``
1620 .. index:: show ip large-community-list NAME
1621
1622 ``show ip large-community-list NAME``
1623 This command display current large-community-list information. When
1624 `name` is specified the community list information is shown.
1625
1626 .. index:: show ip bgp large-community-info
1627
1628 ``show ip bgp large-community-info``
1629 This command displays the current large communities in use.
1630
1631 .. _BGP_Large_Communities_in_Route_Map:
1632
1633 BGP Large Communities in Route Map
1634 ----------------------------------
1635
1636 .. index:: match large-community LINE
1637
1638 ``match large-community LINE``
1639 Where `line` can be a simple string to match, or a regular expression.
1640 It is very important to note that this match occurs on the entire
1641 large-community string as a whole, where each large-community is ordered
1642 from lowest to highest.
1643
1644 .. index:: set large-community LARGE-COMMUNITY
1645
1646 ``set large-community LARGE-COMMUNITY``
1647 .. index:: set large-community LARGE-COMMUNITY LARGE-COMMUNITY
1648
1649 ``set large-community LARGE-COMMUNITY LARGE-COMMUNITY``
1650 .. index:: set large-community LARGE-COMMUNITY additive
1651
1652 ``set large-community LARGE-COMMUNITY additive``
1653 These commands are used for setting large-community values. The first
1654 command will overwrite any large-communities currently present.
1655 The second specifies two large-communities, which overwrites the current
1656 large-community list. The third will add a large-community value without
1657 overwriting other values. Multiple large-community values can be specified.
1658
1659 .. _Displaying_BGP_information:
1660
1661 Displaying BGP information
1662 ==========================
1663
1664
1665 .. _Showing_BGP_information:
1666
1667 Showing BGP information
1668 -----------------------
1669
1670 .. index:: show ip bgp
1671
1672 ``show ip bgp``
1673 .. index:: show ip bgp A.B.C.D
1674
1675 ``show ip bgp A.B.C.D``
1676 .. index:: show ip bgp X:X::X:X
1677
1678 ``show ip bgp X:X::X:X``
1679 This command displays BGP routes. When no route is specified it
1680 display all of IPv4 BGP routes.
1681
1682 ::
1683
1684 BGP table version is 0, local router ID is 10.1.1.1
1685 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
1686 Origin codes: i - IGP, e - EGP, ? - incomplete
1687
1688 Network Next Hop Metric LocPrf Weight Path
1689 *> 1.1.1.1/32 0.0.0.0 0 32768 i
1690
1691 Total number of prefixes 1
1692
1693
1694 .. index:: show ip bgp regexp LINE
1695
1696 ``show ip bgp regexp LINE``
1697 This command displays BGP routes using AS path regular expression
1698 (:ref:`BGP_Regular_Expressions`).
1699
1700 .. index:: show ip bgp community COMMUNITY
1701
1702 ``show ip bgp community COMMUNITY``
1703 .. index:: show ip bgp community COMMUNITY exact-match
1704
1705 ``show ip bgp community COMMUNITY exact-match``
1706 This command displays BGP routes using `community` (:ref:`Display_BGP_Routes_by_Community`).
1707
1708 .. index:: show ip bgp community-list WORD
1709
1710 ``show ip bgp community-list WORD``
1711 .. index:: show ip bgp community-list WORD exact-match
1712
1713 ``show ip bgp community-list WORD exact-match``
1714 This command displays BGP routes using community list (:ref:`Display_BGP_Routes_by_Community`).
1715
1716 .. index:: show bgp ipv4|ipv6 summary
1717
1718 ``show bgp ipv4|ipv6 summary``
1719 Show a bgp peer summary for the specified address family.
1720
1721 .. index:: show bgp ipv4|ipv6 neighbor [PEER]
1722
1723 ``show bgp ipv4|ipv6 neighbor [PEER]``
1724 This command shows information on a specific BGP `peer`.
1725
1726 .. index:: show bgp ipv4|ipv6 dampening dampened-paths
1727
1728 ``show bgp ipv4|ipv6 dampening dampened-paths``
1729 Display paths suppressed due to dampening.
1730
1731 .. index:: show bgp ipv4|ipv6 dampening flap-statistics
1732
1733 ``show bgp ipv4|ipv6 dampening flap-statistics``
1734 Display flap statistics of routes.
1735
1736 .. _Other_BGP_commands:
1737
1738 Other BGP commands
1739 ------------------
1740
1741 .. index:: clear bgp ipv4|ipv6 \*
1742
1743 ``clear bgp ipv4|ipv6 \*``
1744 Clear all address family peers.
1745
1746 .. index:: clear bgp ipv4|ipv6 PEER
1747
1748 ``clear bgp ipv4|ipv6 PEER``
1749 Clear peers which have addresses of X.X.X.X
1750
1751 .. index:: clear bgp ipv4|ipv6 PEER soft in
1752
1753 ``clear bgp ipv4|ipv6 PEER soft in``
1754 Clear peer using soft reconfiguration.
1755
1756 .. index:: show debug
1757
1758 ``show debug``
1759 .. index:: debug event
1760
1761 ``debug event``
1762 .. index:: debug update
1763
1764 ``debug update``
1765 .. index:: debug keepalive
1766
1767 ``debug keepalive``
1768 .. index:: no debug event
1769
1770 ``no debug event``
1771 .. index:: no debug update
1772
1773 ``no debug update``
1774 .. index:: no debug keepalive
1775
1776 ``no debug keepalive``
1777
1778 .. _Capability_Negotiation:
1779
1780 Capability Negotiation
1781 ======================
1782
1783 When adding IPv6 routing information exchange feature to BGP. There
1784 were some proposals. :abbr:`IETF (Internet Engineering Task Force)`
1785 :abbr:`IDR ( Inter Domain Routing)` :abbr:`IDR ( Inter Domain Routing)` adopted
1786 a proposal called Multiprotocol Extension for BGP. The specification
1787 is described in :t:`RFC2283`. The protocol does not define new protocols.
1788 It defines new attributes to existing BGP. When it is used exchanging
1789 IPv6 routing information it is called BGP-4+. When it is used for
1790 exchanging multicast routing information it is called MBGP.
1791
1792 *bgpd* supports Multiprotocol Extension for BGP. So if remote
1793 peer supports the protocol, *bgpd* can exchange IPv6 and/or
1794 multicast routing information.
1795
1796 Traditional BGP did not have the feature to detect remote peer's
1797 capabilities, e.g. whether it can handle prefix types other than IPv4
1798 unicast routes. This was a big problem using Multiprotocol Extension
1799 for BGP to operational network. @cite{RFC2842, Capabilities
1800 Advertisement with BGP-4} adopted a feature called Capability
1801 Negotiation. *bgpd* use this Capability Negotiation to detect
1802 the remote peer's capabilities. If the peer is only configured as IPv4
1803 unicast neighbor, *bgpd* does not send these Capability
1804 Negotiation packets (at least not unless other optional BGP features
1805 require capability negotation).
1806
1807 By default, Frr will bring up peering with minimal common capability
1808 for the both sides. For example, local router has unicast and
1809 multicast capabilitie and remote router has unicast capability. In
1810 this case, the local router will establish the connection with unicast
1811 only capability. When there are no common capabilities, Frr sends
1812 Unsupported Capability error and then resets the connection.
1813
1814 If you want to completely match capabilities with remote peer. Please
1815 use *strict-capability-match* command.
1816
1817 .. index:: neighbor `peer` strict-capability-match
1818
1819 ``neighbor `peer` strict-capability-match``
1820
1821 .. index:: no neighbor `peer` strict-capability-match
1822
1823 ``no neighbor `peer` strict-capability-match``
1824
1825 Strictly compares remote capabilities and local capabilities. If capabilities
1826 are different, send Unsupported Capability error then reset connection.
1827
1828 You may want to disable sending Capability Negotiation OPEN message
1829 optional parameter to the peer when remote peer does not implement
1830 Capability Negotiation. Please use *dont-capability-negotiate*
1831 command to disable the feature.
1832
1833 .. index:: neighbor `peer` dont-capability-negotiate
1834
1835 ``neighbor `peer` dont-capability-negotiate``
1836
1837 .. index:: no neighbor `peer` dont-capability-negotiate
1838
1839 ``no neighbor `peer` dont-capability-negotiate``
1840
1841 Suppress sending Capability Negotiation as OPEN message optional
1842 parameter to the peer. This command only affects the peer is configured
1843 other than IPv4 unicast configuration.
1844
1845 When remote peer does not have capability negotiation feature, remote
1846 peer will not send any capabilities at all. In that case, bgp
1847 configures the peer with configured capabilities.
1848
1849 You may prefer locally configured capabilities more than the negotiated
1850 capabilities even though remote peer sends capabilities. If the peer
1851 is configured by *override-capability*, *bgpd* ignores
1852 received capabilities then override negotiated capabilities with
1853 configured values.
1854
1855 .. index:: neighbor `peer` override-capability
1856
1857 ``neighbor `peer` override-capability``
1858
1859 .. index:: no neighbor `peer` override-capability
1860
1861 ``no neighbor `peer` override-capability``
1862
1863 Override the result of Capability Negotiation with local configuration.
1864 Ignore remote peer's capability value.
1865
1866 .. _Route_Reflector:
1867
1868 Route Reflector
1869 ===============
1870
1871 .. index:: bgp cluster-id `a.b.c.d`
1872
1873 ``bgp cluster-id `a.b.c.d```
1874
1875
1876 .. index:: neighbor `peer` route-reflector-client
1877
1878 ``neighbor `peer` route-reflector-client``
1879
1880 .. index:: no neighbor `peer` route-reflector-client
1881
1882 ``no neighbor `peer` route-reflector-client``
1883
1884
1885 .. _Route_Server:
1886
1887 Route Server
1888 ============
1889
1890 At an Internet Exchange point, many ISPs are connected to each other by
1891 external BGP peering. Normally these external BGP connection are done by
1892 @samp{full mesh} method. As with internal BGP full mesh formation,
1893 this method has a scaling problem.
1894
1895 This scaling problem is well known. Route Server is a method to resolve
1896 the problem. Each ISP's BGP router only peers to Route Server. Route
1897 Server serves as BGP information exchange to other BGP routers. By
1898 applying this method, numbers of BGP connections is reduced from
1899 O(n*(n-1)/2) to O(n).
1900
1901 Unlike normal BGP router, Route Server must have several routing tables
1902 for managing different routing policies for each BGP speaker. We call the
1903 routing tables as different ``view`` s. *bgpd* can work as
1904 normal BGP router or Route Server or both at the same time.
1905
1906 .. _Multiple_instance:
1907
1908 Multiple instance
1909 -----------------
1910
1911 To enable multiple view function of `bgpd`, you must turn on
1912 multiple instance feature beforehand.
1913
1914 .. index:: bgp multiple-instance
1915
1916 ``bgp multiple-instance``
1917 Enable BGP multiple instance feature. After this feature is enabled,
1918 you can make multiple BGP instances or multiple BGP views.
1919
1920 .. index:: no bgp multiple-instance
1921
1922 ``no bgp multiple-instance``
1923 Disable BGP multiple instance feature. You can not disable this feature
1924 when BGP multiple instances or views exist.
1925
1926 When you want to make configuration more Cisco like one,
1927
1928 .. index:: bgp config-type cisco
1929
1930 ``bgp config-type cisco``
1931 Cisco compatible BGP configuration output.
1932
1933 When bgp config-type cisco is specified,
1934
1935 'no synchronization' is displayed.
1936 'no auto-summary' is displayed.
1937
1938 'network' and 'aggregate-address' argument is displayed as
1939 'A.B.C.D M.M.M.M'
1940
1941 Frr: network 10.0.0.0/8
1942 Cisco: network 10.0.0.0
1943
1944 Frr: aggregate-address 192.168.0.0/24
1945 Cisco: aggregate-address 192.168.0.0 255.255.255.0
1946
1947 Community attribute handling is also different. If there is no
1948 configuration is specified community attribute and extended community
1949 attribute are sent to neighbor. When user manually disable the
1950 feature community attribute is not sent to the neighbor. In case of
1951 *bgp config-type cisco* is specified, community attribute is not
1952 sent to the neighbor by default. To send community attribute user has
1953 to specify *neighbor A.B.C.D send-community* command.
1954
1955 ::
1956
1957 !
1958 router bgp 1
1959 neighbor 10.0.0.1 remote-as 1
1960 address-family ipv4 unicast
1961 no neighbor 10.0.0.1 send-community
1962 exit-address-family
1963 !
1964 router bgp 1
1965 neighbor 10.0.0.1 remote-as 1
1966 address-family ipv4 unicast
1967 neighbor 10.0.0.1 send-community
1968 exit-address-family
1969 !
1970
1971
1972 .. index:: bgp config-type zebra
1973
1974 ``bgp config-type zebra``
1975 Frr style BGP configuration. This is default.
1976
1977 .. _BGP_instance_and_view:
1978
1979 BGP instance and view
1980 ---------------------
1981
1982 BGP instance is a normal BGP process. The result of route selection
1983 goes to the kernel routing table. You can setup different AS at the
1984 same time when BGP multiple instance feature is enabled.
1985
1986 .. index:: router bgp AS-NUMBER
1987
1988 ``router bgp AS-NUMBER``
1989 Make a new BGP instance. You can use arbitrary word for the `name`.
1990
1991 ::
1992
1993 bgp multiple-instance
1994 !
1995 router bgp 1
1996 neighbor 10.0.0.1 remote-as 2
1997 neighbor 10.0.0.2 remote-as 3
1998 !
1999 router bgp 2
2000 neighbor 10.0.0.3 remote-as 4
2001 neighbor 10.0.0.4 remote-as 5
2002
2003
2004 BGP view is almost same as normal BGP process. The result of
2005 route selection does not go to the kernel routing table. BGP view is
2006 only for exchanging BGP routing information.
2007
2008 .. index:: router bgp AS-NUMBER view NAME
2009
2010 ``router bgp AS-NUMBER view NAME``
2011 Make a new BGP view. You can use arbitrary word for the `name`. This
2012 view's route selection result does not go to the kernel routing table.
2013
2014 With this command, you can setup Route Server like below.
2015
2016 ::
2017
2018 bgp multiple-instance
2019 !
2020 router bgp 1 view 1
2021 neighbor 10.0.0.1 remote-as 2
2022 neighbor 10.0.0.2 remote-as 3
2023 !
2024 router bgp 2 view 2
2025 neighbor 10.0.0.3 remote-as 4
2026 neighbor 10.0.0.4 remote-as 5
2027
2028
2029 .. _Routing_policy:
2030
2031 Routing policy
2032 --------------
2033
2034 You can set different routing policy for a peer. For example, you can
2035 set different filter for a peer.
2036
2037 ::
2038
2039 bgp multiple-instance
2040 !
2041 router bgp 1 view 1
2042 neighbor 10.0.0.1 remote-as 2
2043 address-family ipv4 unicast
2044 neighbor 10.0.0.1 distribute-list 1 in
2045 exit-address-family
2046 !
2047 router bgp 1 view 2
2048 neighbor 10.0.0.1 remote-as 2
2049 address-family ipv4 unicast
2050 neighbor 10.0.0.1 distribute-list 2 in
2051 exit-address-family
2052
2053
2054 This means BGP update from a peer 10.0.0.1 goes to both BGP view 1 and view
2055 2. When the update is inserted into view 1, distribute-list 1 is
2056 applied. On the other hand, when the update is inserted into view 2,
2057 distribute-list 2 is applied.
2058
2059 .. _Viewing_the_view:
2060
2061 Viewing the view
2062 ----------------
2063
2064 To display routing table of BGP view, you must specify view name.
2065
2066 .. index:: show ip bgp view NAME
2067
2068 ``show ip bgp view NAME``
2069 Display routing table of BGP view `name`.
2070
2071 .. _BGP_Regular_Expressions:
2072
2073 BGP Regular Expressions
2074 =======================
2075
2076 BGP regular expressions are based on `POSIX 1003.2` regular
2077 expressions. The following description is just a quick subset of the
2078 `POSIX` regular expressions. Adding to that, the special character
2079 '_' is added.
2080
2081
2082
2083 *.*
2084 Matches any single character.
2085
2086 *
2087 Matches 0 or more occurrences of pattern.
2088
2089 +
2090 Matches 1 or more occurrences of pattern.
2091
2092 ?
2093 Match 0 or 1 occurrences of pattern.
2094
2095 ^
2096 Matches the beginning of the line.
2097
2098 $
2099 Matches the end of the line.
2100
2101 _
2102 Character `_` has special meanings in BGP regular expressions.
2103 It matches to space and comma , and AS set delimiter { and } and AS
2104 confederation delimiter `(` and `)`. And it also matches to
2105 the beginning of the line and the end of the line. So `_` can be
2106 used for AS value boundaries match. This character technically evaluates
2107 to `(^|[,{}() ]|$)`.
2108
2109 .. _How_to_set_up_a_6-Bone_connection:
2110
2111 How to set up a 6-Bone connection
2112 =================================
2113
2114 ::
2115
2116 zebra configuration
2117 ===================
2118 !
2119 ! Actually there is no need to configure zebra
2120 !
2121
2122 bgpd configuration
2123 ==================
2124 !
2125 ! This means that routes go through zebra and into the kernel.
2126 !
2127 router zebra
2128 !
2129 ! MP-BGP configuration
2130 !
2131 router bgp 7675
2132 bgp router-id 10.0.0.1
2133 neighbor 3ffe:1cfa:0:2:2a0:c9ff:fe9e:f56 remote-as `as-number`
2134 !
2135 address-family ipv6
2136 network 3ffe:506::/32
2137 neighbor 3ffe:1cfa:0:2:2a0:c9ff:fe9e:f56 activate
2138 neighbor 3ffe:1cfa:0:2:2a0:c9ff:fe9e:f56 route-map set-nexthop out
2139 neighbor 3ffe:1cfa:0:2:2c0:4fff:fe68:a231 remote-as `as-number`
2140 neighbor 3ffe:1cfa:0:2:2c0:4fff:fe68:a231 route-map set-nexthop out
2141 exit-address-family
2142 !
2143 ipv6 access-list all permit any
2144 !
2145 ! Set output nexthop address.
2146 !
2147 route-map set-nexthop permit 10
2148 match ipv6 address all
2149 set ipv6 nexthop global 3ffe:1cfa:0:2:2c0:4fff:fe68:a225
2150 set ipv6 nexthop local fe80::2c0:4fff:fe68:a225
2151 !
2152 ! logfile FILENAME is obsolete. Please use log file FILENAME
2153
2154 log file bgpd.log
2155 !
2156
2157
2158 .. _Dump_BGP_packets_and_table:
2159
2160 Dump BGP packets and table
2161 ==========================
2162
2163 .. index:: dump bgp all PATH [INTERVAL]
2164
2165 ``dump bgp all PATH [INTERVAL]``
2166 .. index:: dump bgp all-et PATH [INTERVAL]
2167
2168 ``dump bgp all-et PATH [INTERVAL]``
2169 .. index:: no dump bgp all [PATH] [INTERVAL]
2170
2171 ``no dump bgp all [PATH] [INTERVAL]``
2172 Dump all BGP packet and events to `path` file.
2173 If `interval` is set, a new file will be created for echo `interval` of seconds.
2174 The path `path` can be set with date and time formatting (strftime).
2175 The type ‘all-et’ enables support for Extended Timestamp Header (:ref:`Packet_Binary_Dump_Format`).
2176 (:ref:`Packet_Binary_Dump_Format`)
2177
2178 .. index:: dump bgp updates PATH [INTERVAL]
2179
2180 ``dump bgp updates PATH [INTERVAL]``
2181 .. index:: dump bgp updates-et PATH [INTERVAL]
2182
2183 ``dump bgp updates-et PATH [INTERVAL]``
2184 .. index:: no dump bgp updates [PATH] [INTERVAL]
2185
2186 ``no dump bgp updates [PATH] [INTERVAL]``
2187 Dump only BGP updates messages to `path` file.
2188 If `interval` is set, a new file will be created for echo `interval` of seconds.
2189 The path `path` can be set with date and time formatting (strftime).
2190 The type ‘updates-et’ enables support for Extended Timestamp Header (:ref:`Packet_Binary_Dump_Format`).
2191
2192 .. index:: dump bgp routes-mrt PATH
2193
2194 ``dump bgp routes-mrt PATH``
2195 .. index:: dump bgp routes-mrt PATH INTERVAL
2196
2197 ``dump bgp routes-mrt PATH INTERVAL``
2198 .. index:: no dump bgp route-mrt [PATH] [INTERVAL]
2199
2200 ``no dump bgp route-mrt [PATH] [INTERVAL]``
2201 Dump whole BGP routing table to `path`. This is heavy process.
2202 The path `path` can be set with date and time formatting (strftime).
2203 If `interval` is set, a new file will be created for echo `interval` of seconds.
2204
2205 Note: the interval variable can also be set using hours and minutes: 04h20m00.
2206
2207 BGP Configuration Examples
2208 ==========================
2209
2210 Example of a session to an upstream, advertising only one prefix to it.
2211
2212 ::
2213
2214 router bgp 64512
2215 bgp router-id 10.236.87.1
2216 neighbor upstream peer-group
2217 neighbor upstream remote-as 64515
2218 neighbor upstream capability dynamic
2219 neighbor 10.1.1.1 peer-group upstream
2220 neighbor 10.1.1.1 description ACME ISP
2221
2222 address-family ipv4 unicast
2223 network 10.236.87.0/24
2224 neighbor upstream prefix-list pl-allowed-adv out
2225 exit-address-family
2226 !
2227 ip prefix-list pl-allowed-adv seq 5 permit 82.195.133.0/25
2228 ip prefix-list pl-allowed-adv seq 10 deny any
2229
2230
2231
2232 A more complex example. With upstream, peer and customer sessions.
2233 Advertising global prefixes and NO_EXPORT prefixes and providing
2234 actions for customer routes based on community values. Extensive use of
2235 route-maps and the 'call' feature to support selective advertising of
2236 prefixes. This example is intended as guidance only, it has NOT been
2237 tested and almost certainly containts silly mistakes, if not serious
2238 flaws.
2239
2240 ::
2241
2242 router bgp 64512
2243 bgp router-id 10.236.87.1
2244 neighbor upstream capability dynamic
2245 neighbor cust capability dynamic
2246 neighbor peer capability dynamic
2247 neighbor 10.1.1.1 remote-as 64515
2248 neighbor 10.1.1.1 peer-group upstream
2249 neighbor 10.2.1.1 remote-as 64516
2250 neighbor 10.2.1.1 peer-group upstream
2251 neighbor 10.3.1.1 remote-as 64517
2252 neighbor 10.3.1.1 peer-group cust-default
2253 neighbor 10.3.1.1 description customer1
2254 neighbor 10.4.1.1 remote-as 64518
2255 neighbor 10.4.1.1 peer-group cust
2256 neighbor 10.4.1.1 description customer2
2257 neighbor 10.5.1.1 remote-as 64519
2258 neighbor 10.5.1.1 peer-group peer
2259 neighbor 10.5.1.1 description peer AS 1
2260 neighbor 10.6.1.1 remote-as 64520
2261 neighbor 10.6.1.1 peer-group peer
2262 neighbor 10.6.1.1 description peer AS 2
2263
2264 address-family ipv4 unicast
2265 network 10.123.456.0/24
2266 network 10.123.456.128/25 route-map rm-no-export
2267 neighbor upstream route-map rm-upstream-out out
2268 neighbor cust route-map rm-cust-in in
2269 neighbor cust route-map rm-cust-out out
2270 neighbor cust send-community both
2271 neighbor peer route-map rm-peer-in in
2272 neighbor peer route-map rm-peer-out out
2273 neighbor peer send-community both
2274 neighbor 10.3.1.1 prefix-list pl-cust1-network in
2275 neighbor 10.4.1.1 prefix-list pl-cust2-network in
2276 neighbor 10.5.1.1 prefix-list pl-peer1-network in
2277 neighbor 10.6.1.1 prefix-list pl-peer2-network in
2278 exit-address-family
2279 !
2280 ip prefix-list pl-default permit 0.0.0.0/0
2281 !
2282 ip prefix-list pl-upstream-peers permit 10.1.1.1/32
2283 ip prefix-list pl-upstream-peers permit 10.2.1.1/32
2284 !
2285 ip prefix-list pl-cust1-network permit 10.3.1.0/24
2286 ip prefix-list pl-cust1-network permit 10.3.2.0/24
2287 !
2288 ip prefix-list pl-cust2-network permit 10.4.1.0/24
2289 !
2290 ip prefix-list pl-peer1-network permit 10.5.1.0/24
2291 ip prefix-list pl-peer1-network permit 10.5.2.0/24
2292 ip prefix-list pl-peer1-network permit 192.168.0.0/24
2293 !
2294 ip prefix-list pl-peer2-network permit 10.6.1.0/24
2295 ip prefix-list pl-peer2-network permit 10.6.2.0/24
2296 ip prefix-list pl-peer2-network permit 192.168.1.0/24
2297 ip prefix-list pl-peer2-network permit 192.168.2.0/24
2298 ip prefix-list pl-peer2-network permit 172.16.1/24
2299 !
2300 ip as-path access-list asp-own-as permit ^$
2301 ip as-path access-list asp-own-as permit _64512_
2302 !
2303 ! #################################################################
2304 ! Match communities we provide actions for, on routes receives from
2305 ! customers. Communities values of <our-ASN>:X, with X, have actions:
2306 !
2307 ! 100 - blackhole the prefix
2308 ! 200 - set no_export
2309 ! 300 - advertise only to other customers
2310 ! 400 - advertise only to upstreams
2311 ! 500 - set no_export when advertising to upstreams
2312 ! 2X00 - set local_preference to X00
2313 !
2314 ! blackhole the prefix of the route
2315 ip community-list standard cm-blackhole permit 64512:100
2316 !
2317 ! set no-export community before advertising
2318 ip community-list standard cm-set-no-export permit 64512:200
2319 !
2320 ! advertise only to other customers
2321 ip community-list standard cm-cust-only permit 64512:300
2322 !
2323 ! advertise only to upstreams
2324 ip community-list standard cm-upstream-only permit 64512:400
2325 !
2326 ! advertise to upstreams with no-export
2327 ip community-list standard cm-upstream-noexport permit 64512:500
2328 !
2329 ! set local-pref to least significant 3 digits of the community
2330 ip community-list standard cm-prefmod-100 permit 64512:2100
2331 ip community-list standard cm-prefmod-200 permit 64512:2200
2332 ip community-list standard cm-prefmod-300 permit 64512:2300
2333 ip community-list standard cm-prefmod-400 permit 64512:2400
2334 ip community-list expanded cme-prefmod-range permit 64512:2...
2335 !
2336 ! Informational communities
2337 !
2338 ! 3000 - learned from upstream
2339 ! 3100 - learned from customer
2340 ! 3200 - learned from peer
2341 !
2342 ip community-list standard cm-learnt-upstream permit 64512:3000
2343 ip community-list standard cm-learnt-cust permit 64512:3100
2344 ip community-list standard cm-learnt-peer permit 64512:3200
2345 !
2346 ! ###################################################################
2347 ! Utility route-maps
2348 !
2349 ! These utility route-maps generally should not used to permit/deny
2350 ! routes, i.e. they do not have meaning as filters, and hence probably
2351 ! should be used with 'on-match next'. These all finish with an empty
2352 ! permit entry so as not interfere with processing in the caller.
2353 !
2354 route-map rm-no-export permit 10
2355 set community additive no-export
2356 route-map rm-no-export permit 20
2357 !
2358 route-map rm-blackhole permit 10
2359 description blackhole, up-pref and ensure it cant escape this AS
2360 set ip next-hop 127.0.0.1
2361 set local-preference 10
2362 set community additive no-export
2363 route-map rm-blackhole permit 20
2364 !
2365 ! Set local-pref as requested
2366 route-map rm-prefmod permit 10
2367 match community cm-prefmod-100
2368 set local-preference 100
2369 route-map rm-prefmod permit 20
2370 match community cm-prefmod-200
2371 set local-preference 200
2372 route-map rm-prefmod permit 30
2373 match community cm-prefmod-300
2374 set local-preference 300
2375 route-map rm-prefmod permit 40
2376 match community cm-prefmod-400
2377 set local-preference 400
2378 route-map rm-prefmod permit 50
2379 !
2380 ! Community actions to take on receipt of route.
2381 route-map rm-community-in permit 10
2382 description check for blackholing, no point continuing if it matches.
2383 match community cm-blackhole
2384 call rm-blackhole
2385 route-map rm-community-in permit 20
2386 match community cm-set-no-export
2387 call rm-no-export
2388 on-match next
2389 route-map rm-community-in permit 30
2390 match community cme-prefmod-range
2391 call rm-prefmod
2392 route-map rm-community-in permit 40
2393 !
2394 ! #####################################################################
2395 ! Community actions to take when advertising a route.
2396 ! These are filtering route-maps,
2397 !
2398 ! Deny customer routes to upstream with cust-only set.
2399 route-map rm-community-filt-to-upstream deny 10
2400 match community cm-learnt-cust
2401 match community cm-cust-only
2402 route-map rm-community-filt-to-upstream permit 20
2403 !
2404 ! Deny customer routes to other customers with upstream-only set.
2405 route-map rm-community-filt-to-cust deny 10
2406 match community cm-learnt-cust
2407 match community cm-upstream-only
2408 route-map rm-community-filt-to-cust permit 20
2409 !
2410 ! ###################################################################
2411 ! The top-level route-maps applied to sessions. Further entries could
2412 ! be added obviously..
2413 !
2414 ! Customers
2415 route-map rm-cust-in permit 10
2416 call rm-community-in
2417 on-match next
2418 route-map rm-cust-in permit 20
2419 set community additive 64512:3100
2420 route-map rm-cust-in permit 30
2421 !
2422 route-map rm-cust-out permit 10
2423 call rm-community-filt-to-cust
2424 on-match next
2425 route-map rm-cust-out permit 20
2426 !
2427 ! Upstream transit ASes
2428 route-map rm-upstream-out permit 10
2429 description filter customer prefixes which are marked cust-only
2430 call rm-community-filt-to-upstream
2431 on-match next
2432 route-map rm-upstream-out permit 20
2433 description only customer routes are provided to upstreams/peers
2434 match community cm-learnt-cust
2435 !
2436 ! Peer ASes
2437 ! outbound policy is same as for upstream
2438 route-map rm-peer-out permit 10
2439 call rm-upstream-out
2440 !
2441 route-map rm-peer-in permit 10
2442 set community additive 64512:3200
2443
2444
2445 @include rpki.texi