]> git.proxmox.com Git - mirror_frr.git/blame - doc/user/basic.rst
Merge pull request #12558 from donaldsharp/bgp_static_route_mem_leak
[mirror_frr.git] / doc / user / basic.rst
CommitLineData
0efdf0fe 1.. _basic-commands:
42fc5d26
QY
2
3**************
db910447 4Basic Commands
42fc5d26
QY
5**************
6
2da6ccc3 7The following sections discuss commands common to all the routing daemons.
42fc5d26 8
0efdf0fe 9.. _config-commands:
42fc5d26
QY
10
11Config Commands
12===============
13
42fc5d26 14
42fc5d26 15
42fc5d26 16
42fc5d26
QY
17
18In a config file, you can write the debugging options, a vty's password,
2da6ccc3
QY
19routing daemon configurations, a log file name, and so forth. This information
20forms the initial command set for a routing beast as it is starting.
42fc5d26 21
dc5564c7 22Config files are generally found in |INSTALL_PREFIX_ETC|.
42fc5d26 23
d7432def 24Config Methods
d71b9156 25--------------
d7432def
QY
26
27There are two ways of configuring FRR.
28
29Traditionally each of the daemons had its own config file. The daemon name plus
30``.conf`` was the default config file name. For example, zebra's default config
31file was :file:`zebra.conf`. This method is deprecated.
32
33Because of the amount of config files this creates, and the tendency of one
34daemon to rely on others for certain functionality, most deployments now use
35"integrated" configuration. In this setup all configuration goes into a single
36file, typically :file:`/etc/frr/frr.conf`. When starting up FRR using an init
37script or systemd, ``vtysh`` is invoked to read the config file and send the
38appropriate portions to only the daemons interested in them. Running
39configuration updates are persisted back to this single file using ``vtysh``.
40This is the recommended method. To use this method, add the following line to
41:file:`/etc/frr/vtysh.conf`:
42
43.. code-block:: frr
44
45 service integrated-vtysh-config
46
47If you installed from source or used a package, this is probably already
48present.
49
50If desired, you can specify a config file using the :option:`-f` or
51:option:`--config_file` options when starting a daemon.
52
42fc5d26 53
0efdf0fe 54.. _basic-config-commands:
42fc5d26
QY
55
56Basic Config Commands
57---------------------
58
29adcd50
QY
59.. clicmd:: hostname HOSTNAME
60
8f58056c 61 Set hostname of the router. It is only for current ``vtysh``, it will not be
62 saved to any configuration file even with ``write file``.
63
64.. clicmd:: domainname DOMAINNAME
65
66 Set domainname of the router. It is only for current ``vtysh``, it will not
67 be saved to any configuration file even with ``write file``.
42fc5d26 68
03750f1e 69.. clicmd:: password PASSWORD
29adcd50 70
322e2d5c
PM
71 Set password for vty interface. The ``no`` form of the command deletes the
72 password. If there is no password, a vty won't accept connections.
42fc5d26 73
03750f1e 74.. clicmd:: enable password PASSWORD
29adcd50 75
322e2d5c
PM
76 Set enable password. The ``no`` form of the command deletes the enable
77 password.
42fc5d26 78
9b802bf4
DL
79.. clicmd:: service cputime-stats
80
81 Collect CPU usage statistics for individual FRR event handlers and CLI
82 commands. This is enabled by default and can be disabled if the extra
83 overhead causes a noticeable slowdown on your system.
84
85 Disabling these statistics will also make the
86 :clicmd:`service cputime-warning (1-4294967295)` limit non-functional.
87
88.. clicmd:: service cputime-warning (1-4294967295)
89
90 Warn if the CPU usage of an event handler or CLI command exceeds the
91 specified limit (in milliseconds.) Such warnings are generally indicative
92 of some routine in FRR mistakenly blocking/hogging the processing loop and
93 should be reported as a FRR bug.
94
95 The default limit is 5 seconds (i.e. 5000), but this can be changed by the
96 deprecated ``--enable-time-check=...`` compile-time option.
97
98 This command has no effect if :clicmd:`service cputime-stats` is disabled.
99
100.. clicmd:: service walltime-warning (1-4294967295)
101
102 Warn if the total wallclock time spent handling an event or executing a CLI
103 command exceeds the specified limit (in milliseconds.) This includes time
104 spent waiting for I/O or other tasks executing and may produce excessive
105 warnings if the system is overloaded. (This may still be useful to
106 provide an immediate sign that FRR is not operating correctly due to
107 externally caused starvation.)
108
109 The default limit is 5 seconds as above, including the same deprecated
110 ``--enable-time-check=...`` compile-time option.
111
03750f1e 112.. clicmd:: log trap LEVEL
29adcd50
QY
113
114 These commands are deprecated and are present only for historical
115 compatibility. The log trap command sets the current logging level for all
116 enabled logging destinations, and it sets the default for all future logging
117 commands that do not specify a level. The normal default logging level is
2da6ccc3
QY
118 debugging. The ``no`` form of the command resets the default level for
119 future logging commands to debugging, but it does not change the logging
120 level of existing logging destinations.
8d209861 121
29adcd50 122
03750f1e 123.. clicmd:: log stdout LEVEL
29adcd50
QY
124
125 Enable logging output to stdout. If the optional second argument specifying
126 the logging level is not present, the default logging level (typically
2da6ccc3
QY
127 debugging) will be used. The ``no`` form of the command disables logging to
128 stdout. The ``LEVEL`` argument must have one of these values: emergencies,
129 alerts, critical, errors, warnings, notifications, informational, or
130 debugging. Note that the existing code logs its most important messages with
131 severity ``errors``.
8d209861 132
f93640b8
DL
133 .. note::
134
135 If ``systemd`` is in use and stdout is connected to systemd, FRR will
136 automatically switch to ``journald`` extended logging for this target.
137
0eb5f938
DL
138 .. warning::
139
140 FRRouting uses the ``writev()`` system call to write log messages. This
141 call is supposed to be atomic, but in reality this does not hold for
142 pipes or terminals, only regular files. This means that in rare cases,
143 concurrent log messages from distinct threads may get jumbled in
144 terminal output. Use a log file and ``tail -f`` if this rare chance is
145 inacceptable to your setup.
146
03750f1e 147.. clicmd:: log file [FILENAME [LEVEL]]
8d209861 148
29adcd50 149 If you want to log into a file, please specify ``filename`` as
2da6ccc3 150 in this example:
8d209861 151
2da6ccc3
QY
152 ::
153
154 log file /var/log/frr/bgpd.log informational
8d209861 155
29adcd50
QY
156 If the optional second argument specifying the logging level is not present,
157 the default logging level (typically debugging, but can be changed using the
158 deprecated ``log trap`` command) will be used. The ``no`` form of the command
2da6ccc3
QY
159 disables logging to a file.
160
03750f1e 161.. clicmd:: log syslog [LEVEL]
8d209861 162
29adcd50
QY
163 Enable logging output to syslog. If the optional second argument specifying
164 the logging level is not present, the default logging level (typically
165 debugging, but can be changed using the deprecated ``log trap`` command) will
166 be used. The ``no`` form of the command disables logging to syslog.
8d209861 167
f93640b8
DL
168 .. note::
169
170 This uses the system's ``syslog()`` API, which does not support message
171 batching or structured key/value data pairs. If possible, use
172 :clicmd:`log extended EXTLOGNAME` with
173 :clicmd:`destination syslog [supports-rfc5424]` instead of this.
174
175.. clicmd:: log extended EXTLOGNAME
176
177 Create an extended logging target with the specified name. The name has
178 no further meaning and is only used to identify the target. Multiple
179 targets can be created and deleted with the ``no`` form.
180
181 Refer to :ref:`ext-log-target` for further details and suboptions.
182
03750f1e 183.. clicmd:: log monitor [LEVEL]
29adcd50 184
f93640b8 185 This command is deprecated and does nothing.
8d209861 186
03750f1e 187.. clicmd:: log facility [FACILITY]
29adcd50
QY
188
189 This command changes the facility used in syslog messages. The default
2da6ccc3
QY
190 facility is ``daemon``. The ``no`` form of the command resets the facility
191 to the default ``daemon`` facility.
8d209861 192
03750f1e 193.. clicmd:: log record-priority
29adcd50
QY
194
195 To include the severity in all messages logged to a file, to stdout, or to
196 a terminal monitor (i.e. anything except syslog),
197 use the ``log record-priority`` global configuration command.
198 To disable this option, use the ``no`` form of the command. By default,
199 the severity level is not included in logged messages. Note: some
32d9e333
DS
200 versions of syslogd can be configured to include the facility and
201 level in the messages emitted.
8d209861 202
03750f1e 203.. clicmd:: log timestamp precision [(0-6)]
29adcd50 204
2da6ccc3
QY
205 This command sets the precision of log message timestamps to the given
206 number of digits after the decimal point. Currently, the value must be in
207 the range 0 to 6 (i.e. the maximum precision is microseconds). To restore
208 the default behavior (1-second accuracy), use the ``no`` form of the
209 command, or set the precision explicitly to 0.
42fc5d26 210
2da6ccc3 211 ::
42fc5d26 212
2da6ccc3 213 log timestamp precision 3
42fc5d26 214
29adcd50
QY
215 In this example, the precision is set to provide timestamps with
216 millisecond accuracy.
42fc5d26 217
03750f1e 218.. clicmd:: log commands
29adcd50 219
2da6ccc3
QY
220 This command enables the logging of all commands typed by a user to all
221 enabled log destinations. The note that logging includes full command lines,
80d02adb
DS
222 including passwords. If the daemon startup option `--command-log-always`
223 is used to start the daemon then this command is turned on by default
224 and cannot be turned off and the [no] form of the command is dissallowed.
42fc5d26 225
9c2aa919
DL
226.. clicmd:: log filtered-file [FILENAME [LEVEL]]
227
228 Configure a destination file for filtered logs with the
229 :clicmd:`log filter-text WORD` command.
230
231.. clicmd:: log filter-text WORD
c103b19f
SW
232
233 This command forces logs to be filtered on a specific string. A log message
234 will only be printed if it matches on one of the filters in the log-filter
9c2aa919
DL
235 table. The filter only applies to file logging targets configured with
236 :clicmd:`log filtered-file [FILENAME [LEVEL]]`.
c103b19f 237
018fa5f8
SW
238 .. note::
239
240 Log filters help when you need to turn on debugs that cause significant
241 load on the system (enabling certain debugs can bring FRR to a halt).
242 Log filters prevent this but you should still expect a small performance
243 hit due to filtering each of all those logs.
244
9c2aa919
DL
245 .. note::
246
247 This setting is not saved to ``frr.conf`` and not shown in
248 :clicmd:`show running-config`. It is intended for ephemeral debugging
249 purposes only.
250
251.. clicmd:: clear log filter-text
c103b19f 252
9c2aa919 253 This command clears all current filters in the log-filter table.
c103b19f 254
7c945dff
MS
255
256.. clicmd:: log immediate-mode
257
258 Use unbuffered output for log and debug messages; normally there is
259 some internal buffering.
260
de75bdc3
DL
261.. clicmd:: log unique-id
262
263 Include ``[XXXXX-XXXXX]`` log message unique identifier in the textual part
264 of log messages. This is enabled by default, but can be disabled with
265 ``no log unique-id``. Please make sure the IDs are enabled when including
266 logs for FRR bug reports.
267
268 The unique identifiers are automatically generated based on source code
269 file name, format string (before filling out) and severity. They do not
270 change "randomly", but some cleanup work may cause large chunks of ID
271 changes between releases. The IDs always start with a letter, consist of
272 letters and numbers (and a dash for readability), are case insensitive, and
273 ``I``, ``L``, ``O`` & ``U`` are excluded.
274
275 This option will not affect future logging targets which allow putting the
276 unique identifier in auxiliary metadata outside the log message text
277 content. (No such logging target exists currently, but RFC5424 syslog and
278 systemd's journald both support it.)
279
280.. clicmd:: debug unique-id XXXXX-XXXXX backtrace
281
282 Print backtraces (call stack) for specific log messages, identified by
283 their unique ID (see above.) Includes source code location and current
284 event handler being executed. On some systems you may need to install a
285 `debug symbols` package to get proper function names rather than raw code
286 pointers.
287
288 This command can be issued inside and outside configuration mode, and is
289 saved to configuration only if it was given in configuration mode.
290
291 .. warning::
292
293 Printing backtraces can significantly slow down logging calls and cause
294 log files to quickly balloon in size. Remember to disable backtraces
295 when they're no longer needed.
296
29adcd50
QY
297.. clicmd:: service password-encryption
298
299 Encrypt password.
42fc5d26 300
29adcd50 301.. clicmd:: service advanced-vty
42fc5d26 302
29adcd50 303 Enable advanced mode VTY.
42fc5d26 304
29adcd50
QY
305.. clicmd:: service terminal-length (0-512)
306
2da6ccc3
QY
307 Set system wide line configuration. This configuration command applies to
308 all VTY interfaces.
42fc5d26 309
29adcd50
QY
310.. clicmd:: line vty
311
312 Enter vty configuration mode.
42fc5d26 313
29adcd50
QY
314.. clicmd:: banner motd default
315
316 Set default motd string.
42fc5d26 317
038984fd
DA
318.. clicmd:: banner motd file FILE
319
320 Set motd string from file. The file must be in directory specified
321 under ``--sysconfdir``.
322
038984fd
DA
323.. clicmd:: banner motd line LINE
324
325 Set motd string from an input.
326
29adcd50
QY
327.. clicmd:: exec-timeout MINUTE [SECOND]
328
329 Set VTY connection timeout value. When only one argument is specified
330 it is used for timeout value in minutes. Optional second argument is
331 used for timeout value in seconds. Default timeout value is 10 minutes.
332 When timeout value is zero, it means no timeout.
42fc5d26 333
03750f1e
QY
334 Not setting this, or setting the values to 0 0, means a timeout will not be
335 enabled.
42fc5d26 336
29adcd50
QY
337.. clicmd:: access-class ACCESS-LIST
338
339 Restrict vty connections with an access list.
42fc5d26 340
a28af472
DA
341.. clicmd:: allow-reserved-ranges
342
343 Allow using IPv4 reserved (Class E) IP ranges for daemons. E.g.: setting
344 IPv4 addresses for interfaces or allowing reserved ranges in BGP next-hops.
345
346 Default: off.
2da6ccc3 347
0efdf0fe 348.. _sample-config-file:
42fc5d26
QY
349
350Sample Config File
351------------------
352
353Below is a sample configuration file for the zebra daemon.
354
9eb95b3b 355.. code-block:: frr
42fc5d26 356
9eb95b3b
QY
357 !
358 ! Zebra configuration file
359 !
a048cda5
DL
360 frr version 6.0
361 frr defaults traditional
362 !
9eb95b3b
QY
363 hostname Router
364 password zebra
365 enable password zebra
366 !
367 log stdout
368 !
369 !
42fc5d26 370
8d209861 371
2da6ccc3
QY
372``!`` and ``#`` are comment characters. If the first character of the word is
373one of the comment characters then from the rest of the line forward will be
374ignored as a comment.
42fc5d26 375
9eb95b3b 376.. code-block:: frr
42fc5d26 377
9eb95b3b 378 password zebra!password
42fc5d26 379
2da6ccc3
QY
380If a comment character is not the first character of the word, it's a normal
381character. So in the above example ``!`` will not be regarded as a comment and
382the password is set to ``zebra!password``.
42fc5d26 383
a048cda5
DL
384
385Configuration versioning, profiles and upgrade behavior
386-------------------------------------------------------
387
388All |PACKAGE_NAME| daemons share a mechanism to specify a configuration profile
389and version for loading and saving configuration. Specific configuration
390settings take different default values depending on the selected profile and
391version.
392
393While the profile can be selected by user configuration and will remain over
394upgrades, |PACKAGE_NAME| will always write configurations using its current
395version. This means that, after upgrading, a ``write file`` may write out a
396slightly different configuration than what was read in.
397
398Since the previous configuration is loaded with its version's defaults, but
399the new configuration is written with the new defaults, any default that
400changed between versions will result in an appropriate configuration entry
401being written out. **FRRouting configuration is sticky, staying consistent
402over upgrades.** Changed defaults will only affect new configuration.
403
404Note that the loaded version persists into interactive configuration
405sessions. Commands executed in an interactive configuration session are
406no different from configuration loaded at startup. This means that when,
407say, you configure a new BGP peer, the defaults used for configuration
408are the ones selected by the last ``frr version`` command.
409
410.. warning::
411
412 Saving the configuration does not bump the daemons forward to use the new
413 version for their defaults, but restarting them will, since they will then
414 apply the new ``frr version`` command that was written out. Manually
415 execute the ``frr version`` command in ``show running-config`` to avoid
416 this intermediate state.
417
418This is visible in ``show running-config``:
419
420.. code-block:: frr
421
422 Current configuration:
423 !
424 ! loaded from 6.0
425 frr version 6.1-dev
426 frr defaults traditional
427 !
428
429If you save and then restart with this configuration, the old defaults will
430no longer apply. Similarly, you could execute ``frr version 6.1-dev``, causing
431the new defaults to apply and the ``loaded from 6.0`` comment to disappear.
432
433
434Profiles
435^^^^^^^^
436
437|PACKAGE_NAME| provides configuration profiles to adapt its default settings
438to various usage scenarios. Currently, the following profiles are
439implemented:
440
441* ``traditional`` - reflects defaults adhering mostly to IETF standards or
442 common practices in wide-area internet routing.
443* ``datacenter`` - reflects a single administrative domain with intradomain
444 links using aggressive timers.
445
446Your distribution/installation may pre-set a profile through the ``-F`` command
447line option on all daemons. All daemons must be configured for the same
448profile. The value specified on the command line is only a pre-set and any
449``frr defaults`` statement in the configuration will take precedence.
450
451.. note::
452
453 The profile must be the same across all daemons. Mismatches may result
454 in undefined behavior.
455
456You can freely switch between profiles without causing any interruption or
457configuration changes. All settings remain at their previous values, and
458``show running-configuration`` output will have new output listing the previous
459default values as explicit configuration. New configuration, e.g. adding a
460BGP peer, will use the new defaults. To apply the new defaults for existing
461configuration, the previously-invisible old defaults that are now shown must
462be removed from the configuration.
463
464
465Upgrade practices for interactive configuration
466^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
467
468If you configure |PACKAGE_NAME| interactively and use the configuration
469writing functionality to make changes persistent, the following
470recommendations apply in regards to upgrades:
471
4721. Skipping major versions should generally work but is still inadvisable.
473 To avoid unneeded issue, upgrade one major version at a time and write
474 out the configuration after each update.
475
4762. After installing a new |PACKAGE_NAME| version, check the configuration
477 for differences against your old configuration. If any defaults changed
478 that affect your setup, lines may appear or disappear. If a new line
479 appears, it was previously the default (or not supported) and is now
485ac9a7 480 necessary to retain previous behavior. If a line disappears, it
a048cda5
DL
481 previously wasn't the default, but now is, so it is no longer necessary.
482
4833. Check the log files for deprecation warnings by using ``grep -i deprecat``.
484
4854. After completing each upgrade, save the configuration and either restart
486 |PACKAGE_NAME| or execute ``frr version <CURRENT>`` to ensure defaults of
487 the new version are fully applied.
488
489
490Upgrade practices for autogenerated configuration
491^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
492
493When using |PACKAGE_NAME| with generated configurations (e.g. Ansible,
494Puppet, etc.), upgrade considerations differ somewhat:
495
4961. Always write out a ``frr version`` statement in the configurations you
497 generate. This ensures that defaults are applied consistently.
498
4992. Try to not run more distinct versions of |PACKAGE_NAME| than necessary.
500 Each version may need to be checked individually. If running a mix of
501 older and newer installations, use the oldest version for the
502 ``frr version`` statement.
503
5043. When rolling out upgrades, generate a configuration as usual with the old
505 version identifier and load it. Check for any differences or deprecation
506 warnings. If there are differences in the configuration, propagate these
507 back to the configuration generator to minimize relying on actual default
508 values.
509
5104. After the last installation of an old version is removed, change the
511 configuration generation to a newer ``frr version`` as appropriate. Perform
512 the same checks as when rolling out upgrades.
513
514
0efdf0fe 515.. _terminal-mode-commands:
42fc5d26
QY
516
517Terminal Mode Commands
518======================
519
29adcd50
QY
520.. clicmd:: write terminal
521
d1a242fd 522 Displays the current configuration to the vty interface.
42fc5d26 523
29adcd50
QY
524.. clicmd:: write file
525
d1a242fd 526 Write current configuration to configuration file.
42fc5d26 527
982589a3 528.. clicmd:: configure [terminal]
29adcd50 529
d1a242fd
QY
530 Change to configuration mode. This command is the first step to
531 configuration.
42fc5d26 532
29adcd50
QY
533.. clicmd:: terminal length (0-512)
534
2da6ccc3
QY
535 Set terminal display length to ``(0-512)``. If length is 0, no display
536 control is performed.
42fc5d26 537
29adcd50
QY
538.. clicmd:: who
539
d1a242fd 540 Show a list of currently connected vty sessions.
42fc5d26 541
29adcd50
QY
542.. clicmd:: list
543
d1a242fd 544 List all available commands.
42fc5d26 545
29adcd50
QY
546.. clicmd:: show version
547
d1a242fd 548 Show the current version of |PACKAGE_NAME| and its build host information.
42fc5d26 549
29adcd50
QY
550.. clicmd:: show logging
551
2da6ccc3
QY
552 Shows the current configuration of the logging system. This includes the
553 status of all logging destinations.
42fc5d26 554
c103b19f
SW
555.. clicmd:: show log-filter
556
557 Shows the current log filters applied to each daemon.
558
aa270404 559.. clicmd:: show memory [DAEMON]
0a62b873
DL
560
561 Show information on how much memory is used for which specific things in
562 |PACKAGE_NAME|. Output may vary depending on system capabilities but will
563 generally look something like this:
564
565 ::
566
567 frr# show memory
568 System allocator statistics:
569 Total heap allocated: 1584 KiB
570 Holding block headers: 0 bytes
571 Used small blocks: 0 bytes
572 Used ordinary blocks: 1484 KiB
573 Free small blocks: 2096 bytes
574 Free ordinary blocks: 100 KiB
575 Ordinary blocks: 2
576 Small blocks: 60
577 Holding blocks: 0
578 (see system documentation for 'mallinfo' for meaning)
579 --- qmem libfrr ---
580 Buffer : 3 24 72
581 Buffer data : 1 4120 4120
582 Host config : 3 (variably sized) 72
583 Command Tokens : 3427 72 247160
584 Command Token Text : 2555 (variably sized) 83720
585 Command Token Help : 2555 (variably sized) 61720
586 Command Argument : 2 (variably sized) 48
587 Command Argument Name : 641 (variably sized) 15672
588 [...]
589 --- qmem Label Manager ---
590 --- qmem zebra ---
591 ZEBRA VRF : 1 912 920
592 Route Entry : 11 80 968
593 Static route : 1 192 200
594 RIB destination : 8 48 448
595 RIB table info : 4 16 96
596 Nexthop tracking object : 1 200 200
597 Zebra Name Space : 1 312 312
598 --- qmem Table Manager ---
599
600 To understand system allocator statistics, refer to your system's
601 :manpage:`mallinfo(3)` man page.
602
603 Below these statistics, statistics on individual memory allocation types
604 in |PACKAGE_NAME| (so-called `MTYPEs`) is printed:
605
606 * the first column of numbers is the current count of allocations made for
607 the type (the number decreases when items are freed.)
608 * the second column is the size of each item. This is only available if
609 allocations on a type are always made with the same size.
610 * the third column is the total amount of memory allocated for the
611 particular type, including padding applied by malloc. This means that
612 the number may be larger than the first column multiplied by the second.
613 Overhead incurred by malloc's bookkeeping is not included in this, and
614 the column may be missing if system support is not available.
615
616 When executing this command from ``vtysh``, each of the daemons' memory
aa270404
IR
617 usage is printed sequentially. You can specify the daemon's name to print
618 only its memory usage.
0a62b873 619
012f7ae4
SR
620.. clicmd:: show motd
621
622 Show current motd banner.
623
a65f4b5d
DS
624.. clicmd:: show history
625
626 Dump the vtysh cli history.
627
29adcd50
QY
628.. clicmd:: logmsg LEVEL MESSAGE
629
2da6ccc3
QY
630 Send a message to all logging destinations that are enabled for messages of
631 the given severity.
632
fdd40d51 633.. clicmd:: find REGEX...
8421b140 634
fdd40d51
QY
635 This command performs a regex search across all defined commands in all
636 modes. As an example, suppose you're in enable mode and can't remember where
637 the command to turn OSPF segment routing on is:
8421b140
QY
638
639 ::
640
641 frr# find segment-routing on
642 (ospf) segment-routing on
fdd40d51
QY
643 (isis) segment-routing on
644
8421b140
QY
645
646 The CLI mode is displayed next to each command. In this example,
647 :clicmd:`segment-routing on` is under the `router ospf` mode.
648
fdd40d51
QY
649 Similarly, suppose you want a listing of all commands that contain "l2vpn"
650 and "neighbor":
8421b140
QY
651
652 ::
653
fdd40d51
QY
654 frr# find l2vpn.*neighbor
655 (view) show [ip] bgp l2vpn evpn neighbors <A.B.C.D|X:X::X:X|WORD> advertised-routes [json]
656 (view) show [ip] bgp l2vpn evpn neighbors <A.B.C.D|X:X::X:X|WORD> routes [json]
657 (view) show [ip] bgp l2vpn evpn rd ASN:NN_OR_IP-ADDRESS:NN neighbors <A.B.C.D|X:X::X:X|WORD> advertised-routes [json]
658 (view) show [ip] bgp l2vpn evpn rd ASN:NN_OR_IP-ADDRESS:NN neighbors <A.B.C.D|X:X::X:X|WORD> routes [json]
8421b140
QY
659 ...
660
fdd40d51
QY
661
662 Note that when entering spaces as part of a regex specification, repeated
663 spaces will be compressed into a single space for matching purposes. This is
664 a consequence of spaces being used to delimit CLI tokens. If you need to
665 match more than one space, use the ``\s`` escape.
666
667 POSIX Extended Regular Expressions are supported.
668
669
8b1148bf
DS
670.. _common-show-commands:
671
8b1148bf
DS
672.. clicmd:: show thread cpu [r|w|t|e|x]
673
674 This command displays system run statistics for all the different event
675 types. If no options is specified all different run types are displayed
676 together. Additionally you can ask to look at (r)ead, (w)rite, (t)imer,
f75e802d
DS
677 (e)vent and e(x)ecute thread event types. If you have compiled with
678 disable-cpu-time then this command will not show up.
8b1148bf 679
8b1148bf
DS
680.. clicmd:: show thread poll
681
682 This command displays FRR's poll data. It allows a glimpse into how
683 we are setting each individual fd for the poll command at that point
684 in time.
42fc5d26 685
a698ba16
DS
686.. clicmd:: show thread timers
687
688 This command displays FRR's timer data for timers that will pop in
689 the future.
690
1c9bd416
RZ
691.. clicmd:: show yang operational-data XPATH [{format <json|xml>|translate TRANSLATOR|with-config}] DAEMON
692
693 Display the YANG operational data starting from XPATH. The default
694 format is JSON, but can be displayed in XML as well.
695
696 Normally YANG operational data are located inside containers marked
697 as `read-only`.
698
699 Optionally it is also possible to display configuration leaves in
700 addition to operational data with the option `with-config`. This
701 option enables the display of configuration leaves with their
702 currently configured value (if the leaf is optional it will only show
703 if it was created or has a default value).
704
0efdf0fe 705.. _common-invocation-options:
42fc5d26
QY
706
707Common Invocation Options
708=========================
709
be46d288 710These options apply to all |PACKAGE_NAME| daemons.
42fc5d26
QY
711
712
c9365894 713.. option:: -d, --daemon
42fc5d26 714
d1a242fd 715 Run in daemon mode.
29adcd50 716
c9365894 717.. option:: -f, --config_file <file>
42fc5d26 718
d1a242fd 719 Set configuration file name.
42fc5d26 720
d1a242fd 721.. option:: -h, --help
42fc5d26 722
d1a242fd 723 Display this help and exit.
29adcd50 724
c9365894 725.. option:: -i, --pid_file <file>
42fc5d26 726
d1a242fd
QY
727 Upon startup the process identifier of the daemon is written to a file,
728 typically in :file:`/var/run`. This file can be used by the init system
729 to implement commands such as ``.../init.d/zebra status``,
730 ``.../init.d/zebra restart`` or ``.../init.d/zebra stop``.
42fc5d26 731
2da6ccc3
QY
732 The file name is an run-time option rather than a configure-time option so
733 that multiple routing daemons can be run simultaneously. This is useful when
734 using |PACKAGE_NAME| to implement a routing looking glass. One machine can
735 be used to collect differing routing views from differing points in the
736 network.
29adcd50 737
c9365894 738.. option:: -A, --vty_addr <address>
42fc5d26 739
2da6ccc3
QY
740 Set the VTY local address to bind to. If set, the VTY socket will only be
741 bound to this address.
42fc5d26 742
c9365894 743.. option:: -P, --vty_port <port>
29adcd50 744
d1a242fd
QY
745 Set the VTY TCP port number. If set to 0 then the TCP VTY sockets will not
746 be opened.
42fc5d26 747
d1a242fd 748.. option:: -u <user>
42fc5d26 749
d1a242fd 750 Set the user and group to run as.
29adcd50 751
6ed85950
DS
752.. option:: -N <namespace>
753
754 Set the namespace that the daemon will run in. A "/<namespace>" will
755 be added to all files that use the statedir. If you have "/var/run/frr"
756 as the default statedir then it will become "/var/run/frr/<namespace>".
757
ac2cb9bf
IR
758.. option:: -o, --vrfdefaultname <name>
759
760 Set the name used for the *Default VRF* in CLI commands and YANG models.
761 This option must be the same for all running daemons. By default, the name
762 is "default".
763
764 .. seealso:: :ref:`zebra-vrf`
765
c9365894 766.. option:: -v, --version
42fc5d26 767
d1a242fd 768 Print program version.
42fc5d26 769
80d02adb
DS
770.. option:: --command-log-always
771
772 Cause the daemon to always log commands entered to the specified log file.
773 This also makes the `no log commands` command dissallowed. Enabling this
774 is suggested if you have need to track what the operator is doing on
775 this router.
776
ed74ddf4
DS
777.. option:: --log <stdout|syslog|file:/path/to/log/file>
778
779 When initializing the daemon, setup the log to go to either stdout,
780 syslog or to a file. These values will be displayed as part of
781 a show run. Additionally they can be overridden at runtime if
782 desired via the normal log commands.
783
3cf3e018
DS
784.. option:: --log-level <emergencies|alerts|critical|errors|warnings|notifications|informational|debugging>
785
786 When initializing the daemon, allow the specification of a default
787 log level at startup from one of the specified levels.
788
1c2facd1
RW
789.. option:: --tcli
790
791 Enable the transactional CLI mode.
792
1a9f340b
MS
793.. option:: --limit-fds <number>
794
795 Limit the number of file descriptors that will be used internally
796 by the FRR daemons. By default, the daemons use the system ulimit
797 value.
798
0efdf0fe 799.. _loadable-module-support:
42fc5d26
QY
800
801Loadable Module Support
802=======================
803
8d209861
QY
804FRR supports loading extension modules at startup. Loading, reloading or
805unloading modules at runtime is not supported (yet). To load a module, use
42fc5d26
QY
806the following command line option at daemon startup:
807
808
c9365894 809.. option:: -M, --module <module:options>
29adcd50 810
d1a242fd
QY
811 Load the specified module, optionally passing options to it. If the module
812 name contains a slash (/), it is assumed to be a full pathname to a file to
813 be loaded. If it does not contain a slash, the |INSTALL_PREFIX_MODULES|
814 directory is searched for a module of the given name; first with the daemon
815 name prepended (e.g. ``zebra_mod`` for ``mod``), then without the daemon
816 name prepended.
42fc5d26 817
d1a242fd
QY
818 This option is available on all daemons, though some daemons may not have
819 any modules available to be loaded.
42fc5d26 820
2da6ccc3 821
42fc5d26
QY
822The SNMP Module
823---------------
824
825If SNMP is enabled during compile-time and installed as part of the package,
2da6ccc3 826the ``snmp`` module can be loaded for the *Zebra*, *bgpd*, *ospfd*, *ospf6d*
8d209861 827and *ripd* daemons.
42fc5d26 828
2da6ccc3
QY
829The module ignores any options passed to it. Refer to :ref:`snmp-support` for
830information on its usage.
831
42fc5d26
QY
832
833The FPM Module
834--------------
835
d1a242fd
QY
836If FPM is enabled during compile-time and installed as part of the package, the
837``fpm`` module can be loaded for the *zebra* daemon. This provides the
838Forwarding Plane Manager ("FPM") API.
42fc5d26 839
d1e7591e
QY
840The module expects its argument to be either ``Netlink`` or ``protobuf``,
841specifying the encapsulation to use. ``Netlink`` is the default, and
d1a242fd 842``protobuf`` may not be available if the module was built without protobuf
0efdf0fe 843support. Refer to :ref:`zebra-fib-push-interface` for more information.
42fc5d26 844
2da6ccc3 845
0efdf0fe 846.. _virtual-terminal-interfaces:
42fc5d26
QY
847
848Virtual Terminal Interfaces
849===========================
850
851VTY -- Virtual Terminal [aka TeletYpe] Interface is a command line
852interface (CLI) for user interaction with the routing daemon.
853
2da6ccc3 854
0efdf0fe 855.. _vty-overview:
42fc5d26
QY
856
857VTY Overview
858------------
859
8d209861 860VTY stands for Virtual TeletYpe interface. It means you can connect to
42fc5d26
QY
861the daemon via the telnet protocol.
862
8d209861 863To enable a VTY interface, you have to setup a VTY password. If there
42fc5d26
QY
864is no VTY password, one cannot connect to the VTY interface at all.
865
866::
867
9eb95b3b
QY
868 % telnet localhost 2601
869 Trying 127.0.0.1...
870 Connected to localhost.
871 Escape character is '^]'.
42fc5d26 872
9eb95b3b
QY
873 Hello, this is |PACKAGE_NAME| (version |PACKAGE_VERSION|)
874 |COPYRIGHT_STR|
42fc5d26 875
9eb95b3b 876 User Access Verification
42fc5d26 877
9eb95b3b
QY
878 Password: XXXXX
879 Router> ?
880 enable . . . Turn on privileged commands
881 exit . . . Exit current mode and down to previous mode
882 help . . . Description of the interactive help system
883 list . . . Print command list
884 show . . . Show system inform
8d209861 885
9eb95b3b
QY
886 wh. . . Display who is on a vty
887 Router> enable
888 Password: XXXXX
889 Router# configure terminal
890 Router(config)# interface eth0
891 Router(config-if)# ip address 10.0.0.1/8
892 Router(config-if)# ^Z
893 Router#
42fc5d26 894
8d209861 895
0efdf0fe 896.. _vty-modes:
42fc5d26
QY
897
898VTY Modes
899---------
900
901There are three basic VTY modes:
902
903There are commands that may be restricted to specific VTY modes.
904
0efdf0fe 905.. _vty-view-mode:
42fc5d26
QY
906
907VTY View Mode
908^^^^^^^^^^^^^
909
910This mode is for read-only access to the CLI. One may exit the mode by
911leaving the system, or by entering `enable` mode.
912
0efdf0fe 913.. _vty-enable-mode:
42fc5d26
QY
914
915VTY Enable Mode
916^^^^^^^^^^^^^^^
917
918This mode is for read-write access to the CLI. One may exit the mode by
919leaving the system, or by escaping to view mode.
920
0efdf0fe 921.. _vty-other-modes:
42fc5d26
QY
922
923VTY Other Modes
924^^^^^^^^^^^^^^^
925
926This page is for describing other modes.
927
0efdf0fe 928.. _vty-cli-commands:
42fc5d26
QY
929
930VTY CLI Commands
931----------------
932
933Commands that you may use at the command-line are described in the following
934three subsubsections.
935
0efdf0fe 936.. _cli-movement-commands:
42fc5d26
QY
937
938CLI Movement Commands
939^^^^^^^^^^^^^^^^^^^^^
940
941These commands are used for moving the CLI cursor. The :kbd:`C` character
942means press the Control Key.
943
8d209861 944:kbd:`C-f` / :kbd:`LEFT`
9eb95b3b 945 Move forward one character.
42fc5d26 946
8d209861 947:kbd:`C-b` / :kbd:`RIGHT`
9eb95b3b 948 Move backward one character.
42fc5d26 949
8d209861 950:kbd:`M-f`
9eb95b3b 951 Move forward one word.
42fc5d26 952
8d209861 953:kbd:`M-b`
9eb95b3b 954 Move backward one word.
42fc5d26 955
8d209861 956:kbd:`C-a`
9eb95b3b 957 Move to the beginning of the line.
42fc5d26 958
8d209861 959:kbd:`C-e`
9eb95b3b 960 Move to the end of the line.
42fc5d26
QY
961
962
0efdf0fe 963.. _cli-editing-commands:
42fc5d26
QY
964
965CLI Editing Commands
966^^^^^^^^^^^^^^^^^^^^
967
968These commands are used for editing text on a line. The :kbd:`C`
969character means press the Control Key.
970
971
8d209861 972:kbd:`C-h` / :kbd:`DEL`
9eb95b3b 973 Delete the character before point.
42fc5d26
QY
974
975
8d209861 976:kbd:`C-d`
9eb95b3b 977 Delete the character after point.
42fc5d26
QY
978
979
8d209861 980:kbd:`M-d`
9eb95b3b 981 Forward kill word.
42fc5d26
QY
982
983
8d209861 984:kbd:`C-w`
9eb95b3b 985 Backward kill word.
42fc5d26
QY
986
987
8d209861 988:kbd:`C-k`
9eb95b3b 989 Kill to the end of the line.
42fc5d26
QY
990
991
8d209861 992:kbd:`C-u`
9eb95b3b 993 Kill line from the beginning, erasing input.
42fc5d26
QY
994
995
8d209861 996:kbd:`C-t`
9eb95b3b 997 Transpose character.
42fc5d26
QY
998
999
1000CLI Advanced Commands
1001^^^^^^^^^^^^^^^^^^^^^
1002
1003There are several additional CLI commands for command line completions,
1004insta-help, and VTY session management.
1005
1006
8d209861 1007:kbd:`C-c`
9eb95b3b 1008 Interrupt current input and moves to the next line.
42fc5d26
QY
1009
1010
8d209861 1011:kbd:`C-z`
9eb95b3b 1012 End current configuration session and move to top node.
42fc5d26
QY
1013
1014
8d209861 1015:kbd:`C-n` / :kbd:`DOWN`
9eb95b3b 1016 Move down to next line in the history buffer.
42fc5d26
QY
1017
1018
8d209861 1019:kbd:`C-p` / :kbd:`UP`
9eb95b3b 1020 Move up to previous line in the history buffer.
42fc5d26
QY
1021
1022
8d209861 1023:kbd:`TAB`
9eb95b3b 1024 Use command line completion by typing :kbd:`TAB`.
42fc5d26
QY
1025
1026
8d209861 1027:kbd:`?`
9eb95b3b
QY
1028 You can use command line help by typing ``help`` at the beginning of the
1029 line. Typing :kbd:`?` at any point in the line will show possible
1030 completions.
42fc5d26 1031
4c54343f
QY
1032Pipe Actions
1033^^^^^^^^^^^^
1034
1035VTY supports optional modifiers at the end of commands that perform
1036postprocessing on command output or modify the action of commands. These do not
1037show up in the :kbd:`?` or :kbd:`TAB` suggestion lists.
1038
1039``... | include REGEX``
1040 Filters the output of the preceding command, including only lines which
1041 match the POSIX Extended Regular Expression ``REGEX``. Do not put the regex
1042 in quotes.
1043
1044 Examples:
1045
1046 ::
1047
1048 frr# show ip bgp sum json | include remoteAs
1049 "remoteAs":0,
1050 "remoteAs":455,
1051 "remoteAs":99,
1052
1053 ::
1054
1055 frr# show run | include neigh.*[0-9]{2}\.0\.[2-4]\.[0-9]*
1056 neighbor 10.0.2.106 remote-as 99
1057 neighbor 10.0.2.107 remote-as 99
1058 neighbor 10.0.2.108 remote-as 99
1059 neighbor 10.0.2.109 remote-as 99
1060 neighbor 10.0.2.110 remote-as 99
1061 neighbor 10.0.3.111 remote-as 111
1062