]> git.proxmox.com Git - mirror_frr.git/blob - doc/user/basic.rst
doc: reorganize into multiple toctrees
[mirror_frr.git] / doc / user / basic.rst
1 .. _basic-commands:
2
3 **************
4 Basic Commands
5 **************
6
7 There are five routing daemons in use, and there is one manager daemon.
8 These daemons may be located on separate machines from the manager
9 daemon. Each of these daemons will listen on a particular port for
10 incoming VTY connections. The routing daemons are:
11
12 - *ripd*
13 - *ripngd*
14 - *ospfd*
15 - *ospf6d*
16 - *bgpd*
17 - *zebra*
18
19 The following sections discuss commands common to all the routing
20 daemons.
21
22 .. _config-commands:
23
24 Config Commands
25 ===============
26
27 .. index:: Configuration files for running the software
28
29 .. index:: Files for running configurations
30
31 .. index:: Modifying the herd's behavior
32
33 .. index:: Getting the herd running
34
35 In a config file, you can write the debugging options, a vty's password,
36 routing daemon configurations, a log file name, and so forth. This
37 information forms the initial command set for a routing beast as it is
38 starting.
39
40 Config files are generally found in |INSTALL_PREFIX_ETC|.
41
42 Each of the daemons has its own config file. The daemon name plus ``.conf`` is
43 the default config file name. For example, zebra's default config file name is
44 :file:`zebra.conf`. You can specify a config file using the :option:`-f` or
45 :option:`--config_file` options when starting the daemon.
46
47 .. _basic-config-commands:
48
49 Basic Config Commands
50 ---------------------
51
52 .. index:: hostname HOSTNAME
53
54 .. clicmd:: hostname HOSTNAME
55
56 Set hostname of the router.
57
58 .. index::
59 single: no password PASSWORD
60 single: password PASSWORD
61
62 .. clicmd:: [no] password PASSWORD
63
64 Set password for vty interface. The ``no`` form of the command deletes the
65 password. If there is no password, a vty won't accept connections.
66
67 .. index::
68 single: no enable password PASSWORD
69 single: enable password PASSWORD
70
71 .. clicmd:: [no] enable password PASSWORD
72
73 Set enable password. The ``no`` form of the command deletes the enable
74 password.
75
76 .. index::
77 single: no log trap [LEVEL]
78 single: log trap LEVEL
79
80 .. clicmd:: [no] log trap LEVEL
81
82 These commands are deprecated and are present only for historical
83 compatibility. The log trap command sets the current logging level for all
84 enabled logging destinations, and it sets the default for all future logging
85 commands that do not specify a level. The normal default logging level is
86 debugging. The ``no`` form of the command resets the default level for future
87 logging commands to debugging, but it does not change the logging level of
88 existing logging destinations.
89
90 .. index::
91 single: no log stdout [LEVEL]
92 single: log stdout [LEVEL]
93
94 .. clicmd:: [no] log stdout LEVEL
95
96 Enable logging output to stdout. If the optional second argument specifying
97 the logging level is not present, the default logging level (typically
98 debugging, but can be changed using the deprecated ``log trap`` command) will
99 be used. The ``no`` form of the command disables logging to stdout. The
100 ``LEVEL`` argument must have one of these values: emergencies, alerts,
101 critical, errors, warnings, notifications, informational, or debugging. Note
102 that the existing code logs its most important messages with severity
103 ``errors``.
104
105 .. index::
106 single: no log file [FILENAME [LEVEL]]
107 single: log file FILENAME [LEVEL]
108
109 .. clicmd:: [no] log file [FILENAME [LEVEL]]
110
111 If you want to log into a file, please specify ``filename`` as
112 in this example: ::
113
114 log file /var/log/frr/bgpd.log informational
115
116 If the optional second argument specifying the logging level is not present,
117 the default logging level (typically debugging, but can be changed using the
118 deprecated ``log trap`` command) will be used. The ``no`` form of the command
119 disables logging to a file. *Note:* if you do not configure any file logging,
120 and a daemon crashes due to a signal or an assertion failure, it will attempt
121 to save the crash information in a file named /var/tmp/frr.<daemon
122 name>.crashlog. For security reasons, this will not happen if the file exists
123 already, so it is important to delete the file after reporting the crash
124 information.
125
126 .. index::
127 single: no log syslog [LEVEL]
128 single: log syslog [LEVEL]
129
130 .. clicmd:: [no] log syslog [LEVEL]
131
132 Enable logging output to syslog. If the optional second argument specifying
133 the logging level is not present, the default logging level (typically
134 debugging, but can be changed using the deprecated ``log trap`` command) will
135 be used. The ``no`` form of the command disables logging to syslog.
136
137 .. index::
138 single: no log monitor [LEVEL]
139 single: log monitor [LEVEL]
140
141 .. clicmd:: [no] log monitor [LEVEL]
142
143 Enable logging output to vty terminals that have enabled logging using the
144 ``terminal monitor`` command. By default, monitor logging is enabled at the
145 debugging level, but this command (or the deprecated ``log trap`` command) can
146 be used to change the monitor logging level. If the optional second argument
147 specifying the logging level is not present, the default logging level
148 (typically debugging, but can be changed using the deprecated ``log trap``
149 command) will be used. The ``no`` form of the command disables logging to
150 terminal monitors.
151
152 .. index::
153 single: no log facility [FACILITY]
154 single: log facility [FACILITY]
155
156 .. clicmd:: [no] log facility [FACILITY]
157
158 This command changes the facility used in syslog messages. The default
159 facility is ``daemon``. The ``no`` form of the command resets
160 the facility to the default ``daemon`` facility.
161
162 .. index::
163 single: no log record-priority
164 single: log record-priority
165
166 .. clicmd:: [no] log record-priority
167
168 To include the severity in all messages logged to a file, to stdout, or to
169 a terminal monitor (i.e. anything except syslog),
170 use the ``log record-priority`` global configuration command.
171 To disable this option, use the ``no`` form of the command. By default,
172 the severity level is not included in logged messages. Note: some
173 versions of syslogd (including Solaris) can be configured to include
174 the facility and level in the messages emitted.
175
176 .. index::
177 single: log timestamp precision (0-6)
178 single: [no] log timestamp precision (0-6)
179
180 .. clicmd:: [no] log timestamp precision [(0-6)]
181
182 This command sets the precision of log message timestamps to the given number
183 of digits after the decimal point. Currently, the value must be in the range
184 0 to 6 (i.e. the maximum precision is microseconds). To restore the default
185 behavior (1-second accuracy), use the ``no`` form of the command, or set the
186 precision explicitly to 0.
187
188 ::
189
190 log timestamp precision 3
191
192 In this example, the precision is set to provide timestamps with
193 millisecond accuracy.
194
195 .. index:: log commands
196
197 .. clicmd:: log commands
198
199 This command enables the logging of all commands typed by a user to
200 all enabled log destinations. The note that logging includes full
201 command lines, including passwords. Once set, command logging can only
202 be turned off by restarting the daemon.
203
204 .. index:: service password-encryption
205
206 .. clicmd:: service password-encryption
207
208 Encrypt password.
209
210 .. index:: service advanced-vty
211
212 .. clicmd:: service advanced-vty
213
214 Enable advanced mode VTY.
215
216 .. index:: service terminal-length (0-512)
217
218 .. clicmd:: service terminal-length (0-512)
219
220 Set system wide line configuration. This configuration command applies
221 to all VTY interfaces.
222
223 .. index:: line vty
224
225 .. clicmd:: line vty
226
227 Enter vty configuration mode.
228
229 .. index:: banner motd default
230
231 .. clicmd:: banner motd default
232
233 Set default motd string.
234
235 .. index:: no banner motd
236
237 .. clicmd:: no banner motd
238
239 No motd banner string will be printed.
240
241 .. index:: exec-timeout MINUTE [SECOND]
242
243 .. clicmd:: exec-timeout MINUTE [SECOND]
244
245 Set VTY connection timeout value. When only one argument is specified
246 it is used for timeout value in minutes. Optional second argument is
247 used for timeout value in seconds. Default timeout value is 10 minutes.
248 When timeout value is zero, it means no timeout.
249
250 .. index:: no exec-timeout
251
252 .. clicmd:: no exec-timeout
253
254 Do not perform timeout at all. This command is as same as *exec-timeout 0 0*.
255
256 .. index:: access-class ACCESS-LIST
257
258 .. clicmd:: access-class ACCESS-LIST
259
260 Restrict vty connections with an access list.
261
262 .. _sample-config-file:
263
264 Sample Config File
265 ------------------
266
267 Below is a sample configuration file for the zebra daemon.
268
269 .. code-block:: frr
270
271 !
272 ! Zebra configuration file
273 !
274 hostname Router
275 password zebra
276 enable password zebra
277 !
278 log stdout
279 !
280 !
281
282
283 '!' and '#' are comment characters. If the first character of the word
284 is one of the comment characters then from the rest of the line forward
285 will be ignored as a comment.
286
287 .. code-block:: frr
288
289 password zebra!password
290
291 If a comment character is not the first character of the word, it's a
292 normal character. So in the above example '!' will not be regarded as a
293 comment and the password is set to 'zebra!password'.
294
295 .. _terminal-mode-commands:
296
297 Terminal Mode Commands
298 ======================
299
300 .. index:: write terminal
301
302 .. clicmd:: write terminal
303
304 Displays the current configuration to the vty interface.
305
306 .. index:: write file
307
308 .. clicmd:: write file
309
310 Write current configuration to configuration file.
311
312 .. index:: configure terminal
313
314 .. clicmd:: configure terminal
315
316 Change to configuration mode. This command is the first step to
317 configuration.
318
319 .. index:: terminal length (0-512)
320
321 .. clicmd:: terminal length (0-512)
322
323 Set terminal display length to ``(0-512)``. If length is 0, no
324 display control is performed.
325
326 .. index:: who
327
328 .. clicmd:: who
329
330 Show a list of currently connected vty sessions.
331
332 .. index:: list
333
334 .. clicmd:: list
335
336 List all available commands.
337
338 .. index:: show version
339
340 .. clicmd:: show version
341
342 Show the current version of |PACKAGE_NAME| and its build host information.
343
344 .. index:: show logging
345
346 .. clicmd:: show logging
347
348 Shows the current configuration of the logging system. This includes
349 the status of all logging destinations.
350
351 .. index:: logmsg LEVEL MESSAGE
352
353 .. clicmd:: logmsg LEVEL MESSAGE
354
355 Send a message to all logging destinations that are enabled for messages
356 of the given severity.
357
358 .. _common-invocation-options:
359
360 Common Invocation Options
361 =========================
362
363 These options apply to all |PACKAGE_NAME| daemons.
364
365
366 .. option:: -d, --daemon
367
368 Run in daemon mode.
369
370 .. option:: -f, --config_file <file>
371
372 Set configuration file name.
373
374 .. option:: -h, --help
375
376 Display this help and exit.
377
378 .. option:: -i, --pid_file <file>
379
380 Upon startup the process identifier of the daemon is written to a file,
381 typically in :file:`/var/run`. This file can be used by the init system
382 to implement commands such as ``.../init.d/zebra status``,
383 ``.../init.d/zebra restart`` or ``.../init.d/zebra stop``.
384
385 The file name is an run-time option rather than a configure-time option
386 so that multiple routing daemons can be run simultaneously. This is
387 useful when using |PACKAGE_NAME| to implement a routing looking glass. One
388 machine can be used to collect differing routing views from differing
389 points in the network.
390
391 .. option:: -A, --vty_addr <address>
392
393 Set the VTY local address to bind to. If set, the VTY socket will only
394 be bound to this address.
395
396 .. option:: -P, --vty_port <port>
397
398 Set the VTY TCP port number. If set to 0 then the TCP VTY sockets will not
399 be opened.
400
401 .. option:: -u <user>
402
403 Set the user and group to run as.
404
405 .. option:: -v, --version
406
407 Print program version.
408
409 .. _loadable-module-support:
410
411 Loadable Module Support
412 =======================
413
414 FRR supports loading extension modules at startup. Loading, reloading or
415 unloading modules at runtime is not supported (yet). To load a module, use
416 the following command line option at daemon startup:
417
418
419 .. option:: -M, --module <module:options>
420
421 Load the specified module, optionally passing options to it. If the module
422 name contains a slash (/), it is assumed to be a full pathname to a file to
423 be loaded. If it does not contain a slash, the |INSTALL_PREFIX_MODULES|
424 directory is searched for a module of the given name; first with the daemon
425 name prepended (e.g. ``zebra_mod`` for ``mod``), then without the daemon
426 name prepended.
427
428 This option is available on all daemons, though some daemons may not have
429 any modules available to be loaded.
430
431 The SNMP Module
432 ---------------
433
434 If SNMP is enabled during compile-time and installed as part of the package,
435 the ``snmp`` module can be loaded for the *zebra*, *bgpd*, *ospfd*, *ospf6d*
436 and *ripd* daemons.
437
438 The module ignores any options passed to it. Refer to :ref:`snmp-support`
439 for information on its usage.
440
441 The FPM Module
442 --------------
443
444 If FPM is enabled during compile-time and installed as part of the package, the
445 ``fpm`` module can be loaded for the *zebra* daemon. This provides the
446 Forwarding Plane Manager ("FPM") API.
447
448 The module expects its argument to be either ``Netlink`` or ``protobuf``,
449 specifying the encapsulation to use. ``Netlink`` is the default, and
450 ``protobuf`` may not be available if the module was built without protobuf
451 support. Refer to :ref:`zebra-fib-push-interface` for more information.
452
453 .. _virtual-terminal-interfaces:
454
455 Virtual Terminal Interfaces
456 ===========================
457
458 VTY -- Virtual Terminal [aka TeletYpe] Interface is a command line
459 interface (CLI) for user interaction with the routing daemon.
460
461 .. _vty-overview:
462
463 VTY Overview
464 ------------
465
466 VTY stands for Virtual TeletYpe interface. It means you can connect to
467 the daemon via the telnet protocol.
468
469 To enable a VTY interface, you have to setup a VTY password. If there
470 is no VTY password, one cannot connect to the VTY interface at all.
471
472 ::
473
474 % telnet localhost 2601
475 Trying 127.0.0.1...
476 Connected to localhost.
477 Escape character is '^]'.
478
479 Hello, this is |PACKAGE_NAME| (version |PACKAGE_VERSION|)
480 |COPYRIGHT_STR|
481
482 User Access Verification
483
484 Password: XXXXX
485 Router> ?
486 enable . . . Turn on privileged commands
487 exit . . . Exit current mode and down to previous mode
488 help . . . Description of the interactive help system
489 list . . . Print command list
490 show . . . Show system inform
491
492 wh. . . Display who is on a vty
493 Router> enable
494 Password: XXXXX
495 Router# configure terminal
496 Router(config)# interface eth0
497 Router(config-if)# ip address 10.0.0.1/8
498 Router(config-if)# ^Z
499 Router#
500
501
502 .. _vty-modes:
503
504 VTY Modes
505 ---------
506
507 There are three basic VTY modes:
508
509 There are commands that may be restricted to specific VTY modes.
510
511 .. _vty-view-mode:
512
513 VTY View Mode
514 ^^^^^^^^^^^^^
515
516 This mode is for read-only access to the CLI. One may exit the mode by
517 leaving the system, or by entering `enable` mode.
518
519 .. _vty-enable-mode:
520
521 VTY Enable Mode
522 ^^^^^^^^^^^^^^^
523
524 This mode is for read-write access to the CLI. One may exit the mode by
525 leaving the system, or by escaping to view mode.
526
527 .. _vty-other-modes:
528
529 VTY Other Modes
530 ^^^^^^^^^^^^^^^
531
532 This page is for describing other modes.
533
534 .. _vty-cli-commands:
535
536 VTY CLI Commands
537 ----------------
538
539 Commands that you may use at the command-line are described in the following
540 three subsubsections.
541
542 .. _cli-movement-commands:
543
544 CLI Movement Commands
545 ^^^^^^^^^^^^^^^^^^^^^
546
547 These commands are used for moving the CLI cursor. The :kbd:`C` character
548 means press the Control Key.
549
550 :kbd:`C-f` / :kbd:`LEFT`
551 Move forward one character.
552
553 :kbd:`C-b` / :kbd:`RIGHT`
554 Move backward one character.
555
556 :kbd:`M-f`
557 Move forward one word.
558
559 :kbd:`M-b`
560 Move backward one word.
561
562 :kbd:`C-a`
563 Move to the beginning of the line.
564
565 :kbd:`C-e`
566 Move to the end of the line.
567
568
569 .. _cli-editing-commands:
570
571 CLI Editing Commands
572 ^^^^^^^^^^^^^^^^^^^^
573
574 These commands are used for editing text on a line. The :kbd:`C`
575 character means press the Control Key.
576
577
578 :kbd:`C-h` / :kbd:`DEL`
579 Delete the character before point.
580
581
582 :kbd:`C-d`
583 Delete the character after point.
584
585
586 :kbd:`M-d`
587 Forward kill word.
588
589
590 :kbd:`C-w`
591 Backward kill word.
592
593
594 :kbd:`C-k`
595 Kill to the end of the line.
596
597
598 :kbd:`C-u`
599 Kill line from the beginning, erasing input.
600
601
602 :kbd:`C-t`
603 Transpose character.
604
605
606 CLI Advanced Commands
607 ^^^^^^^^^^^^^^^^^^^^^
608
609 There are several additional CLI commands for command line completions,
610 insta-help, and VTY session management.
611
612
613 :kbd:`C-c`
614 Interrupt current input and moves to the next line.
615
616
617 :kbd:`C-z`
618 End current configuration session and move to top node.
619
620
621 :kbd:`C-n` / :kbd:`DOWN`
622 Move down to next line in the history buffer.
623
624
625 :kbd:`C-p` / :kbd:`UP`
626 Move up to previous line in the history buffer.
627
628
629 :kbd:`TAB`
630 Use command line completion by typing :kbd:`TAB`.
631
632
633 :kbd:`?`
634 You can use command line help by typing ``help`` at the beginning of the
635 line. Typing :kbd:`?` at any point in the line will show possible
636 completions.
637
638 .. index:: find COMMAND...
639 .. clicmd:: find COMMAND...
640
641 This commmand performs a simple substring search across all defined commands
642 in all modes. As an example, suppose you're in enable mode and can't
643 remember where the command to turn OSPF segment routing on is:
644
645 ::
646
647 frr# find segment-routing on
648 (ospf) segment-routing on
649
650 The CLI mode is displayed next to each command. In this example,
651 :clicmd:`segment-routing on` is under the `router ospf` mode.
652
653 Similarly, suppose you want a listing of all commands that contain "l2vpn":
654
655 ::
656
657 frr# find l2vpn
658 (view) show [ip] bgp l2vpn evpn [json]
659 (view) show [ip] bgp l2vpn evpn all <A.B.C.D|A.B.C.D/M> [json]
660 (view) show [ip] bgp l2vpn evpn all neighbors A.B.C.D advertised-routes [json]
661 (view) show [ip] bgp l2vpn evpn all neighbors A.B.C.D routes [json]
662 (view) show [ip] bgp l2vpn evpn all overlay
663 ...
664
665 Pipe Actions
666 ^^^^^^^^^^^^
667
668 VTY supports optional modifiers at the end of commands that perform
669 postprocessing on command output or modify the action of commands. These do not
670 show up in the :kbd:`?` or :kbd:`TAB` suggestion lists.
671
672 ``... | include REGEX``
673 Filters the output of the preceding command, including only lines which
674 match the POSIX Extended Regular Expression ``REGEX``. Do not put the regex
675 in quotes.
676
677 Examples:
678
679 ::
680
681 frr# show ip bgp sum json | include remoteAs
682 "remoteAs":0,
683 "remoteAs":455,
684 "remoteAs":99,
685
686 ::
687
688 frr# show run | include neigh.*[0-9]{2}\.0\.[2-4]\.[0-9]*
689 neighbor 10.0.2.106 remote-as 99
690 neighbor 10.0.2.107 remote-as 99
691 neighbor 10.0.2.108 remote-as 99
692 neighbor 10.0.2.109 remote-as 99
693 neighbor 10.0.2.110 remote-as 99
694 neighbor 10.0.3.111 remote-as 111
695