--- title: Juniper Junos General breadcrumbs: - title: Configuration - title: Network --- {% include header.md %} **TODO** Clean up, reorganize and add remaining stuff. ### Related Pages {:.no_toc} - [Juniper Hardware](/config/network/juniper-hardware/) - [Juniper Junos Switches](/config/network/juniper-junos-switches/) ## Resources - [Day One Books (Juniper)](https://www.juniper.net/documentation/jnbooks/us/en/day-one-books) - [Introduction to Junos – Part 1 (Packet Pushers)](https://packetpushers.net/introduction-to-junos-part-1/) - [Introduction to Junos – Part 2 (Packet Pushers)](https://packetpushers.net/introduction-to-junos-part-2/) ## Info ### Junos OS - Based on FreeBSD. - Used on all Juniper devices. - Juniper's next-generation OS "Junos OS evolved" (not "Junos OS") is based on Linux. ## General **TODO** Cleanup. ### Usage - Controlling the CLI: - Auto-complete: Tab or space. - Show allowed tokens/help: `?` - Pipe output: ` | ` - Regex match output: ` | match ` - Count lines (e.g. after matching): ` | count` - Watch command: ` | refresh ` (e.g. `show x | match y | refresh 5`) - Supports GNU readline (Emacs-like) keybinds (some examples below). - Jump to start or end of line: `Ctrl+A` (start) and `Ctrl+E` (end) - Cut or paste entire line: `Ctrl+U` (cut) and `Ctrl+Y` (paste) - Search command history: `Ctrl+R` + search - Copy last word from last command: `Meta+.` (typically `Alt+.`) - Long outputs (less/more): - Long output is typically showed with less and supports less keybinds (use `h` for help). - Show long output without more hold: ` | no-more` - Jump to start or end: `g` (start) or `G` (end) - Search: `/` (forwards) or `?` (backwards) - Show only matching lines (supports regex): `m` - Clear searching etc.: `c` - Help: - Show topic: `help topic ` - Show reference: `help reference ` - Show syslog symbol description: `help syslog ` - Show general information: - Show time and uptime: `show system uptime` - Show version (and haiku): `show version [and haiku]` - Show system resource usage: `show system processes brief` - Show RE info and usage: `show chassis routing-engine` - Open CLI in operational mode (from shell): `cli` - Open shell (from op mode): - Local: `start shell user root` - VC: `request session member ` - CLI settings: - Show: `show cli` - Enable timestamp for commands: `set cli timestamp` - Enter configuration mode (from op mode): `configure {|exclusive|private}` - By default, a shared config mode session is used where multiple users may edit the same candidate config. Be careful when committing in this mode to avoid accidentally applying changes from the other users. - Specify `exclusive` to avoid having other users make changes in config mode at the same time. - Specify `private` to start a separate/private config mode session, independent of other users. This is weird and rarely used. - **TODO** Certain restrictions of committing for exclusive mode. - Exit any mode: `exit` - Show configuration: - (Note) You can only see config elements and changes you have permissions to see. Chekc the `system login` section to check. - From (op mode): `show configuration [statement]` - From (conf mode): `show [statement]` - Show changes (conf mode): `show | compare` - Show as set-statements (op mode): `show configuration | display set` - Hide secret data: `show configuration | except SECRET-DATA` - Show commit log: `show system commit` - Show older config: `show system rollback ` (1 is the last etc.) - Compare active with older version: `show configuration | compare rollback ` - Compare two older versions: `show system rollback compare ` - Show details and defaults: `show configuration | display detail` (add `| except "##$"` to omit empty comment lines) - Show with inherited properties from apply groups: `show | display inheritance` - Config files: - Revisions: The most recent are stored in `/config/`, the rest (up to some count) are stored in `/var/db/config/`. - Configs are gzip-compressed. - The active configuration is `/config/juniper.conf.gz`. - Run op command in config mode: `run ` - Navigate config mode: - The config is structures as nested container statements and leaf statements. - Change context to container statement: `edit ` - Go up in context: `up` or `top` - Show configuration for current level: `show` - Perform operation on multiple interfaces or similar: `wildcard range set int ge-0/0/[0-47] unit 0 family ethernet-switching` (example) - Rename a config element: `rename to ` - Move config element to before another element: `insert before ` - Copy config element: `copy to ` - Delete config element: `delete ` - Search and replace (global): `replace pattern with ` - Add comment to element: `annotate ""` - Deactivate element (instead of deleting it): `deactivate ` - Use `activate <...>` to undo. - Prevent changes to element: `protect ` - Use `unprotect` to undo. - User privileges may be set such that certain users are not allowed to unprotect, as a sort of access control to certain config sections. - Hide section for `show configuration`: Set `apply-flags omit` inside the section - Use `show configuration | display omit` to override and show omitted sections too. - Commit config changes: - Commit candidate to active: `commit [comment ] [confirmed ] [synchronize]` - `confirmed` automatically rolls back the commit if it is not confirmed within a time limit. Run `commit check` (or `commit` to also create a new commit) to confirm changes and prevent rollback. - `and-quit` will quit configuration mode after a successful commit. - `synchronize` will apply the change to all REs. It can be configured as the default. - Check without committing: `commit check` - Use `at