]> git.proxmox.com Git - mirror_frr.git/blame - doc/user/zebra.rst
zebra: PBR dpdk programming
[mirror_frr.git] / doc / user / zebra.rst
CommitLineData
0efdf0fe 1.. _zebra:
42fc5d26
QY
2
3*****
4Zebra
5*****
6
d1a242fd 7*zebra* is an IP routing manager. It provides kernel routing
42fc5d26
QY
8table updates, interface lookups, and redistribution of routes between
9different routing protocols.
10
0efdf0fe 11.. _invoking-zebra:
42fc5d26
QY
12
13Invoking zebra
14==============
15
0efdf0fe 16Besides the common invocation options (:ref:`common-invocation-options`), the
42fc5d26
QY
17*zebra* specific invocation options are listed below.
18
d1a242fd 19.. program:: zebra
42fc5d26 20
c9365894 21.. option:: -b, --batch
42fc5d26 22
d1a242fd
QY
23 Runs in batch mode. *zebra* parses configuration file and terminates
24 immediately.
42fc5d26 25
d4644d41
DS
26.. option:: -K TIME, --graceful_restart TIME
27
28 If this option is specified, the graceful restart time is TIME seconds.
29 Zebra, when started, will read in routes. Those routes that Zebra
30 identifies that it was the originator of will be swept in TIME seconds.
31 If no time is specified then we will sweep those routes immediately.
bdbdd2a7 32 Under the \*BSD's, there is no way to properly store the originating
fd149fe6
DS
33 route and the route types in this case will show up as a static route
34 with an admin distance of 255.
d4644d41 35
c9365894 36.. option:: -r, --retain
42fc5d26 37
da7e1a92
QY
38 When program terminates, do not flush routes installed by *zebra* from the
39 kernel.
42fc5d26 40
0d8df934
DS
41.. option:: -e X, --ecmp X
42
43 Run zebra with a limited ecmp ability compared to what it is compiled to.
44 If you are running zebra on hardware limited functionality you can
45 force zebra to limit the maximum ecmp allowed to X. This number
46 is bounded by what you compiled FRR with as the maximum number.
47
204ed384
PG
48.. option:: -n, --vrfwnetns
49
50 When *Zebra* starts with this option, the VRF backend is based on Linux
51 network namespaces. That implies that all network namespaces discovered by
52 ZEBRA will create an associated VRF. The other daemons will operate on the VRF
80ca5b6d 53 VRF defined by *Zebra*, as usual.
204ed384 54
f90115c5 55 .. seealso:: :ref:`zebra-vrf`
013f9762 56
6ed85950
DS
57.. option:: -z <path_to_socket>, --socket <path_to_socket>
58
59 If this option is supplied on the cli, the path to the zebra
60 control socket(zapi), is used. This option overrides a -N <namespace>
61 option if handed to it on the cli.
62
4354d381
DS
63.. option:: --v6-rr-semantics
64
65 The linux kernel is receiving the ability to use the same route
66 replacement semantics for v6 that v4 uses. If you are using a
67 kernel that supports this functionality then run *Zebra* with this
68 option and we will use Route Replace Semantics instead of delete
69 than add.
70
e4876266
DS
71.. option:: --asic-offload [notify_on_offload|notify_on_ack]
72
73 The linux kernel has the ability to use asic-offload ( see switchdev
74 development ). When the operator knows that FRR will be working in
75 this way, allow them to specify this with FRR. At this point this
76 code only supports asynchronous notification of the offload state.
77 In other words the initial ACK received for linux kernel installation
78 does not give zebra any data about what the state of the offload
79 is. This option takes the optional paramegers notify_on_offload
80 or notify_on_ack. This signals to zebra to notify upper level
81 protocols about route installation/update on ack received from
82 the linux kernel or from offload notification.
83
4dca0c10
DS
84.. option:: -s <SIZE>, --nl-bufsize <SIZE>
85
86 Allow zebra to modify the default receive buffer size to SIZE
2f5997dc 87 in bytes. Under \*BSD only the -s option is available.
4dca0c10 88
0efdf0fe 89.. _interface-commands:
42fc5d26 90
4d25da4f
PG
91Configuration Addresses behaviour
92=================================
93
94At startup, *Zebra* will first discover the underlying networking objects
95from the operating system. This includes interfaces, addresses of
96interfaces, static routes, etc. Then, it will read the configuration
97file, including its own interface addresses, static routes, etc. All this
98information comprises the operational context from *Zebra*. But
99configuration context from *Zebra* will remain the same as the one from
100:file:`zebra.conf` config file. As an example, executing the following
101:clicmd:`show running-config` will reflect what was in :file:`zebra.conf`.
102In a similar way, networking objects that are configured outside of the
103*Zebra* like *iproute2* will not impact the configuration context from
104*Zebra*. This behaviour permits you to continue saving your own config
105file, and decide what is really to be pushed on the config file, and what
106is dependent on the underlying system.
107Note that inversely, from *Zebra*, you will not be able to delete networking
108objects that were previously configured outside of *Zebra*.
109
110
42fc5d26
QY
111Interface Commands
112==================
113
0efdf0fe 114.. _standard-commands:
42fc5d26
QY
115
116Standard Commands
117-----------------
118
d1a242fd
QY
119
120.. clicmd:: interface IFNAME
121
204ed384
PG
122
123.. clicmd:: interface IFNAME vrf VRF
124
42fc5d26 125
d1a242fd 126.. clicmd:: shutdown
42fc5d26 127
42fc5d26 128
d1a242fd 129 Up or down the current interface.
42fc5d26 130
42fc5d26 131
d1a242fd 132.. clicmd:: ip address ADDRESS/PREFIX
42fc5d26 133
d1a242fd 134.. clicmd:: ipv6 address ADDRESS/PREFIX
42fc5d26 135
42fc5d26 136
42fc5d26 137
d1a242fd 138 Set the IPv4 or IPv6 address/prefix for the interface.
42fc5d26 139
42fc5d26 140
d1a242fd 141.. clicmd:: ip address LOCAL-ADDR peer PEER-ADDR/PREFIX
42fc5d26 142
42fc5d26 143
d1e7591e
QY
144 Configure an IPv4 Point-to-Point address on the interface. (The concept of
145 PtP addressing does not exist for IPv6.)
42fc5d26 146
23c5949f
DA
147 ``local-addr`` has no subnet mask since the local side in PtP addressing is
148 always a single (/32) address. ``peer-addr/prefix`` can be an arbitrary subnet
d1a242fd
QY
149 behind the other end of the link (or even on the link in Point-to-Multipoint
150 setups), though generally /32s are used.
42fc5d26 151
42fc5d26 152
d1a242fd 153.. clicmd:: description DESCRIPTION ...
42fc5d26 154
d1a242fd 155 Set description for the interface.
42fc5d26 156
42fc5d26 157
d1a242fd 158.. clicmd:: multicast
42fc5d26 159
42fc5d26 160
23c5949f 161 Enable or disable multicast flag for the interface.
42fc5d26 162
42fc5d26 163
d1a242fd 164.. clicmd:: bandwidth (1-10000000)
d1a242fd 165
d1a242fd
QY
166
167 Set bandwidth value of the interface in kilobits/sec. This is for
168 calculating OSPF cost. This command does not affect the actual device
169 configuration.
170
d1a242fd
QY
171
172.. clicmd:: link-detect
d1a242fd 173
d1a242fd 174
23c5949f 175 Enable or disable link-detect on platforms which support this. Currently only
32d9e333
DS
176 Linux, and only where network interface drivers support reporting
177 link-state via the ``IFF_RUNNING`` flag.
4c97fd1a 178
30980e0a 179 In FRR, link-detect is on by default.
42fc5d26 180
0efdf0fe 181.. _link-parameters-commands:
42fc5d26
QY
182
183Link Parameters Commands
184------------------------
185
85400b29
MS
186.. note::
187
188 At this time, FRR offers partial support for some of the routing
189 protocol extensions that can be used with MPLS-TE. FRR does not
190 support a complete RSVP-TE solution currently.
191
d1a242fd 192.. clicmd:: link-params
42fc5d26 193
42fc5d26 194
85400b29
MS
195 Enter into the link parameters sub node. At least 'enable' must be
196 set to activate the link parameters, and consequently routing
197 information that could be used as part of Traffic Engineering on
198 this interface. MPLS-TE must be enable at the OSPF
199 (:ref:`ospf-traffic-engineering`) or ISIS
200 (:ref:`isis-traffic-engineering`) router level in complement to
e33dbe08 201 this.
42fc5d26 202
d1a242fd 203 Under link parameter statement, the following commands set the different TE values:
42fc5d26 204
e33dbe08 205.. clicmd:: enable
42fc5d26 206
d1a242fd 207 Enable link parameters for this interface.
42fc5d26 208
e33dbe08 209.. clicmd:: metric (0-4294967295)
42fc5d26 210
e33dbe08 211.. clicmd:: max-bw BANDWIDTH
42fc5d26 212
e33dbe08 213.. clicmd:: max-rsv-bw BANDWIDTH
42fc5d26 214
e33dbe08 215.. clicmd:: unrsv-bw (0-7) BANDWIDTH
42fc5d26 216
e33dbe08 217.. clicmd:: admin-grp BANDWIDTH
42fc5d26 218
d1a242fd
QY
219 These commands specifies the Traffic Engineering parameters of the interface
220 in conformity to RFC3630 (OSPF) or RFC5305 (ISIS). There are respectively
221 the TE Metric (different from the OSPF or ISIS metric), Maximum Bandwidth
222 (interface speed by default), Maximum Reservable Bandwidth, Unreserved
223 Bandwidth for each 0-7 priority and Admin Group (ISIS) or Resource
224 Class/Color (OSPF).
42fc5d26 225
c5e0101c 226 Note that BANDWIDTH is specified in IEEE floating point format and express
d1a242fd 227 in Bytes/second.
42fc5d26 228
e33dbe08 229.. clicmd:: delay (0-16777215) [min (0-16777215) | max (0-16777215)]
42fc5d26 230
e33dbe08 231.. clicmd:: delay-variation (0-16777215)
42fc5d26 232
e33dbe08 233.. clicmd:: packet-loss PERCENTAGE
42fc5d26 234
e33dbe08 235.. clicmd:: res-bw BANDWIDTH
42fc5d26 236
e33dbe08 237.. clicmd:: ava-bw BANDWIDTH
42fc5d26 238
e33dbe08 239.. clicmd:: use-bw BANDWIDTH
42fc5d26 240
d1e7591e 241 These command specifies additional Traffic Engineering parameters of the
d1a242fd
QY
242 interface in conformity to draft-ietf-ospf-te-metrics-extension-05.txt and
243 draft-ietf-isis-te-metrics-extension-03.txt. There are respectively the
244 delay, jitter, loss, available bandwidth, reservable bandwidth and utilized
245 bandwidth.
42fc5d26 246
d1a242fd
QY
247 Note that BANDWIDTH is specified in IEEE floating point format and express
248 in Bytes/second. Delays and delay variation are express in micro-second
249 (µs). Loss is specified in PERCENTAGE ranging from 0 to 50.331642% by step
250 of 0.000003.
42fc5d26 251
e33dbe08 252.. clicmd:: neighbor <A.B.C.D> as (0-65535)
42fc5d26 253
d1a242fd
QY
254 Specifies the remote ASBR IP address and Autonomous System (AS) number
255 for InterASv2 link in OSPF (RFC5392). Note that this option is not yet
256 supported for ISIS (RFC5316).
42fc5d26 257
c40e1b1c
SW
258Global Commands
259------------------------
260
261.. clicmd:: zebra protodown reason-bit (0-31)
262
263 This command is only supported for linux and a kernel > 5.1.
264 Change reason-bit frr uses for setting protodown. We default to 7, but
265 if another userspace app ever conflicts with this, you can change it here.
266 The descriptor for this bit should exist in :file:`/etc/iproute2/protodown_reasons.d/`
267 to display with :clicmd:`ip -d link show`.
268
a090c2da
IR
269Nexthop Tracking
270================
271
272Nexthop tracking doesn't resolve nexthops via the default route by default.
273Allowing this might be useful when e.g. you want to allow BGP to peer across
274the default route.
275
c9af62e3
DS
276.. clicmd:: zebra nexthop-group keep (1-3600)
277
278 Set the time that zebra will keep a created and installed nexthop group
279 before removing it from the system if the nexthop group is no longer
280 being used. The default time is 180 seconds.
281
43b8e264
QY
282.. clicmd:: ip nht resolve-via-default
283
a090c2da
IR
284 Allow IPv4 nexthop tracking to resolve via the default route. This parameter
285 is configured per-VRF, so the command is also available in the VRF subnode.
286
287.. clicmd:: ipv6 nht resolve-via-default
288
289 Allow IPv6 nexthop tracking to resolve via the default route. This parameter
290 is configured per-VRF, so the command is also available in the VRF subnode.
43b8e264 291
050d6444
DS
292.. clicmd:: show ip nht [vrf NAME] [A.B.C.D|X:X::X:X] [mrib]
293
294 Show nexthop tracking status for address resolution. If vrf is not specified
295 then display the default vrf. If ``all`` is specified show all vrf address
296 resolution output. If an ipv4 or ipv6 address is not specified then display
297 all addresses tracked, else display the requested address. The mrib keyword
298 indicates that the operator wants to see the multicast rib address resolution
299 table. An alternative form of the command is ``show ip import-check`` and this
300 form of the command is deprecated at this point in time.
301
4f822345
AK
302PBR dataplane programming
303=========================
304
305Some dataplanes require the PBR nexthop to be resolved into a SMAC, DMAC and
306outgoing interface
307
308.. clicmd:: pbr nexthop-resolve
309
310 Resolve PBR nexthop via ip neigh tracking
050d6444 311
9187f11a
DS
312Administrative Distance
313=======================
314
315Administrative distance allows FRR to make decisions about what routes
316should be installed in the rib based upon the originating protocol.
317The lowest Admin Distance is the route selected. This is purely a
318subjective decision about ordering and care has been taken to choose
ed18e04d 319the same distances that other routing suites have chosen.
9187f11a
DS
320
321+------------+-----------+
322| Protocol | Distance |
323+------------+-----------+
324| System | 0 |
325+------------+-----------+
326| Kernel | 0 |
327+------------+-----------+
328| Connect | 0 |
329+------------+-----------+
330| Static | 1 |
331+------------+-----------+
332| NHRP | 10 |
333+------------+-----------+
334| EBGP | 20 |
335+------------+-----------+
336| EIGRP | 90 |
337+------------+-----------+
338| BABEL | 100 |
339+------------+-----------+
340| OSPF | 110 |
341+------------+-----------+
342| ISIS | 115 |
343+------------+-----------+
344| OPENFABRIC | 115 |
345+------------+-----------+
346| RIP | 120 |
347+------------+-----------+
348| Table | 150 |
349+------------+-----------+
350| SHARP | 150 |
351+------------+-----------+
352| IBGP | 200 |
353+------------+-----------+
354| PBR | 200 |
355+------------+-----------+
356
357An admin distance of 255 indicates to Zebra that the route should not be
358installed into the Data Plane. Additionally routes with an admin distance
359of 255 will not be redistributed.
360
361Zebra does treat Kernel routes as special case for the purposes of Admin
362Distance. Upon learning about a route that is not originated by FRR
363we read the metric value as a uint32_t. The top byte of the value
364is interpreted as the Administrative Distance and the low three bytes
365are read in as the metric. This special case is to facilitate VRF
366default routes.
367
ba5e7ae2
DS
368Route Replace Semantics
369=======================
370
371When using the Linux Kernel as a forwarding plane, routes are installed
372with a metric of 20 to the kernel. Please note that the kernel's metric
373value bears no resemblence to FRR's RIB metric or admin distance. It
374merely is a way for the Linux Kernel to decide which route to use if it
375has multiple routes for the same prefix from multiple sources. An example
376here would be if someone else was running another routing suite besides
377FRR at the same time, the kernel must choose what route to use to forward
378on. FRR choose the value of 20 because of two reasons. FRR wanted a
ed18e04d 379value small enough to be chosen but large enough that the operator could
ba5e7ae2
DS
380allow route prioritization by the kernel when multiple routing suites are
381being run and FRR wanted to take advantage of Route Replace semantics that
382the linux kernel offers. In order for Route Replacement semantics to
383work FRR must use the same metric when issuing the replace command.
384Currently FRR only supports Route Replace semantics using the Linux
385Kernel.
386
75b8d482
IR
387.. _zebra-vrf:
388
80ca5b6d
QY
389Virtual Routing and Forwarding
390==============================
42fc5d26 391
80ca5b6d
QY
392FRR supports :abbr:`VRF (Virtual Routing and Forwarding)`. VRF is a way to
393separate networking contexts on the same machine. Those networking contexts are
394associated with separate interfaces, thus making it possible to associate one
395interface with a specific VRF.
204ed384 396
204ed384 397VRF can be used, for example, when instantiating per enterprise networking
80ca5b6d
QY
398services, without having to instantiate the physical host machine or the
399routing management daemons for each enterprise. As a result, interfaces are
400separate for each set of VRF, and routing daemons can have their own context
401for each VRF.
204ed384
PG
402
403This conceptual view introduces the *Default VRF* case. If the user does not
ac2cb9bf
IR
404configure any specific VRF, then by default, FRR uses the *Default VRF*. The
405name "default" is used to refer to this VRF in various CLI commands and YANG
406models. It is possible to change that name by passing the ``-o`` option to all
407daemons, for example, one can use ``-o vrf0`` to change the name to "vrf0".
408The easiest way to pass the same option to all daemons is to use the
409``frr_global_options`` variable in the
410:ref:`Daemons Configuration File <daemons-configuration-file>`.
80ca5b6d 411
204ed384 412Configuring VRF networking contexts can be done in various ways on FRR. The VRF
80ca5b6d 413interfaces can be configured by entering in interface configuration mode
614aa5c1 414:clicmd:`interface IFNAME vrf VRF`.
204ed384
PG
415
416A VRF backend mode is chosen when running *Zebra*.
417
418If no option is chosen, then the *Linux VRF* implementation as references in
80ca5b6d 419https://www.kernel.org/doc/Documentation/networking/vrf.txt will be mapped over
204ed384
PG
420the *Zebra* VRF. The routing table associated to that VRF is a Linux table
421identifier located in the same *Linux network namespace* where *Zebra* started.
eff8e8a2
DS
422Please note when using the *Linux VRF* routing table it is expected that a
423default Kernel route will be installed that has a metric as outlined in the
424www.kernel.org doc above. The Linux Kernel does table lookup via a combination
425of rule application of the rule table and then route lookup of the specified
426table. If no route match is found then the next applicable rule is applied
427to find the next route table to use to look for a route match. As such if
428your VRF table does not have a default blackhole route with a high metric
429VRF route lookup will leave the table specified by the VRF, which is undesirable.
204ed384 430
80ca5b6d
QY
431If the :option:`-n` option is chosen, then the *Linux network namespace* will
432be mapped over the *Zebra* VRF. That implies that *Zebra* is able to configure
433several *Linux network namespaces*. The routing table associated to that VRF
434is the whole routing tables located in that namespace. For instance, this mode
435matches OpenStack Network Namespaces. It matches also OpenFastPath. The default
436behavior remains Linux VRF which is supported by the Linux kernel community,
437see https://www.kernel.org/doc/Documentation/networking/vrf.txt.
204ed384
PG
438
439Because of that difference, there are some subtle differences when running some
440commands in relationship to VRF. Here is an extract of some of those commands:
441
204ed384
PG
442.. clicmd:: vrf VRF
443
444 This command is available on configuration mode. By default, above command
52119114 445 permits accessing the VRF configuration mode. This mode is available for
d66a93dd
PG
446 both VRFs. It is to be noted that *Zebra* does not create Linux VRF.
447 The network administrator can however decide to provision this command in
448 configuration file to provide more clarity about the intended configuration.
204ed384 449
204ed384
PG
450.. clicmd:: netns NAMESPACE
451
80ca5b6d
QY
452 This command is based on VRF configuration mode. This command is available
453 when *Zebra* is run in :option:`-n` mode. This command reflects which *Linux
454 network namespace* is to be mapped with *Zebra* VRF. It is to be noted that
455 *Zebra* creates and detects added/suppressed VRFs from the Linux environment
d66a93dd
PG
456 (in fact, those managed with iproute2). The network administrator can however
457 decide to provision this command in configuration file to provide more clarity
458 about the intended configuration.
204ed384 459
204ed384
PG
460.. clicmd:: show ip route vrf VRF
461
462 The show command permits dumping the routing table associated to the VRF. If
80ca5b6d
QY
463 *Zebra* is launched with default settings, this will be the ``TABLENO`` of
464 the VRF configured on the kernel, thanks to information provided in
465 https://www.kernel.org/doc/Documentation/networking/vrf.txt. If *Zebra* is
466 launched with :option:`-n` option, this will be the default routing table of
467 the *Linux network namespace* ``VRF``.
204ed384 468
204ed384
PG
469.. clicmd:: show ip route vrf VRF table TABLENO
470
80ca5b6d
QY
471 The show command is only available with :option:`-n` option. This command
472 will dump the routing table ``TABLENO`` of the *Linux network namespace*
473 ``VRF``.
474
5a81528c
PG
475.. clicmd:: show ip route vrf VRF tables
476
23c5949f 477 This command will dump the routing tables within the vrf scope. If ``vrf all``
5a81528c
PG
478 is executed, all routing tables will be dumped.
479
a3fd74f7
DS
480.. clicmd:: show <ip|ipv6> route summary [vrf VRF] [table TABLENO] [prefix]
481
482 This command will dump a summary output of the specified VRF and TABLENO
483 combination. If neither VRF or TABLENO is specified FRR defaults to
484 the default vrf and default table. If prefix is specified dump the
485 number of prefix routes.
486
42d4b30e
PG
487.. _zebra-table-allocation:
488
489Table Allocation
490================
491
492Some services like BGP flowspec allocate routing tables to perform policy
493routing based on netfilter criteria and IP rules. In order to avoid
494conflicts between VRF allocated routing tables and those services, Zebra
495proposes to define a chunk of routing tables to use by other services.
496
497Allocation configuration can be done like below, with the range of the
498chunk of routing tables to be used by the given service.
499
500.. clicmd:: ip table range <STARTTABLENO> <ENDTABLENO>
501
df55b448
DS
502.. _zebra-ecmp:
503
504ECMP
505====
506
507FRR supports ECMP as part of normal operations and is generally compiled
508with a limit of 64 way ECMP. This of course can be modified via configure
509options on compilation if the end operator desires to do so. Individual
510protocols each have their own way of dictating ECMP policy and their
511respective documentation should be read.
512
23c5949f 513ECMP can be inspected in zebra by doing a ``show ip route X`` command.
df55b448
DS
514
515.. code-block:: shell
516
517 eva# show ip route 4.4.4.4/32
518 Codes: K - kernel route, C - connected, S - static, R - RIP,
519 O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
520 T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
521 F - PBR, f - OpenFabric,
522 > - selected route, * - FIB route, q - queued, r - rejected, b - backup
523 t - trapped, o - offload failure
524
525 D>* 4.4.4.4/32 [150/0] via 192.168.161.1, enp39s0, weight 1, 00:00:02
526 * via 192.168.161.2, enp39s0, weight 1, 00:00:02
527 * via 192.168.161.3, enp39s0, weight 1, 00:00:02
528 * via 192.168.161.4, enp39s0, weight 1, 00:00:02
529 * via 192.168.161.5, enp39s0, weight 1, 00:00:02
530 * via 192.168.161.6, enp39s0, weight 1, 00:00:02
531 * via 192.168.161.7, enp39s0, weight 1, 00:00:02
532 * via 192.168.161.8, enp39s0, weight 1, 00:00:02
533 * via 192.168.161.9, enp39s0, weight 1, 00:00:02
534 * via 192.168.161.10, enp39s0, weight 1, 00:00:02
535 * via 192.168.161.11, enp39s0, weight 1, 00:00:02
536 * via 192.168.161.12, enp39s0, weight 1, 00:00:02
537 * via 192.168.161.13, enp39s0, weight 1, 00:00:02
538 * via 192.168.161.14, enp39s0, weight 1, 00:00:02
539 * via 192.168.161.15, enp39s0, weight 1, 00:00:02
540 * via 192.168.161.16, enp39s0, weight 1, 00:00:02
541
23c5949f 542In this example we have 16 way ecmp for the 4.4.4.4/32 route. The ``*`` character
df55b448
DS
543tells us that the route is installed in the Data Plane, or FIB.
544
545If you are using the Linux kernel as a Data Plane, this can be inspected
23c5949f 546via a ``ip route show X`` command:
df55b448
DS
547
548.. code-block:: shell
549
550 sharpd@eva ~/f/doc(ecmp_doc_change)> ip route show 4.4.4.4/32
551 4.4.4.4 nhid 185483868 proto sharp metric 20
552 nexthop via 192.168.161.1 dev enp39s0 weight 1
553 nexthop via 192.168.161.10 dev enp39s0 weight 1
554 nexthop via 192.168.161.11 dev enp39s0 weight 1
555 nexthop via 192.168.161.12 dev enp39s0 weight 1
556 nexthop via 192.168.161.13 dev enp39s0 weight 1
557 nexthop via 192.168.161.14 dev enp39s0 weight 1
558 nexthop via 192.168.161.15 dev enp39s0 weight 1
559 nexthop via 192.168.161.16 dev enp39s0 weight 1
560 nexthop via 192.168.161.2 dev enp39s0 weight 1
561 nexthop via 192.168.161.3 dev enp39s0 weight 1
562 nexthop via 192.168.161.4 dev enp39s0 weight 1
563 nexthop via 192.168.161.5 dev enp39s0 weight 1
564 nexthop via 192.168.161.6 dev enp39s0 weight 1
565 nexthop via 192.168.161.7 dev enp39s0 weight 1
566 nexthop via 192.168.161.8 dev enp39s0 weight 1
567 nexthop via 192.168.161.9 dev enp39s0 weight 1
568
569Once installed into the FIB, FRR currently has little control over what
ed18e04d 570nexthops are chosen to forward packets on. Currently the Linux kernel
23c5949f 571has a ``fib_multipath_hash_policy`` sysctl which dictates how the hashing
df55b448
DS
572algorithm is used to forward packets.
573
b03d3432
PG
574.. _zebra-mpls:
575
576MPLS Commands
577=============
578
579You can configure static mpls entries in zebra. Basically, handling MPLS
580consists of popping, swapping or pushing labels to IP packets.
581
582MPLS Acronyms
583-------------
584
585:abbr:`LSR (Labeled Switch Router)`
586 Networking devices handling labels used to forward traffic between and through
587 them.
588
589:abbr:`LER (Labeled Edge Router)`
590 A Labeled edge router is located at the edge of an MPLS network, generally
591 between an IP network and an MPLS network.
592
593MPLS Push Action
594----------------
595
596The push action is generally used for LER devices, which want to encapsulate
597all traffic for a wished destination into an MPLS label. This action is stored
598in routing entry, and can be configured like a route:
599
03750f1e 600.. clicmd:: ip route NETWORK MASK GATEWAY|INTERFACE label LABEL
b03d3432 601
56f0bea7 602 NETWORK and MASK stand for the IP prefix entry to be added as static
b03d3432
PG
603 route entry.
604 GATEWAY is the gateway IP address to reach, in order to reach the prefix.
605 INTERFACE is the interface behind which the prefix is located.
606 LABEL is the MPLS label to use to reach the prefix abovementioned.
607
608 You can check that the static entry is stored in the zebra RIB database, by
609 looking at the presence of the entry.
610
611 ::
612
613 zebra(configure)# ip route 1.1.1.1/32 10.0.1.1 label 777
614 zebra# show ip route
615 Codes: K - kernel route, C - connected, S - static, R - RIP,
616 O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
617 T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
618 F - PBR,
619 > - selected route, * - FIB route
620
621 S>* 1.1.1.1/32 [1/0] via 10.0.1.1, r2-eth0, label 777, 00:39:42
622
623MPLS Swap and Pop Action
624------------------------
625
626The swap action is generally used for LSR devices, which swap a packet with a
627label, with an other label. The Pop action is used on LER devices, at the
628termination of the MPLS traffic; this is used to remove MPLS header.
629
03750f1e 630.. clicmd:: mpls lsp INCOMING_LABEL GATEWAY OUTGOING_LABEL|explicit-null|implicit-null
b03d3432
PG
631
632 INCOMING_LABEL and OUTGOING_LABEL are MPLS labels with values ranging from 16
633 to 1048575.
634 GATEWAY is the gateway IP address where to send MPLS packet.
635 The outgoing label can either be a value or have an explicit-null label header. This
636 specific header can be read by IP devices. The incoming label can also be removed; in
637 that case the implicit-null keyword is used, and the outgoing packet emitted is an IP
638 packet without MPLS header.
639
640You can check that the MPLS actions are stored in the zebra MPLS table, by looking at the
641presence of the entry.
642
b03d3432
PG
643.. clicmd:: show mpls table
644
645::
646
647 zebra(configure)# mpls lsp 18 10.125.0.2 implicit-null
648 zebra(configure)# mpls lsp 19 10.125.0.2 20
649 zebra(configure)# mpls lsp 21 10.125.0.2 explicit-null
650 zebra# show mpls table
651 Inbound Outbound
652 Label Type Nexthop Label
653 -------- ------- --------------- --------
654 18 Static 10.125.0.2 implicit-null
655 19 Static 10.125.0.2 20
656 21 Static 10.125.0.2 IPv4 Explicit Null
657
658
4c6f9934
HS
659.. _zebra-srv6:
660
4ccd4033 661Segment-Routing IPv6
4c6f9934
HS
662====================
663
664Segment-Routing is source routing paradigm that allows
665network operator to encode network intent into the packets.
666SRv6 is an implementation of Segment-Routing
667with application of IPv6 and segment-routing-header.
668
669All routing daemon can use the Segment-Routing base
670framework implemented on zebra to use SRv6 routing mechanism.
671In that case, user must configure initial srv6 setting on
672FRR's cli or frr.conf or zebra.conf. This section shows how
673to configure SRv6 on FRR. Of course SRv6 can be used as standalone,
674and this section also helps that case.
675
4c6f9934
HS
676.. clicmd:: show segment-routing srv6 locator [json]
677
4ccd4033
HS
678 This command dump SRv6-locator configured on zebra. SRv6-locator is used
679 to route to the node before performing the SRv6-function. and that works as
680 aggregation of SRv6-function's IDs. Following console log shows two
681 SRv6-locators loc1 and loc2. All locators are identified by unique IPv6
682 prefix. User can get that information as JSON string when ``json`` key word
683 at the end of cli is presented.
4c6f9934
HS
684
685::
686
687 router# sh segment-routing srv6 locator
688 Locator:
689 Name ID Prefix Status
690 -------------------- ------- ------------------------ -------
4ccd4033
HS
691 loc1 1 2001:db8:1:1::/64 Up
692 loc2 2 2001:db8:2:2::/64 Up
693
4ccd4033
HS
694.. clicmd:: show segment-routing srv6 locator NAME detail [json]
695
696 As shown in the example, by specifying the name of the locator, you
697 can see the detailed information for each locator. Locator can be
698 represented by a single IPv6 prefix, but SRv6 is designed to share this
699 Locator among multiple Routing Protocols. For this purpose, zebra divides
700 the IPv6 prefix block that makes the Locator unique into multiple chunks,
701 and manages the ownership of each chunk.
702
703 For example, loc1 has system as its owner. For example, loc1 is owned by
704 system, which means that it is not yet proprietary to any routing protocol.
705 For example, loc2 has sharp as its owner. This means that the shaprd for
706 function development holds the owner of the chunk of this locator, and no
707 other routing protocol will use this area.
708
709::
710
711 router# show segment-routing srv6 locator loc1 detail
712 Name: loc1
713 Prefix: 2001:db8:1:1::/64
714 Chunks:
715 - prefix: 2001:db8:1:1::/64, owner: system
716
717 router# show segment-routing srv6 locator loc2 detail
718 Name: loc2
719 Prefix: 2001:db8:2:2::/64
720 Chunks:
721 - prefix: 2001:db8:2:2::/64, owner: sharp
4c6f9934 722
4c6f9934 723.. clicmd:: segment-routing
4ccd4033
HS
724
725 Move from configure mode to segment-routing node.
726
4c6f9934 727.. clicmd:: srv6
4ccd4033
HS
728
729 Move from segment-routing node to srv6 node.
730
4c6f9934
HS
731.. clicmd:: locators
732
4ccd4033
HS
733 Move from srv6 node to locator node. In this locator node, user can
734 configure detailed settings such as the actual srv6 locator.
4c6f9934 735
4c6f9934 736.. clicmd:: locator NAME
4c6f9934 737
4ccd4033
HS
738 Create a new locator. If the name of an existing locator is specified,
739 move to specified locator's configuration node to change the settings it.
4c6f9934 740
5a22d2ad 741.. clicmd:: prefix X:X::X:X/M [func-bits 32]
4c6f9934 742
4ccd4033
HS
743 Set the ipv6 prefix block of the locator. SRv6 locator is defined by
744 RFC8986. The actual routing protocol specifies the locator and allocates a
745 SID to be used by each routing protocol. This SID is included in the locator
746 as an IPv6 prefix.
747
748 Following example console log shows the typical configuration of SRv6
749 data-plane. After a new SRv6 locator, named loc1, is created, loc1's prefix
750 is configured as ``2001:db8:1:1::/64``. If user or some routing daemon
751 allocates new SID on this locator, new SID will allocated in range of this
752 prefix. For example, if some routing daemon creates new SID on locator
753 (``2001:db8:1:1::/64``), Then new SID will be ``2001:db8:1:1:7::/80``,
754 ``2001:db8:1:1:8::/80``, and so on. Each locator has default SID that is
755 SRv6 local function "End". Usually default SID is allocated as
756 ``PREFIX:1::``. (``PREFIX`` is locator's prefix) For example, if user
757 configure the locator's prefix as ``2001:db8:1:1::/64``, then default SID
758 will be ``2001:db8:1:1:1::``)
759
760 The function bits range is 16bits by default. If operator want to change
5a22d2ad 761 function bits range, they can configure with ``func-bits``
4ccd4033 762 option.
4c6f9934
HS
763
764::
765
766 router# configure terminal
767 router(config)# segment-routinig
768 router(config-sr)# srv6
769 router(config-srv6)# locators
4ccd4033
HS
770 router(config-srv6-locs)# locator loc1
771 router(config-srv6-loc)# prefix 2001:db8:1:1::/64
4c6f9934
HS
772
773 router(config-srv6-loc)# show run
774 ...
775 segment-routing
776 srv6
777 locators
4ccd4033
HS
778 locator loc1
779 prefix 2001:db8:1:1::/64
4c6f9934
HS
780 !
781 ...
782
80ca5b6d
QY
783.. _multicast-rib-commands:
784
42fc5d26
QY
785Multicast RIB Commands
786======================
787
788The Multicast RIB provides a separate table of unicast destinations which
d1a242fd 789is used for Multicast Reverse Path Forwarding decisions. It is used with
42fc5d26
QY
790a multicast source's IP address, hence contains not multicast group
791addresses but unicast addresses.
792
d1a242fd 793This table is fully separate from the default unicast table. However,
42fc5d26
QY
794RPF lookup can include the unicast table.
795
dc1046f7 796WARNING: RPF lookup results are non-responsive in this version of FRR,
42fc5d26
QY
797i.e. multicast routing does not actively react to changes in underlying
798unicast topology!
799
d1a242fd 800.. clicmd:: ip multicast rpf-lookup-mode MODE
42fc5d26 801
42fc5d26 802
d1a242fd 803 MODE sets the method used to perform RPF lookups. Supported modes:
42fc5d26 804
9eb95b3b
QY
805 urib-only
806 Performs the lookup on the Unicast RIB. The Multicast RIB is never used.
42fc5d26 807
9eb95b3b
QY
808 mrib-only
809 Performs the lookup on the Multicast RIB. The Unicast RIB is never used.
42fc5d26 810
9eb95b3b
QY
811 mrib-then-urib
812 Tries to perform the lookup on the Multicast RIB. If any route is found,
813 that route is used. Otherwise, the Unicast RIB is tried.
42fc5d26 814
9eb95b3b
QY
815 lower-distance
816 Performs a lookup on the Multicast RIB and Unicast RIB each. The result
817 with the lower administrative distance is used; if they're equal, the
818 Multicast RIB takes precedence.
42fc5d26 819
9eb95b3b
QY
820 longer-prefix
821 Performs a lookup on the Multicast RIB and Unicast RIB each. The result
822 with the longer prefix length is used; if they're equal, the
823 Multicast RIB takes precedence.
42fc5d26 824
23c5949f 825 The ``mrib-then-urib`` setting is the default behavior if nothing is
9eb95b3b
QY
826 configured. If this is the desired behavior, it should be explicitly
827 configured to make the configuration immune against possible changes in
828 what the default behavior is.
42fc5d26 829
d1a242fd 830.. warning::
1e31580f 831
d1a242fd
QY
832 Unreachable routes do not receive special treatment and do not cause
833 fallback to a second lookup.
42fc5d26 834
d1a242fd 835.. clicmd:: show ip rpf ADDR
42fc5d26 836
d1a242fd
QY
837 Performs a Multicast RPF lookup, as configured with ``ip multicast
838 rpf-lookup-mode MODE``. ADDR specifies the multicast source address to look
839 up.
42fc5d26 840
d1a242fd 841 ::
42fc5d26
QY
842
843 > show ip rpf 192.0.2.1
844 Routing entry for 192.0.2.0/24 using Unicast RIB
d1a242fd
QY
845
846 Known via "kernel", distance 0, metric 0, best
847 * 198.51.100.1, via eth0
a8c90e15 848
42fc5d26 849
d1a242fd
QY
850 Indicates that a multicast source lookup for 192.0.2.1 would use an
851 Unicast RIB entry for 192.0.2.0/24 with a gateway of 198.51.100.1.
42fc5d26 852
d1a242fd 853.. clicmd:: show ip rpf
42fc5d26 854
d1a242fd
QY
855 Prints the entire Multicast RIB. Note that this is independent of the
856 configured RPF lookup mode, the Multicast RIB may be printed yet not
857 used at all.
42fc5d26 858
d1a242fd 859.. clicmd:: ip mroute PREFIX NEXTHOP [DISTANCE]
42fc5d26 860
42fc5d26 861
d1a242fd
QY
862 Adds a static route entry to the Multicast RIB. This performs exactly as the
863 ``ip route`` command, except that it inserts the route in the Multicast RIB
864 instead of the Unicast RIB.
42fc5d26 865
0efdf0fe 866.. _zebra-route-filtering:
42fc5d26
QY
867
868zebra Route Filtering
869=====================
870
0efdf0fe 871Zebra supports :dfn:`prefix-list` s and :ref:`route-map` s to match routes
013f9762 872received from other FRR components. The permit/deny facilities provided by
d1a242fd
QY
873these commands can be used to filter which routes zebra will install in the
874kernel.
42fc5d26 875
d1a242fd 876.. clicmd:: ip protocol PROTOCOL route-map ROUTEMAP
42fc5d26 877
013f9762 878 Apply a route-map filter to routes for the specified protocol. PROTOCOL can
431dd37e 879 be:
013f9762 880
563018b9
DS
881 - any,
882 - babel,
883 - bgp,
013f9762 884 - connected,
563018b9
DS
885 - eigrp,
886 - isis,
887 - kernel,
888 - nhrp,
889 - openfabric,
013f9762
QY
890 - ospf,
891 - ospf6,
563018b9
DS
892 - rip,
893 - sharp,
894 - static,
895 - ripng,
896 - table,
897 - vnc.
898
899 If you choose any as the option that will cause all protocols that are sending
900 routes to zebra. You can specify a :dfn:`ip protocol PROTOCOL route-map ROUTEMAP`
901 on a per vrf basis, by entering this command under vrf mode for the vrf you
902 want to apply the route-map against.
d1a242fd 903
d1a242fd
QY
904.. clicmd:: set src ADDRESS
905
906 Within a route-map, set the preferred source address for matching routes
907 when installing in the kernel.
908
909
910The following creates a prefix-list that matches all addresses, a route-map
911that sets the preferred source address, and applies the route-map to all
912*rip* routes.
913
9eb95b3b 914.. code-block:: frr
42fc5d26 915
d1a242fd
QY
916 ip prefix-list ANY permit 0.0.0.0/0 le 32
917 route-map RM1 permit 10
23c5949f
DA
918 match ip address prefix-list ANY
919 set src 10.0.0.1
42fc5d26 920
d1a242fd 921 ip protocol rip route-map RM1
a8c90e15 922
1d0372dd
TB
923IPv6 example for OSPFv3.
924
925.. code-block:: frr
926
927 ipv6 prefix-list ANY seq 10 permit any
928 route-map RM6 permit 10
23c5949f
DA
929 match ipv6 address prefix-list ANY
930 set src 2001:db8:425:1000::3
1d0372dd
TB
931
932 ipv6 protocol ospf6 route-map RM6
933
934
935.. note::
936
1f74d96c
IR
937 For both IPv4 and IPv6, the IP address has to exist on some interface when
938 the route is getting installed into the system. Otherwise, kernel rejects
939 the route. To solve the problem of disappearing IPv6 addresses when the
940 interface goes down, use ``net.ipv6.conf.all.keep_addr_on_down``
941 :ref:`sysctl option <zebra-sysctl>`.
42fc5d26 942
03750f1e 943.. clicmd:: zebra route-map delay-timer (0-600)
3d34678f
DS
944
945 Set the delay before any route-maps are processed in zebra. The
946 default time for this is 5 seconds.
947
0efdf0fe 948.. _zebra-fib-push-interface:
42fc5d26
QY
949
950zebra FIB push interface
951========================
952
953Zebra supports a 'FIB push' interface that allows an external
dc1046f7 954component to learn the forwarding information computed by the FRR
d1a242fd 955routing suite. This is a loadable module that needs to be enabled
0efdf0fe 956at startup as described in :ref:`loadable-module-support`.
42fc5d26 957
dc1046f7 958In FRR, the Routing Information Base (RIB) resides inside
42fc5d26
QY
959zebra. Routing protocols communicate their best routes to zebra, and
960zebra computes the best route across protocols for each prefix. This
961latter information makes up the Forwarding Information Base
962(FIB). Zebra feeds the FIB to the kernel, which allows the IP stack in
963the kernel to forward packets according to the routes computed by
dc1046f7 964FRR. The kernel FIB is updated in an OS-specific way. For example,
23c5949f 965the ``Netlink`` interface is used on Linux, and route sockets are
42fc5d26
QY
966used on FreeBSD.
967
968The FIB push interface aims to provide a cross-platform mechanism to
969support scenarios where the router has a forwarding path that is
970distinct from the kernel, commonly a hardware-based fast path. In
971these cases, the FIB needs to be maintained reliably in the fast path
972as well. We refer to the component that programs the forwarding plane
973(directly or indirectly) as the Forwarding Plane Manager or FPM.
974
80ca5b6d
QY
975.. program:: configure
976
42fc5d26 977The relevant zebra code kicks in when zebra is configured with the
9d736133
RZ
978:option:`--enable-fpm` flag and started with the module (``-M fpm``
979or ``-M dplane_fpm_nl``).
980
981.. note::
982
983 The ``fpm`` implementation attempts to connect to ``127.0.0.1`` port ``2620``
984 by default without configurations. The ``dplane_fpm_nl`` only attempts to
985 connect to a server if configured.
986
987Zebra periodically attempts to connect to the well-known FPM port (``2620``).
988Once the connection is up, zebra starts sending messages containing routes
989over the socket to the FPM. Zebra sends a complete copy of the forwarding
990table to the FPM, including routes that it may have picked up from the kernel.
991The existing interaction of zebra with the kernel remains unchanged -- that
992is, the kernel continues to receive FIB updates as before.
993
994The default FPM message format is netlink, however it can be controlled
995with the module load-time option. The modules accept the following options:
996
997- ``fpm``: ``netlink`` and ``protobuf``.
998- ``dplane_fpm_nl``: none, it only implements netlink.
42fc5d26
QY
999
1000The zebra FPM interface uses replace semantics. That is, if a 'route
1001add' message for a prefix is followed by another 'route add' message,
1002the information in the second message is complete by itself, and
1003replaces the information sent in the first message.
1004
1005If the connection to the FPM goes down for some reason, zebra sends
1006the FPM a complete copy of the forwarding table(s) when it reconnects.
1007
9d736133
RZ
1008For more details on the implementation, please read the developer's manual FPM
1009section.
1010
1011FPM Commands
1012============
1013
1014``fpm`` implementation
1015----------------------
1016
9d736133
RZ
1017.. clicmd:: fpm connection ip A.B.C.D port (1-65535)
1018
03750f1e
QY
1019 Configure ``zebra`` to connect to a different FPM server than the default of
1020 ``127.0.0.1:2060``
9d736133 1021
9d736133
RZ
1022.. clicmd:: show zebra fpm stats
1023
1024 Shows the FPM statistics.
1025
1026 Sample output:
1027
1028 ::
1029
1030 Counter Total Last 10 secs
1031
1032 connect_calls 3 2
1033 connect_no_sock 0 0
1034 read_cb_calls 2 2
1035 write_cb_calls 2 0
1036 write_calls 1 0
1037 partial_writes 0 0
1038 max_writes_hit 0 0
1039 t_write_yields 0 0
1040 nop_deletes_skipped 6 0
1041 route_adds 5 0
1042 route_dels 0 0
1043 updates_triggered 11 0
1044 redundant_triggers 0 0
1045 dests_del_after_update 0 0
1046 t_conn_down_starts 0 0
1047 t_conn_down_dests_processed 0 0
1048 t_conn_down_yields 0 0
1049 t_conn_down_finishes 0 0
1050 t_conn_up_starts 1 0
1051 t_conn_up_dests_processed 11 0
1052 t_conn_up_yields 0 0
1053 t_conn_up_aborts 0 0
1054 t_conn_up_finishes 1 0
1055
1056
9d736133
RZ
1057.. clicmd:: clear zebra fpm stats
1058
6d8589da
RZ
1059 Reset statistics related to the zebra code that interacts with the
1060 optional Forwarding Plane Manager (FPM) component.
9d736133
RZ
1061
1062
1063``dplane_fpm_nl`` implementation
1064--------------------------------
1065
9d736133
RZ
1066.. clicmd:: fpm address <A.B.C.D|X:X::X:X> [port (1-65535)]
1067
1068 Configures the FPM server address. Once configured ``zebra`` will attempt
1069 to connect to it immediately.
1070
03750f1e
QY
1071 The ``no`` form disables FPM entirely. ``zebra`` will close any current
1072 connections and will not attempt to connect to it anymore.
9d736133 1073
5f66e9a0
RZ
1074.. clicmd:: fpm use-next-hop-groups
1075
1076 Use the new netlink messages ``RTM_NEWNEXTHOP`` / ``RTM_DELNEXTHOP`` to
1077 group repeated route next hop information.
1078
f41ddc27 1079 The ``no`` form uses the old known FPM behavior of including next hop
03750f1e 1080 information in the route (e.g. ``RTM_NEWROUTE``) messages.
5f66e9a0 1081
9d736133
RZ
1082.. clicmd:: show fpm counters [json]
1083
1084 Show the FPM statistics (plain text or JSON formatted).
1085
1086 Sample output:
1087
1088 ::
1089
1090 FPM counters
1091 ============
1092 Input bytes: 0
1093 Output bytes: 308
1094 Output buffer current size: 0
1095 Output buffer peak size: 308
1096 Connection closes: 0
1097 Connection errors: 0
1098 Data plane items processed: 0
1099 Data plane items enqueued: 0
1100 Data plane items queue peak: 0
1101 Buffer full hits: 0
1102 User FPM configurations: 1
1103 User FPM disable requests: 0
1104
1105
9d736133
RZ
1106.. clicmd:: clear fpm counters
1107
6d8589da
RZ
1108 Reset statistics related to the zebra code that interacts with the
1109 optional Forwarding Plane Manager (FPM) component.
9d736133
RZ
1110
1111
3fdcb303
MS
1112.. _zebra-dplane:
1113
1114Dataplane Commands
1115==================
1116
1117The zebra dataplane subsystem provides a framework for FIB
1118programming. Zebra uses the dataplane to program the local kernel as
1119it makes changes to objects such as IP routes, MPLS LSPs, and
1120interface IP addresses. The dataplane runs in its own pthread, in
1121order to off-load work from the main zebra pthread.
1122
1123
3fdcb303
MS
1124.. clicmd:: show zebra dplane [detailed]
1125
1126 Display statistics about the updates and events passing through the
1127 dataplane subsystem.
1128
1129
3fdcb303
MS
1130.. clicmd:: show zebra dplane providers
1131
1132 Display information about the running dataplane plugins that are
1133 providing updates to a FIB. By default, the local kernel plugin is
1134 present.
1135
1136
3fdcb303
MS
1137.. clicmd:: zebra dplane limit [NUMBER]
1138
1139 Configure the limit on the number of pending updates that are
1140 waiting to be processed by the dataplane pthread.
1141
1142
42fc5d26
QY
1143zebra Terminal Mode Commands
1144============================
1145
d1a242fd 1146.. clicmd:: show ip route
42fc5d26 1147
d1a242fd 1148 Display current routes which zebra holds in its database.
42fc5d26
QY
1149
1150::
1151
42fc5d26
QY
1152 Router# show ip route
1153 Codes: K - kernel route, C - connected, S - static, R - RIP,
d1a242fd 1154 B - BGP * - FIB route.
42fc5d26 1155
d1a242fd
QY
1156 K* 0.0.0.0/0 203.181.89.241
1157 S 0.0.0.0/0 203.181.89.1
1158 C* 127.0.0.0/8 lo
42fc5d26 1159 C* 203.181.89.240/28 eth0
a8c90e15 1160
42fc5d26 1161
d1a242fd 1162.. clicmd:: show ipv6 route
42fc5d26 1163
da3ef85b 1164.. clicmd:: show [ip|ipv6] route [PREFIX] [nexthop-group]
fbe49edb 1165
da3ef85b
SW
1166 Display detailed information about a route. If [nexthop-group] is
1167 included, it will display the nexthop group ID the route is using as well.
1168
c15dc24f
RW
1169.. clicmd:: show interface [NAME] [{vrf VRF|brief}] [json]
1170
1171.. clicmd:: show interface [NAME] [{vrf all|brief}] [json]
1172
da3ef85b
SW
1173.. clicmd:: show interface [NAME] [{vrf VRF|brief}] [nexthop-group]
1174
da3ef85b
SW
1175.. clicmd:: show interface [NAME] [{vrf all|brief}] [nexthop-group]
1176
1177 Display interface information. If no extra information is added, it will
1178 dump information on all interfaces. If [NAME] is specified, it will display
1179 detailed information about that single interface. If [nexthop-group] is
1180 specified, it will display nexthop groups pointing out that interface.
42fc5d26 1181
c15dc24f
RW
1182 If the ``json`` option is specified, output is displayed in JSON format.
1183
d1a242fd 1184.. clicmd:: show ip prefix-list [NAME]
42fc5d26 1185
d1a242fd 1186.. clicmd:: show route-map [NAME]
42fc5d26 1187
d1a242fd 1188.. clicmd:: show ip protocol
42fc5d26 1189
854cdf7c 1190.. clicmd:: show ip forward
42fc5d26 1191
d1a242fd
QY
1192 Display whether the host's IP forwarding function is enabled or not.
1193 Almost any UNIX kernel can be configured with IP forwarding disabled.
1194 If so, the box can't work as a router.
42fc5d26 1195
854cdf7c 1196.. clicmd:: show ipv6 forward
42fc5d26 1197
d1a242fd 1198 Display whether the host's IP v6 forwarding is enabled or not.
42fc5d26 1199
4f822345
AK
1200.. clicmd:: show ip neigh
1201
1202 Display the ip neighbor table
1203
1204.. clicmd:: show pbr rule
1205
1206 Display the pbr rule table with resolved nexthops
1207
d1a242fd 1208.. clicmd:: show zebra
42fc5d26 1209
d1a242fd 1210 Display various statistics related to the installation and deletion
446f6ec5
DS
1211 of routes, neighbor updates, and LSP's into the kernel. In addition
1212 show various zebra state that is useful when debugging an operator's
1213 setup.
42fc5d26 1214
46677ed2
DS
1215.. clicmd:: show zebra client [summary]
1216
1217 Display statistics about clients that are connected to zebra. This is
1218 useful for debugging and seeing how much data is being passed between
ed18e04d 1219 zebra and it's clients. If the summary form of the command is chosen
46677ed2
DS
1220 a table is displayed with shortened information.
1221
46677ed2
DS
1222.. clicmd:: show zebra router table summary
1223
1224 Display summarized data about tables created, their afi/safi/tableid
1225 and how many routes each table contains. Please note this is the
1226 total number of route nodes in the table. Which will be higher than
1227 the actual number of routes that are held.
1228
a8ad9a89 1229.. clicmd:: show nexthop-group rib [ID] [vrf NAME] [singleton [ip|ip6]] [type]
083954e9
DS
1230
1231 Display nexthop groups created by zebra. The [vrf NAME] option
1232 is only meaningful if you have started zebra with the --vrfwnetns
1233 option as that nexthop groups are per namespace in linux.
1234 If you specify singleton you would like to see the singleton
a8ad9a89
SW
1235 nexthop groups that do have an afi. [type] allows you to filter those
1236 only coming from a specific NHG type (protocol).
da3ef85b 1237
d29fd1b7 1238.. clicmd:: show <ip|ipv6> zebra route dump [<vrf> VRFNAME]
1239
1240 It dumps all the routes from RIB with detailed information including
1241 internal flags, status etc. This is defined as a hidden command.
1242
13b01f2f
JAG
1243
1244Router-id
1245=========
1246
1247Many routing protocols require a router-id to be configured. To have a
1248consistent router-id across all daemons, the following commands are available
1249to configure and display the router-id:
1250
03750f1e 1251.. clicmd:: [ip] router-id A.B.C.D
13b01f2f 1252
17d1eafa 1253 Allow entering of the router-id. This command also works under the
98a3fb0a 1254 vrf subnode, to allow router-id's per vrf.
13b01f2f 1255
03750f1e 1256.. clicmd:: [ip] router-id A.B.C.D vrf NAME
17d1eafa
DS
1257
1258 Configure the router-id of this router from the configure NODE.
1259 A show run of this command will display the router-id command
1260 under the vrf sub node. This command is deprecated and will
1261 be removed at some point in time in the future.
98a3fb0a 1262
98a3fb0a 1263.. clicmd:: show [ip] router-id [vrf NAME]
13b01f2f
JAG
1264
1265 Display the user configured router-id.
1266
98a3fb0a
SM
1267For protocols requiring an IPv6 router-id, the following commands are available:
1268
03750f1e 1269.. clicmd:: ipv6 router-id X:X::X:X
98a3fb0a
SM
1270
1271 Configure the IPv6 router-id of this router. Like its IPv4 counterpart,
1272 this command works under the vrf subnode, to allow router-id's per vrf.
1273
98a3fb0a 1274.. clicmd:: show ipv6 router-id [vrf NAME]
13b01f2f 1275
98a3fb0a 1276 Display the user configured IPv6 router-id.
8d150f52 1277
1f74d96c
IR
1278.. _zebra-sysctl:
1279
229f842b
TA
1280sysctl settings
1281===============
cbacd05b
DS
1282
1283The linux kernel has a variety of sysctl's that affect it's operation as a router. This
1284section is meant to act as a starting point for those sysctl's that must be used in
1285order to provide FRR with smooth operation as a router. This section is not meant
1286as the full documentation for sysctl's. The operator must use the sysctl documentation
229f842b
TA
1287with the linux kernel for that. The following link has helpful references to many relevant
1288sysctl values: https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt
1289
1290Expected sysctl settings
4c9cf198 1291------------------------
cbacd05b
DS
1292
1293.. option:: net.ipv4.ip_forward = 1
1294
229f842b
TA
1295 This global option allows the linux kernel to forward (route) ipv4 packets incoming from one
1296 interface to an outgoing interface. If this is set to 0, the system will not route transit
1297 ipv4 packets, i.e. packets that are not sent to/from a process running on the local system.
cbacd05b 1298
229f842b 1299.. option:: net.ipv4.conf.{all,default,<interface>}.forwarding = 1
cbacd05b 1300
229f842b
TA
1301 The linux kernel can selectively enable forwarding (routing) of ipv4 packets on a per
1302 interface basis. The forwarding check in the kernel dataplane occurs against the ingress
1303 Layer 3 interface, i.e. if the ingress L3 interface has forwarding set to 0, packets will not
1304 be routed.
cbacd05b 1305
229f842b
TA
1306.. option:: net.ipv6.conf.{all,default,<interface>}.forwarding = 1
1307
1308 This per interface option allows the linux kernel to forward (route) transit ipv6 packets
1309 i.e. incoming from one Layer 3 interface to an outgoing Layer 3 interface.
1310 The forwarding check in the kernel dataplane occurs against the ingress Layer 3 interface,
1311 i.e. if the ingress L3 interface has forwarding set to 0, packets will not be routed.
1312
1313.. option:: net.ipv6.conf.all.keep_addr_on_down = 1
cbacd05b
DS
1314
1315 When an interface is taken down, do not remove the v6 addresses associated with the interface.
1316 This option is recommended because this is the default behavior for v4 as well.
1317
229f842b 1318.. option:: net.ipv6.route.skip_notify_on_dev_down = 1
cbacd05b
DS
1319
1320 When an interface is taken down, the linux kernel will not notify, via netlink, about routes
1321 that used that interface being removed from the FIB. This option is recommended because this
1322 is the default behavior for v4 as well.
8d150f52 1323
229f842b 1324Optional sysctl settings
4c9cf198 1325------------------------
229f842b
TA
1326
1327.. option:: net.ipv4.conf.{all,default,<interface>}.bc_forwarding = 0
1328
1329 This per interface option allows the linux kernel to optionally allow Directed Broadcast
1330 (i.e. Routed Broadcast or Subnet Broadcast) packets to be routed onto the connected network
1331 segment where the subnet exists.
1332 If the local router receives a routed packet destined for a broadcast address of a connected
1333 subnet, setting bc_forwarding to 1 on the interface with the target subnet assigned to it will
1334 allow non locally-generated packets to be routed via the broadcast route.
1335 If bc_forwarding is set to 0, routed packets destined for a broadcast route will be dropped.
1336 e.g.
1337 Host1 (SIP:192.0.2.10, DIP:10.0.0.255) -> (eth0:192.0.2.1/24) Router1 (eth1:10.0.0.1/24) -> BC
1338 If net.ipv4.conf.{all,default,<interface>}.bc_forwarding=1, then Router1 will forward each
1339 packet destined to 10.0.0.255 onto the eth1 interface with a broadcast DMAC (ff:ff:ff:ff:ff:ff).
1340
1341.. option:: net.ipv4.conf.{all,default,<interface>}.arp_accept = 1
1342
1343 This per interface option allows the linux kernel to optionally skip the creation of ARP
1344 entries upon the receipt of a Gratuitous ARP (GARP) frame carrying an IP that is not already
1345 present in the ARP cache. Setting arp_accept to 0 on an interface will ensure NEW ARP entries
1346 are not created due to the arrival of a GARP frame.
1347 Note: This does not impact how the kernel reacts to GARP frames that carry a "known" IP
1348 (that is already in the ARP cache) -- an existing ARP entry will always be updated
1349 when a GARP for that IP is received.
1350
1351.. option:: net.ipv4.conf.{all,default,<interface>}.arp_ignore = 0
1352
1353 This per interface option allows the linux kernel to control what conditions must be met in
1354 order for an ARP reply to be sent in response to an ARP request targeting a local IP address.
1355 When arp_ignore is set to 0, the kernel will send ARP replies in response to any ARP Request
1356 with a Target-IP matching a local address.
1357 When arp_ignore is set to 1, the kernel will send ARP replies if the Target-IP in the ARP
1358 Request matches an IP address on the interface the Request arrived at.
1359 When arp_ignore is set to 2, the kernel will send ARP replies only if the Target-IP matches an
1360 IP address on the interface where the Request arrived AND the Sender-IP falls within the subnet
1361 assigned to the local IP/interface.
1362
1363.. option:: net.ipv4.conf.{all,default,<interface>}.arp_notify = 1
1364
1365 This per interface option allows the linux kernel to decide whether to send a Gratuitious ARP
1366 (GARP) frame when the Layer 3 interface comes UP.
1367 When arp_notify is set to 0, no GARP is sent.
1368 When arp_notify is set to 1, a GARP is sent when the interface comes UP.
1369
1370.. option:: net.ipv6.conf.{all,default,<interface>}.ndisc_notify = 1
1371
1372 This per interface option allows the linux kernel to decide whether to send an Unsolicited
1373 Neighbor Advertisement (U-NA) frame when the Layer 3 interface comes UP.
1374 When ndisc_notify is set to 0, no U-NA is sent.
1375 When ndisc_notify is set to 1, a U-NA is sent when the interface comes UP.
1376
48dbe48a
DS
1377Useful sysctl settings
1378----------------------
1379
23c5949f 1380.. option:: net.ipv6.conf.all.use_oif_addrs_only = 1
48dbe48a
DS
1381
1382 When enabled, the candidate source addresses for destinations routed via this interface are
1383 restricted to the set of addresses configured on this interface (RFC 6724 section 4). If
1384 an operator has hundreds of IP addresses per interface this solves the latency problem.
1385
8d150f52
MS
1386Debugging
1387=========
1388
1389.. clicmd:: debug zebra mpls [detailed]
1390
1391 MPLS-related events and information.
1392
1393.. clicmd:: debug zebra events
1394
1395 Zebra events
1396
1397.. clicmd:: debug zebra nht [detailed]
1398
1399 Nexthop-tracking / reachability information
1400
1401.. clicmd:: debug zebra vxlan
1402
1403 VxLAN (EVPN) events
1404
1405.. clicmd:: debug zebra pseudowires
1406
1407 Pseudowire events.
1408
1409.. clicmd:: debug zebra packet [<recv|send>] [detail]
1410
1411 ZAPI message and packet details
1412
1413.. clicmd:: debug zebra kernel
1414
1415 Kernel / OS events.
1416
1417.. clicmd:: debug zebra kernel msgdump [<recv|send>]
1418
1419 Raw OS (netlink) message details.
1420
1421.. clicmd:: debug zebra rib [detailed]
1422
1423 RIB events.
1424
1425.. clicmd:: debug zebra fpm
1426
1427 FPM (forwarding-plane manager) events.
1428
1429.. clicmd:: debug zebra dplane [detailed]
1430
1431 Dataplane / FIB events.
1432
1433.. clicmd:: debug zebra pbr
1434
1435 PBR (policy-based routing) events.
1436
1437.. clicmd:: debug zebra mlag
1438
1439 MLAG events.
1440
1441.. clicmd:: debug zebra evpn mh <es|mac|neigh|nh>
1442
1443 EVPN multi-hop events.
1444
1445.. clicmd:: debug zebra nexthop [detail]
1446
1447 Nexthop and nexthop-group events.
1448
30085ba5
DL
1449Scripting
1450=========
1451
1452.. clicmd:: zebra on-rib-process script SCRIPT
1453
1454 Set a Lua script for :ref:`on-rib-process-dplane-results` hook call.
23c5949f 1455 SCRIPT is the basename of the script, without ``.lua``.
30085ba5
DL
1456
1457Data structures
1458---------------
1459
1460.. _const-struct-zebra-dplane-ctx:
1461
1462const struct zebra_dplane_ctx
1463^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1464
1465.. code-block:: console
1466
1467 * integer zd_op
1468 * integer zd_status
1469 * integer zd_provider
1470 * integer zd_vrf_id
1471 * integer zd_table_id
1472 * integer zd_ifname
1473 * integer zd_ifindex
1474 * table rinfo (if zd_op is DPLANE_OP_ROUTE*, DPLANE_NH_*)
1475
1476 * prefix zd_dest
1477 * prefix zd_src
1478 * integer zd_afi
1479 * integer zd_safi
1480 * integer zd_type
1481 * integer zd_old_type
1482 * integer zd_tag
1483 * integer zd_old_tag
1484 * integer zd_metric
1485 * integer zd_old_metric
1486 * integer zd_instance
1487 * integer zd_old_instance
1488 * integer zd_distance
1489 * integer zd_old_distance
1490 * integer zd_mtu
1491 * integer zd_nexthop_mtu
1492 * table nhe
1493
1494 * integer id
1495 * integer old_id
1496 * integer afi
1497 * integer vrf_id
1498 * integer type
1499 * nexthop_group ng
1500 * nh_grp
1501 * integer nh_grp_count
1502
1503 * integer zd_nhg_id
1504 * nexthop_group zd_ng
1505 * nexthop_group backup_ng
1506 * nexthop_group zd_old_ng
1507 * nexthop_group old_backup_ng
1508
1509 * integer label (if zd_op is DPLANE_OP_LSP_*)
1510 * table pw (if zd_op is DPLANE_OP_PW_*)
1511
1512 * integer type
1513 * integer af
1514 * integer status
1515 * integer flags
1516 * integer local_label
1517 * integer remote_label
1518
1519 * table macinfo (if zd_op is DPLANE_OP_MAC_*)
1520
1521 * integer vid
1522 * integer br_ifindex
1523 * ethaddr mac
1524 * integer vtep_ip
1525 * integer is_sticky
1526 * integer nhg_id
1527 * integer update_flags
1528
1529 * table rule (if zd_op is DPLANE_OP_RULE_*)
1530
1531 * integer sock
1532 * integer unique
1533 * integer seq
1534 * string ifname
1535 * integer priority
1536 * integer old_priority
1537 * integer table
1538 * integer old_table
1539 * integer filter_bm
1540 * integer old_filter_bm
1541 * integer fwmark
1542 * integer old_fwmark
1543 * integer dsfield
1544 * integer old_dsfield
1545 * integer ip_proto
1546 * integer old_ip_proto
1547 * prefix src_ip
1548 * prefix old_src_ip
1549 * prefix dst_ip
1550 * prefix old_dst_ip
1551
1552 * table iptable (if zd_op is DPLANE_OP_IPTABLE_*)
1553
1554 * integer sock
1555 * integer vrf_id
1556 * integer unique
1557 * integer type
1558 * integer filter_bm
1559 * integer fwmark
1560 * integer action
1561 * integer pkt_len_min
1562 * integer pkt_len_max
1563 * integer tcp_flags
1564 * integer dscp_value
1565 * integer fragment
1566 * integer protocol
1567 * integer nb_interface
1568 * integer flow_label
1569 * integer family
1570 * string ipset_name
1571
1572 * table ipset (if zd_op is DPLANE_OP_IPSET_*)
1573 * integer sock
1574 * integer vrf_id
1575 * integer unique
1576 * integer type
1577 * integer family
1578 * string ipset_name
1579
1580 * table neigh (if zd_op is DPLANE_OP_NEIGH_*)
1581
1582 * ipaddr ip_addr
1583 * table link
1584
1585 * ethaddr mac
1586 * ipaddr ip_addr
1587
1588 * integer flags
1589 * integer state
1590 * integer update_flags
1591
1592 * table br_port (if zd_op is DPLANE_OP_BR_PORT_UPDATE)
1593
1594 * integer sph_filter_cnt
1595 * integer flags
1596 * integer backup_nhg_id
1597
1598 * table neightable (if zd_op is DPLANE_OP_NEIGH_TABLE_UPDATE)
1599
1600 * integer family
1601 * integer app_probes
1602 * integer ucast_probes
1603 * integer mcast_probes
1604
1605 * table gre (if zd_op is DPLANE_OP_GRE_SET)**
1606
1607 * integer link_ifindex
1608 * integer mtu
1609
1610
1611.. _const-struct-nh-grp:
1612
1613const struct nh_grp
1614^^^^^^^^^^^^^^^^^^^
1615
1616.. code-block:: console
1617
1618 * integer id
1619 * integer weight
1620
1621
1622.. _zebra-hook-calls:
1623
1624Zebra Hook calls
1625----------------
1626
1627.. _on-rib-process-dplane-results:
1628
1629on_rib_process_dplane_results
1630^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1631
1632Called when RIB processes dataplane events.
1633Set script location with the ``zebra on-rib-process script SCRIPT`` command.
1634
1635**Arguments**
1636
1637* :ref:`const struct zebra_dplane_ctx<const-struct-zebra-dplane-ctx>` ctx
1638
1639
1640.. code-block:: lua
1641
1642 function on_rib_process_dplane_results(ctx)
1643 log.info(ctx.rinfo.zd_dest.network)
1644 return {}