]> git.proxmox.com Git - mirror_frr.git/blame - doc/user/bgp.rst
bgpd: Rework BGP dampening to be per AFI/SAFI
[mirror_frr.git] / doc / user / bgp.rst
CommitLineData
0efdf0fe 1.. _bgp:
42fc5d26
QY
2
3***
4BGP
5***
6
8fcedbd2 7:abbr:`BGP` stands for Border Gateway Protocol. The latest BGP version is 4.
d1e7591e 8BGP-4 is one of the Exterior Gateway Protocols and the de facto standard
8fcedbd2
QY
9interdomain routing protocol. BGP-4 is described in :rfc:`1771` and updated by
10:rfc:`4271`. :rfc:`2858` adds multiprotocol support to BGP-4.
42fc5d26 11
0efdf0fe 12.. _starting-bgp:
42fc5d26
QY
13
14Starting BGP
15============
16
8fcedbd2
QY
17The default configuration file of *bgpd* is :file:`bgpd.conf`. *bgpd* searches
18the current directory first, followed by |INSTALL_PREFIX_ETC|/bgpd.conf. All of
19*bgpd*'s commands must be configured in :file:`bgpd.conf` when the integrated
20config is not being used.
42fc5d26 21
c1a54c05 22*bgpd* specific invocation options are described below. Common options may also
0efdf0fe 23be specified (:ref:`common-invocation-options`).
42fc5d26 24
c1a54c05 25.. program:: bgpd
42fc5d26 26
c9365894 27.. option:: -p, --bgp_port <port>
42fc5d26 28
db759bb0 29 Set the bgp protocol's port number. When port number is 0, that means do not
30 listen bgp port.
42fc5d26 31
c9365894 32.. option:: -l, --listenon
42fc5d26 33
c0868e8b
QY
34 Specify a specific IP address for bgpd to listen on, rather than its default
35 of ``0.0.0.0`` / ``::``. This can be useful to constrain bgpd to an internal
36 address, or to run multiple bgpd processes on one host.
42fc5d26 37
11a9a236
DS
38.. option:: -n, --no_kernel
39
40 Do not install learned routes into the linux kernel. This option is useful
41 for a route-reflector environment or if you are running multiple bgp
42 processes in the same namespace. This option is different than the --no_zebra
43 option in that a ZAPI connection is made.
44
45.. option:: -S, --skip_runas
46
47 Skip the normal process of checking capabilities and changing user and group
48 information.
49
50.. option:: -e, --ecmp
51
52 Run BGP with a limited ecmp capability, that is different than what BGP
53 was compiled with. The value specified must be greater than 0 and less
54 than or equal to the MULTIPATH_NUM specified on compilation.
55
56.. option:: -Z, --no_zebra
57
58 Do not communicate with zebra at all. This is different than the --no_kernel
59 option in that we do not even open a ZAPI connection to the zebra process.
60
61.. option:: -s, --socket_size
62
63 When opening tcp connections to our peers, set the socket send buffer
64 size that the kernel will use for the peers socket. This option
65 is only really useful at a very large scale. Experimentation should
66 be done to see if this is helping or not at the scale you are running
67 at.
68
69LABEL MANAGER
70-------------
71
72.. option:: -I, --int_num
73
74 Set zclient id. This is required when using Zebra label manager in proxy mode.
75
8fcedbd2 76.. _bgp-basic-concepts:
42fc5d26 77
8fcedbd2
QY
78Basic Concepts
79==============
42fc5d26 80
8fcedbd2 81.. _bgp-autonomous-systems:
c3c5a71f 82
8fcedbd2
QY
83Autonomous Systems
84------------------
42fc5d26 85
c0868e8b
QY
86From :rfc:`1930`:
87
88 An AS is a connected group of one or more IP prefixes run by one or more
89 network operators which has a SINGLE and CLEARLY DEFINED routing policy.
90
91Each AS has an identifying number associated with it called an :abbr:`ASN
92(Autonomous System Number)`. This is a two octet value ranging in value from 1
93to 65535. The AS numbers 64512 through 65535 are defined as private AS numbers.
94Private AS numbers must not be advertised on the global Internet.
95
96The :abbr:`ASN (Autonomous System Number)` is one of the essential elements of
8fcedbd2 97BGP. BGP is a distance vector routing protocol, and the AS-Path framework
c0868e8b 98provides distance vector metric and loop detection to BGP.
42fc5d26 99
c0868e8b 100.. seealso:: :rfc:`1930`
42fc5d26 101
8fcedbd2 102.. _bgp-address-families:
42fc5d26 103
8fcedbd2
QY
104Address Families
105----------------
42fc5d26 106
c0868e8b
QY
107Multiprotocol extensions enable BGP to carry routing information for multiple
108network layer protocols. BGP supports an Address Family Identifier (AFI) for
109IPv4 and IPv6. Support is also provided for multiple sets of per-AFI
110information via the BGP Subsequent Address Family Identifier (SAFI). FRR
111supports SAFIs for unicast information, labeled information (:rfc:`3107` and
112:rfc:`8277`), and Layer 3 VPN information (:rfc:`4364` and :rfc:`4659`).
c3c5a71f 113
8fcedbd2 114.. _bgp-route-selection:
42fc5d26 115
8fcedbd2
QY
116Route Selection
117---------------
42fc5d26 118
8fcedbd2
QY
119The route selection process used by FRR's BGP implementation uses the following
120decision criterion, starting at the top of the list and going towards the
121bottom until one of the factors can be used.
42fc5d26 122
8fcedbd2 1231. **Weight check**
42fc5d26 124
c1a54c05 125 Prefer higher local weight routes to lower routes.
42fc5d26 126
8fcedbd2
QY
1272. **Local preference check**
128
c1a54c05 129 Prefer higher local preference routes to lower.
42fc5d26 130
8fcedbd2
QY
1313. **Local route check**
132
c1a54c05 133 Prefer local routes (statics, aggregates, redistributed) to received routes.
42fc5d26 134
8fcedbd2
QY
1354. **AS path length check**
136
c1a54c05 137 Prefer shortest hop-count AS_PATHs.
42fc5d26 138
8fcedbd2
QY
1395. **Origin check**
140
c1a54c05
QY
141 Prefer the lowest origin type route. That is, prefer IGP origin routes to
142 EGP, to Incomplete routes.
42fc5d26 143
8fcedbd2
QY
1446. **MED check**
145
c1a54c05 146 Where routes with a MED were received from the same AS, prefer the route
0efdf0fe 147 with the lowest MED. :ref:`bgp-med`.
42fc5d26 148
8fcedbd2
QY
1497. **External check**
150
c1a54c05
QY
151 Prefer the route received from an external, eBGP peer over routes received
152 from other types of peers.
42fc5d26 153
8fcedbd2
QY
1548. **IGP cost check**
155
c1a54c05 156 Prefer the route with the lower IGP cost.
42fc5d26 157
8fcedbd2
QY
1589. **Multi-path check**
159
c1a54c05
QY
160 If multi-pathing is enabled, then check whether the routes not yet
161 distinguished in preference may be considered equal. If
9e146a81 162 :clicmd:`bgp bestpath as-path multipath-relax` is set, all such routes are
c1a54c05
QY
163 considered equal, otherwise routes received via iBGP with identical AS_PATHs
164 or routes received from eBGP neighbours in the same AS are considered equal.
42fc5d26 165
8fcedbd2
QY
16610. **Already-selected external check**
167
07738543
QY
168 Where both routes were received from eBGP peers, then prefer the route
169 which is already selected. Note that this check is not applied if
170 :clicmd:`bgp bestpath compare-routerid` is configured. This check can
171 prevent some cases of oscillation.
172
8fcedbd2
QY
17311. **Router-ID check**
174
07738543
QY
175 Prefer the route with the lowest `router-ID`. If the route has an
176 `ORIGINATOR_ID` attribute, through iBGP reflection, then that router ID is
177 used, otherwise the `router-ID` of the peer the route was received from is
178 used.
179
8fcedbd2
QY
18012. **Cluster-List length check**
181
07738543
QY
182 The route with the shortest cluster-list length is used. The cluster-list
183 reflects the iBGP reflection path the route has taken.
184
8fcedbd2
QY
18513. **Peer address**
186
07738543
QY
187 Prefer the route received from the peer with the higher transport layer
188 address, as a last-resort tie-breaker.
42fc5d26 189
8fcedbd2
QY
190.. _bgp-capability-negotiation:
191
192Capability Negotiation
193----------------------
194
195When adding IPv6 routing information exchange feature to BGP. There were some
196proposals. :abbr:`IETF (Internet Engineering Task Force)`
197:abbr:`IDR (Inter Domain Routing)` adopted a proposal called Multiprotocol
198Extension for BGP. The specification is described in :rfc:`2283`. The protocol
199does not define new protocols. It defines new attributes to existing BGP. When
200it is used exchanging IPv6 routing information it is called BGP-4+. When it is
201used for exchanging multicast routing information it is called MBGP.
202
203*bgpd* supports Multiprotocol Extension for BGP. So if a remote peer supports
204the protocol, *bgpd* can exchange IPv6 and/or multicast routing information.
205
206Traditional BGP did not have the feature to detect a remote peer's
207capabilities, e.g. whether it can handle prefix types other than IPv4 unicast
208routes. This was a big problem using Multiprotocol Extension for BGP in an
209operational network. :rfc:`2842` adopted a feature called Capability
210Negotiation. *bgpd* use this Capability Negotiation to detect the remote peer's
211capabilities. If a peer is only configured as an IPv4 unicast neighbor, *bgpd*
212does not send these Capability Negotiation packets (at least not unless other
213optional BGP features require capability negotiation).
214
215By default, FRR will bring up peering with minimal common capability for the
216both sides. For example, if the local router has unicast and multicast
217capabilities and the remote router only has unicast capability the local router
218will establish the connection with unicast only capability. When there are no
219common capabilities, FRR sends Unsupported Capability error and then resets the
220connection.
221
8fcedbd2
QY
222.. _bgp-router-configuration:
223
224BGP Router Configuration
225========================
226
227ASN and Router ID
228-----------------
229
230First of all you must configure BGP router with the :clicmd:`router bgp ASN`
231command. The AS number is an identifier for the autonomous system. The BGP
232protocol uses the AS number for detecting whether the BGP connection is
233internal or external.
234
235.. index:: router bgp ASN
236.. clicmd:: router bgp ASN
237
238 Enable a BGP protocol process with the specified ASN. After
239 this statement you can input any `BGP Commands`.
240
241.. index:: no router bgp ASN
242.. clicmd:: no router bgp ASN
243
244 Destroy a BGP protocol process with the specified ASN.
245
246.. index:: bgp router-id A.B.C.D
247.. clicmd:: bgp router-id A.B.C.D
248
249 This command specifies the router-ID. If *bgpd* connects to *zebra* it gets
250 interface and address information. In that case default router ID value is
251 selected as the largest IP Address of the interfaces. When `router zebra` is
252 not enabled *bgpd* can't get interface information so `router-id` is set to
253 0.0.0.0. So please set router-id by hand.
254
c8a5e5e1
QY
255
256.. _bgp-multiple-autonomous-systems:
257
258Multiple Autonomous Systems
259---------------------------
260
261FRR's BGP implementation is capable of running multiple autonomous systems at
262once. Each configured AS corresponds to a :ref:`zebra-vrf`. In the past, to get
263the same functionality the network administrator had to run a new *bgpd*
264process; using VRFs allows multiple autonomous systems to be handled in a
265single process.
266
267When using multiple autonomous systems, all router config blocks after the
268first one must specify a VRF to be the target of BGP's route selection. This
269VRF must be unique within respect to all other VRFs being used for the same
270purpose, i.e. two different autonomous systems cannot use the same VRF.
271However, the same AS can be used with different VRFs.
272
273.. note::
274
275 The separated nature of VRFs makes it possible to peer a single *bgpd*
edde3ce9
QY
276 process to itself, on one machine. Note that this can be done fully within
277 BGP without a corresponding VRF in the kernel or Zebra, which enables some
278 practical use cases such as :ref:`route reflectors <bgp-route-reflector>`
279 and route servers.
c8a5e5e1
QY
280
281Configuration of additional autonomous systems, or of a router that targets a
282specific VRF, is accomplished with the following command:
283
284.. index:: router bgp ASN vrf VRFNAME
285.. clicmd:: router bgp ASN vrf VRFNAME
286
287 ``VRFNAME`` is matched against VRFs configured in the kernel. When ``vrf
288 VRFNAME`` is not specified, the BGP protocol process belongs to the default
289 VRF.
290
291An example configuration with multiple autonomous systems might look like this:
292
293.. code-block:: frr
294
295 router bgp 1
296 neighbor 10.0.0.1 remote-as 20
297 neighbor 10.0.0.2 remote-as 30
298 !
299 router bgp 2 vrf blue
300 neighbor 10.0.0.3 remote-as 40
301 neighbor 10.0.0.4 remote-as 50
302 !
303 router bgp 3 vrf red
304 neighbor 10.0.0.5 remote-as 60
305 neighbor 10.0.0.6 remote-as 70
306 ...
307
c8a5e5e1
QY
308.. seealso:: :ref:`bgp-vrf-route-leaking`
309.. seealso:: :ref:`zebra-vrf`
310
311
312.. _bgp-views:
313
314Views
315-----
316
317In addition to supporting multiple autonomous systems, FRR's BGP implementation
318also supports *views*.
319
320BGP views are almost the same as normal BGP processes, except that routes
195c7461
QY
321selected by BGP are not installed into the kernel routing table. Each BGP view
322provides an independent set of routing information which is only distributed
323via BGP. Multiple views can be supported, and BGP view information is always
324independent from other routing protocols and Zebra/kernel routes. BGP views use
325the core instance (i.e., default VRF) for communication with peers.
edde3ce9 326
c8a5e5e1
QY
327.. index:: router bgp AS-NUMBER view NAME
328.. clicmd:: router bgp AS-NUMBER view NAME
329
330 Make a new BGP view. You can use an arbitrary word for the ``NAME``. Routes
331 selected by the view are not installed into the kernel routing table.
332
333 With this command, you can setup Route Server like below.
334
335 .. code-block:: frr
336
337 !
338 router bgp 1 view 1
339 neighbor 10.0.0.1 remote-as 2
340 neighbor 10.0.0.2 remote-as 3
341 !
342 router bgp 2 view 2
343 neighbor 10.0.0.3 remote-as 4
344 neighbor 10.0.0.4 remote-as 5
345
346.. index:: show [ip] bgp view NAME
347.. clicmd:: show [ip] bgp view NAME
348
349 Display the routing table of BGP view ``NAME``.
350
351
8fcedbd2
QY
352Route Selection
353---------------
c3c5a71f 354
c1a54c05 355.. index:: bgp bestpath as-path confed
29adcd50 356.. clicmd:: bgp bestpath as-path confed
42fc5d26 357
c1a54c05
QY
358 This command specifies that the length of confederation path sets and
359 sequences should should be taken into account during the BGP best path
360 decision process.
42fc5d26 361
c3c5a71f 362.. index:: bgp bestpath as-path multipath-relax
29adcd50 363.. clicmd:: bgp bestpath as-path multipath-relax
42fc5d26 364
c1a54c05
QY
365 This command specifies that BGP decision process should consider paths
366 of equal AS_PATH length candidates for multipath computation. Without
367 the knob, the entire AS_PATH must match for multipath computation.
c3c5a71f 368
29adcd50 369.. clicmd:: bgp bestpath compare-routerid
42fc5d26 370
c1a54c05
QY
371 Ensure that when comparing routes where both are equal on most metrics,
372 including local-pref, AS_PATH length, IGP cost, MED, that the tie is broken
373 based on router-ID.
42fc5d26 374
c1a54c05
QY
375 If this option is enabled, then the already-selected check, where
376 already selected eBGP routes are preferred, is skipped.
42fc5d26 377
c1a54c05
QY
378 If a route has an `ORIGINATOR_ID` attribute because it has been reflected,
379 that `ORIGINATOR_ID` will be used. Otherwise, the router-ID of the peer the
380 route was received from will be used.
42fc5d26 381
c1a54c05
QY
382 The advantage of this is that the route-selection (at this point) will be
383 more deterministic. The disadvantage is that a few or even one lowest-ID
d1e7591e 384 router may attract all traffic to otherwise-equal paths because of this
c1a54c05
QY
385 check. It may increase the possibility of MED or IGP oscillation, unless
386 other measures were taken to avoid these. The exact behaviour will be
387 sensitive to the iBGP and reflection topology.
42fc5d26 388
8fcedbd2
QY
389.. _bgp-distance:
390
391Administrative Distance Metrics
392-------------------------------
393
394.. index:: distance bgp (1-255) (1-255) (1-255)
395.. clicmd:: distance bgp (1-255) (1-255) (1-255)
396
397 This command change distance value of BGP. The arguments are the distance
398 values for for external routes, internal routes and local routes
399 respectively.
400
401.. index:: distance (1-255) A.B.C.D/M
402.. clicmd:: distance (1-255) A.B.C.D/M
403
404.. index:: distance (1-255) A.B.C.D/M WORD
405.. clicmd:: distance (1-255) A.B.C.D/M WORD
406
407 Sets the administrative distance for a particular route.
42fc5d26 408
713c64dd
DA
409.. _bgp-requires-policy:
410
411Require policy on EBGP
412-------------------------------
413
414.. index:: [no] bgp ebgp-requires-policy
415.. clicmd:: [no] bgp ebgp-requires-policy
416
417 This command requires incoming and outgoing filters to be applied for eBGP sessions. Without the incoming filter, no routes will be accepted. Without the outgoing filter, no routes will be announced.
418
0efdf0fe 419.. _bgp-route-flap-dampening:
42fc5d26 420
8fcedbd2
QY
421Route Flap Dampening
422--------------------
42fc5d26 423
c1a54c05
QY
424.. clicmd:: bgp dampening (1-45) (1-20000) (1-20000) (1-255)
425
c1a54c05 426 This command enables BGP route-flap dampening and specifies dampening parameters.
42fc5d26 427
c1a54c05
QY
428 half-life
429 Half-life time for the penalty
42fc5d26 430
c1a54c05
QY
431 reuse-threshold
432 Value to start reusing a route
42fc5d26 433
c1a54c05
QY
434 suppress-threshold
435 Value to start suppressing a route
42fc5d26 436
c1a54c05
QY
437 max-suppress
438 Maximum duration to suppress a stable route
42fc5d26 439
c1a54c05
QY
440 The route-flap damping algorithm is compatible with :rfc:`2439`. The use of
441 this command is not recommended nowadays.
42fc5d26 442
c1a54c05 443.. seealso::
8fcedbd2 444 https://www.ripe.net/publications/docs/ripe-378
42fc5d26 445
0efdf0fe 446.. _bgp-med:
42fc5d26 447
8fcedbd2
QY
448Multi-Exit Discriminator
449------------------------
42fc5d26 450
8fcedbd2 451The BGP :abbr:`MED (Multi-Exit Discriminator)` attribute has properties which
c1a54c05
QY
452can cause subtle convergence problems in BGP. These properties and problems
453have proven to be hard to understand, at least historically, and may still not
454be widely understood. The following attempts to collect together and present
455what is known about MED, to help operators and FRR users in designing and
456configuring their networks.
42fc5d26 457
07a17e6d
QY
458The BGP :abbr:`MED` attribute is intended to allow one AS to indicate its
459preferences for its ingress points to another AS. The MED attribute will not be
460propagated on to another AS by the receiving AS - it is 'non-transitive' in the
461BGP sense.
42fc5d26 462
c1a54c05
QY
463E.g., if AS X and AS Y have 2 different BGP peering points, then AS X might set
464a MED of 100 on routes advertised at one and a MED of 200 at the other. When AS
465Y selects between otherwise equal routes to or via AS X, AS Y should prefer to
466take the path via the lower MED peering of 100 with AS X. Setting the MED
467allows an AS to influence the routing taken to it within another, neighbouring
468AS.
42fc5d26
QY
469
470In this use of MED it is not really meaningful to compare the MED value on
c1a54c05
QY
471routes where the next AS on the paths differs. E.g., if AS Y also had a route
472for some destination via AS Z in addition to the routes from AS X, and AS Z had
473also set a MED, it wouldn't make sense for AS Y to compare AS Z's MED values to
474those of AS X. The MED values have been set by different administrators, with
475different frames of reference.
42fc5d26
QY
476
477The default behaviour of BGP therefore is to not compare MED values across
dc1046f7 478routes received from different neighbouring ASes. In FRR this is done by
c1a54c05
QY
479comparing the neighbouring, left-most AS in the received AS_PATHs of the routes
480and only comparing MED if those are the same.
481
482Unfortunately, this behaviour of MED, of sometimes being compared across routes
483and sometimes not, depending on the properties of those other routes, means MED
484can cause the order of preference over all the routes to be undefined. That is,
485given routes A, B, and C, if A is preferred to B, and B is preferred to C, then
486a well-defined order should mean the preference is transitive (in the sense of
013f9762 487orders [#med-transitivity-rant]_) and that A would be preferred to C.
42fc5d26 488
c3c5a71f
QY
489However, when MED is involved this need not be the case. With MED it is
490possible that C is actually preferred over A. So A is preferred to B, B is
491preferred to C, but C is preferred to A. This can be true even where BGP
c1a54c05
QY
492defines a deterministic 'most preferred' route out of the full set of A,B,C.
493With MED, for any given set of routes there may be a deterministically
494preferred route, but there need not be any way to arrange them into any order
495of preference. With unmodified MED, the order of preference of routes literally
496becomes undefined.
42fc5d26 497
c3c5a71f 498That MED can induce non-transitive preferences over routes can cause issues.
c1a54c05
QY
499Firstly, it may be perceived to cause routing table churn locally at speakers;
500secondly, and more seriously, it may cause routing instability in iBGP
501topologies, where sets of speakers continually oscillate between different
502paths.
42fc5d26 503
c3c5a71f 504The first issue arises from how speakers often implement routing decisions.
c1a54c05
QY
505Though BGP defines a selection process that will deterministically select the
506same route as best at any given speaker, even with MED, that process requires
507evaluating all routes together. For performance and ease of implementation
508reasons, many implementations evaluate route preferences in a pair-wise fashion
509instead. Given there is no well-defined order when MED is involved, the best
510route that will be chosen becomes subject to implementation details, such as
511the order the routes are stored in. That may be (locally) non-deterministic,
512e.g.: it may be the order the routes were received in.
42fc5d26
QY
513
514This indeterminism may be considered undesirable, though it need not cause
c1a54c05
QY
515problems. It may mean additional routing churn is perceived, as sometimes more
516updates may be produced than at other times in reaction to some event .
42fc5d26
QY
517
518This first issue can be fixed with a more deterministic route selection that
c3c5a71f 519ensures routes are ordered by the neighbouring AS during selection.
9e146a81 520:clicmd:`bgp deterministic-med`. This may reduce the number of updates as routes
c1a54c05
QY
521are received, and may in some cases reduce routing churn. Though, it could
522equally deterministically produce the largest possible set of updates in
523response to the most common sequence of received updates.
42fc5d26
QY
524
525A deterministic order of evaluation tends to imply an additional overhead of
c3c5a71f 526sorting over any set of n routes to a destination. The implementation of
dc1046f7 527deterministic MED in FRR scales significantly worse than most sorting
c1a54c05
QY
528algorithms at present, with the number of paths to a given destination. That
529number is often low enough to not cause any issues, but where there are many
530paths, the deterministic comparison may quickly become increasingly expensive
531in terms of CPU.
532
533Deterministic local evaluation can *not* fix the second, more major, issue of
534MED however. Which is that the non-transitive preference of routes MED can
535cause may lead to routing instability or oscillation across multiple speakers
536in iBGP topologies. This can occur with full-mesh iBGP, but is particularly
537problematic in non-full-mesh iBGP topologies that further reduce the routing
538information known to each speaker. This has primarily been documented with iBGP
749afd7d
RF
539:ref:`route-reflection <bgp-route-reflector>` topologies. However, any
540route-hiding technologies potentially could also exacerbate oscillation with MED.
c1a54c05
QY
541
542This second issue occurs where speakers each have only a subset of routes, and
543there are cycles in the preferences between different combinations of routes -
544as the undefined order of preference of MED allows - and the routes are
545distributed in a way that causes the BGP speakers to 'chase' those cycles. This
546can occur even if all speakers use a deterministic order of evaluation in route
547selection.
548
549E.g., speaker 4 in AS A might receive a route from speaker 2 in AS X, and from
550speaker 3 in AS Y; while speaker 5 in AS A might receive that route from
551speaker 1 in AS Y. AS Y might set a MED of 200 at speaker 1, and 100 at speaker
5523. I.e, using ASN:ID:MED to label the speakers:
42fc5d26
QY
553
554::
555
c1a54c05
QY
556 .
557 /---------------\\
42fc5d26 558 X:2------|--A:4-------A:5--|-Y:1:200
c1a54c05
QY
559 Y:3:100--|-/ |
560 \\---------------/
c3c5a71f 561
42fc5d26 562
42fc5d26 563
c1a54c05
QY
564Assuming all other metrics are equal (AS_PATH, ORIGIN, 0 IGP costs), then based
565on the RFC4271 decision process speaker 4 will choose X:2 over Y:3:100, based
566on the lower ID of 2. Speaker 4 advertises X:2 to speaker 5. Speaker 5 will
567continue to prefer Y:1:200 based on the ID, and advertise this to speaker 4.
568Speaker 4 will now have the full set of routes, and the Y:1:200 it receives
569from 5 will beat X:2, but when speaker 4 compares Y:1:200 to Y:3:100 the MED
570check now becomes active as the ASes match, and now Y:3:100 is preferred.
571Speaker 4 therefore now advertises Y:3:100 to 5, which will also agrees that
572Y:3:100 is preferred to Y:1:200, and so withdraws the latter route from 4.
573Speaker 4 now has only X:2 and Y:3:100, and X:2 beats Y:3:100, and so speaker 4
574implicitly updates its route to speaker 5 to X:2. Speaker 5 sees that Y:1:200
575beats X:2 based on the ID, and advertises Y:1:200 to speaker 4, and the cycle
576continues.
42fc5d26
QY
577
578The root cause is the lack of a clear order of preference caused by how MED
579sometimes is and sometimes is not compared, leading to this cycle in the
580preferences between the routes:
581
582::
583
c1a54c05
QY
584 .
585 /---> X:2 ---beats---> Y:3:100 --\\
586 | |
587 | |
588 \\---beats--- Y:1:200 <---beats---/
c3c5a71f 589
42fc5d26 590
42fc5d26
QY
591
592This particular type of oscillation in full-mesh iBGP topologies can be
593avoided by speakers preferring already selected, external routes rather than
c1a54c05
QY
594choosing to update to new a route based on a post-MED metric (e.g. router-ID),
595at the cost of a non-deterministic selection process. FRR implements this, as
596do many other implementations, so long as it is not overridden by setting
9e146a81 597:clicmd:`bgp bestpath compare-routerid`, and see also
8fcedbd2 598:ref:`bgp-route-selection`.
42fc5d26
QY
599
600However, more complex and insidious cycles of oscillation are possible with
c3c5a71f 601iBGP route-reflection, which are not so easily avoided. These have been
c1a54c05
QY
602documented in various places. See, e.g.:
603
604- [bgp-route-osci-cond]_
605- [stable-flexible-ibgp]_
606- [ibgp-correctness]_
607
608for concrete examples and further references.
609
610There is as of this writing *no* known way to use MED for its original purpose;
611*and* reduce routing information in iBGP topologies; *and* be sure to avoid the
612instability problems of MED due the non-transitive routing preferences it can
613induce; in general on arbitrary networks.
614
615There may be iBGP topology specific ways to reduce the instability risks, even
616while using MED, e.g.: by constraining the reflection topology and by tuning
013f9762 617IGP costs between route-reflector clusters, see :rfc:`3345` for details. In the
c1a54c05
QY
618near future, the Add-Path extension to BGP may also solve MED oscillation while
619still allowing MED to be used as intended, by distributing "best-paths per
620neighbour AS". This would be at the cost of distributing at least as many
621routes to all speakers as a full-mesh iBGP would, if not more, while also
622imposing similar CPU overheads as the "Deterministic MED" feature at each
623Add-Path reflector.
42fc5d26
QY
624
625More generally, the instability problems that MED can introduce on more
626complex, non-full-mesh, iBGP topologies may be avoided either by:
627
013f9762 628- Setting :clicmd:`bgp always-compare-med`, however this allows MED to be compared
42fc5d26
QY
629 across values set by different neighbour ASes, which may not produce
630 coherent desirable results, of itself.
4b44467c 631- Effectively ignoring MED by setting MED to the same value (e.g.: 0) using
013f9762
QY
632 :clicmd:`set metric METRIC` on all received routes, in combination with
633 setting :clicmd:`bgp always-compare-med` on all speakers. This is the simplest
42fc5d26
QY
634 and most performant way to avoid MED oscillation issues, where an AS is happy
635 not to allow neighbours to inject this problematic metric.
636
42fc5d26
QY
637As MED is evaluated after the AS_PATH length check, another possible use for
638MED is for intra-AS steering of routes with equal AS_PATH length, as an
c1a54c05
QY
639extension of the last case above. As MED is evaluated before IGP metric, this
640can allow cold-potato routing to be implemented to send traffic to preferred
641hand-offs with neighbours, rather than the closest hand-off according to the
642IGP metric.
643
644Note that even if action is taken to address the MED non-transitivity issues,
645other oscillations may still be possible. E.g., on IGP cost if iBGP and IGP
646topologies are at cross-purposes with each other - see the Flavel and Roughan
647paper above for an example. Hence the guideline that the iBGP topology should
648follow the IGP topology.
649
c3c5a71f 650.. index:: bgp deterministic-med
29adcd50 651.. clicmd:: bgp deterministic-med
42fc5d26 652
c1a54c05
QY
653 Carry out route-selection in way that produces deterministic answers
654 locally, even in the face of MED and the lack of a well-defined order of
655 preference it can induce on routes. Without this option the preferred route
656 with MED may be determined largely by the order that routes were received
657 in.
42fc5d26 658
c1a54c05
QY
659 Setting this option will have a performance cost that may be noticeable when
660 there are many routes for each destination. Currently in FRR it is
661 implemented in a way that scales poorly as the number of routes per
662 destination increases.
42fc5d26 663
c1a54c05 664 The default is that this option is not set.
42fc5d26
QY
665
666Note that there are other sources of indeterminism in the route selection
667process, specifically, the preference for older and already selected routes
8fcedbd2 668from eBGP peers, :ref:`bgp-route-selection`.
42fc5d26 669
c3c5a71f 670.. index:: bgp always-compare-med
29adcd50 671.. clicmd:: bgp always-compare-med
42fc5d26 672
c1a54c05
QY
673 Always compare the MED on routes, even when they were received from
674 different neighbouring ASes. Setting this option makes the order of
675 preference of routes more defined, and should eliminate MED induced
676 oscillations.
42fc5d26 677
c1a54c05 678 If using this option, it may also be desirable to use
9e146a81 679 :clicmd:`set metric METRIC` to set MED to 0 on routes received from external
c1a54c05 680 neighbours.
42fc5d26 681
9e146a81
QY
682 This option can be used, together with :clicmd:`set metric METRIC` to use
683 MED as an intra-AS metric to steer equal-length AS_PATH routes to, e.g.,
684 desired exit points.
42fc5d26 685
0efdf0fe 686.. _bgp-network:
42fc5d26 687
8fcedbd2
QY
688Networks
689--------
42fc5d26 690
c1a54c05
QY
691.. index:: network A.B.C.D/M
692.. clicmd:: network A.B.C.D/M
42fc5d26 693
9eb95b3b 694 This command adds the announcement network.
c3c5a71f 695
9eb95b3b
QY
696 .. code-block:: frr
697
698 router bgp 1
699 address-family ipv4 unicast
700 network 10.0.0.0/8
701 exit-address-family
42fc5d26 702
c1a54c05
QY
703 This configuration example says that network 10.0.0.0/8 will be
704 announced to all neighbors. Some vendors' routers don't advertise
705 routes if they aren't present in their IGP routing tables; `bgpd`
706 doesn't care about IGP routes when announcing its routes.
c3c5a71f 707
c1a54c05
QY
708.. index:: no network A.B.C.D/M
709.. clicmd:: no network A.B.C.D/M
42fc5d26 710
8fcedbd2 711.. _bgp-route-aggregation:
42fc5d26
QY
712
713Route Aggregation
714-----------------
715
5101fece 716.. _bgp-route-aggregation-ipv4:
717
718Route Aggregation-IPv4 Address Family
719^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
720
c1a54c05
QY
721.. index:: aggregate-address A.B.C.D/M
722.. clicmd:: aggregate-address A.B.C.D/M
c3c5a71f 723
c1a54c05 724 This command specifies an aggregate address.
42fc5d26 725
ac2201bb
DA
726.. index:: aggregate-address A.B.C.D/M route-map NAME
727.. clicmd:: aggregate-address A.B.C.D/M route-map NAME
728
729 Apply a route-map for an aggregated prefix.
730
c1a54c05
QY
731.. index:: aggregate-address A.B.C.D/M as-set
732.. clicmd:: aggregate-address A.B.C.D/M as-set
42fc5d26 733
c1a54c05
QY
734 This command specifies an aggregate address. Resulting routes include
735 AS set.
42fc5d26 736
c1a54c05
QY
737.. index:: aggregate-address A.B.C.D/M summary-only
738.. clicmd:: aggregate-address A.B.C.D/M summary-only
c3c5a71f 739
d1e7591e 740 This command specifies an aggregate address. Aggregated routes will
c1a54c05 741 not be announce.
42fc5d26 742
c1a54c05
QY
743.. index:: no aggregate-address A.B.C.D/M
744.. clicmd:: no aggregate-address A.B.C.D/M
ac2201bb 745
5101fece 746 This command removes an aggregate address.
747
748
ac2201bb 749 This configuration example setup the aggregate-address under
5101fece 750 ipv4 address-family.
751
752 .. code-block:: frr
753
754 router bgp 1
755 address-family ipv4 unicast
756 aggregate-address 10.0.0.0/8
757 aggregate-address 20.0.0.0/8 as-set
758 aggregate-address 40.0.0.0/8 summary-only
ac2201bb 759 aggregate-address 50.0.0.0/8 route-map aggr-rmap
5101fece 760 exit-address-family
761
762
763.. _bgp-route-aggregation-ipv6:
764
765Route Aggregation-IPv6 Address Family
766^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
767
768.. index:: aggregate-address X:X::X:X/M
769.. clicmd:: aggregate-address X:X::X:X/M
770
771 This command specifies an aggregate address.
772
ac2201bb
DA
773.. index:: aggregate-address X:X::X:X/M route-map NAME
774.. clicmd:: aggregate-address X:X::X:X/M route-map NAME
775
776 Apply a route-map for an aggregated prefix.
777
5101fece 778.. index:: aggregate-address X:X::X:X/M as-set
779.. clicmd:: aggregate-address X:X::X:X/M as-set
780
781 This command specifies an aggregate address. Resulting routes include
782 AS set.
783
784.. index:: aggregate-address X:X::X:X/M summary-only
785.. clicmd:: aggregate-address X:X::X:X/M summary-only
786
787 This command specifies an aggregate address. Aggregated routes will
788 not be announce.
789
790.. index:: no aggregate-address X:X::X:X/M
791.. clicmd:: no aggregate-address X:X::X:X/M
792
793 This command removes an aggregate address.
794
795
ac2201bb
DA
796 This configuration example setup the aggregate-address under
797 ipv6 address-family.
5101fece 798
799 .. code-block:: frr
800
801 router bgp 1
802 address-family ipv6 unicast
803 aggregate-address 10::0/64
ac2201bb
DA
804 aggregate-address 20::0/64 as-set
805 aggregate-address 40::0/64 summary-only
806 aggregate-address 50::0/64 route-map aggr-rmap
5101fece 807 exit-address-family
c3c5a71f 808
8fcedbd2 809.. _bgp-redistribute-to-bgp:
42fc5d26 810
8fcedbd2
QY
811Redistribution
812--------------
42fc5d26 813
c3c5a71f 814.. index:: redistribute kernel
29adcd50 815.. clicmd:: redistribute kernel
42fc5d26 816
c1a54c05 817 Redistribute kernel route to BGP process.
42fc5d26 818
c3c5a71f 819.. index:: redistribute static
29adcd50 820.. clicmd:: redistribute static
42fc5d26 821
c1a54c05 822 Redistribute static route to BGP process.
42fc5d26 823
c3c5a71f 824.. index:: redistribute connected
29adcd50 825.. clicmd:: redistribute connected
42fc5d26 826
c1a54c05 827 Redistribute connected route to BGP process.
42fc5d26 828
c3c5a71f 829.. index:: redistribute rip
29adcd50 830.. clicmd:: redistribute rip
42fc5d26 831
c1a54c05 832 Redistribute RIP route to BGP process.
42fc5d26 833
c3c5a71f 834.. index:: redistribute ospf
29adcd50 835.. clicmd:: redistribute ospf
42fc5d26 836
c1a54c05 837 Redistribute OSPF route to BGP process.
42fc5d26 838
99ad55e0
DA
839.. index:: redistribute vnc
840.. clicmd:: redistribute vnc
42fc5d26 841
c1a54c05 842 Redistribute VNC routes to BGP process.
42fc5d26 843
245d354f
DA
844.. index:: redistribute vnc-direct
845.. clicmd:: redistribute vnc-direct
846
847 Redistribute VNC direct (not via zebra) routes to BGP process.
848
c1a54c05
QY
849.. index:: update-delay MAX-DELAY
850.. clicmd:: update-delay MAX-DELAY
c3c5a71f 851
c1a54c05
QY
852.. index:: update-delay MAX-DELAY ESTABLISH-WAIT
853.. clicmd:: update-delay MAX-DELAY ESTABLISH-WAIT
c3c5a71f 854
c1a54c05
QY
855 This feature is used to enable read-only mode on BGP process restart or when
856 BGP process is cleared using 'clear ip bgp \*'. When applicable, read-only
857 mode would begin as soon as the first peer reaches Established status and a
858 timer for max-delay seconds is started.
42fc5d26 859
c1a54c05
QY
860 During this mode BGP doesn't run any best-path or generate any updates to its
861 peers. This mode continues until:
42fc5d26 862
c1a54c05
QY
863 1. All the configured peers, except the shutdown peers, have sent explicit EOR
864 (End-Of-RIB) or an implicit-EOR. The first keep-alive after BGP has reached
865 Established is considered an implicit-EOR.
866 If the establish-wait optional value is given, then BGP will wait for
d1e7591e 867 peers to reach established from the beginning of the update-delay till the
c1a54c05
QY
868 establish-wait period is over, i.e. the minimum set of established peers for
869 which EOR is expected would be peers established during the establish-wait
870 window, not necessarily all the configured neighbors.
871 2. max-delay period is over.
42fc5d26 872
c1a54c05
QY
873 On hitting any of the above two conditions, BGP resumes the decision process
874 and generates updates to its peers.
42fc5d26 875
c1a54c05 876 Default max-delay is 0, i.e. the feature is off by default.
c3c5a71f 877
c1a54c05
QY
878.. index:: table-map ROUTE-MAP-NAME
879.. clicmd:: table-map ROUTE-MAP-NAME
42fc5d26 880
c1a54c05
QY
881 This feature is used to apply a route-map on route updates from BGP to
882 Zebra. All the applicable match operations are allowed, such as match on
883 prefix, next-hop, communities, etc. Set operations for this attach-point are
884 limited to metric and next-hop only. Any operation of this feature does not
885 affect BGPs internal RIB.
42fc5d26 886
c1a54c05
QY
887 Supported for ipv4 and ipv6 address families. It works on multi-paths as
888 well, however, metric setting is based on the best-path only.
42fc5d26 889
8fcedbd2 890.. _bgp-peers:
42fc5d26 891
8fcedbd2
QY
892Peers
893-----
42fc5d26 894
8fcedbd2 895.. _bgp-defining-peers:
42fc5d26 896
8fcedbd2
QY
897Defining Peers
898^^^^^^^^^^^^^^
42fc5d26 899
c1a54c05
QY
900.. index:: neighbor PEER remote-as ASN
901.. clicmd:: neighbor PEER remote-as ASN
42fc5d26 902
c1a54c05 903 Creates a new neighbor whose remote-as is ASN. PEER can be an IPv4 address
9eb95b3b 904 or an IPv6 address or an interface to use for the connection.
76bd1499 905
9eb95b3b
QY
906 .. code-block:: frr
907
908 router bgp 1
909 neighbor 10.0.0.1 remote-as 2
76bd1499 910
c1a54c05 911 In this case my router, in AS-1, is trying to peer with AS-2 at 10.0.0.1.
76bd1499 912
c1a54c05 913 This command must be the first command used when configuring a neighbor. If
9eb95b3b 914 the remote-as is not specified, *bgpd* will complain like this: ::
76bd1499 915
c1a54c05 916 can't find neighbor 10.0.0.1
c3c5a71f 917
5413757f
DS
918.. index:: neighbor PEER remote-as internal
919.. clicmd:: neighbor PEER remote-as internal
920
921 Create a peer as you would when you specify an ASN, except that if the
922 peers ASN is different than mine as specified under the :clicmd:`router bgp ASN`
923 command the connection will be denied.
924
925.. index:: neighbor PEER remote-as external
926.. clicmd:: neighbor PEER remote-as external
927
928 Create a peer as you would when you specify an ASN, except that if the
929 peers ASN is the same as mine as specified under the :clicmd:`router bgp ASN`
930 command the connection will be denied.
42fc5d26 931
d7b9898c
DA
932.. index:: [no] bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME
933.. clicmd:: [no] bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME
d79e0e08
QY
934
935 Accept connections from any peers in the specified prefix. Configuration
936 from the specified peer-group is used to configure these peers.
937
938.. note::
939
940 When using BGP listen ranges, if the associated peer group has TCP MD5
941 authentication configured, your kernel must support this on prefixes. On
942 Linux, this support was added in kernel version 4.14. If your kernel does
943 not support this feature you will get a warning in the log file, and the
944 listen range will only accept connections from peers without MD5 configured.
945
946 Additionally, we have observed that when using this option at scale (several
947 hundred peers) the kernel may hit its option memory limit. In this situation
948 you will see error messages like:
949
950 ``bgpd: sockopt_tcp_signature: setsockopt(23): Cannot allocate memory``
951
952 In this case you need to increase the value of the sysctl
953 ``net.core.optmem_max`` to allow the kernel to allocate the necessary option
954 memory.
955
8fcedbd2 956.. _bgp-configuring-peers:
42fc5d26 957
8fcedbd2
QY
958Configuring Peers
959^^^^^^^^^^^^^^^^^
42fc5d26 960
c0868e8b
QY
961.. index:: [no] neighbor PEER shutdown
962.. clicmd:: [no] neighbor PEER shutdown
c3c5a71f 963
c1a54c05
QY
964 Shutdown the peer. We can delete the neighbor's configuration by
965 ``no neighbor PEER remote-as ASN`` but all configuration of the neighbor
966 will be deleted. When you want to preserve the configuration, but want to
967 drop the BGP peer, use this syntax.
c3c5a71f 968
c0868e8b
QY
969.. index:: [no] neighbor PEER disable-connected-check
970.. clicmd:: [no] neighbor PEER disable-connected-check
c3c5a71f 971
c0868e8b
QY
972 Allow peerings between directly connected eBGP peers using loopback
973 addresses.
c3c5a71f 974
c0868e8b
QY
975.. index:: [no] neighbor PEER ebgp-multihop
976.. clicmd:: [no] neighbor PEER ebgp-multihop
42fc5d26 977
c0868e8b
QY
978.. index:: [no] neighbor PEER description ...
979.. clicmd:: [no] neighbor PEER description ...
42fc5d26 980
c1a54c05 981 Set description of the peer.
42fc5d26 982
c0868e8b
QY
983.. index:: [no] neighbor PEER version VERSION
984.. clicmd:: [no] neighbor PEER version VERSION
42fc5d26 985
4da7fda3
QY
986 Set up the neighbor's BGP version. `version` can be `4`, `4+` or `4-`. BGP
987 version `4` is the default value used for BGP peering. BGP version `4+`
988 means that the neighbor supports Multiprotocol Extensions for BGP-4. BGP
989 version `4-` is similar but the neighbor speaks the old Internet-Draft
990 revision 00's Multiprotocol Extensions for BGP-4. Some routing software is
991 still using this version.
42fc5d26 992
c0868e8b
QY
993.. index:: [no] neighbor PEER interface IFNAME
994.. clicmd:: [no] neighbor PEER interface IFNAME
42fc5d26 995
c1a54c05
QY
996 When you connect to a BGP peer over an IPv6 link-local address, you have to
997 specify the IFNAME of the interface used for the connection. To specify
998 IPv4 session addresses, see the ``neighbor PEER update-source`` command
999 below.
42fc5d26 1000
c1a54c05
QY
1001 This command is deprecated and may be removed in a future release. Its use
1002 should be avoided.
42fc5d26 1003
c0868e8b
QY
1004.. index:: [no] neighbor PEER next-hop-self [all]
1005.. clicmd:: [no] neighbor PEER next-hop-self [all]
42fc5d26 1006
c1a54c05
QY
1007 This command specifies an announced route's nexthop as being equivalent to
1008 the address of the bgp router if it is learned via eBGP. If the optional
d1e7591e 1009 keyword `all` is specified the modification is done also for routes learned
c1a54c05 1010 via iBGP.
42fc5d26 1011
c0868e8b
QY
1012.. index:: [no] neighbor PEER update-source <IFNAME|ADDRESS>
1013.. clicmd:: [no] neighbor PEER update-source <IFNAME|ADDRESS>
42fc5d26 1014
c1a54c05
QY
1015 Specify the IPv4 source address to use for the :abbr:`BGP` session to this
1016 neighbour, may be specified as either an IPv4 address directly or as an
1017 interface name (in which case the *zebra* daemon MUST be running in order
9eb95b3b
QY
1018 for *bgpd* to be able to retrieve interface state).
1019
1020 .. code-block:: frr
42fc5d26 1021
c1a54c05
QY
1022 router bgp 64555
1023 neighbor foo update-source 192.168.0.1
1024 neighbor bar update-source lo0
42fc5d26 1025
42fc5d26 1026
c0868e8b
QY
1027.. index:: [no] neighbor PEER default-originate
1028.. clicmd:: [no] neighbor PEER default-originate
42fc5d26 1029
4da7fda3
QY
1030 *bgpd*'s default is to not announce the default route (0.0.0.0/0) even if it
1031 is in routing table. When you want to announce default routes to the peer,
1032 use this command.
42fc5d26 1033
c1a54c05
QY
1034.. index:: neighbor PEER port PORT
1035.. clicmd:: neighbor PEER port PORT
42fc5d26 1036
c1a54c05
QY
1037.. index:: neighbor PEER send-community
1038.. clicmd:: neighbor PEER send-community
42fc5d26 1039
c0868e8b
QY
1040.. index:: [no] neighbor PEER weight WEIGHT
1041.. clicmd:: [no] neighbor PEER weight WEIGHT
42fc5d26 1042
c1a54c05 1043 This command specifies a default `weight` value for the neighbor's routes.
42fc5d26 1044
c0868e8b
QY
1045.. index:: [no] neighbor PEER maximum-prefix NUMBER
1046.. clicmd:: [no] neighbor PEER maximum-prefix NUMBER
42fc5d26 1047
886026c8
QY
1048 Sets a maximum number of prefixes we can receive from a given peer. If this
1049 number is exceeded, the BGP session will be destroyed.
1050
1051 In practice, it is generally preferable to use a prefix-list to limit what
1052 prefixes are received from the peer instead of using this knob. Tearing down
1053 the BGP session when a limit is exceeded is far more destructive than merely
1054 rejecting undesired prefixes. The prefix-list method is also much more
1055 granular and offers much smarter matching criterion than number of received
1056 prefixes, making it more suited to implementing policy.
1057
1058.. index:: [no] neighbor PEER local-as AS-NUMBER [no-prepend] [replace-as]
1059.. clicmd:: [no] neighbor PEER local-as AS-NUMBER [no-prepend] [replace-as]
42fc5d26 1060
c1a54c05
QY
1061 Specify an alternate AS for this BGP process when interacting with the
1062 specified peer. With no modifiers, the specified local-as is prepended to
1063 the received AS_PATH when receiving routing updates from the peer, and
1064 prepended to the outgoing AS_PATH (after the process local AS) when
1065 transmitting local routes to the peer.
42fc5d26 1066
c1a54c05
QY
1067 If the no-prepend attribute is specified, then the supplied local-as is not
1068 prepended to the received AS_PATH.
c3c5a71f 1069
c1a54c05
QY
1070 If the replace-as attribute is specified, then only the supplied local-as is
1071 prepended to the AS_PATH when transmitting local-route updates to this peer.
c3c5a71f 1072
c1a54c05 1073 Note that replace-as can only be specified if no-prepend is.
c3c5a71f 1074
c1a54c05 1075 This command is only allowed for eBGP peers.
c3c5a71f 1076
c0868e8b
QY
1077.. index:: [no] neighbor PEER ttl-security hops NUMBER
1078.. clicmd:: [no] neighbor PEER ttl-security hops NUMBER
c3c5a71f 1079
c1a54c05
QY
1080 This command enforces Generalized TTL Security Mechanism (GTSM), as
1081 specified in RFC 5082. With this command, only neighbors that are the
1082 specified number of hops away will be allowed to become neighbors. This
d1e7591e 1083 command is mutually exclusive with *ebgp-multihop*.
42fc5d26 1084
19f2b5e8
DS
1085.. index:: [no] neighbor PEER capability extended-nexthop
1086.. clicmd:: [no] neighbor PEER capability extended-nexthop
1087
1088 Allow bgp to negotiate the extended-nexthop capability with it's peer.
1089 If you are peering over a v6 LL address then this capability is turned
1090 on automatically. If you are peering over a v6 Global Address then
1091 turning on this command will allow BGP to install v4 routes with
1092 v6 nexthops if you do not have v4 configured on interfaces.
1093
eb938189
DS
1094.. index:: [no] bgp fast-external-failover
1095.. clicmd:: [no] bgp fast-external-failover
1096
1097 This command causes bgp to not take down ebgp peers immediately
1098 when a link flaps. `bgp fast-external-failover` is the default
1099 and will not be displayed as part of a `show run`. The no form
1100 of the command turns off this ability.
1101
bc132029
DS
1102.. index:: [no] bgp default ipv4-unicast
1103.. clicmd:: [no] bgp default ipv4-unicast
1104
1105 This command allows the user to specify that v4 peering is turned
1106 on by default or not. This command defaults to on and is not displayed.
1107 The `no bgp default ipv4-unicast` form of the command is displayed.
1108
e10dda57
DS
1109.. index:: [no] neighbor PEER advertisement-interval (0-600)
1110.. clicmd:: [no] neighbor PEER advertisement-interval (0-600)
1111
1112 Setup the minimum route advertisement interval(mrai) for the
1113 peer in question. This number is between 0 and 600 seconds,
1114 with the default advertisement interval being 0.
1115
8fcedbd2 1116.. _bgp-peer-filtering:
42fc5d26 1117
8fcedbd2
QY
1118Peer Filtering
1119^^^^^^^^^^^^^^
42fc5d26 1120
c1a54c05
QY
1121.. index:: neighbor PEER distribute-list NAME [in|out]
1122.. clicmd:: neighbor PEER distribute-list NAME [in|out]
42fc5d26 1123
c1a54c05
QY
1124 This command specifies a distribute-list for the peer. `direct` is
1125 ``in`` or ``out``.
42fc5d26 1126
c3c5a71f 1127.. index:: neighbor PEER prefix-list NAME [in|out]
29adcd50 1128.. clicmd:: neighbor PEER prefix-list NAME [in|out]
42fc5d26 1129
c1a54c05 1130.. index:: neighbor PEER filter-list NAME [in|out]
29adcd50 1131.. clicmd:: neighbor PEER filter-list NAME [in|out]
42fc5d26 1132
c1a54c05
QY
1133.. index:: neighbor PEER route-map NAME [in|out]
1134.. clicmd:: neighbor PEER route-map NAME [in|out]
42fc5d26 1135
c1a54c05 1136 Apply a route-map on the neighbor. `direct` must be `in` or `out`.
42fc5d26 1137
c3c5a71f 1138.. index:: bgp route-reflector allow-outbound-policy
29adcd50 1139.. clicmd:: bgp route-reflector allow-outbound-policy
42fc5d26 1140
c1a54c05
QY
1141 By default, attribute modification via route-map policy out is not reflected
1142 on reflected routes. This option allows the modifications to be reflected as
1143 well. Once enabled, it affects all reflected routes.
42fc5d26 1144
583a9fd4
RZ
1145.. index:: [no] neighbor PEER sender-as-path-loop-detection
1146.. clicmd:: [no] neighbor PEER sender-as-path-loop-detection
1147
1148 Enable the detection of sender side AS path loops and filter the
1149 bad routes before they are sent.
1150
1151 This setting is disabled by default.
1152
0efdf0fe 1153.. _bgp-peer-group:
42fc5d26 1154
8fcedbd2
QY
1155Peer Groups
1156^^^^^^^^^^^
42fc5d26 1157
199ad5c4
LB
1158Peer groups are used to help improve scaling by generating the same
1159update information to all members of a peer group. Note that this means
1160that the routes generated by a member of a peer group will be sent back
1161to that originating peer with the originator identifier attribute set to
1162indicated the originating peer. All peers not associated with a
1163specific peer group are treated as belonging to a default peer group,
1164and will share updates.
1165
c1a54c05
QY
1166.. index:: neighbor WORD peer-group
1167.. clicmd:: neighbor WORD peer-group
42fc5d26 1168
c1a54c05 1169 This command defines a new peer group.
42fc5d26 1170
d7b9898c
DA
1171.. index:: neighbor PEER peer-group PGNAME
1172.. clicmd:: neighbor PEER peer-group PGNAME
c3c5a71f 1173
c1a54c05 1174 This command bind specific peer to peer group WORD.
42fc5d26 1175
199ad5c4
LB
1176.. index:: neighbor PEER solo
1177.. clicmd:: neighbor PEER solo
1178
1179 This command is used to indicate that routes advertised by the peer
1180 should not be reflected back to the peer. This command only is only
1181 meaningful when there is a single peer defined in the peer-group.
1182
8fcedbd2
QY
1183Capability Negotiation
1184^^^^^^^^^^^^^^^^^^^^^^
42fc5d26 1185
8fcedbd2
QY
1186.. index:: neighbor PEER strict-capability-match
1187.. clicmd:: neighbor PEER strict-capability-match
42fc5d26 1188
8fcedbd2
QY
1189.. index:: no neighbor PEER strict-capability-match
1190.. clicmd:: no neighbor PEER strict-capability-match
c1a54c05 1191
8fcedbd2
QY
1192 Strictly compares remote capabilities and local capabilities. If
1193 capabilities are different, send Unsupported Capability error then reset
1194 connection.
42fc5d26 1195
8fcedbd2
QY
1196 You may want to disable sending Capability Negotiation OPEN message optional
1197 parameter to the peer when remote peer does not implement Capability
1198 Negotiation. Please use *dont-capability-negotiate* command to disable the
1199 feature.
42fc5d26 1200
7cdc9530
DS
1201.. index:: [no] neighbor PEER dont-capability-negotiate
1202.. clicmd:: [no] neighbor PEER dont-capability-negotiate
42fc5d26 1203
8fcedbd2
QY
1204 Suppress sending Capability Negotiation as OPEN message optional parameter
1205 to the peer. This command only affects the peer is configured other than
1206 IPv4 unicast configuration.
42fc5d26 1207
8fcedbd2
QY
1208 When remote peer does not have capability negotiation feature, remote peer
1209 will not send any capabilities at all. In that case, bgp configures the peer
1210 with configured capabilities.
42fc5d26 1211
8fcedbd2
QY
1212 You may prefer locally configured capabilities more than the negotiated
1213 capabilities even though remote peer sends capabilities. If the peer is
1214 configured by *override-capability*, *bgpd* ignores received capabilities
1215 then override negotiated capabilities with configured values.
42fc5d26 1216
7cdc9530
DS
1217 Additionally the operator should be reminded that this feature fundamentally
1218 disables the ability to use widely deployed BGP features. BGP unnumbered,
1219 hostname support, AS4, Addpath, Route Refresh, ORF, Dynamic Capabilities,
1220 and graceful restart.
1221
8fcedbd2
QY
1222.. index:: neighbor PEER override-capability
1223.. clicmd:: neighbor PEER override-capability
42fc5d26 1224
8fcedbd2
QY
1225.. index:: no neighbor PEER override-capability
1226.. clicmd:: no neighbor PEER override-capability
c1a54c05 1227
8fcedbd2
QY
1228 Override the result of Capability Negotiation with local configuration.
1229 Ignore remote peer's capability value.
42fc5d26 1230
8fcedbd2 1231.. _bgp-as-path-access-lists:
42fc5d26 1232
8fcedbd2
QY
1233AS Path Access Lists
1234--------------------
42fc5d26
QY
1235
1236AS path access list is user defined AS path.
1237
a64e0ee5
DA
1238.. index:: bgp as-path access-list WORD permit|deny LINE
1239.. clicmd:: bgp as-path access-list WORD permit|deny LINE
42fc5d26 1240
c1a54c05 1241 This command defines a new AS path access list.
42fc5d26 1242
a64e0ee5
DA
1243.. index:: no bgp as-path access-list WORD
1244.. clicmd:: no bgp as-path access-list WORD
42fc5d26 1245
a64e0ee5
DA
1246.. index:: no bgp as-path access-list WORD permit|deny LINE
1247.. clicmd:: no bgp as-path access-list WORD permit|deny LINE
42fc5d26 1248
8fcedbd2 1249.. _bgp-using-as-path-in-route-map:
42fc5d26
QY
1250
1251Using AS Path in Route Map
1252--------------------------
1253
eb1f303d
DS
1254.. index:: [no] match as-path WORD
1255.. clicmd:: [no] match as-path WORD
42fc5d26 1256
eb1f303d
DS
1257 For a given as-path, WORD, match it on the BGP as-path given for the prefix
1258 and if it matches do normal route-map actions. The no form of the command
1259 removes this match from the route-map.
42fc5d26 1260
eb1f303d
DS
1261.. index:: [no] set as-path prepend AS-PATH
1262.. clicmd:: [no] set as-path prepend AS-PATH
42fc5d26 1263
eb1f303d
DS
1264 Prepend the given string of AS numbers to the AS_PATH of the BGP path's NLRI.
1265 The no form of this command removes this set operation from the route-map.
42fc5d26 1266
eb1f303d
DS
1267.. index:: [no] set as-path prepend last-as NUM
1268.. clicmd:: [no] set as-path prepend last-as NUM
c1a54c05
QY
1269
1270 Prepend the existing last AS number (the leftmost ASN) to the AS_PATH.
eb1f303d 1271 The no form of this command removes this set operation from the route-map.
42fc5d26 1272
0efdf0fe 1273.. _bgp-communities-attribute:
42fc5d26 1274
8fcedbd2
QY
1275Communities Attribute
1276---------------------
42fc5d26 1277
8fcedbd2 1278The BGP communities attribute is widely used for implementing policy routing.
c1a54c05
QY
1279Network operators can manipulate BGP communities attribute based on their
1280network policy. BGP communities attribute is defined in :rfc:`1997` and
1281:rfc:`1998`. It is an optional transitive attribute, therefore local policy can
1282travel through different autonomous system.
1283
8fcedbd2
QY
1284The communities attribute is a set of communities values. Each community value
1285is 4 octet long. The following format is used to define the community value.
c1a54c05 1286
8fcedbd2 1287``AS:VAL``
c1a54c05
QY
1288 This format represents 4 octet communities value. ``AS`` is high order 2
1289 octet in digit format. ``VAL`` is low order 2 octet in digit format. This
1290 format is useful to define AS oriented policy value. For example,
1291 ``7675:80`` can be used when AS 7675 wants to pass local policy value 80 to
1292 neighboring peer.
1293
8fcedbd2
QY
1294``internet``
1295 ``internet`` represents well-known communities value 0.
c1a54c05 1296
cae770d3
C
1297``graceful-shutdown``
1298 ``graceful-shutdown`` represents well-known communities value
1299 ``GRACEFUL_SHUTDOWN`` ``0xFFFF0000`` ``65535:0``. :rfc:`8326` implements
1300 the purpose Graceful BGP Session Shutdown to reduce the amount of
56f0bea7 1301 lost traffic when taking BGP sessions down for maintenance. The use
cae770d3
C
1302 of the community needs to be supported from your peers side to
1303 actually have any effect.
1304
1305``accept-own``
1306 ``accept-own`` represents well-known communities value ``ACCEPT_OWN``
1307 ``0xFFFF0001`` ``65535:1``. :rfc:`7611` implements a way to signal
1308 to a router to accept routes with a local nexthop address. This
1309 can be the case when doing policing and having traffic having a
1310 nexthop located in another VRF but still local interface to the
1311 router. It is recommended to read the RFC for full details.
1312
1313``route-filter-translated-v4``
1314 ``route-filter-translated-v4`` represents well-known communities value
1315 ``ROUTE_FILTER_TRANSLATED_v4`` ``0xFFFF0002`` ``65535:2``.
1316
1317``route-filter-v4``
1318 ``route-filter-v4`` represents well-known communities value
1319 ``ROUTE_FILTER_v4`` ``0xFFFF0003`` ``65535:3``.
1320
1321``route-filter-translated-v6``
1322 ``route-filter-translated-v6`` represents well-known communities value
1323 ``ROUTE_FILTER_TRANSLATED_v6`` ``0xFFFF0004`` ``65535:4``.
1324
1325``route-filter-v6``
1326 ``route-filter-v6`` represents well-known communities value
1327 ``ROUTE_FILTER_v6`` ``0xFFFF0005`` ``65535:5``.
1328
1329``llgr-stale``
1330 ``llgr-stale`` represents well-known communities value ``LLGR_STALE``
1331 ``0xFFFF0006`` ``65535:6``.
56f0bea7 1332 Assigned and intended only for use with routers supporting the
cae770d3 1333 Long-lived Graceful Restart Capability as described in
49606d58 1334 [Draft-IETF-uttaro-idr-bgp-persistence]_.
56f0bea7 1335 Routers receiving routes with this community may (depending on
cae770d3
C
1336 implementation) choose allow to reject or modify routes on the
1337 presence or absence of this community.
1338
1339``no-llgr``
1340 ``no-llgr`` represents well-known communities value ``NO_LLGR``
1341 ``0xFFFF0007`` ``65535:7``.
56f0bea7 1342 Assigned and intended only for use with routers supporting the
cae770d3 1343 Long-lived Graceful Restart Capability as described in
49606d58 1344 [Draft-IETF-uttaro-idr-bgp-persistence]_.
56f0bea7 1345 Routers receiving routes with this community may (depending on
cae770d3
C
1346 implementation) choose allow to reject or modify routes on the
1347 presence or absence of this community.
1348
1349``accept-own-nexthop``
1350 ``accept-own-nexthop`` represents well-known communities value
1351 ``accept-own-nexthop`` ``0xFFFF0008`` ``65535:8``.
49606d58 1352 [Draft-IETF-agrewal-idr-accept-own-nexthop]_ describes
cae770d3
C
1353 how to tag and label VPN routes to be able to send traffic between VRFs
1354 via an internal layer 2 domain on the same PE device. Refer to
49606d58 1355 [Draft-IETF-agrewal-idr-accept-own-nexthop]_ for full details.
cae770d3
C
1356
1357``blackhole``
1358 ``blackhole`` represents well-known communities value ``BLACKHOLE``
1359 ``0xFFFF029A`` ``65535:666``. :rfc:`7999` documents sending prefixes to
1360 EBGP peers and upstream for the purpose of blackholing traffic.
1361 Prefixes tagged with the this community should normally not be
1362 re-advertised from neighbors of the originating network. It is
1363 recommended upon receiving prefixes tagged with this community to
1364 add ``NO_EXPORT`` and ``NO_ADVERTISE``.
1365
8fcedbd2 1366``no-export``
c1a54c05
QY
1367 ``no-export`` represents well-known communities value ``NO_EXPORT``
1368 ``0xFFFFFF01``. All routes carry this value must not be advertised to
1369 outside a BGP confederation boundary. If neighboring BGP peer is part of BGP
1370 confederation, the peer is considered as inside a BGP confederation
1371 boundary, so the route will be announced to the peer.
1372
8fcedbd2 1373``no-advertise``
c1a54c05
QY
1374 ``no-advertise`` represents well-known communities value ``NO_ADVERTISE``
1375 ``0xFFFFFF02``. All routes carry this value must not be advertise to other
1376 BGP peers.
1377
8fcedbd2 1378``local-AS``
c1a54c05
QY
1379 ``local-AS`` represents well-known communities value ``NO_EXPORT_SUBCONFED``
1380 ``0xFFFFFF03``. All routes carry this value must not be advertised to
1381 external BGP peers. Even if the neighboring router is part of confederation,
1382 it is considered as external BGP peer, so the route will not be announced to
1383 the peer.
1384
cae770d3
C
1385``no-peer``
1386 ``no-peer`` represents well-known communities value ``NOPEER``
1387 ``0xFFFFFF04`` ``65535:65284``. :rfc:`3765` is used to communicate to
1388 another network how the originating network want the prefix propagated.
1389
aa9eafa4
QY
1390When the communities attribute is received duplicate community values in the
1391attribute are ignored and value is sorted in numerical order.
42fc5d26 1392
49606d58
PG
1393.. [Draft-IETF-uttaro-idr-bgp-persistence] <https://tools.ietf.org/id/draft-uttaro-idr-bgp-persistence-04.txt>
1394.. [Draft-IETF-agrewal-idr-accept-own-nexthop] <https://tools.ietf.org/id/draft-agrewal-idr-accept-own-nexthop-00.txt>
1395
0efdf0fe 1396.. _bgp-community-lists:
42fc5d26 1397
8fcedbd2
QY
1398Community Lists
1399^^^^^^^^^^^^^^^
aa9eafa4
QY
1400Community lists are user defined lists of community attribute values. These
1401lists can be used for matching or manipulating the communities attribute in
1402UPDATE messages.
42fc5d26 1403
aa9eafa4 1404There are two types of community list:
c1a54c05 1405
aa9eafa4 1406standard
56f0bea7 1407 This type accepts an explicit value for the attribute.
aa9eafa4
QY
1408
1409expanded
1410 This type accepts a regular expression. Because the regex must be
1411 interpreted on each use expanded community lists are slower than standard
1412 lists.
42fc5d26 1413
a64e0ee5
DA
1414.. index:: bgp community-list standard NAME permit|deny COMMUNITY
1415.. clicmd:: bgp community-list standard NAME permit|deny COMMUNITY
42fc5d26 1416
aa9eafa4
QY
1417 This command defines a new standard community list. ``COMMUNITY`` is
1418 communities value. The ``COMMUNITY`` is compiled into community structure.
1419 We can define multiple community list under same name. In that case match
1420 will happen user defined order. Once the community list matches to
1421 communities attribute in BGP updates it return permit or deny by the
1422 community list definition. When there is no matched entry, deny will be
1423 returned. When ``COMMUNITY`` is empty it matches to any routes.
42fc5d26 1424
a64e0ee5
DA
1425.. index:: bgp community-list expanded NAME permit|deny COMMUNITY
1426.. clicmd:: bgp community-list expanded NAME permit|deny COMMUNITY
42fc5d26 1427
aa9eafa4
QY
1428 This command defines a new expanded community list. ``COMMUNITY`` is a
1429 string expression of communities attribute. ``COMMUNITY`` can be a regular
1430 expression (:ref:`bgp-regular-expressions`) to match the communities
47f47873
PG
1431 attribute in BGP updates. The expanded community is only used to filter,
1432 not `set` actions.
42fc5d26 1433
aa9eafa4
QY
1434.. deprecated:: 5.0
1435 It is recommended to use the more explicit versions of this command.
42fc5d26 1436
a64e0ee5
DA
1437.. index:: bgp community-list NAME permit|deny COMMUNITY
1438.. clicmd:: bgp community-list NAME permit|deny COMMUNITY
aa9eafa4
QY
1439
1440 When the community list type is not specified, the community list type is
1441 automatically detected. If ``COMMUNITY`` can be compiled into communities
1442 attribute, the community list is defined as a standard community list.
1443 Otherwise it is defined as an expanded community list. This feature is left
1444 for backward compatibility. Use of this feature is not recommended.
42fc5d26 1445
42fc5d26 1446
a64e0ee5
DA
1447.. index:: no bgp community-list [standard|expanded] NAME
1448.. clicmd:: no bgp community-list [standard|expanded] NAME
42fc5d26 1449
aa9eafa4
QY
1450 Deletes the community list specified by ``NAME``. All community lists share
1451 the same namespace, so it's not necessary to specify ``standard`` or
1452 ``expanded``; these modifiers are purely aesthetic.
42fc5d26 1453
a64e0ee5
DA
1454.. index:: show bgp community-list [NAME]
1455.. clicmd:: show bgp community-list [NAME]
42fc5d26 1456
aa9eafa4
QY
1457 Displays community list information. When ``NAME`` is specified the
1458 specified community list's information is shown.
c3c5a71f 1459
c1a54c05 1460 ::
76bd1499 1461
a64e0ee5 1462 # show bgp community-list
c1a54c05
QY
1463 Named Community standard list CLIST
1464 permit 7675:80 7675:100 no-export
1465 deny internet
1466 Named Community expanded list EXPAND
1467 permit :
76bd1499 1468
a64e0ee5 1469 # show bgp community-list CLIST
c1a54c05
QY
1470 Named Community standard list CLIST
1471 permit 7675:80 7675:100 no-export
1472 deny internet
42fc5d26 1473
42fc5d26 1474
8fcedbd2 1475.. _bgp-numbered-community-lists:
42fc5d26 1476
8fcedbd2
QY
1477Numbered Community Lists
1478^^^^^^^^^^^^^^^^^^^^^^^^
42fc5d26
QY
1479
1480When number is used for BGP community list name, the number has
c3c5a71f
QY
1481special meanings. Community list number in the range from 1 and 99 is
1482standard community list. Community list number in the range from 100
1483to 199 is expanded community list. These community lists are called
1484as numbered community lists. On the other hand normal community lists
42fc5d26
QY
1485is called as named community lists.
1486
a64e0ee5
DA
1487.. index:: bgp community-list (1-99) permit|deny COMMUNITY
1488.. clicmd:: bgp community-list (1-99) permit|deny COMMUNITY
42fc5d26 1489
aa9eafa4
QY
1490 This command defines a new community list. The argument to (1-99) defines
1491 the list identifier.
42fc5d26 1492
a64e0ee5
DA
1493.. index:: bgp community-list (100-199) permit|deny COMMUNITY
1494.. clicmd:: bgp community-list (100-199) permit|deny COMMUNITY
42fc5d26 1495
aa9eafa4
QY
1496 This command defines a new expanded community list. The argument to
1497 (100-199) defines the list identifier.
42fc5d26 1498
8fcedbd2 1499.. _bgp-using-communities-in-route-map:
42fc5d26 1500
8fcedbd2
QY
1501Using Communities in Route Maps
1502^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42fc5d26 1503
aa9eafa4
QY
1504In :ref:`route-map` we can match on or set the BGP communities attribute. Using
1505this feature network operator can implement their network policy based on BGP
1506communities attribute.
42fc5d26 1507
aa9eafa4 1508The ollowing commands can be used in route maps:
42fc5d26 1509
aa9eafa4
QY
1510.. index:: match community WORD exact-match [exact-match]
1511.. clicmd:: match community WORD exact-match [exact-match]
42fc5d26 1512
c1a54c05
QY
1513 This command perform match to BGP updates using community list WORD. When
1514 the one of BGP communities value match to the one of communities value in
d1e7591e 1515 community list, it is match. When `exact-match` keyword is specified, match
c1a54c05
QY
1516 happen only when BGP updates have completely same communities value
1517 specified in the community list.
42fc5d26 1518
aa9eafa4
QY
1519.. index:: set community <none|COMMUNITY> additive
1520.. clicmd:: set community <none|COMMUNITY> additive
42fc5d26 1521
aa9eafa4
QY
1522 This command sets the community value in BGP updates. If the attribute is
1523 already configured, the newly provided value replaces the old one unless the
1524 ``additive`` keyword is specified, in which case the new value is appended
1525 to the existing value.
42fc5d26 1526
aa9eafa4
QY
1527 If ``none`` is specified as the community value, the communities attribute
1528 is not sent.
42fc5d26 1529
47f47873
PG
1530 It is not possible to set an expanded community list.
1531
c1a54c05 1532.. index:: set comm-list WORD delete
29adcd50 1533.. clicmd:: set comm-list WORD delete
c1a54c05 1534
aa9eafa4
QY
1535 This command remove communities value from BGP communities attribute. The
1536 ``word`` is community list name. When BGP route's communities value matches
1537 to the community list ``word``, the communities value is removed. When all
1538 of communities value is removed eventually, the BGP update's communities
1539 attribute is completely removed.
42fc5d26 1540
8fcedbd2 1541.. _bgp-communities-example:
c1a54c05 1542
8fcedbd2
QY
1543Example Configuration
1544^^^^^^^^^^^^^^^^^^^^^
9eb95b3b 1545
8fcedbd2
QY
1546The following configuration is exemplary of the most typical usage of BGP
1547communities attribute. In the example, AS 7675 provides an upstream Internet
1548connection to AS 100. When the following configuration exists in AS 7675, the
1549network operator of AS 100 can set local preference in AS 7675 network by
1550setting BGP communities attribute to the updates.
9eb95b3b
QY
1551
1552.. code-block:: frr
c1a54c05
QY
1553
1554 router bgp 7675
1555 neighbor 192.168.0.1 remote-as 100
1556 address-family ipv4 unicast
1557 neighbor 192.168.0.1 route-map RMAP in
1558 exit-address-family
1559 !
a64e0ee5
DA
1560 bgp community-list 70 permit 7675:70
1561 bgp community-list 70 deny
1562 bgp community-list 80 permit 7675:80
1563 bgp community-list 80 deny
1564 bgp community-list 90 permit 7675:90
1565 bgp community-list 90 deny
c1a54c05
QY
1566 !
1567 route-map RMAP permit 10
1568 match community 70
1569 set local-preference 70
1570 !
1571 route-map RMAP permit 20
1572 match community 80
1573 set local-preference 80
1574 !
1575 route-map RMAP permit 30
1576 match community 90
1577 set local-preference 90
c3c5a71f 1578
42fc5d26 1579
8fcedbd2
QY
1580The following configuration announces ``10.0.0.0/8`` from AS 100 to AS 7675.
1581The route has communities value ``7675:80`` so when above configuration exists
1582in AS 7675, the announced routes' local preference value will be set to 80.
9eb95b3b
QY
1583
1584.. code-block:: frr
c1a54c05
QY
1585
1586 router bgp 100
1587 network 10.0.0.0/8
1588 neighbor 192.168.0.2 remote-as 7675
1589 address-family ipv4 unicast
1590 neighbor 192.168.0.2 route-map RMAP out
1591 exit-address-family
1592 !
1593 ip prefix-list PLIST permit 10.0.0.0/8
1594 !
1595 route-map RMAP permit 10
1596 match ip address prefix-list PLIST
1597 set community 7675:80
c3c5a71f 1598
42fc5d26 1599
8fcedbd2
QY
1600The following configuration is an example of BGP route filtering using
1601communities attribute. This configuration only permit BGP routes which has BGP
1602communities value ``0:80`` or ``0:90``. The network operator can set special
1603internal communities value at BGP border router, then limit the BGP route
1604announcements into the internal network.
9eb95b3b
QY
1605
1606.. code-block:: frr
42fc5d26 1607
c1a54c05
QY
1608 router bgp 7675
1609 neighbor 192.168.0.1 remote-as 100
1610 address-family ipv4 unicast
1611 neighbor 192.168.0.1 route-map RMAP in
1612 exit-address-family
1613 !
a64e0ee5 1614 bgp community-list 1 permit 0:80 0:90
c1a54c05
QY
1615 !
1616 route-map RMAP permit in
1617 match community 1
c3c5a71f 1618
42fc5d26 1619
8fcedbd2
QY
1620The following example filters BGP routes which have a community value of
1621``1:1``. When there is no match community-list returns ``deny``. To avoid
1622filtering all routes, a ``permit`` line is set at the end of the
1623community-list.
9eb95b3b
QY
1624
1625.. code-block:: frr
42fc5d26 1626
c1a54c05
QY
1627 router bgp 7675
1628 neighbor 192.168.0.1 remote-as 100
1629 address-family ipv4 unicast
1630 neighbor 192.168.0.1 route-map RMAP in
1631 exit-address-family
1632 !
a64e0ee5
DA
1633 bgp community-list standard FILTER deny 1:1
1634 bgp community-list standard FILTER permit
c1a54c05
QY
1635 !
1636 route-map RMAP permit 10
1637 match community FILTER
c3c5a71f 1638
42fc5d26 1639
8fcedbd2
QY
1640The communities value keyword ``internet`` has special meanings in standard
1641community lists. In the below example ``internet`` matches all BGP routes even
1642if the route does not have communities attribute at all. So community list
1643``INTERNET`` is the same as ``FILTER`` in the previous example.
9eb95b3b
QY
1644
1645.. code-block:: frr
42fc5d26 1646
a64e0ee5
DA
1647 bgp community-list standard INTERNET deny 1:1
1648 bgp community-list standard INTERNET permit internet
c3c5a71f 1649
42fc5d26 1650
8fcedbd2
QY
1651The following configuration is an example of communities value deletion. With
1652this configuration the community values ``100:1`` and ``100:2`` are removed
1653from BGP updates. For communities value deletion, only ``permit``
1654community-list is used. ``deny`` community-list is ignored.
9eb95b3b
QY
1655
1656.. code-block:: frr
42fc5d26 1657
c1a54c05
QY
1658 router bgp 7675
1659 neighbor 192.168.0.1 remote-as 100
1660 address-family ipv4 unicast
1661 neighbor 192.168.0.1 route-map RMAP in
1662 exit-address-family
1663 !
a64e0ee5 1664 bgp community-list standard DEL permit 100:1 100:2
c1a54c05
QY
1665 !
1666 route-map RMAP permit 10
1667 set comm-list DEL delete
c3c5a71f 1668
42fc5d26 1669
0efdf0fe 1670.. _bgp-extended-communities-attribute:
42fc5d26 1671
8fcedbd2
QY
1672Extended Communities Attribute
1673^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42fc5d26 1674
c1a54c05
QY
1675BGP extended communities attribute is introduced with MPLS VPN/BGP technology.
1676MPLS VPN/BGP expands capability of network infrastructure to provide VPN
1677functionality. At the same time it requires a new framework for policy routing.
1678With BGP Extended Communities Attribute we can use Route Target or Site of
1679Origin for implementing network policy for MPLS VPN/BGP.
42fc5d26 1680
c1a54c05
QY
1681BGP Extended Communities Attribute is similar to BGP Communities Attribute. It
1682is an optional transitive attribute. BGP Extended Communities Attribute can
1683carry multiple Extended Community value. Each Extended Community value is
1684eight octet length.
42fc5d26 1685
c1a54c05
QY
1686BGP Extended Communities Attribute provides an extended range compared with BGP
1687Communities Attribute. Adding to that there is a type field in each value to
1688provides community space structure.
42fc5d26 1689
c1a54c05
QY
1690There are two format to define Extended Community value. One is AS based format
1691the other is IP address based format.
42fc5d26 1692
8fcedbd2
QY
1693``AS:VAL``
1694 This is a format to define AS based Extended Community value. ``AS`` part
1695 is 2 octets Global Administrator subfield in Extended Community value.
1696 ``VAL`` part is 4 octets Local Administrator subfield. ``7675:100``
1697 represents AS 7675 policy value 100.
42fc5d26 1698
8fcedbd2 1699``IP-Address:VAL``
c1a54c05 1700 This is a format to define IP address based Extended Community value.
8fcedbd2
QY
1701 ``IP-Address`` part is 4 octets Global Administrator subfield. ``VAL`` part
1702 is 2 octets Local Administrator subfield.
42fc5d26 1703
0efdf0fe 1704.. _bgp-extended-community-lists:
42fc5d26 1705
8fcedbd2
QY
1706Extended Community Lists
1707^^^^^^^^^^^^^^^^^^^^^^^^
42fc5d26 1708
a64e0ee5
DA
1709.. index:: bgp extcommunity-list standard NAME permit|deny EXTCOMMUNITY
1710.. clicmd:: bgp extcommunity-list standard NAME permit|deny EXTCOMMUNITY
42fc5d26 1711
4da7fda3
QY
1712 This command defines a new standard extcommunity-list. `extcommunity` is
1713 extended communities value. The `extcommunity` is compiled into extended
1714 community structure. We can define multiple extcommunity-list under same
1715 name. In that case match will happen user defined order. Once the
1716 extcommunity-list matches to extended communities attribute in BGP updates
1717 it return permit or deny based upon the extcommunity-list definition. When
1718 there is no matched entry, deny will be returned. When `extcommunity` is
1719 empty it matches to any routes.
42fc5d26 1720
a64e0ee5
DA
1721.. index:: bgp extcommunity-list expanded NAME permit|deny LINE
1722.. clicmd:: bgp extcommunity-list expanded NAME permit|deny LINE
42fc5d26 1723
4da7fda3
QY
1724 This command defines a new expanded extcommunity-list. `line` is a string
1725 expression of extended communities attribute. `line` can be a regular
1726 expression (:ref:`bgp-regular-expressions`) to match an extended communities
1727 attribute in BGP updates.
42fc5d26 1728
a64e0ee5
DA
1729.. index:: no bgp extcommunity-list NAME
1730.. clicmd:: no bgp extcommunity-list NAME
42fc5d26 1731
a64e0ee5
DA
1732.. index:: no bgp extcommunity-list standard NAME
1733.. clicmd:: no bgp extcommunity-list standard NAME
42fc5d26 1734
a64e0ee5
DA
1735.. index:: no bgp extcommunity-list expanded NAME
1736.. clicmd:: no bgp extcommunity-list expanded NAME
42fc5d26 1737
4da7fda3
QY
1738 These commands delete extended community lists specified by `name`. All of
1739 extended community lists shares a single name space. So extended community
d1e7591e 1740 lists can be removed simply specifying the name.
42fc5d26 1741
a64e0ee5
DA
1742.. index:: show bgp extcommunity-list
1743.. clicmd:: show bgp extcommunity-list
42fc5d26 1744
a64e0ee5
DA
1745.. index:: show bgp extcommunity-list NAME
1746.. clicmd:: show bgp extcommunity-list NAME
c1a54c05 1747
4da7fda3 1748 This command displays current extcommunity-list information. When `name` is
9eb95b3b 1749 specified the community list's information is shown.::
42fc5d26 1750
a64e0ee5 1751 # show bgp extcommunity-list
c3c5a71f 1752
42fc5d26 1753
0efdf0fe 1754.. _bgp-extended-communities-in-route-map:
42fc5d26
QY
1755
1756BGP Extended Communities in Route Map
8fcedbd2 1757"""""""""""""""""""""""""""""""""""""
42fc5d26 1758
c3c5a71f 1759.. index:: match extcommunity WORD
29adcd50 1760.. clicmd:: match extcommunity WORD
42fc5d26 1761
c1a54c05 1762.. index:: set extcommunity rt EXTCOMMUNITY
29adcd50 1763.. clicmd:: set extcommunity rt EXTCOMMUNITY
42fc5d26 1764
c1a54c05 1765 This command set Route Target value.
42fc5d26 1766
c1a54c05 1767.. index:: set extcommunity soo EXTCOMMUNITY
29adcd50 1768.. clicmd:: set extcommunity soo EXTCOMMUNITY
c1a54c05
QY
1769
1770 This command set Site of Origin value.
42fc5d26 1771
47f47873
PG
1772
1773Note that the extended expanded community is only used for `match` rule, not for
1774`set` actions.
1775
0efdf0fe 1776.. _bgp-large-communities-attribute:
42fc5d26 1777
8fcedbd2
QY
1778Large Communities Attribute
1779^^^^^^^^^^^^^^^^^^^^^^^^^^^
42fc5d26
QY
1780
1781The BGP Large Communities attribute was introduced in Feb 2017 with
c1a54c05 1782:rfc:`8092`.
42fc5d26 1783
8fcedbd2
QY
1784The BGP Large Communities Attribute is similar to the BGP Communities Attribute
1785except that it has 3 components instead of two and each of which are 4 octets
1786in length. Large Communities bring additional functionality and convenience
1787over traditional communities, specifically the fact that the ``GLOBAL`` part
1788below is now 4 octets wide allowing seamless use in networks using 4-byte ASNs.
1789
1790``GLOBAL:LOCAL1:LOCAL2``
1791 This is the format to define Large Community values. Referencing :rfc:`8195`
1792 the values are commonly referred to as follows:
1793
1794 - The ``GLOBAL`` part is a 4 octet Global Administrator field, commonly used
1795 as the operators AS number.
1796 - The ``LOCAL1`` part is a 4 octet Local Data Part 1 subfield referred to as
1797 a function.
1798 - The ``LOCAL2`` part is a 4 octet Local Data Part 2 field and referred to
1799 as the parameter subfield.
1800
1801 As an example, ``65551:1:10`` represents AS 65551 function 1 and parameter
1802 10. The referenced RFC above gives some guidelines on recommended usage.
42fc5d26 1803
0efdf0fe 1804.. _bgp-large-community-lists:
42fc5d26 1805
8fcedbd2
QY
1806Large Community Lists
1807"""""""""""""""""""""
42fc5d26
QY
1808
1809Two types of large community lists are supported, namely `standard` and
1810`expanded`.
1811
a64e0ee5
DA
1812.. index:: bgp large-community-list standard NAME permit|deny LARGE-COMMUNITY
1813.. clicmd:: bgp large-community-list standard NAME permit|deny LARGE-COMMUNITY
42fc5d26 1814
4da7fda3
QY
1815 This command defines a new standard large-community-list. `large-community`
1816 is the Large Community value. We can add multiple large communities under
1817 same name. In that case the match will happen in the user defined order.
1818 Once the large-community-list matches the Large Communities attribute in BGP
1819 updates it will return permit or deny based upon the large-community-list
1820 definition. When there is no matched entry, a deny will be returned. When
1821 `large-community` is empty it matches any routes.
42fc5d26 1822
a64e0ee5
DA
1823.. index:: bgp large-community-list expanded NAME permit|deny LINE
1824.. clicmd:: bgp large-community-list expanded NAME permit|deny LINE
42fc5d26 1825
4da7fda3
QY
1826 This command defines a new expanded large-community-list. Where `line` is a
1827 string matching expression, it will be compared to the entire Large
1828 Communities attribute as a string, with each large-community in order from
1829 lowest to highest. `line` can also be a regular expression which matches
1830 this Large Community attribute.
42fc5d26 1831
a64e0ee5
DA
1832.. index:: no bgp large-community-list NAME
1833.. clicmd:: no bgp large-community-list NAME
42fc5d26 1834
a64e0ee5
DA
1835.. index:: no bgp large-community-list standard NAME
1836.. clicmd:: no bgp large-community-list standard NAME
42fc5d26 1837
a64e0ee5
DA
1838.. index:: no bgp large-community-list expanded NAME
1839.. clicmd:: no bgp large-community-list expanded NAME
42fc5d26 1840
4da7fda3
QY
1841 These commands delete Large Community lists specified by `name`. All Large
1842 Community lists share a single namespace. This means Large Community lists
1843 can be removed by simply specifying the name.
42fc5d26 1844
a64e0ee5
DA
1845.. index:: show bgp large-community-list
1846.. clicmd:: show bgp large-community-list
42fc5d26 1847
a64e0ee5
DA
1848.. index:: show bgp large-community-list NAME
1849.. clicmd:: show bgp large-community-list NAME
42fc5d26 1850
c1a54c05
QY
1851 This command display current large-community-list information. When
1852 `name` is specified the community list information is shown.
42fc5d26 1853
c1a54c05 1854.. index:: show ip bgp large-community-info
29adcd50 1855.. clicmd:: show ip bgp large-community-info
c1a54c05
QY
1856
1857 This command displays the current large communities in use.
42fc5d26 1858
0efdf0fe 1859.. _bgp-large-communities-in-route-map:
42fc5d26 1860
8fcedbd2
QY
1861Large Communities in Route Map
1862""""""""""""""""""""""""""""""
42fc5d26 1863
03ff9a14 1864.. index:: match large-community LINE [exact-match]
1865.. clicmd:: match large-community LINE [exact-match]
42fc5d26 1866
4da7fda3
QY
1867 Where `line` can be a simple string to match, or a regular expression. It
1868 is very important to note that this match occurs on the entire
c1a54c05 1869 large-community string as a whole, where each large-community is ordered
03ff9a14 1870 from lowest to highest. When `exact-match` keyword is specified, match
1871 happen only when BGP updates have completely same large communities value
1872 specified in the large community list.
42fc5d26 1873
c1a54c05 1874.. index:: set large-community LARGE-COMMUNITY
29adcd50 1875.. clicmd:: set large-community LARGE-COMMUNITY
42fc5d26 1876
c1a54c05 1877.. index:: set large-community LARGE-COMMUNITY LARGE-COMMUNITY
29adcd50 1878.. clicmd:: set large-community LARGE-COMMUNITY LARGE-COMMUNITY
42fc5d26 1879
c1a54c05 1880.. index:: set large-community LARGE-COMMUNITY additive
29adcd50 1881.. clicmd:: set large-community LARGE-COMMUNITY additive
c1a54c05
QY
1882
1883 These commands are used for setting large-community values. The first
1884 command will overwrite any large-communities currently present.
1885 The second specifies two large-communities, which overwrites the current
1886 large-community list. The third will add a large-community value without
1887 overwriting other values. Multiple large-community values can be specified.
42fc5d26 1888
47f47873
PG
1889Note that the large expanded community is only used for `match` rule, not for
1890`set` actions.
b572f826 1891
c8a5e5e1 1892.. _bgp-l3vpn-vrfs:
b572f826 1893
c8a5e5e1
QY
1894L3VPN VRFs
1895----------
b572f826 1896
c8a5e5e1
QY
1897*bgpd* supports :abbr:`L3VPN (Layer 3 Virtual Private Networks)` :abbr:`VRFs
1898(Virtual Routing and Forwarding)` for IPv4 :rfc:`4364` and IPv6 :rfc:`4659`.
1899L3VPN routes, and their associated VRF MPLS labels, can be distributed to VPN
1900SAFI neighbors in the *default*, i.e., non VRF, BGP instance. VRF MPLS labels
1901are reached using *core* MPLS labels which are distributed using LDP or BGP
1902labeled unicast. *bgpd* also supports inter-VRF route leaking.
b572f826 1903
b572f826 1904
c8a5e5e1 1905.. _bgp-vrf-route-leaking:
8fcedbd2
QY
1906
1907VRF Route Leaking
c8a5e5e1 1908-----------------
8fcedbd2
QY
1909
1910BGP routes may be leaked (i.e. copied) between a unicast VRF RIB and the VPN
f90115c5
LB
1911SAFI RIB of the default VRF for use in MPLS-based L3VPNs. Unicast routes may
1912also be leaked between any VRFs (including the unicast RIB of the default BGP
1913instanced). A shortcut syntax is also available for specifying leaking from one
1914VRF to another VRF using the default instance's VPN RIB as the intemediary. A
1915common application of the VRF-VRF feature is to connect a customer's private
8fcedbd2
QY
1916routing domain to a provider's VPN service. Leaking is configured from the
1917point of view of an individual VRF: ``import`` refers to routes leaked from VPN
1918to a unicast VRF, whereas ``export`` refers to routes leaked from a unicast VRF
1919to VPN.
1920
1921Required parameters
c8a5e5e1 1922^^^^^^^^^^^^^^^^^^^
b572f826 1923
4da7fda3
QY
1924Routes exported from a unicast VRF to the VPN RIB must be augmented by two
1925parameters:
1926
1927- an :abbr:`RD (Route Distinguisher)`
1928- an :abbr:`RTLIST (Route-target List)`
1929
1930Configuration for these exported routes must, at a minimum, specify these two
1931parameters.
1932
1933Routes imported from the VPN RIB to a unicast VRF are selected according to
1934their RTLISTs. Routes whose RTLIST contains at least one route-target in
1935common with the configured import RTLIST are leaked. Configuration for these
1936imported routes must specify an RTLIST to be matched.
1937
1938The RD, which carries no semantic value, is intended to make the route unique
1939in the VPN RIB among all routes of its prefix that originate from all the
1940customers and sites that are attached to the provider's VPN service.
1941Accordingly, each site of each customer is typically assigned an RD that is
1942unique across the entire provider network.
1943
1944The RTLIST is a set of route-target extended community values whose purpose is
1945to specify route-leaking policy. Typically, a customer is assigned a single
1946route-target value for import and export to be used at all customer sites. This
1947configuration specifies a simple topology wherein a customer has a single
1948routing domain which is shared across all its sites. More complex routing
1949topologies are possible through use of additional route-targets to augment the
1950leaking of sets of routes in various ways.
b572f826 1951
e967a1d0
DS
1952When using the shortcut syntax for vrf-to-vrf leaking, the RD and RT are
1953auto-derived.
fb3d9f3e 1954
8fcedbd2 1955General configuration
c8a5e5e1 1956^^^^^^^^^^^^^^^^^^^^^
b572f826 1957
f90115c5 1958Configuration of route leaking between a unicast VRF RIB and the VPN SAFI RIB
4da7fda3
QY
1959of the default VRF is accomplished via commands in the context of a VRF
1960address-family:
b572f826
PZ
1961
1962.. index:: rd vpn export AS:NN|IP:nn
1963.. clicmd:: rd vpn export AS:NN|IP:nn
1964
4da7fda3
QY
1965 Specifies the route distinguisher to be added to a route exported from the
1966 current unicast VRF to VPN.
b572f826
PZ
1967
1968.. index:: no rd vpn export [AS:NN|IP:nn]
1969.. clicmd:: no rd vpn export [AS:NN|IP:nn]
1970
1971 Deletes any previously-configured export route distinguisher.
1972
1973.. index:: rt vpn import|export|both RTLIST...
1974.. clicmd:: rt vpn import|export|both RTLIST...
1975
4da7fda3
QY
1976 Specifies the route-target list to be attached to a route (export) or the
1977 route-target list to match against (import) when exporting/importing between
1978 the current unicast VRF and VPN.
b572f826 1979
4da7fda3
QY
1980 The RTLIST is a space-separated list of route-targets, which are BGP
1981 extended community values as described in
b572f826
PZ
1982 :ref:`bgp-extended-communities-attribute`.
1983
1984.. index:: no rt vpn import|export|both [RTLIST...]
1985.. clicmd:: no rt vpn import|export|both [RTLIST...]
1986
1987 Deletes any previously-configured import or export route-target list.
1988
e70e9f8e
PZ
1989.. index:: label vpn export (0..1048575)|auto
1990.. clicmd:: label vpn export (0..1048575)|auto
b572f826 1991
8a2124f7 1992 Enables an MPLS label to be attached to a route exported from the current
1993 unicast VRF to VPN. If the value specified is ``auto``, the label value is
1994 automatically assigned from a pool maintained by the Zebra daemon. If Zebra
1995 is not running, or if this command is not configured, automatic label
1996 assignment will not complete, which will block corresponding route export.
b572f826 1997
e70e9f8e
PZ
1998.. index:: no label vpn export [(0..1048575)|auto]
1999.. clicmd:: no label vpn export [(0..1048575)|auto]
b572f826
PZ
2000
2001 Deletes any previously-configured export label.
2002
2003.. index:: nexthop vpn export A.B.C.D|X:X::X:X
2004.. clicmd:: nexthop vpn export A.B.C.D|X:X::X:X
2005
4da7fda3
QY
2006 Specifies an optional nexthop value to be assigned to a route exported from
2007 the current unicast VRF to VPN. If left unspecified, the nexthop will be set
2008 to 0.0.0.0 or 0:0::0:0 (self).
b572f826
PZ
2009
2010.. index:: no nexthop vpn export [A.B.C.D|X:X::X:X]
2011.. clicmd:: no nexthop vpn export [A.B.C.D|X:X::X:X]
2012
2013 Deletes any previously-configured export nexthop.
2014
2015.. index:: route-map vpn import|export MAP
2016.. clicmd:: route-map vpn import|export MAP
2017
4da7fda3 2018 Specifies an optional route-map to be applied to routes imported or exported
d1e7591e 2019 between the current unicast VRF and VPN.
b572f826
PZ
2020
2021.. index:: no route-map vpn import|export [MAP]
2022.. clicmd:: no route-map vpn import|export [MAP]
2023
2024 Deletes any previously-configured import or export route-map.
2025
2026.. index:: import|export vpn
2027.. clicmd:: import|export vpn
2028
d1e7591e 2029 Enables import or export of routes between the current unicast VRF and VPN.
b572f826
PZ
2030
2031.. index:: no import|export vpn
2032.. clicmd:: no import|export vpn
2033
d1e7591e 2034 Disables import or export of routes between the current unicast VRF and VPN.
b572f826 2035
fb3d9f3e
DS
2036.. index:: import vrf VRFNAME
2037.. clicmd:: import vrf VRFNAME
2038
e967a1d0
DS
2039 Shortcut syntax for specifying automatic leaking from vrf VRFNAME to
2040 the current VRF using the VPN RIB as intermediary. The RD and RT
2041 are auto derived and should not be specified explicitly for either the
2042 source or destination VRF's.
2043
2044 This shortcut syntax mode is not compatible with the explicit
2045 `import vpn` and `export vpn` statements for the two VRF's involved.
2046 The CLI will disallow attempts to configure incompatible leaking
2047 modes.
fb3d9f3e
DS
2048
2049.. index:: no import vrf VRFNAME
2050.. clicmd:: no import vrf VRFNAME
2051
e967a1d0
DS
2052 Disables automatic leaking from vrf VRFNAME to the current VRF using
2053 the VPN RIB as intermediary.
b572f826 2054
42fc5d26 2055
8fcedbd2 2056.. _bgp-cisco-compatibility:
42fc5d26 2057
8fcedbd2
QY
2058Cisco Compatibility
2059-------------------
42fc5d26 2060
8fcedbd2
QY
2061FRR has commands that change some configuration syntax and default behavior to
2062behave more closely to Cisco conventions. These are deprecated and will be
2063removed in a future version of FRR.
42fc5d26 2064
8fcedbd2
QY
2065.. deprecated:: 5.0
2066 Please transition to using the FRR specific syntax for your configuration.
42fc5d26 2067
8fcedbd2
QY
2068.. index:: bgp config-type cisco
2069.. clicmd:: bgp config-type cisco
42fc5d26 2070
8fcedbd2 2071 Cisco compatible BGP configuration output.
42fc5d26 2072
8fcedbd2 2073 When this configuration line is specified:
c1a54c05 2074
8fcedbd2
QY
2075 - ``no synchronization`` is displayed. This command does nothing and is for
2076 display purposes only.
2077 - ``no auto-summary`` is displayed.
2078 - The ``network`` and ``aggregate-address`` arguments are displayed as:
42fc5d26 2079
8fcedbd2 2080 ::
42fc5d26 2081
8fcedbd2 2082 A.B.C.D M.M.M.M
42fc5d26 2083
8fcedbd2
QY
2084 FRR: network 10.0.0.0/8
2085 Cisco: network 10.0.0.0
42fc5d26 2086
8fcedbd2
QY
2087 FRR: aggregate-address 192.168.0.0/24
2088 Cisco: aggregate-address 192.168.0.0 255.255.255.0
42fc5d26 2089
8fcedbd2
QY
2090 Community attribute handling is also different. If no configuration is
2091 specified community attribute and extended community attribute are sent to
2092 the neighbor. If a user manually disables the feature, the community
2093 attribute is not sent to the neighbor. When ``bgp config-type cisco`` is
2094 specified, the community attribute is not sent to the neighbor by default.
2095 To send the community attribute user has to specify
2096 :clicmd:`neighbor A.B.C.D send-community` like so:
42fc5d26 2097
8fcedbd2 2098 .. code-block:: frr
42fc5d26 2099
8fcedbd2
QY
2100 !
2101 router bgp 1
2102 neighbor 10.0.0.1 remote-as 1
2103 address-family ipv4 unicast
2104 no neighbor 10.0.0.1 send-community
2105 exit-address-family
2106 !
2107 router bgp 1
2108 neighbor 10.0.0.1 remote-as 1
2109 address-family ipv4 unicast
2110 neighbor 10.0.0.1 send-community
2111 exit-address-family
2112 !
42fc5d26 2113
8fcedbd2
QY
2114.. deprecated:: 5.0
2115 Please transition to using the FRR specific syntax for your configuration.
2116
2117.. index:: bgp config-type zebra
2118.. clicmd:: bgp config-type zebra
2119
2120 FRR style BGP configuration. This is the default.
2121
2122.. _bgp-debugging:
2123
2124Debugging
2125---------
42fc5d26 2126
c1a54c05 2127.. index:: show debug
29adcd50 2128.. clicmd:: show debug
42fc5d26 2129
8fcedbd2 2130 Show all enabled debugs.
42fc5d26 2131
53b758f3
PG
2132.. index:: [no] debug bgp neighbor-events
2133.. clicmd:: [no] debug bgp neighbor-events
42fc5d26 2134
8fcedbd2
QY
2135 Enable or disable debugging for neighbor events. This provides general
2136 information on BGP events such as peer connection / disconnection, session
2137 establishment / teardown, and capability negotiation.
42fc5d26 2138
53b758f3
PG
2139.. index:: [no] debug bgp updates
2140.. clicmd:: [no] debug bgp updates
42fc5d26 2141
8fcedbd2
QY
2142 Enable or disable debugging for BGP updates. This provides information on
2143 BGP UPDATE messages transmitted and received between local and remote
2144 instances.
42fc5d26 2145
53b758f3
PG
2146.. index:: [no] debug bgp keepalives
2147.. clicmd:: [no] debug bgp keepalives
42fc5d26 2148
8fcedbd2
QY
2149 Enable or disable debugging for BGP keepalives. This provides information on
2150 BGP KEEPALIVE messages transmitted and received between local and remote
2151 instances.
c1a54c05 2152
8fcedbd2
QY
2153.. index:: [no] debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>
2154.. clicmd:: [no] debug bgp bestpath <A.B.C.D/M|X:X::X:X/M>
42fc5d26 2155
8fcedbd2 2156 Enable or disable debugging for bestpath selection on the specified prefix.
42fc5d26 2157
8fcedbd2
QY
2158.. index:: [no] debug bgp nht
2159.. clicmd:: [no] debug bgp nht
4da7fda3 2160
8fcedbd2 2161 Enable or disable debugging of BGP nexthop tracking.
4da7fda3 2162
8fcedbd2
QY
2163.. index:: [no] debug bgp update-groups
2164.. clicmd:: [no] debug bgp update-groups
4b44467c 2165
8fcedbd2
QY
2166 Enable or disable debugging of dynamic update groups. This provides general
2167 information on group creation, deletion, join and prune events.
4b44467c 2168
8fcedbd2
QY
2169.. index:: [no] debug bgp zebra
2170.. clicmd:: [no] debug bgp zebra
42fc5d26 2171
8fcedbd2 2172 Enable or disable debugging of communications between *bgpd* and *zebra*.
c3c5a71f 2173
8fcedbd2
QY
2174Dumping Messages and Routing Tables
2175^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42fc5d26 2176
8fcedbd2
QY
2177.. index:: dump bgp all PATH [INTERVAL]
2178.. clicmd:: dump bgp all PATH [INTERVAL]
42fc5d26 2179
8fcedbd2
QY
2180.. index:: dump bgp all-et PATH [INTERVAL]
2181.. clicmd:: dump bgp all-et PATH [INTERVAL]
c3c5a71f 2182
8fcedbd2
QY
2183.. index:: no dump bgp all [PATH] [INTERVAL]
2184.. clicmd:: no dump bgp all [PATH] [INTERVAL]
42fc5d26 2185
8fcedbd2
QY
2186 Dump all BGP packet and events to `path` file.
2187 If `interval` is set, a new file will be created for echo `interval` of
2188 seconds. The path `path` can be set with date and time formatting
2189 (strftime). The type ‘all-et’ enables support for Extended Timestamp Header
2190 (:ref:`packet-binary-dump-format`).
c3c5a71f 2191
8fcedbd2
QY
2192.. index:: dump bgp updates PATH [INTERVAL]
2193.. clicmd:: dump bgp updates PATH [INTERVAL]
42fc5d26 2194
8fcedbd2
QY
2195.. index:: dump bgp updates-et PATH [INTERVAL]
2196.. clicmd:: dump bgp updates-et PATH [INTERVAL]
42fc5d26 2197
8fcedbd2
QY
2198.. index:: no dump bgp updates [PATH] [INTERVAL]
2199.. clicmd:: no dump bgp updates [PATH] [INTERVAL]
42fc5d26 2200
8fcedbd2
QY
2201 Dump only BGP updates messages to `path` file.
2202 If `interval` is set, a new file will be created for echo `interval` of
2203 seconds. The path `path` can be set with date and time formatting
2204 (strftime). The type ‘updates-et’ enables support for Extended Timestamp
2205 Header (:ref:`packet-binary-dump-format`).
42fc5d26 2206
8fcedbd2
QY
2207.. index:: dump bgp routes-mrt PATH
2208.. clicmd:: dump bgp routes-mrt PATH
c3c5a71f 2209
8fcedbd2
QY
2210.. index:: dump bgp routes-mrt PATH INTERVAL
2211.. clicmd:: dump bgp routes-mrt PATH INTERVAL
42fc5d26 2212
8fcedbd2
QY
2213.. index:: no dump bgp route-mrt [PATH] [INTERVAL]
2214.. clicmd:: no dump bgp route-mrt [PATH] [INTERVAL]
42fc5d26 2215
8fcedbd2
QY
2216 Dump whole BGP routing table to `path`. This is heavy process. The path
2217 `path` can be set with date and time formatting (strftime). If `interval` is
2218 set, a new file will be created for echo `interval` of seconds.
42fc5d26 2219
8fcedbd2 2220 Note: the interval variable can also be set using hours and minutes: 04h20m00.
42fc5d26 2221
c3c5a71f 2222
8fcedbd2 2223.. _bgp-other-commands:
42fc5d26 2224
8fcedbd2
QY
2225Other BGP Commands
2226------------------
42fc5d26 2227
e312b6c6
QY
2228The following are available in the top level *enable* mode:
2229
dc912615
DS
2230.. index:: clear bgp \*
2231.. clicmd:: clear bgp \*
2232
2233 Clear all peers.
2234
8fcedbd2
QY
2235.. index:: clear bgp ipv4|ipv6 \*
2236.. clicmd:: clear bgp ipv4|ipv6 \*
42fc5d26 2237
dc912615
DS
2238 Clear all peers with this address-family activated.
2239
2240.. index:: clear bgp ipv4|ipv6 unicast \*
2241.. clicmd:: clear bgp ipv4|ipv6 unicast \*
2242
2243 Clear all peers with this address-family and sub-address-family activated.
42fc5d26 2244
8fcedbd2
QY
2245.. index:: clear bgp ipv4|ipv6 PEER
2246.. clicmd:: clear bgp ipv4|ipv6 PEER
42fc5d26 2247
dc912615
DS
2248 Clear peers with address of X.X.X.X and this address-family activated.
2249
2250.. index:: clear bgp ipv4|ipv6 unicast PEER
2251.. clicmd:: clear bgp ipv4|ipv6 unicast PEER
2252
2253 Clear peer with address of X.X.X.X and this address-family and sub-address-family activated.
2254
2255.. index:: clear bgp ipv4|ipv6 PEER soft|in|out
2256.. clicmd:: clear bgp ipv4|ipv6 PEER soft|in|out
2257
2258 Clear peer using soft reconfiguration in this address-family.
42fc5d26 2259
dc912615
DS
2260.. index:: clear bgp ipv4|ipv6 unicast PEER soft|in|out
2261.. clicmd:: clear bgp ipv4|ipv6 unicast PEER soft|in|out
42fc5d26 2262
dc912615 2263 Clear peer using soft reconfiguration in this address-family and sub-address-family.
42fc5d26 2264
e312b6c6
QY
2265The following are available in the ``router bgp`` mode:
2266
2267.. index:: write-quanta (1-64)
2268.. clicmd:: write-quanta (1-64)
2269
2270 BGP message Tx I/O is vectored. This means that multiple packets are written
2271 to the peer socket at the same time each I/O cycle, in order to minimize
2272 system call overhead. This value controls how many are written at a time.
2273 Under certain load conditions, reducing this value could make peer traffic
2274 less 'bursty'. In practice, leave this settings on the default (64) unless
2275 you truly know what you are doing.
2276
2277.. index:: read-quanta (1-10)
dad83b67 2278.. clicmd:: read-quanta (1-10)
e312b6c6
QY
2279
2280 Unlike Tx, BGP Rx traffic is not vectored. Packets are read off the wire one
2281 at a time in a loop. This setting controls how many iterations the loop runs
2282 for. As with write-quanta, it is best to leave this setting on the default.
42fc5d26 2283
8fcedbd2 2284.. _bgp-displaying-bgp-information:
42fc5d26 2285
8fcedbd2
QY
2286Displaying BGP Information
2287==========================
42fc5d26 2288
e6f59415
PG
2289The following four commands display the IPv6 and IPv4 routing tables, depending
2290on whether or not the ``ip`` keyword is used.
2291Actually, :clicmd:`show ip bgp` command was used on older `Quagga` routing
2292daemon project, while :clicmd:`show bgp` command is the new format. The choice
2293has been done to keep old format with IPv4 routing table, while new format
2294displays IPv6 routing table.
2295
8fcedbd2
QY
2296.. index:: show ip bgp
2297.. clicmd:: show ip bgp
42fc5d26 2298
8fcedbd2
QY
2299.. index:: show ip bgp A.B.C.D
2300.. clicmd:: show ip bgp A.B.C.D
c1a54c05 2301
e6f59415
PG
2302.. index:: show bgp
2303.. clicmd:: show bgp
2304
2305.. index:: show bgp X:X::X:X
2306.. clicmd:: show bgp X:X::X:X
42fc5d26 2307
8fcedbd2 2308 These commands display BGP routes. When no route is specified, the default
e6f59415 2309 is to display all BGP routes.
42fc5d26 2310
8fcedbd2 2311 ::
c1a54c05 2312
8fcedbd2
QY
2313 BGP table version is 0, local router ID is 10.1.1.1
2314 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
2315 Origin codes: i - IGP, e - EGP, ? - incomplete
42fc5d26 2316
8fcedbd2
QY
2317 Network Next Hop Metric LocPrf Weight Path
2318 \*> 1.1.1.1/32 0.0.0.0 0 32768 i
42fc5d26 2319
8fcedbd2 2320 Total number of prefixes 1
4da7fda3 2321
e6f59415
PG
2322Some other commands provide additional options for filtering the output.
2323
2324.. index:: show [ip] bgp regexp LINE
2325.. clicmd:: show [ip] bgp regexp LINE
42fc5d26 2326
8fcedbd2
QY
2327 This command displays BGP routes using AS path regular expression
2328 (:ref:`bgp-regular-expressions`).
42fc5d26 2329
e6f59415
PG
2330.. index:: show [ip] bgp summary
2331.. clicmd:: show [ip] bgp summary
42fc5d26 2332
8fcedbd2 2333 Show a bgp peer summary for the specified address family.
42fc5d26 2334
e6f59415
PG
2335The old command structure :clicmd:`show ip bgp` may be removed in the future
2336and should no longer be used. In order to reach the other BGP routing tables
2337other than the IPv6 routing table given by :clicmd:`show bgp`, the new command
2338structure is extended with :clicmd:`show bgp [afi] [safi]`.
2339
2340.. index:: show bgp [afi] [safi]
2341.. clicmd:: show bgp [afi] [safi]
2342
2343.. index:: show bgp <ipv4|ipv6> <unicast|multicast|vpn|labeled-unicast>
2344.. clicmd:: show bgp <ipv4|ipv6> <unicast|multicast|vpn|labeled-unicast>
2345
2346 These commands display BGP routes for the specific routing table indicated by
2347 the selected afi and the selected safi. If no afi and no safi value is given,
2348 the command falls back to the default IPv6 routing table
2349
2350.. index:: show bgp [afi] [safi] summary
2351.. clicmd:: show bgp [afi] [safi] summary
2352
2353 Show a bgp peer summary for the specified address family, and subsequent
2354 address-family.
2355
3577f1c5
DD
2356.. index:: show bgp [afi] [safi] summary failed [json]
2357.. clicmd:: show bgp [afi] [safi] summary failed [json]
2358
2359 Show a bgp peer summary for peers that are not succesfully exchanging routes
2360 for the specified address family, and subsequent address-family.
2361
e6f59415
PG
2362.. index:: show bgp [afi] [safi] neighbor [PEER]
2363.. clicmd:: show bgp [afi] [safi] neighbor [PEER]
9eb95b3b 2364
e6f59415
PG
2365 This command shows information on a specific BGP peer of the relevant
2366 afi and safi selected.
c1a54c05 2367
e6f59415
PG
2368.. index:: show bgp [afi] [safi] dampening dampened-paths
2369.. clicmd:: show bgp [afi] [safi] dampening dampened-paths
42fc5d26 2370
e6f59415
PG
2371 Display paths suppressed due to dampening of the selected afi and safi
2372 selected.
42fc5d26 2373
e6f59415
PG
2374.. index:: show bgp [afi] [safi] dampening flap-statistics
2375.. clicmd:: show bgp [afi] [safi] dampening flap-statistics
c1a54c05 2376
e6f59415 2377 Display flap statistics of routes of the selected afi and safi selected.
42fc5d26 2378
8fcedbd2 2379.. _bgp-display-routes-by-community:
42fc5d26 2380
8fcedbd2
QY
2381Displaying Routes by Community Attribute
2382----------------------------------------
42fc5d26 2383
8fcedbd2
QY
2384The following commands allow displaying routes based on their community
2385attribute.
42fc5d26 2386
8fcedbd2
QY
2387.. index:: show [ip] bgp <ipv4|ipv6> community
2388.. clicmd:: show [ip] bgp <ipv4|ipv6> community
42fc5d26 2389
8fcedbd2
QY
2390.. index:: show [ip] bgp <ipv4|ipv6> community COMMUNITY
2391.. clicmd:: show [ip] bgp <ipv4|ipv6> community COMMUNITY
42fc5d26 2392
8fcedbd2
QY
2393.. index:: show [ip] bgp <ipv4|ipv6> community COMMUNITY exact-match
2394.. clicmd:: show [ip] bgp <ipv4|ipv6> community COMMUNITY exact-match
76bd1499 2395
8fcedbd2
QY
2396 These commands display BGP routes which have the community attribute.
2397 attribute. When ``COMMUNITY`` is specified, BGP routes that match that
2398 community are displayed. When `exact-match` is specified, it display only
2399 routes that have an exact match.
c3c5a71f 2400
8fcedbd2
QY
2401.. index:: show [ip] bgp <ipv4|ipv6> community-list WORD
2402.. clicmd:: show [ip] bgp <ipv4|ipv6> community-list WORD
42fc5d26 2403
8fcedbd2
QY
2404.. index:: show [ip] bgp <ipv4|ipv6> community-list WORD exact-match
2405.. clicmd:: show [ip] bgp <ipv4|ipv6> community-list WORD exact-match
42fc5d26 2406
8fcedbd2
QY
2407 These commands display BGP routes for the address family specified that
2408 match the specified community list. When `exact-match` is specified, it
2409 displays only routes that have an exact match.
42fc5d26 2410
36a206db 2411.. _bgp-display-routes-by-lcommunity:
2412
2413Displaying Routes by Large Community Attribute
2414----------------------------------------------
2415
ac2201bb 2416The following commands allow displaying routes based on their
36a206db 2417large community attribute.
2418
2419.. index:: show [ip] bgp <ipv4|ipv6> large-community
2420.. clicmd:: show [ip] bgp <ipv4|ipv6> large-community
2421
2422.. index:: show [ip] bgp <ipv4|ipv6> large-community LARGE-COMMUNITY
2423.. clicmd:: show [ip] bgp <ipv4|ipv6> large-community LARGE-COMMUNITY
2424
2425.. index:: show [ip] bgp <ipv4|ipv6> large-community LARGE-COMMUNITY exact-match
2426.. clicmd:: show [ip] bgp <ipv4|ipv6> large-community LARGE-COMMUNITY exact-match
2427
2428.. index:: show [ip] bgp <ipv4|ipv6> large-community LARGE-COMMUNITY json
2429.. clicmd:: show [ip] bgp <ipv4|ipv6> large-community LARGE-COMMUNITY json
2430
2431 These commands display BGP routes which have the large community attribute.
2432 attribute. When ``LARGE-COMMUNITY`` is specified, BGP routes that match that
ac2201bb
DA
2433 large community are displayed. When `exact-match` is specified, it display
2434 only routes that have an exact match. When `json` is specified, it display
36a206db 2435 routes in json format.
2436
2437.. index:: show [ip] bgp <ipv4|ipv6> large-community-list WORD
2438.. clicmd:: show [ip] bgp <ipv4|ipv6> large-community-list WORD
2439
2440.. index:: show [ip] bgp <ipv4|ipv6> large-community-list WORD exact-match
2441.. clicmd:: show [ip] bgp <ipv4|ipv6> large-community-list WORD exact-match
2442
2443.. index:: show [ip] bgp <ipv4|ipv6> large-community-list WORD json
2444.. clicmd:: show [ip] bgp <ipv4|ipv6> large-community-list WORD json
2445
2446 These commands display BGP routes for the address family specified that
ac2201bb
DA
2447 match the specified large community list. When `exact-match` is specified,
2448 it displays only routes that have an exact match. When `json` is specified,
36a206db 2449 it display routes in json format.
2450
8fcedbd2 2451.. _bgp-display-routes-by-as-path:
42fc5d26 2452
36a206db 2453
8fcedbd2
QY
2454Displaying Routes by AS Path
2455----------------------------
42fc5d26 2456
8fcedbd2
QY
2457.. index:: show bgp ipv4|ipv6 regexp LINE
2458.. clicmd:: show bgp ipv4|ipv6 regexp LINE
76bd1499 2459
8fcedbd2
QY
2460 This commands displays BGP routes that matches a regular
2461 expression `line` (:ref:`bgp-regular-expressions`).
2462
e6f59415
PG
2463.. index:: show [ip] bgp ipv4 vpn
2464.. clicmd:: show [ip] bgp ipv4 vpn
8fcedbd2 2465
e6f59415
PG
2466.. index:: show [ip] bgp ipv6 vpn
2467.. clicmd:: show [ip] bgp ipv6 vpn
8fcedbd2
QY
2468
2469 Print active IPV4 or IPV6 routes advertised via the VPN SAFI.
2470
2471.. index:: show bgp ipv4 vpn summary
2472.. clicmd:: show bgp ipv4 vpn summary
2473
2474.. index:: show bgp ipv6 vpn summary
2475.. clicmd:: show bgp ipv6 vpn summary
2476
2477 Print a summary of neighbor connections for the specified AFI/SAFI combination.
2478
09d78f10
DS
2479Displaying Update Group Information
2480-----------------------------------
2481
2482..index:: show bgp update-groups SUBGROUP-ID [advertise-queue|advertised-routes|packet-queue]
2483..clicmd:: show bgp update-groups [advertise-queue|advertised-routes|packet-queue]
2484
2485 Display Information about each individual update-group being used.
2486 If SUBGROUP-ID is specified only display about that particular group. If
2487 advertise-queue is specified the list of routes that need to be sent
2488 to the peers in the update-group is displayed, advertised-routes means
a64e0ee5 2489 the list of routes we have sent to the peers in the update-group and
09d78f10
DS
2490 packet-queue specifies the list of packets in the queue to be sent.
2491
2492..index:: show bgp update-groups statistics
2493..clicmd:: show bgp update-groups statistics
2494
2495 Display Information about update-group events in FRR.
8fcedbd2
QY
2496
2497.. _bgp-route-reflector:
2498
2499Route Reflector
2500===============
2501
749afd7d
RF
2502BGP routers connected inside the same AS through BGP belong to an internal
2503BGP session, or IBGP. In order to prevent routing table loops, IBGP does not
2504advertise IBGP-learned routes to other routers in the same session. As such,
2505IBGP requires a full mesh of all peers. For large networks, this quickly becomes
2506unscalable. Introducing route reflectors removes the need for the full-mesh.
8fcedbd2 2507
749afd7d
RF
2508When route reflectors are configured, these will reflect the routes announced
2509by the peers configured as clients. A route reflector client is configured
2510with:
8fcedbd2
QY
2511
2512.. index:: neighbor PEER route-reflector-client
2513.. clicmd:: neighbor PEER route-reflector-client
2514
2515.. index:: no neighbor PEER route-reflector-client
2516.. clicmd:: no neighbor PEER route-reflector-client
c3c5a71f 2517
749afd7d
RF
2518To avoid single points of failure, multiple route reflectors can be configured.
2519
2520A cluster is a collection of route reflectors and their clients, and is used
2521by route reflectors to avoid looping.
2522
2523.. index:: bgp cluster-id A.B.C.D
2524.. clicmd:: bgp cluster-id A.B.C.D
42fc5d26 2525
0efdf0fe 2526.. _routing-policy:
42fc5d26 2527
8fcedbd2
QY
2528Routing Policy
2529==============
42fc5d26 2530
4da7fda3 2531You can set different routing policy for a peer. For example, you can set
9eb95b3b
QY
2532different filter for a peer.
2533
2534.. code-block:: frr
c1a54c05 2535
c1a54c05
QY
2536 !
2537 router bgp 1 view 1
2538 neighbor 10.0.0.1 remote-as 2
2539 address-family ipv4 unicast
2540 neighbor 10.0.0.1 distribute-list 1 in
2541 exit-address-family
2542 !
2543 router bgp 1 view 2
2544 neighbor 10.0.0.1 remote-as 2
2545 address-family ipv4 unicast
2546 neighbor 10.0.0.1 distribute-list 2 in
2547 exit-address-family
c3c5a71f 2548
4da7fda3
QY
2549This means BGP update from a peer 10.0.0.1 goes to both BGP view 1 and view 2.
2550When the update is inserted into view 1, distribute-list 1 is applied. On the
2551other hand, when the update is inserted into view 2, distribute-list 2 is
2552applied.
42fc5d26 2553
42fc5d26 2554
0efdf0fe 2555.. _bgp-regular-expressions:
42fc5d26
QY
2556
2557BGP Regular Expressions
2558=======================
2559
8fcedbd2
QY
2560BGP regular expressions are based on :t:`POSIX 1003.2` regular expressions. The
2561following description is just a quick subset of the POSIX regular expressions.
42fc5d26
QY
2562
2563
8fcedbd2 2564.\*
c1a54c05 2565 Matches any single character.
42fc5d26 2566
8fcedbd2 2567\*
c1a54c05 2568 Matches 0 or more occurrences of pattern.
42fc5d26 2569
8fcedbd2 2570\+
c1a54c05 2571 Matches 1 or more occurrences of pattern.
42fc5d26
QY
2572
2573?
c1a54c05 2574 Match 0 or 1 occurrences of pattern.
42fc5d26
QY
2575
2576^
c1a54c05 2577 Matches the beginning of the line.
42fc5d26
QY
2578
2579$
c1a54c05 2580 Matches the end of the line.
42fc5d26
QY
2581
2582_
8fcedbd2
QY
2583 The ``_`` character has special meanings in BGP regular expressions. It
2584 matches to space and comma , and AS set delimiter ``{`` and ``}`` and AS
2585 confederation delimiter ``(`` and ``)``. And it also matches to the
2586 beginning of the line and the end of the line. So ``_`` can be used for AS
2587 value boundaries match. This character technically evaluates to
2588 ``(^|[,{}()]|$)``.
42fc5d26 2589
42fc5d26 2590
c1a54c05 2591.. _bgp-configuration-examples:
42fc5d26 2592
8fcedbd2
QY
2593Miscellaneous Configuration Examples
2594====================================
42fc5d26 2595
9eb95b3b
QY
2596Example of a session to an upstream, advertising only one prefix to it.
2597
2598.. code-block:: frr
42fc5d26 2599
c1a54c05
QY
2600 router bgp 64512
2601 bgp router-id 10.236.87.1
2602 neighbor upstream peer-group
2603 neighbor upstream remote-as 64515
2604 neighbor upstream capability dynamic
2605 neighbor 10.1.1.1 peer-group upstream
2606 neighbor 10.1.1.1 description ACME ISP
c3c5a71f 2607
c1a54c05
QY
2608 address-family ipv4 unicast
2609 network 10.236.87.0/24
2610 neighbor upstream prefix-list pl-allowed-adv out
2611 exit-address-family
2612 !
2613 ip prefix-list pl-allowed-adv seq 5 permit 82.195.133.0/25
2614 ip prefix-list pl-allowed-adv seq 10 deny any
42fc5d26 2615
aa9eafa4
QY
2616A more complex example including upstream, peer and customer sessions
2617advertising global prefixes and NO_EXPORT prefixes and providing actions for
2618customer routes based on community values. Extensive use is made of route-maps
2619and the 'call' feature to support selective advertising of prefixes. This
2620example is intended as guidance only, it has NOT been tested and almost
2621certainly contains silly mistakes, if not serious flaws.
42fc5d26 2622
9eb95b3b 2623.. code-block:: frr
42fc5d26 2624
c1a54c05
QY
2625 router bgp 64512
2626 bgp router-id 10.236.87.1
2627 neighbor upstream capability dynamic
2628 neighbor cust capability dynamic
2629 neighbor peer capability dynamic
2630 neighbor 10.1.1.1 remote-as 64515
2631 neighbor 10.1.1.1 peer-group upstream
2632 neighbor 10.2.1.1 remote-as 64516
2633 neighbor 10.2.1.1 peer-group upstream
2634 neighbor 10.3.1.1 remote-as 64517
2635 neighbor 10.3.1.1 peer-group cust-default
2636 neighbor 10.3.1.1 description customer1
2637 neighbor 10.4.1.1 remote-as 64518
2638 neighbor 10.4.1.1 peer-group cust
2639 neighbor 10.4.1.1 description customer2
2640 neighbor 10.5.1.1 remote-as 64519
2641 neighbor 10.5.1.1 peer-group peer
2642 neighbor 10.5.1.1 description peer AS 1
2643 neighbor 10.6.1.1 remote-as 64520
2644 neighbor 10.6.1.1 peer-group peer
2645 neighbor 10.6.1.1 description peer AS 2
2646
2647 address-family ipv4 unicast
2648 network 10.123.456.0/24
2649 network 10.123.456.128/25 route-map rm-no-export
2650 neighbor upstream route-map rm-upstream-out out
2651 neighbor cust route-map rm-cust-in in
2652 neighbor cust route-map rm-cust-out out
2653 neighbor cust send-community both
2654 neighbor peer route-map rm-peer-in in
2655 neighbor peer route-map rm-peer-out out
2656 neighbor peer send-community both
2657 neighbor 10.3.1.1 prefix-list pl-cust1-network in
2658 neighbor 10.4.1.1 prefix-list pl-cust2-network in
2659 neighbor 10.5.1.1 prefix-list pl-peer1-network in
2660 neighbor 10.6.1.1 prefix-list pl-peer2-network in
2661 exit-address-family
2662 !
2663 ip prefix-list pl-default permit 0.0.0.0/0
2664 !
2665 ip prefix-list pl-upstream-peers permit 10.1.1.1/32
2666 ip prefix-list pl-upstream-peers permit 10.2.1.1/32
2667 !
2668 ip prefix-list pl-cust1-network permit 10.3.1.0/24
2669 ip prefix-list pl-cust1-network permit 10.3.2.0/24
2670 !
2671 ip prefix-list pl-cust2-network permit 10.4.1.0/24
2672 !
2673 ip prefix-list pl-peer1-network permit 10.5.1.0/24
2674 ip prefix-list pl-peer1-network permit 10.5.2.0/24
2675 ip prefix-list pl-peer1-network permit 192.168.0.0/24
2676 !
2677 ip prefix-list pl-peer2-network permit 10.6.1.0/24
2678 ip prefix-list pl-peer2-network permit 10.6.2.0/24
2679 ip prefix-list pl-peer2-network permit 192.168.1.0/24
2680 ip prefix-list pl-peer2-network permit 192.168.2.0/24
2681 ip prefix-list pl-peer2-network permit 172.16.1/24
2682 !
2683 ip as-path access-list asp-own-as permit ^$
2684 ip as-path access-list asp-own-as permit _64512_
2685 !
2686 ! #################################################################
2687 ! Match communities we provide actions for, on routes receives from
2688 ! customers. Communities values of <our-ASN>:X, with X, have actions:
2689 !
2690 ! 100 - blackhole the prefix
2691 ! 200 - set no_export
2692 ! 300 - advertise only to other customers
2693 ! 400 - advertise only to upstreams
2694 ! 500 - set no_export when advertising to upstreams
2695 ! 2X00 - set local_preference to X00
2696 !
2697 ! blackhole the prefix of the route
a64e0ee5 2698 bgp community-list standard cm-blackhole permit 64512:100
c1a54c05
QY
2699 !
2700 ! set no-export community before advertising
a64e0ee5 2701 bgp community-list standard cm-set-no-export permit 64512:200
c1a54c05
QY
2702 !
2703 ! advertise only to other customers
a64e0ee5 2704 bgp community-list standard cm-cust-only permit 64512:300
c1a54c05
QY
2705 !
2706 ! advertise only to upstreams
a64e0ee5 2707 bgp community-list standard cm-upstream-only permit 64512:400
c1a54c05
QY
2708 !
2709 ! advertise to upstreams with no-export
a64e0ee5 2710 bgp community-list standard cm-upstream-noexport permit 64512:500
c1a54c05
QY
2711 !
2712 ! set local-pref to least significant 3 digits of the community
a64e0ee5
DA
2713 bgp community-list standard cm-prefmod-100 permit 64512:2100
2714 bgp community-list standard cm-prefmod-200 permit 64512:2200
2715 bgp community-list standard cm-prefmod-300 permit 64512:2300
2716 bgp community-list standard cm-prefmod-400 permit 64512:2400
2717 bgp community-list expanded cme-prefmod-range permit 64512:2...
c1a54c05
QY
2718 !
2719 ! Informational communities
2720 !
2721 ! 3000 - learned from upstream
2722 ! 3100 - learned from customer
2723 ! 3200 - learned from peer
2724 !
a64e0ee5
DA
2725 bgp community-list standard cm-learnt-upstream permit 64512:3000
2726 bgp community-list standard cm-learnt-cust permit 64512:3100
2727 bgp community-list standard cm-learnt-peer permit 64512:3200
c1a54c05
QY
2728 !
2729 ! ###################################################################
2730 ! Utility route-maps
2731 !
2732 ! These utility route-maps generally should not used to permit/deny
2733 ! routes, i.e. they do not have meaning as filters, and hence probably
2734 ! should be used with 'on-match next'. These all finish with an empty
2735 ! permit entry so as not interfere with processing in the caller.
2736 !
2737 route-map rm-no-export permit 10
2738 set community additive no-export
2739 route-map rm-no-export permit 20
2740 !
2741 route-map rm-blackhole permit 10
f6aa36f5 2742 description blackhole, up-pref and ensure it cannot escape this AS
c1a54c05
QY
2743 set ip next-hop 127.0.0.1
2744 set local-preference 10
2745 set community additive no-export
2746 route-map rm-blackhole permit 20
2747 !
2748 ! Set local-pref as requested
2749 route-map rm-prefmod permit 10
2750 match community cm-prefmod-100
2751 set local-preference 100
2752 route-map rm-prefmod permit 20
2753 match community cm-prefmod-200
2754 set local-preference 200
2755 route-map rm-prefmod permit 30
2756 match community cm-prefmod-300
2757 set local-preference 300
2758 route-map rm-prefmod permit 40
2759 match community cm-prefmod-400
2760 set local-preference 400
2761 route-map rm-prefmod permit 50
2762 !
2763 ! Community actions to take on receipt of route.
2764 route-map rm-community-in permit 10
2765 description check for blackholing, no point continuing if it matches.
2766 match community cm-blackhole
2767 call rm-blackhole
2768 route-map rm-community-in permit 20
2769 match community cm-set-no-export
2770 call rm-no-export
2771 on-match next
2772 route-map rm-community-in permit 30
2773 match community cme-prefmod-range
2774 call rm-prefmod
2775 route-map rm-community-in permit 40
2776 !
2777 ! #####################################################################
2778 ! Community actions to take when advertising a route.
2779 ! These are filtering route-maps,
2780 !
2781 ! Deny customer routes to upstream with cust-only set.
2782 route-map rm-community-filt-to-upstream deny 10
2783 match community cm-learnt-cust
2784 match community cm-cust-only
2785 route-map rm-community-filt-to-upstream permit 20
2786 !
2787 ! Deny customer routes to other customers with upstream-only set.
2788 route-map rm-community-filt-to-cust deny 10
2789 match community cm-learnt-cust
2790 match community cm-upstream-only
2791 route-map rm-community-filt-to-cust permit 20
2792 !
2793 ! ###################################################################
2794 ! The top-level route-maps applied to sessions. Further entries could
2795 ! be added obviously..
2796 !
2797 ! Customers
2798 route-map rm-cust-in permit 10
2799 call rm-community-in
2800 on-match next
2801 route-map rm-cust-in permit 20
2802 set community additive 64512:3100
2803 route-map rm-cust-in permit 30
2804 !
2805 route-map rm-cust-out permit 10
2806 call rm-community-filt-to-cust
2807 on-match next
2808 route-map rm-cust-out permit 20
2809 !
2810 ! Upstream transit ASes
2811 route-map rm-upstream-out permit 10
2812 description filter customer prefixes which are marked cust-only
2813 call rm-community-filt-to-upstream
2814 on-match next
2815 route-map rm-upstream-out permit 20
2816 description only customer routes are provided to upstreams/peers
2817 match community cm-learnt-cust
2818 !
2819 ! Peer ASes
2820 ! outbound policy is same as for upstream
2821 route-map rm-peer-out permit 10
2822 call rm-upstream-out
2823 !
2824 route-map rm-peer-in permit 10
2825 set community additive 64512:3200
c3c5a71f 2826
8fcedbd2
QY
2827
2828Example of how to set up a 6-Bone connection.
2829
2830.. code-block:: frr
2831
2832 ! bgpd configuration
2833 ! ==================
2834 !
2835 ! MP-BGP configuration
2836 !
2837 router bgp 7675
2838 bgp router-id 10.0.0.1
2839 neighbor 3ffe:1cfa:0:2:2a0:c9ff:fe9e:f56 remote-as `as-number`
2840 !
2841 address-family ipv6
2842 network 3ffe:506::/32
2843 neighbor 3ffe:1cfa:0:2:2a0:c9ff:fe9e:f56 activate
2844 neighbor 3ffe:1cfa:0:2:2a0:c9ff:fe9e:f56 route-map set-nexthop out
2845 neighbor 3ffe:1cfa:0:2:2c0:4fff:fe68:a231 remote-as `as-number`
2846 neighbor 3ffe:1cfa:0:2:2c0:4fff:fe68:a231 route-map set-nexthop out
2847 exit-address-family
2848 !
2849 ipv6 access-list all permit any
2850 !
2851 ! Set output nexthop address.
2852 !
2853 route-map set-nexthop permit 10
2854 match ipv6 address all
2855 set ipv6 nexthop global 3ffe:1cfa:0:2:2c0:4fff:fe68:a225
2856 set ipv6 nexthop local fe80::2c0:4fff:fe68:a225
2857 !
2858 log file bgpd.log
2859 !
2860
2861
9e146a81 2862.. include:: routeserver.rst
f3817860
QY
2863
2864.. include:: rpki.rst
c1a54c05 2865
00458d01
PG
2866.. include:: flowspec.rst
2867
d1e7591e 2868.. [#med-transitivity-rant] For some set of objects to have an order, there *must* be some binary ordering relation that is defined for *every* combination of those objects, and that relation *must* be transitive. I.e.:, if the relation operator is <, and if a < b and b < c then that relation must carry over and it *must* be that a < c for the objects to have an order. The ordering relation may allow for equality, i.e. a < b and b < a may both be true and imply that a and b are equal in the order and not distinguished by it, in which case the set has a partial order. Otherwise, if there is an order, all the objects have a distinct place in the order and the set has a total order)
c1a54c05
QY
2869.. [bgp-route-osci-cond] McPherson, D. and Gill, V. and Walton, D., "Border Gateway Protocol (BGP) Persistent Route Oscillation Condition", IETF RFC3345
2870.. [stable-flexible-ibgp] Flavel, A. and M. Roughan, "Stable and flexible iBGP", ACM SIGCOMM 2009
2871.. [ibgp-correctness] Griffin, T. and G. Wilfong, "On the correctness of IBGP configuration", ACM SIGCOMM 2002