]> git.proxmox.com Git - mirror_frr.git/blame - doc/user/routemap.rst
Merge pull request #6740 from FRRouting/revert-5015-rpki_vrf_encapsulation
[mirror_frr.git] / doc / user / routemap.rst
CommitLineData
0efdf0fe 1.. _route-map:
42fc5d26 2
655cdc32
QY
3**********
4Route Maps
5**********
42fc5d26 6
655cdc32
QY
7Route maps provide a means to both filter and/or apply actions to route, hence
8allowing policy to be applied to routes.
42fc5d26 9
a690202f 10For a route reflector to apply a ``route-map`` to reflected routes, be sure to
11include ``bgp route-reflector allow-outbound-policy`` in ``router bgp`` mode.
12
655cdc32 13Route maps are an ordered list of route map entries. Each entry may specify up
d1e7591e 14to four distinct sets of clauses:
42fc5d26 15
013f9762 16.. glossary::
42fc5d26 17
013f9762
QY
18 Matching Conditions
19 A route-map entry may, optionally, specify one or more conditions which
20 must be matched if the entry is to be considered further, as governed by
d1e7591e 21 the Match Policy. If a route-map entry does not explicitly specify any
013f9762 22 matching conditions, then it always matches.
42fc5d26 23
013f9762
QY
24 Set Actions
25 A route-map entry may, optionally, specify one or more Set Actions to set
26 or modify attributes of the route.
42fc5d26 27
013f9762
QY
28 Matching Policy
29 This specifies the policy implied if the :term:`Matching Conditions` are
30 met or not met, and which actions of the route-map are to be taken, if
31 any. The two possibilities are:
42fc5d26 32
013f9762
QY
33 - :dfn:`permit`: If the entry matches, then carry out the
34 :term:`Set Actions`. Then finish processing the route-map, permitting
35 the route, unless an :term:`Exit Policy` action indicates otherwise.
42fc5d26 36
013f9762
QY
37 - :dfn:`deny`: If the entry matches, then finish processing the route-map and
38 deny the route (return `deny`).
42fc5d26 39
013f9762
QY
40 The `Matching Policy` is specified as part of the command which defines
41 the ordered entry in the route-map. See below.
42fc5d26 42
013f9762 43 Call Action
c9cf9db6
QY
44 Call to another route-map, after any :term:`Set Actions` have been
45 carried out. If the route-map called returns `deny` then processing of
46 the route-map finishes and the route is denied, regardless of the
47 :term:`Matching Policy` or the :term:`Exit Policy`. If the called
48 route-map returns `permit`, then :term:`Matching Policy` and :term:`Exit
49 Policy` govern further behaviour, as normal.
42fc5d26 50
013f9762
QY
51 Exit Policy
52 An entry may, optionally, specify an alternative :dfn:`Exit Policy` to
53 take if the entry matched, rather than the normal policy of exiting the
54 route-map and permitting the route. The two possibilities are:
42fc5d26 55
013f9762 56 - :dfn:`next`: Continue on with processing of the route-map entries.
42fc5d26 57
013f9762
QY
58 - :dfn:`goto N`: Jump ahead to the first route-map entry whose order in
59 the route-map is >= N. Jumping to a previous entry is not permitted.
42fc5d26 60
655cdc32
QY
61The default action of a route-map, if no entries match, is to deny. I.e. a
62route-map essentially has as its last entry an empty *deny* entry, which
63matches all routes. To change this behaviour, one must specify an empty
64*permit* entry as the last entry in the route-map.
42fc5d26
QY
65
66To summarise the above:
67
655cdc32
QY
68+--------+--------+----------+
69| | Match | No Match |
70+========+========+==========+
71| Permit | action | cont |
72+--------+--------+----------+
73| Deny | deny | cont |
74+--------+--------+----------+
75
76action
77 - Apply *set* statements
78 - If *call* is present, call given route-map. If that returns a ``deny``,
79 finish processing and return ``deny``.
80 - If *Exit Policy* is *next*, goto next route-map entry
81 - If *Exit Policy* is *goto*, goto first entry whose order in the
82 list is >= the given order.
83 - Finish processing the route-map and permit the route.
84
85deny
86 The route is denied by the route-map (return ``deny``).
87
88cont
89 goto next route-map entry
42fc5d26 90
1fa30509
DS
91.. _route-map-show-command:
92
93.. index:: show route-map [WORD]
94.. clicmd:: show route-map [WORD]
95
96 Display data about each daemons knowledge of individual route-maps.
97 If WORD is supplied narrow choice to that particular route-map.
98
99.. _route-map-clear-counter-command:
100
101.. index:: clear route-map counter [WORD]
102.. clicmd:: clear route-map counter [WORD]
103
104 Clear counters that are being stored about the route-map utilization
105 so that subsuquent show commands will indicate since the last clear.
106 If WORD is specified clear just that particular route-map's counters.
107
0efdf0fe 108.. _route-map-command:
42fc5d26
QY
109
110Route Map Command
111=================
112
655cdc32
QY
113.. index:: route-map ROUTE-MAP-NAME (permit|deny) ORDER
114.. clicmd:: route-map ROUTE-MAP-NAME (permit|deny) ORDER
42fc5d26 115
655cdc32
QY
116 Configure the `order`'th entry in `route-map-name` with ``Match Policy`` of
117 either *permit* or *deny*.
42fc5d26 118
0efdf0fe 119.. _route-map-match-command:
42fc5d26
QY
120
121Route Map Match Command
122=======================
123
655cdc32
QY
124.. index:: match ip address ACCESS_LIST
125.. clicmd:: match ip address ACCESS_LIST
42fc5d26 126
655cdc32 127 Matches the specified `access_list`
42fc5d26 128
ec3bff6f
TA
129.. index:: match ip address prefix-list PREFIX_LIST
130.. clicmd:: match ip address prefix-list PREFIX_LIST
42fc5d26 131
ec3bff6f 132 Matches the specified `PREFIX_LIST`
42fc5d26 133
655cdc32
QY
134.. index:: match ip address prefix-len 0-32
135.. clicmd:: match ip address prefix-len 0-32
42fc5d26 136
655cdc32 137 Matches the specified `prefix-len`. This is a Zebra specific command.
42fc5d26 138
655cdc32
QY
139.. index:: match ipv6 address ACCESS_LIST
140.. clicmd:: match ipv6 address ACCESS_LIST
42fc5d26 141
655cdc32 142 Matches the specified `access_list`
42fc5d26 143
ec3bff6f
TA
144.. index:: match ipv6 address prefix-list PREFIX_LIST
145.. clicmd:: match ipv6 address prefix-list PREFIX_LIST
42fc5d26 146
ec3bff6f 147 Matches the specified `PREFIX_LIST`
42fc5d26 148
655cdc32
QY
149.. index:: match ipv6 address prefix-len 0-128
150.. clicmd:: match ipv6 address prefix-len 0-128
42fc5d26 151
655cdc32 152 Matches the specified `prefix-len`. This is a Zebra specific command.
42fc5d26 153
be7735b3
PG
154.. index:: match ip next-hop address IPV4_ADDR
155.. clicmd:: match ip next-hop address IPV4_ADDR
42fc5d26 156
be7735b3
PG
157 This is a BGP specific match command. Matches the specified `ipv4_addr`.
158
159.. index:: match ipv6 next-hop IPV6_ADDR
160.. clicmd:: match ipv6 next-hop IPV6_ADDR
161
162 This is a BGP specific match command. Matches the specified `ipv6_addr`.
42fc5d26 163
c7854434
VB
164.. index:: match as-path AS_PATH
165.. clicmd:: match as-path AS_PATH
42fc5d26 166
655cdc32 167 Matches the specified `as_path`.
42fc5d26 168
655cdc32
QY
169.. index:: match metric METRIC
170.. clicmd:: match metric METRIC
42fc5d26 171
655cdc32 172 Matches the specified `metric`.
42fc5d26 173
a5a48dbf
QY
174.. index:: match tag TAG
175.. clicmd:: match tag TAG
176
177 Matches the specified tag value associated with the route. This tag value
178 can be in the range of (1-4294967295).
179
655cdc32
QY
180.. index:: match local-preference METRIC
181.. clicmd:: match local-preference METRIC
42fc5d26 182
655cdc32 183 Matches the specified `local-preference`.
42fc5d26 184
655cdc32
QY
185.. index:: match community COMMUNITY_LIST
186.. clicmd:: match community COMMUNITY_LIST
42fc5d26 187
655cdc32 188 Matches the specified `community_list`
42fc5d26 189
655cdc32
QY
190.. index:: match peer IPV4_ADDR
191.. clicmd:: match peer IPV4_ADDR
42fc5d26 192
655cdc32
QY
193 This is a BGP specific match command. Matches the peer ip address
194 if the neighbor was specified in this manner.
42fc5d26 195
655cdc32
QY
196.. index:: match peer IPV6_ADDR
197.. clicmd:: match peer IPV6_ADDR
42fc5d26 198
655cdc32
QY
199 This is a BGP specific match command. Matches the peer ipv6
200 address if the neighbor was specified in this manner.
42fc5d26 201
655cdc32
QY
202.. index:: match peer INTERFACE_NAME
203.. clicmd:: match peer INTERFACE_NAME
42fc5d26 204
655cdc32 205 This is a BGP specific match command. Matches the peer
42fc5d26
QY
206 interface name specified if the neighbor was specified
207 in this manner.
208
af21c682
DS
209.. index:: match source-protocol PROTOCOL_NAME
210.. clicmd:: match source-protocol PROTOCOL_NAME
211
212 This is a ZEBRA specific match command. Matches the
213 originating protocol specified.
214
215.. index:: match source-instance NUMBER
216.. clicmd:: match source-instance NUMBER
217
218 This is a ZEBRA specific match command. The number is a range from (0-255).
219 Matches the originating protocols instance specified.
220
0efdf0fe 221.. _route-map-set-command:
42fc5d26
QY
222
223Route Map Set Command
224=====================
225
013f9762
QY
226.. program:: configure
227
a5a48dbf
QY
228.. index:: set tag TAG
229.. clicmd:: set tag TAG
230
a5a48dbf
QY
231 Set a tag on the matched route. This tag value can be from (1-4294967295).
232 Additionally if you have compiled with the :option:`--enable-realms`
233 configure option. Tag values from (1-255) are sent to the Linux kernel as a
234 realm value. Then route policy can be applied. See the tc man page.
235
655cdc32
QY
236.. index:: set ip next-hop IPV4_ADDRESS
237.. clicmd:: set ip next-hop IPV4_ADDRESS
42fc5d26 238
e13fd66f
DS
239 Set the BGP nexthop address to the specified IPV4_ADDRESS. For both
240 incoming and outgoing route-maps.
241
242.. index:: set ip next-hop peer-address
243.. clicmd:: set ip next-hop peer-address
244
245 Set the BGP nexthop address to the address of the peer. For an incoming
246 route-map this means the ip address of our peer is used. For an outgoing
247 route-map this means the ip address of our self is used to establish the
248 peering with our neighbor.
249
250.. index:: set ip next-hop unchanged
251.. clicmd:: set ip next-hop unchanged
252
253 Set the route-map as unchanged. Pass the route-map through without
254 changing it's value.
255
256.. index:: set ipv6 next-hop peer-address
257.. clicmd:: set ipv6 next-hop peer-address
258
259 Set the BGP nexthop address to the address of the peer. For an incoming
260 route-map this means the ipv6 address of our peer is used. For an outgoing
261 route-map this means the ip address of our self is used to establish the
262 peering with our neighbor.
263
264.. index:: set ipv6 next-hop prefer-global
265.. clicmd:: set ipv6 next-hop prefer-global
266
267 For Incoming and Import Route-maps if we receive a v6 global and v6 LL
268 address for the route, then prefer to use the global address as the nexthop.
269
270.. index:: set ipv6 next-hop global IPV6_ADDRESS
271.. clicmd:: set ipv6 next-hop global IPV6_ADDRESS
272
f22744c3 273 Set the next-hop to the specified IPV6_ADDRESS for both incoming and
e13fd66f 274 outgoing route-maps.
42fc5d26 275
655cdc32
QY
276.. index:: set local-preference LOCAL_PREF
277.. clicmd:: set local-preference LOCAL_PREF
42fc5d26 278
655cdc32 279 Set the BGP local preference to `local_pref`.
42fc5d26 280
94f75688
DA
281.. index:: set local-preference +LOCAL_PREF
282.. clicmd:: set local-preference +LOCAL_PREF
283
284 Add the BGP local preference to an existing `local_pref`.
285
286.. index:: set local-preference -LOCAL_PREF
287.. clicmd:: set local-preference -LOCAL_PREF
288
289 Subtract the BGP local preference from an existing `local_pref`.
290
4dac4cc9
DS
291.. index:: [no] set distance DISTANCE
292.. clicmd:: [no] set distance DISTANCE
293
294 Set the Administrative distance to DISTANCE to use for the route.
295 This is only locally significant and will not be dispersed to peers.
296
655cdc32
QY
297.. index:: set weight WEIGHT
298.. clicmd:: set weight WEIGHT
42fc5d26 299
655cdc32 300 Set the route's weight.
42fc5d26 301
655cdc32
QY
302.. index:: set metric METRIC
303.. clicmd:: set metric METRIC
42fc5d26 304
655cdc32 305 Set the BGP attribute MED.
42fc5d26 306
655cdc32
QY
307.. index:: set as-path prepend AS_PATH
308.. clicmd:: set as-path prepend AS_PATH
42fc5d26 309
655cdc32 310 Set the BGP AS path to prepend.
42fc5d26 311
655cdc32
QY
312.. index:: set community COMMUNITY
313.. clicmd:: set community COMMUNITY
42fc5d26 314
655cdc32 315 Set the BGP community attribute.
42fc5d26 316
655cdc32
QY
317.. index:: set ipv6 next-hop local IPV6_ADDRESS
318.. clicmd:: set ipv6 next-hop local IPV6_ADDRESS
42fc5d26 319
655cdc32 320 Set the BGP-4+ link local IPv6 nexthop address.
42fc5d26 321
90da9a14
C
322.. index:: set origin ORIGIN <egp|igp|incomplete>
323.. clicmd:: set origin ORIGIN <egp|igp|incomplete>
324
325 Set BGP route origin.
326
951745bd
PG
327.. index:: set table (1-4294967295)
328.. clicmd:: set table (1-4294967295)
329
330 Set the BGP table to a given table identifier
331
0efdf0fe 332.. _route-map-call-command:
42fc5d26
QY
333
334Route Map Call Command
335======================
336
655cdc32
QY
337.. index:: call NAME
338.. clicmd:: call NAME
42fc5d26 339
655cdc32
QY
340 Call route-map `name`. If it returns deny, deny the route and
341 finish processing the route-map.
42fc5d26 342
0efdf0fe 343.. _route-map-exit-action-command:
42fc5d26
QY
344
345Route Map Exit Action Command
346=============================
347
655cdc32
QY
348.. index:: on-match next
349.. clicmd:: on-match next
42fc5d26 350
655cdc32
QY
351.. index:: continue
352.. clicmd:: continue
42fc5d26 353
655cdc32 354 Proceed on to the next entry in the route-map.
42fc5d26 355
655cdc32
QY
356.. index:: on-match goto N
357.. clicmd:: on-match goto N
42fc5d26 358
655cdc32
QY
359.. index:: continue N
360.. clicmd:: continue N
42fc5d26 361
655cdc32 362 Proceed processing the route-map at the first entry whose order is >= N
42fc5d26 363
009d25a0
NT
364.. _route-map-optimization-command:
365
366Route Map Optimization Command
367==============================
368
369.. index:: route-map optimization
370.. clicmd:: route-map optimization
371
372 Enable route-map processing optimization. The optimization is
373 enabled by default.
374 Instead of sequentially passing through all the route-map indexes
375 until a match is found, the search for the best-match index will be
376 based on a look-up in a prefix-tree. A per-route-map prefix-tree
377 will be constructed for this purpose. The prefix-tree will compose
378 of all the prefixes in all the prefix-lists that are included in the
379 match rule of all the sequences of a route-map.
380
381.. index:: no route-map optimization
382.. clicmd:: no route-map optimization
383
384 Disable the route-map processing optimization.
1fa30509 385
42fc5d26
QY
386Route Map Examples
387==================
388
389A simple example of a route-map:
390
9eb95b3b 391.. code-block:: frr
42fc5d26 392
9eb95b3b
QY
393 route-map test permit 10
394 match ip address 10
395 set local-preference 200
a8c90e15 396
42fc5d26
QY
397
398This means that if a route matches ip access-list number 10 it's
399local-preference value is set to 200.
400
c1a54c05 401See :ref:`bgp-configuration-examples` for examples of more sophisticated
d1e7591e 402usage of route-maps, including of the ``call`` action.
42fc5d26 403