]>
Commit | Line | Data |
---|---|---|
0efdf0fe | 1 | .. _route-map: |
42fc5d26 | 2 | |
655cdc32 QY |
3 | ********** |
4 | Route Maps | |
5 | ********** | |
42fc5d26 | 6 | |
655cdc32 QY |
7 | Route maps provide a means to both filter and/or apply actions to route, hence |
8 | allowing policy to be applied to routes. | |
42fc5d26 | 9 | |
a690202f | 10 | For a route reflector to apply a ``route-map`` to reflected routes, be sure to |
11 | include ``bgp route-reflector allow-outbound-policy`` in ``router bgp`` mode. | |
12 | ||
655cdc32 | 13 | Route maps are an ordered list of route map entries. Each entry may specify up |
d1e7591e | 14 | to 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 |
61 | The default action of a route-map, if no entries match, is to deny. I.e. a |
62 | route-map essentially has as its last entry an empty *deny* entry, which | |
63 | matches 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 | |
66 | To summarise the above: | |
67 | ||
655cdc32 QY |
68 | +--------+--------+----------+ |
69 | | | Match | No Match | | |
70 | +========+========+==========+ | |
71 | | Permit | action | cont | | |
72 | +--------+--------+----------+ | |
73 | | Deny | deny | cont | | |
74 | +--------+--------+----------+ | |
75 | ||
76 | action | |
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 | ||
85 | deny | |
86 | The route is denied by the route-map (return ``deny``). | |
87 | ||
88 | cont | |
89 | goto next route-map entry | |
42fc5d26 | 90 | |
1fa30509 DS |
91 | .. _route-map-show-command: |
92 | ||
1fa30509 DS |
93 | .. clicmd:: show route-map [WORD] |
94 | ||
95 | Display data about each daemons knowledge of individual route-maps. | |
96 | If WORD is supplied narrow choice to that particular route-map. | |
97 | ||
98 | .. _route-map-clear-counter-command: | |
99 | ||
1fa30509 DS |
100 | .. clicmd:: clear route-map counter [WORD] |
101 | ||
102 | Clear counters that are being stored about the route-map utilization | |
103 | so that subsuquent show commands will indicate since the last clear. | |
104 | If WORD is specified clear just that particular route-map's counters. | |
105 | ||
0efdf0fe | 106 | .. _route-map-command: |
42fc5d26 QY |
107 | |
108 | Route Map Command | |
109 | ================= | |
110 | ||
655cdc32 | 111 | .. clicmd:: route-map ROUTE-MAP-NAME (permit|deny) ORDER |
42fc5d26 | 112 | |
655cdc32 QY |
113 | Configure the `order`'th entry in `route-map-name` with ``Match Policy`` of |
114 | either *permit* or *deny*. | |
42fc5d26 | 115 | |
0efdf0fe | 116 | .. _route-map-match-command: |
42fc5d26 QY |
117 | |
118 | Route Map Match Command | |
119 | ======================= | |
120 | ||
655cdc32 | 121 | .. clicmd:: match ip address ACCESS_LIST |
42fc5d26 | 122 | |
655cdc32 | 123 | Matches the specified `access_list` |
42fc5d26 | 124 | |
ec3bff6f | 125 | .. clicmd:: match ip address prefix-list PREFIX_LIST |
42fc5d26 | 126 | |
ec3bff6f | 127 | Matches the specified `PREFIX_LIST` |
42fc5d26 | 128 | |
655cdc32 | 129 | .. clicmd:: match ip address prefix-len 0-32 |
42fc5d26 | 130 | |
655cdc32 | 131 | Matches the specified `prefix-len`. This is a Zebra specific command. |
42fc5d26 | 132 | |
655cdc32 | 133 | .. clicmd:: match ipv6 address ACCESS_LIST |
42fc5d26 | 134 | |
655cdc32 | 135 | Matches the specified `access_list` |
42fc5d26 | 136 | |
ec3bff6f | 137 | .. clicmd:: match ipv6 address prefix-list PREFIX_LIST |
42fc5d26 | 138 | |
ec3bff6f | 139 | Matches the specified `PREFIX_LIST` |
42fc5d26 | 140 | |
655cdc32 | 141 | .. clicmd:: match ipv6 address prefix-len 0-128 |
42fc5d26 | 142 | |
655cdc32 | 143 | Matches the specified `prefix-len`. This is a Zebra specific command. |
42fc5d26 | 144 | |
be7735b3 | 145 | .. clicmd:: match ip next-hop address IPV4_ADDR |
42fc5d26 | 146 | |
be7735b3 PG |
147 | This is a BGP specific match command. Matches the specified `ipv4_addr`. |
148 | ||
be7735b3 PG |
149 | .. clicmd:: match ipv6 next-hop IPV6_ADDR |
150 | ||
151 | This is a BGP specific match command. Matches the specified `ipv6_addr`. | |
42fc5d26 | 152 | |
c7854434 | 153 | .. clicmd:: match as-path AS_PATH |
42fc5d26 | 154 | |
655cdc32 | 155 | Matches the specified `as_path`. |
42fc5d26 | 156 | |
655cdc32 | 157 | .. clicmd:: match metric METRIC |
42fc5d26 | 158 | |
655cdc32 | 159 | Matches the specified `metric`. |
42fc5d26 | 160 | |
a5a48dbf QY |
161 | .. clicmd:: match tag TAG |
162 | ||
163 | Matches the specified tag value associated with the route. This tag value | |
164 | can be in the range of (1-4294967295). | |
165 | ||
655cdc32 | 166 | .. clicmd:: match local-preference METRIC |
42fc5d26 | 167 | |
655cdc32 | 168 | Matches the specified `local-preference`. |
42fc5d26 | 169 | |
655cdc32 | 170 | .. clicmd:: match community COMMUNITY_LIST |
42fc5d26 | 171 | |
655cdc32 | 172 | Matches the specified `community_list` |
42fc5d26 | 173 | |
655cdc32 | 174 | .. clicmd:: match peer IPV4_ADDR |
42fc5d26 | 175 | |
655cdc32 QY |
176 | This is a BGP specific match command. Matches the peer ip address |
177 | if the neighbor was specified in this manner. | |
42fc5d26 | 178 | |
655cdc32 | 179 | .. clicmd:: match peer IPV6_ADDR |
42fc5d26 | 180 | |
655cdc32 QY |
181 | This is a BGP specific match command. Matches the peer ipv6 |
182 | address if the neighbor was specified in this manner. | |
42fc5d26 | 183 | |
655cdc32 | 184 | .. clicmd:: match peer INTERFACE_NAME |
42fc5d26 | 185 | |
655cdc32 | 186 | This is a BGP specific match command. Matches the peer |
42fc5d26 QY |
187 | interface name specified if the neighbor was specified |
188 | in this manner. | |
189 | ||
af21c682 DS |
190 | .. clicmd:: match source-protocol PROTOCOL_NAME |
191 | ||
192 | This is a ZEBRA specific match command. Matches the | |
193 | originating protocol specified. | |
194 | ||
af21c682 DS |
195 | .. clicmd:: match source-instance NUMBER |
196 | ||
197 | This is a ZEBRA specific match command. The number is a range from (0-255). | |
198 | Matches the originating protocols instance specified. | |
199 | ||
0efdf0fe | 200 | .. _route-map-set-command: |
42fc5d26 QY |
201 | |
202 | Route Map Set Command | |
203 | ===================== | |
204 | ||
013f9762 QY |
205 | .. program:: configure |
206 | ||
a5a48dbf QY |
207 | .. clicmd:: set tag TAG |
208 | ||
a5a48dbf QY |
209 | Set a tag on the matched route. This tag value can be from (1-4294967295). |
210 | Additionally if you have compiled with the :option:`--enable-realms` | |
211 | configure option. Tag values from (1-255) are sent to the Linux kernel as a | |
212 | realm value. Then route policy can be applied. See the tc man page. | |
213 | ||
655cdc32 | 214 | .. clicmd:: set ip next-hop IPV4_ADDRESS |
42fc5d26 | 215 | |
e13fd66f DS |
216 | Set the BGP nexthop address to the specified IPV4_ADDRESS. For both |
217 | incoming and outgoing route-maps. | |
218 | ||
e13fd66f DS |
219 | .. clicmd:: set ip next-hop peer-address |
220 | ||
221 | Set the BGP nexthop address to the address of the peer. For an incoming | |
222 | route-map this means the ip address of our peer is used. For an outgoing | |
223 | route-map this means the ip address of our self is used to establish the | |
224 | peering with our neighbor. | |
225 | ||
e13fd66f DS |
226 | .. clicmd:: set ip next-hop unchanged |
227 | ||
228 | Set the route-map as unchanged. Pass the route-map through without | |
229 | changing it's value. | |
230 | ||
e13fd66f DS |
231 | .. clicmd:: set ipv6 next-hop peer-address |
232 | ||
233 | Set the BGP nexthop address to the address of the peer. For an incoming | |
234 | route-map this means the ipv6 address of our peer is used. For an outgoing | |
235 | route-map this means the ip address of our self is used to establish the | |
236 | peering with our neighbor. | |
237 | ||
e13fd66f DS |
238 | .. clicmd:: set ipv6 next-hop prefer-global |
239 | ||
240 | For Incoming and Import Route-maps if we receive a v6 global and v6 LL | |
241 | address for the route, then prefer to use the global address as the nexthop. | |
242 | ||
e13fd66f DS |
243 | .. clicmd:: set ipv6 next-hop global IPV6_ADDRESS |
244 | ||
f22744c3 | 245 | Set the next-hop to the specified IPV6_ADDRESS for both incoming and |
e13fd66f | 246 | outgoing route-maps. |
42fc5d26 | 247 | |
655cdc32 | 248 | .. clicmd:: set local-preference LOCAL_PREF |
42fc5d26 | 249 | |
655cdc32 | 250 | Set the BGP local preference to `local_pref`. |
42fc5d26 | 251 | |
94f75688 DA |
252 | .. clicmd:: set local-preference +LOCAL_PREF |
253 | ||
254 | Add the BGP local preference to an existing `local_pref`. | |
255 | ||
94f75688 DA |
256 | .. clicmd:: set local-preference -LOCAL_PREF |
257 | ||
258 | Subtract the BGP local preference from an existing `local_pref`. | |
259 | ||
03750f1e | 260 | .. clicmd:: set distance DISTANCE |
4dac4cc9 DS |
261 | |
262 | Set the Administrative distance to DISTANCE to use for the route. | |
263 | This is only locally significant and will not be dispersed to peers. | |
264 | ||
655cdc32 | 265 | .. clicmd:: set weight WEIGHT |
42fc5d26 | 266 | |
655cdc32 | 267 | Set the route's weight. |
42fc5d26 | 268 | |
03750f1e | 269 | .. clicmd:: set metric <[+|-](1-4294967295)|rtt|+rtt|-rtt> |
42fc5d26 | 270 | |
fe430836 DS |
271 | Set the BGP attribute MED to a specific value. Use `+`/`-` to add or subtract |
272 | the specified value to/from the MED. Use `rtt` to set the MED to the round | |
273 | trip time or `+rtt`/`-rtt` to add/subtract the round trip time to/from the | |
274 | MED. | |
42fc5d26 | 275 | |
655cdc32 | 276 | .. clicmd:: set as-path prepend AS_PATH |
42fc5d26 | 277 | |
655cdc32 | 278 | Set the BGP AS path to prepend. |
42fc5d26 | 279 | |
655cdc32 | 280 | .. clicmd:: set community COMMUNITY |
42fc5d26 | 281 | |
655cdc32 | 282 | Set the BGP community attribute. |
42fc5d26 | 283 | |
655cdc32 | 284 | .. clicmd:: set ipv6 next-hop local IPV6_ADDRESS |
42fc5d26 | 285 | |
655cdc32 | 286 | Set the BGP-4+ link local IPv6 nexthop address. |
42fc5d26 | 287 | |
90da9a14 C |
288 | .. clicmd:: set origin ORIGIN <egp|igp|incomplete> |
289 | ||
290 | Set BGP route origin. | |
291 | ||
951745bd PG |
292 | .. clicmd:: set table (1-4294967295) |
293 | ||
294 | Set the BGP table to a given table identifier | |
295 | ||
ef3e0d04 SM |
296 | .. clicmd:: set sr-te color (1-4294967295) |
297 | ||
298 | Set the color of a SR-TE Policy to be applied to a learned route. The SR-TE | |
299 | Policy is uniquely determined by the color and the BGP nexthop. | |
300 | ||
03750f1e | 301 | |
0efdf0fe | 302 | .. _route-map-call-command: |
42fc5d26 QY |
303 | |
304 | Route Map Call Command | |
305 | ====================== | |
306 | ||
655cdc32 | 307 | .. clicmd:: call NAME |
42fc5d26 | 308 | |
655cdc32 QY |
309 | Call route-map `name`. If it returns deny, deny the route and |
310 | finish processing the route-map. | |
42fc5d26 | 311 | |
03750f1e | 312 | |
0efdf0fe | 313 | .. _route-map-exit-action-command: |
42fc5d26 QY |
314 | |
315 | Route Map Exit Action Command | |
316 | ============================= | |
317 | ||
655cdc32 | 318 | .. clicmd:: on-match next |
42fc5d26 | 319 | |
655cdc32 | 320 | .. clicmd:: continue |
42fc5d26 | 321 | |
655cdc32 | 322 | Proceed on to the next entry in the route-map. |
42fc5d26 | 323 | |
655cdc32 | 324 | .. clicmd:: on-match goto N |
42fc5d26 | 325 | |
655cdc32 | 326 | .. clicmd:: continue N |
42fc5d26 | 327 | |
655cdc32 | 328 | Proceed processing the route-map at the first entry whose order is >= N |
42fc5d26 | 329 | |
03750f1e | 330 | |
009d25a0 NT |
331 | .. _route-map-optimization-command: |
332 | ||
333 | Route Map Optimization Command | |
334 | ============================== | |
335 | ||
009d25a0 NT |
336 | .. clicmd:: route-map optimization |
337 | ||
338 | Enable route-map processing optimization. The optimization is | |
339 | enabled by default. | |
340 | Instead of sequentially passing through all the route-map indexes | |
341 | until a match is found, the search for the best-match index will be | |
342 | based on a look-up in a prefix-tree. A per-route-map prefix-tree | |
343 | will be constructed for this purpose. The prefix-tree will compose | |
344 | of all the prefixes in all the prefix-lists that are included in the | |
345 | match rule of all the sequences of a route-map. | |
346 | ||
1fa30509 | 347 | |
42fc5d26 QY |
348 | Route Map Examples |
349 | ================== | |
350 | ||
351 | A simple example of a route-map: | |
352 | ||
9eb95b3b | 353 | .. code-block:: frr |
42fc5d26 | 354 | |
9eb95b3b QY |
355 | route-map test permit 10 |
356 | match ip address 10 | |
357 | set local-preference 200 | |
a8c90e15 | 358 | |
42fc5d26 QY |
359 | |
360 | This means that if a route matches ip access-list number 10 it's | |
361 | local-preference value is set to 200. | |
362 | ||
c1a54c05 | 363 | See :ref:`bgp-configuration-examples` for examples of more sophisticated |
d1e7591e | 364 | usage of route-maps, including of the ``call`` action. |
42fc5d26 | 365 |