]> git.proxmox.com Git - mirror_frr.git/blob - doc/user/zebra.rst
doc: use frr syntax highlighting
[mirror_frr.git] / doc / user / zebra.rst
1 .. _zebra:
2
3 *****
4 Zebra
5 *****
6
7 *zebra* is an IP routing manager. It provides kernel routing
8 table updates, interface lookups, and redistribution of routes between
9 different routing protocols.
10
11 .. _invoking-zebra:
12
13 Invoking zebra
14 ==============
15
16 Besides the common invocation options (:ref:`common-invocation-options`), the
17 *zebra* specific invocation options are listed below.
18
19 .. program:: zebra
20
21 .. option:: -b, --batch
22
23 Runs in batch mode. *zebra* parses configuration file and terminates
24 immediately.
25
26 .. option:: -k, --keep_kernel
27
28 When zebra starts up, don't delete old self inserted routes.
29
30 .. option:: -r, --retain
31
32 When program terminates, retain routes added by zebra.
33
34 .. program:: configure
35
36 .. _interface-commands:
37
38 Interface Commands
39 ==================
40
41 .. _standard-commands:
42
43 Standard Commands
44 -----------------
45
46 .. index:: interface IFNAME
47
48 .. clicmd:: interface IFNAME
49
50 .. index:: shutdown
51
52 .. clicmd:: shutdown
53 .. index:: no shutdown
54
55 .. clicmd:: no shutdown
56
57 Up or down the current interface.
58
59 .. index:: ip address ADDRESS/PREFIX
60
61 .. clicmd:: ip address ADDRESS/PREFIX
62 .. index:: ipv6 address ADDRESS/PREFIX
63
64 .. clicmd:: ipv6 address ADDRESS/PREFIX
65 .. index:: no ip address ADDRESS/PREFIX
66
67 .. clicmd:: no ip address ADDRESS/PREFIX
68 .. index:: no ipv6 address ADDRESS/PREFIX
69
70 .. clicmd:: no ipv6 address ADDRESS/PREFIX
71
72 Set the IPv4 or IPv6 address/prefix for the interface.
73
74 .. index:: ip address LOCAL-ADDR peer PEER-ADDR/PREFIX
75
76 .. clicmd:: ip address LOCAL-ADDR peer PEER-ADDR/PREFIX
77 .. index:: no ip address LOCAL-ADDR peer PEER-ADDR/PREFIX
78
79 .. clicmd:: no ip address LOCAL-ADDR peer PEER-ADDR/PREFIX
80
81 Configure an IPv4 Pointopoint address on the interface. (The concept of PtP
82 addressing does not exist for IPv6.)
83
84 `local-addr` has no subnet mask since the local side in PtP addressing is
85 always a single (/32) address. `peer-addr/prefix` can be an arbitrary subnet
86 behind the other end of the link (or even on the link in Point-to-Multipoint
87 setups), though generally /32s are used.
88
89 .. index:: ip address ADDRESS/PREFIX secondary
90
91 .. clicmd:: ip address ADDRESS/PREFIX secondary
92 .. index:: no ip address ADDRESS/PREFIX secondary
93
94 .. clicmd:: no ip address ADDRESS/PREFIX secondary
95
96 Set the secondary flag for this address. This causes ospfd to not treat the
97 address as a distinct subnet.
98
99 .. index:: description DESCRIPTION ...
100
101 .. clicmd:: description DESCRIPTION ...
102
103 Set description for the interface.
104
105 .. index:: multicast
106
107 .. clicmd:: multicast
108 .. index:: no multicast
109
110 .. clicmd:: no multicast
111
112 Enable or disables multicast flag for the interface.
113
114 .. index:: bandwidth (1-10000000)
115
116 .. clicmd:: bandwidth (1-10000000)
117 .. index:: no bandwidth (1-10000000)
118
119 .. clicmd:: no bandwidth (1-10000000)
120
121 Set bandwidth value of the interface in kilobits/sec. This is for
122 calculating OSPF cost. This command does not affect the actual device
123 configuration.
124
125 .. index:: link-detect
126
127 .. clicmd:: link-detect
128 .. index:: no link-detect
129
130 .. clicmd:: no link-detect
131
132 Enable/disable link-detect on platforms which support this. Currently only
133 Linux and Solaris, and only where network interface drivers support
134 reporting link-state via the ``IFF_RUNNING`` flag.
135
136 .. _link-parameters-commands:
137
138 Link Parameters Commands
139 ------------------------
140
141 .. index:: link-params
142 .. clicmd:: link-params
143
144 .. index:: no link-param
145 .. clicmd:: no link-param
146
147 Enter into the link parameters sub node. At least 'enable' must be set to
148 activate the link parameters, and consequently Traffic Engineering on this
149 interface. MPLS-TE must be enable at the OSPF
150 (:ref:`ospf-traffic-engineering`) or ISIS (:ref:`isis-traffic-engineering`)
151 router level in complement to this. Disable link parameters for this
152 interface.
153
154 Under link parameter statement, the following commands set the different TE values:
155
156 .. index:: link-params [enable]
157 .. clicmd:: link-params [enable]
158
159 Enable link parameters for this interface.
160
161 .. index:: link-params [metric (0-4294967295)]
162 .. clicmd:: link-params [metric (0-4294967295)]
163
164 .. index:: link-params max-bw BANDWIDTH
165 .. clicmd:: link-params max-bw BANDWIDTH
166
167 .. index:: link-params max-rsv-bw BANDWIDTH
168 .. clicmd:: link-params max-rsv-bw BANDWIDTH
169
170 .. index:: link-params unrsv-bw (0-7) BANDWIDTH
171 .. clicmd:: link-params unrsv-bw (0-7) BANDWIDTH
172
173 .. index:: link-params admin-grp BANDWIDTH
174 .. clicmd:: link-params admin-grp BANDWIDTH
175
176 These commands specifies the Traffic Engineering parameters of the interface
177 in conformity to RFC3630 (OSPF) or RFC5305 (ISIS). There are respectively
178 the TE Metric (different from the OSPF or ISIS metric), Maximum Bandwidth
179 (interface speed by default), Maximum Reservable Bandwidth, Unreserved
180 Bandwidth for each 0-7 priority and Admin Group (ISIS) or Resource
181 Class/Color (OSPF).
182
183 Note that BANDIWDTH is specified in IEEE floating point format and express
184 in Bytes/second.
185
186 .. index:: link-param delay (0-16777215) [min (0-16777215) | max (0-16777215)]
187 .. clicmd:: link-param delay (0-16777215) [min (0-16777215) | max (0-16777215)]
188
189 .. index:: link-param delay-variation (0-16777215)
190 .. clicmd:: link-param delay-variation (0-16777215)
191
192 .. index:: link-param packet-loss PERCENTAGE
193 .. clicmd:: link-param packet-loss PERCENTAGE
194
195 .. index:: link-param res-bw BANDWIDTH
196 .. clicmd:: link-param res-bw BANDWIDTH
197
198 .. index:: link-param ava-bw BANDWIDTH
199 .. clicmd:: link-param ava-bw BANDWIDTH
200
201 .. index:: link-param use-bw BANDWIDTH
202 .. clicmd:: link-param use-bw BANDWIDTH
203
204 These command specifies additionnal Traffic Engineering parameters of the
205 interface in conformity to draft-ietf-ospf-te-metrics-extension-05.txt and
206 draft-ietf-isis-te-metrics-extension-03.txt. There are respectively the
207 delay, jitter, loss, available bandwidth, reservable bandwidth and utilized
208 bandwidth.
209
210 Note that BANDWIDTH is specified in IEEE floating point format and express
211 in Bytes/second. Delays and delay variation are express in micro-second
212 (µs). Loss is specified in PERCENTAGE ranging from 0 to 50.331642% by step
213 of 0.000003.
214
215 .. index:: link-param neighbor <A.B.C.D> as (0-65535)
216 .. clicmd:: link-param neighbor <A.B.C.D> as (0-65535)
217
218 .. index:: link-param no neighbor
219 .. clicmd:: link-param no neighbor
220
221 Specifies the remote ASBR IP address and Autonomous System (AS) number
222 for InterASv2 link in OSPF (RFC5392). Note that this option is not yet
223 supported for ISIS (RFC5316).
224
225 .. _static-route-commands:
226
227 Static Route Commands
228 =====================
229
230 Static routing is a very fundamental feature of routing technology. It
231 defines static prefix and gateway.
232
233 .. index:: ip route NETWORK GATEWAY
234 .. clicmd:: ip route NETWORK GATEWAY
235
236 NETWORK is destination prefix with format of A.B.C.D/M. GATEWAY is gateway
237 for the prefix. When GATEWAY is A.B.C.D format. It is taken as a IPv4
238 address gateway. Otherwise it is treated as an interface name. If the
239 interface name is ``null0`` then zebra installs a blackhole route.
240
241 Some example configuration:
242
243 .. code-block:: frr
244
245 ip route 10.0.0.0/8 10.0.0.2
246 ip route 10.0.0.0/8 ppp0
247 ip route 10.0.0.0/8 null0
248
249 First example defines 10.0.0.0/8 static route with gateway 10.0.0.2.
250 Second one defines the same prefix but with gateway to interface ppp0. The
251 third install a blackhole route.
252
253 .. index:: ip route NETWORK NETMASK GATEWAY
254 .. clicmd:: ip route NETWORK NETMASK GATEWAY
255
256 This is alternate version of above command. When NETWORK is
257 A.B.C.D format, user must define NETMASK value with A.B.C.D
258 format. GATEWAY is same option as above command.
259
260 .. code-block:: frr
261
262 ip route 10.0.0.0 255.255.255.0 10.0.0.2
263 ip route 10.0.0.0 255.255.255.0 ppp0
264 ip route 10.0.0.0 255.255.255.0 null0
265
266
267 These statements are equivalent to those in the previous example.
268
269 .. index:: ip route NETWORK GATEWAY DISTANCE
270 .. clicmd:: ip route NETWORK GATEWAY DISTANCE
271
272 Installs the route with the specified distance.
273
274 Multiple nexthop static route:
275
276 .. code-block:: frr
277
278 ip route 10.0.0.1/32 10.0.0.2
279 ip route 10.0.0.1/32 10.0.0.3
280 ip route 10.0.0.1/32 eth0
281
282
283 If there is no route to 10.0.0.2 and 10.0.0.3, and interface eth0
284 is reachable, then the last route is installed into the kernel.
285
286 If zebra has been compiled with multipath support, and both 10.0.0.2 and
287 10.0.0.3 are reachable, zebra will install a multipath route via both
288 nexthops, if the platform supports this.
289
290 ::
291
292 zebra> show ip route
293 S> 10.0.0.1/32 [1/0] via 10.0.0.2 inactive
294 via 10.0.0.3 inactive
295 * is directly connected, eth0
296
297
298 .. code-block:: frr
299
300 ip route 10.0.0.0/8 10.0.0.2
301 ip route 10.0.0.0/8 10.0.0.3
302 ip route 10.0.0.0/8 null0 255
303
304
305 This will install a multihop route via the specified next-hops if they are
306 reachable, as well as a high-metric blackhole route, which can be useful to
307 prevent traffic destined for a prefix to match less-specific routes (eg
308 default) should the specified gateways not be reachable. Eg:
309
310 ::
311
312 zebra> show ip route 10.0.0.0/8
313 Routing entry for 10.0.0.0/8
314 Known via "static", distance 1, metric 0
315 10.0.0.2 inactive
316 10.0.0.3 inactive
317
318 Routing entry for 10.0.0.0/8
319 Known via "static", distance 255, metric 0
320 directly connected, Null0
321
322
323 .. index:: ipv6 route NETWORK GATEWAY
324 .. clicmd:: ipv6 route NETWORK GATEWAY
325
326 .. index:: ipv6 route NETWORK GATEWAY DISTANCE
327 .. clicmd:: ipv6 route NETWORK GATEWAY DISTANCE
328
329 These behave similarly to their ipv4 counterparts.
330
331 .. index:: ipv6 route NETWORK from SRCPREFIX GATEWAY
332 .. clicmd:: ipv6 route NETWORK from SRCPREFIX GATEWAY
333
334 .. index:: ipv6 route NETWORK from SRCPREFIX GATEWAY DISTANCE
335 .. clicmd:: ipv6 route NETWORK from SRCPREFIX GATEWAY DISTANCE
336
337 Install a static source-specific route. These routes are currently supported
338 on Linux operating systems only, and perform AND matching on packet's
339 destination and source addresses in the kernel's forwarding path. Note that
340 destination longest-prefix match is "more important" than source LPM, e.g.
341 *"2001:db8:1::/64 from 2001:db8::/48"* will win over
342 *"2001:db8::/48 from 2001:db8:1::/64"* if both match.
343
344 .. index:: table TABLENO
345 .. clicmd:: table TABLENO
346
347 Select the primary kernel routing table to be used. This only works
348 for kernels supporting multiple routing tables (like GNU/Linux 2.2.x
349 and later). After setting TABLENO with this command,
350 static routes defined after this are added to the specified table.
351
352 .. _multicast-rib-commands:
353
354 Multicast RIB Commands
355 ======================
356
357 The Multicast RIB provides a separate table of unicast destinations which
358 is used for Multicast Reverse Path Forwarding decisions. It is used with
359 a multicast source's IP address, hence contains not multicast group
360 addresses but unicast addresses.
361
362 This table is fully separate from the default unicast table. However,
363 RPF lookup can include the unicast table.
364
365 WARNING: RPF lookup results are non-responsive in this version of FRR,
366 i.e. multicast routing does not actively react to changes in underlying
367 unicast topology!
368
369 .. index:: ip multicast rpf-lookup-mode MODE
370 .. clicmd:: ip multicast rpf-lookup-mode MODE
371
372 .. index:: no ip multicast rpf-lookup-mode [MODE]
373 .. clicmd:: no ip multicast rpf-lookup-mode [MODE]
374
375 MODE sets the method used to perform RPF lookups. Supported modes:
376
377 urib-only
378 Performs the lookup on the Unicast RIB. The Multicast RIB is never used.
379
380 mrib-only
381 Performs the lookup on the Multicast RIB. The Unicast RIB is never used.
382
383 mrib-then-urib
384 Tries to perform the lookup on the Multicast RIB. If any route is found,
385 that route is used. Otherwise, the Unicast RIB is tried.
386
387 lower-distance
388 Performs a lookup on the Multicast RIB and Unicast RIB each. The result
389 with the lower administrative distance is used; if they're equal, the
390 Multicast RIB takes precedence.
391
392 longer-prefix
393 Performs a lookup on the Multicast RIB and Unicast RIB each. The result
394 with the longer prefix length is used; if they're equal, the
395 Multicast RIB takes precedence.
396
397 The `mrib-then-urib` setting is the default behavior if nothing is
398 configured. If this is the desired behavior, it should be explicitly
399 configured to make the configuration immune against possible changes in
400 what the default behavior is.
401
402 .. warning::
403 Unreachable routes do not receive special treatment and do not cause
404 fallback to a second lookup.
405
406 .. index:: show ip rpf ADDR
407 .. clicmd:: show ip rpf ADDR
408
409 Performs a Multicast RPF lookup, as configured with ``ip multicast
410 rpf-lookup-mode MODE``. ADDR specifies the multicast source address to look
411 up.
412
413 ::
414
415 > show ip rpf 192.0.2.1
416 Routing entry for 192.0.2.0/24 using Unicast RIB
417
418 Known via "kernel", distance 0, metric 0, best
419 * 198.51.100.1, via eth0
420
421
422 Indicates that a multicast source lookup for 192.0.2.1 would use an
423 Unicast RIB entry for 192.0.2.0/24 with a gateway of 198.51.100.1.
424
425 .. index:: show ip rpf
426 .. clicmd:: show ip rpf
427
428 Prints the entire Multicast RIB. Note that this is independent of the
429 configured RPF lookup mode, the Multicast RIB may be printed yet not
430 used at all.
431
432 .. index:: ip mroute PREFIX NEXTHOP [DISTANCE]
433 .. clicmd:: ip mroute PREFIX NEXTHOP [DISTANCE]
434
435 .. index:: no ip mroute PREFIX NEXTHOP [DISTANCE]
436 .. clicmd:: no ip mroute PREFIX NEXTHOP [DISTANCE]
437
438 Adds a static route entry to the Multicast RIB. This performs exactly as the
439 ``ip route`` command, except that it inserts the route in the Multicast RIB
440 instead of the Unicast RIB.
441
442 .. _zebra-route-filtering:
443
444 zebra Route Filtering
445 =====================
446
447 Zebra supports :dfn:`prefix-list` s and :ref:`route-map` s to match routes
448 received from other FRR components. The permit/deny facilities provided by
449 these commands can be used to filter which routes zebra will install in the
450 kernel.
451
452 .. index:: ip protocol PROTOCOL route-map ROUTEMAP
453 .. clicmd:: ip protocol PROTOCOL route-map ROUTEMAP
454
455 Apply a route-map filter to routes for the specified protocol. PROTOCOL can
456 be **any** or one of
457
458 - system,
459 - kernel,
460 - connected,
461 - static,
462 - rip,
463 - ripng,
464 - ospf,
465 - ospf6,
466 - isis,
467 - bgp,
468 - hsls.
469
470 .. index:: set src ADDRESS
471 .. clicmd:: set src ADDRESS
472
473 Within a route-map, set the preferred source address for matching routes
474 when installing in the kernel.
475
476
477 The following creates a prefix-list that matches all addresses, a route-map
478 that sets the preferred source address, and applies the route-map to all
479 *rip* routes.
480
481 .. code-block:: frr
482
483 ip prefix-list ANY permit 0.0.0.0/0 le 32
484 route-map RM1 permit 10
485 match ip address prefix-list ANY
486 set src 10.0.0.1
487
488 ip protocol rip route-map RM1
489
490
491 .. _zebra-fib-push-interface:
492
493 zebra FIB push interface
494 ========================
495
496 Zebra supports a 'FIB push' interface that allows an external
497 component to learn the forwarding information computed by the FRR
498 routing suite. This is a loadable module that needs to be enabled
499 at startup as described in :ref:`loadable-module-support`.
500
501 In FRR, the Routing Information Base (RIB) resides inside
502 zebra. Routing protocols communicate their best routes to zebra, and
503 zebra computes the best route across protocols for each prefix. This
504 latter information makes up the Forwarding Information Base
505 (FIB). Zebra feeds the FIB to the kernel, which allows the IP stack in
506 the kernel to forward packets according to the routes computed by
507 FRR. The kernel FIB is updated in an OS-specific way. For example,
508 the `netlink` interface is used on Linux, and route sockets are
509 used on FreeBSD.
510
511 The FIB push interface aims to provide a cross-platform mechanism to
512 support scenarios where the router has a forwarding path that is
513 distinct from the kernel, commonly a hardware-based fast path. In
514 these cases, the FIB needs to be maintained reliably in the fast path
515 as well. We refer to the component that programs the forwarding plane
516 (directly or indirectly) as the Forwarding Plane Manager or FPM.
517
518 The FIB push interface comprises of a TCP connection between zebra and
519 the FPM. The connection is initiated by zebra -- that is, the FPM acts
520 as the TCP server.
521
522 The relevant zebra code kicks in when zebra is configured with the
523 :option:`--enable-fpm` flag. Zebra periodically attempts to connect to
524 the well-known FPM port. Once the connection is up, zebra starts
525 sending messages containing routes over the socket to the FPM. Zebra
526 sends a complete copy of the forwarding table to the FPM, including
527 routes that it may have picked up from the kernel. The existing
528 interaction of zebra with the kernel remains unchanged -- that is, the
529 kernel continues to receive FIB updates as before.
530
531 The encapsulation header for the messages exchanged with the FPM is
532 defined by the file :file:`fpm/fpm.h` in the frr tree. The routes
533 themselves are encoded in netlink or protobuf format, with netlink
534 being the default.
535
536 Protobuf is one of a number of new serialization formats wherein the
537 message schema is expressed in a purpose-built language. Code for
538 encoding/decoding to/from the wire format is generated from the
539 schema. Protobuf messages can be extended easily while maintaining
540 backward-compatibility with older code. Protobuf has the following
541 advantages over netlink:
542
543 - Code for serialization/deserialization is generated automatically. This
544 reduces the likelihood of bugs, allows third-party programs to be integrated
545 quickly, and makes it easy to add fields.
546 - The message format is not tied to an OS (Linux), and can be evolved
547 independently.
548
549 As mentioned before, zebra encodes routes sent to the FPM in netlink
550 format by default. The format can be controlled via the FPM module's
551 load-time option to zebra, which currently takes the values `netlink`
552 and `protobuf`.
553
554 The zebra FPM interface uses replace semantics. That is, if a 'route
555 add' message for a prefix is followed by another 'route add' message,
556 the information in the second message is complete by itself, and
557 replaces the information sent in the first message.
558
559 If the connection to the FPM goes down for some reason, zebra sends
560 the FPM a complete copy of the forwarding table(s) when it reconnects.
561
562 zebra Terminal Mode Commands
563 ============================
564
565 .. index:: show ip route
566 .. clicmd:: show ip route
567
568 Display current routes which zebra holds in its database.
569
570 ::
571
572 Router# show ip route
573 Codes: K - kernel route, C - connected, S - static, R - RIP,
574 B - BGP * - FIB route.
575
576 K* 0.0.0.0/0 203.181.89.241
577 S 0.0.0.0/0 203.181.89.1
578 C* 127.0.0.0/8 lo
579 C* 203.181.89.240/28 eth0
580
581
582 .. index:: show ipv6 route
583 .. clicmd:: show ipv6 route
584
585 .. index:: show interface
586 .. clicmd:: show interface
587
588 .. index:: show ip prefix-list [NAME]
589 .. clicmd:: show ip prefix-list [NAME]
590
591 .. index:: show route-map [NAME]
592 .. clicmd:: show route-map [NAME]
593
594 .. index:: show ip protocol
595 .. clicmd:: show ip protocol
596
597 .. index:: show ipforward
598 .. clicmd:: show ipforward
599
600 Display whether the host's IP forwarding function is enabled or not.
601 Almost any UNIX kernel can be configured with IP forwarding disabled.
602 If so, the box can't work as a router.
603
604 .. index:: show ipv6forward
605 .. clicmd:: show ipv6forward
606
607 Display whether the host's IP v6 forwarding is enabled or not.
608
609 .. index:: show zebra
610 .. clicmd:: show zebra
611
612 Display various statistics related to the installation and deletion
613 of routes, neighbor updates, and LSP's into the kernel.
614
615 .. index:: show zebra fpm stats
616 .. clicmd:: show zebra fpm stats
617
618 Display statistics related to the zebra code that interacts with the
619 optional Forwarding Plane Manager (FPM) component.
620
621 .. index:: clear zebra fpm stats
622 .. clicmd:: clear zebra fpm stats
623
624 Reset statistics related to the zebra code that interacts with the
625 optional Forwarding Plane Manager (FPM) component.
626