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