Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All

    Operational-Mode Commands

    Overview of Junos OS CLI Operational Mode Commands

    This topic provides an overview of Junos OS CLI operational mode commands and contains the following sections:

    CLI Command Categories

    When you log in to a device running Junos OS and the CLI starts, there are several broad groups of CLI commands:

    • Commands for controlling the CLI environment—Some set commands in the set hierarchy configure the CLI display screen. For information about these commands, see Understanding the Junos OS CLI Modes, Commands, and Statement Hierarchies.
    • Commands for monitoring and troubleshooting—The following commands display information and statistics about the software and test network connectivity. Detailed command descriptions are provided in the Junos OS Interfaces Command Reference.
      • clear—Clear statistics and protocol database information.
      • mtrace—Trace mtrace packets from source to receiver.
      • monitor—Perform real-time debugging of various software components, including the routing protocols and interfaces.
      • ping—Determine the reachability of a remote network host.
      • show—Display the current configuration and information about interfaces, routing protocols, routing tables, routing policy filters, system alarms, and the chassis.
      • test—Test the configuration and application of policy filters and autonomous system (AS) path regular expressions.
      • traceroute—Trace the route to a remote network host.
    • Commands for connecting to other network systems—The ssh command opens Secure Shell connections, and the telnet command opens telnet sessions to other hosts on the network. For information about these commands, see the Junos OS Operational Mode Commands.
    • Commands for copying files—The copy command copies files from one location on the router or switch to another, from the router or switch to a remote system, or from a remote system to the router or switch. For information about these commands, see the Junos OS Operational Mode Commands.
    • Commands for restarting software processes—The commands in the restart hierarchy restart the various Junos OS processes, including the routing protocol, interface, and SNMP. For information about these commands, see the Junos OS Operational Mode Commands.
    • A command—request—for performing system-level operations, including stopping and rebooting the router or switch and loading Junos OS images. For information about this command, see the Junos OS Operational Mode Commands.
    • A command—start—to exit the CLI and start a UNIX shell. For information about this command, see the Junos OS Operational Mode Commands.
    • A command—configure—for entering configuration mode, which provides a series of commands that configure Junos OS, including the routing protocols, interfaces, network management, and user access. For information about the CLI configuration commands, see Understanding Junos OS CLI Configuration Mode.
    • A command—quit—to exit the CLI. For information about this command, see the Junos OS Operational Mode Commands.
    • For more information about the CLI operational mode commands, see the Junos OS Operational Mode Commands and the Junos OS Operational Mode Commands.

    Commonly Used Operational Mode Commands

    Table 1 lists some operational commands you may find useful for monitoring router or switch operation. For a complete description of operational commands, see the Junos OS command references.

    Note: The QFX3500 switch does not support the IS-IS, OSPF, BGP, MPLS, and RSVP protocols.

    Table 1: Commonly Used Operational Mode Commands

    Items to Check

    Description

    Command

    Software version

    Versions of software running on the router or switch

    show version

    Log files

    Contents of the log files

    monitor

    Log files and their contents and recent user logins

    show log

    Remote systems

    Host reachability and network connectivity

    ping

    Route to a network system

    traceroute

    Configuration

    Current system configuration

    show configuration

    Manipulate files

    List of files and directories on the router or switch

    file list

    Contents of a file

    file show

    Interface information

    Detailed information about interfaces

    show interfaces

    Chassis

    Chassis alarm status

    show chassis alarms

    Information currently on craft display

    show chassis craft-interface

    Router or switch environment information

    show chassis environment

    Hardware inventory

    show chassis hardware

    Routing table information

    Information about entries in the routing tables

    show route

    Forwarding table information

    Information about data in the kernel’s forwarding table

    show route forwarding-table

    IS-IS

    Adjacent routers or switches

    show isis adjacency

    OSPF

    Display standard information about OSPF neighbors

    show ospf neighbor

    BGP

    Display information about BGP neighbors

    show bgp neighbor

    MPLS

    Status of interfaces on which MPLS is running

    show mpls interface

    Configured LSPs on the router or switch, as well as all ingress, transit, and egress LSPs

    show mpls lsp

    Routes that form a label-switched path

    show route label-switched-path

    RSVP

    Status of interfaces on which RSVP is running

    show rsvp interface

    Currently active RSVP sessions

    show rsvp session

    RSVP packet and error counters

    show rsvp statistics

    Example: Running Operational-Mode Commands on Logical Systems

    This example shows how to set the CLI to a specified logical system view, run operational-mode commands for the logical system, and then return to the main router view.

    Requirements

    You must have the view privilege for the logical system.

    Overview

    For some operational-mode commands, you can include a logical-system option to narrow the output of the command or to limit the operation of the command to the specified logical system. For example, the show route command has a logical-system option. To run this command on a logical system called LS3, you can use show route logical-system LS3. However, some commands, such as show interfaces, do not have a logical-system option. For commands like this, you need another approach.

    You can place yourself into the context of a specific logical system. To configure a logical system context, issue the set cli logical-system logical-system-name command.

    When the CLI is in logical system context mode and you enter an operational-mode command, the output of the command displays information related to the logical system only.

    Configuration

    Step-by-Step Procedure

    The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.

    To set the CLI to a specific logical system context:

    1. From the main router, configure the logical system.

      [edit]user@host# set logical-systems LS3
    2. If you are done configuring the device, commit the configuration.

      [edit]user@host# commituser@host# exit
    3. Set the CLI to view the logical system.
      user@host> set cli logical-system LS3
      Logical system: LS3
      user@host:LS3>
    4. Run an operational-mode command.
      user@host:LS3> show interfaces terse
      Interface               Admin Link Proto    Local                 Remote
      lt-1/2/0               
      lt-1/2/0.3              up    up   inet     10.0.2.1/30     
    5. Enter configuration mode to edit the logical system configuration.
      user@host:LS3> edit
      Entering configuration mode
      user@host:LS3#
    6. Exit configuration mode to return to operational mode.
      user@host:LS3# exit
      Exiting configuration mode
    7. Clear the logical system view to return to the main router view.
      user@host:LS3> clear cli logical-system
      Cleared default logical system
      user@host>
    8. To achieve the same effect when using a Junos XML protocol client application, include the <set-logical-system> tag.
      <rpc> <set-logical-system> <logical-system>LS1</logical-system> </set-logical-system> </rpc>

    Example: Viewing BGP Trace Files on Logical Systems

    This example shows how to list and view files that are stored on a logical system.

    Requirements

    Overview

    Logical systems have their individual directory structure created in the /var/logical-systems/logical-system-name directory. It contains the following subdirectories:

    • /config—Contains the active configuration specific to the logical system.
    • /log—Contains system log and tracing files specific to the logical system.

      To maintain backward compatibility for the log files with previous versions of Junos OS, a symbolic link (symlink) from the /var/logs/logical-system-name directory to the /var/logical-systems/logical-system-name directory is created when a logical system is configured.

    • /tmp—Contains temporary files specific to the logical system.

    The file system for each logical system enables logical system users to view trace logs and modify logical system files. Logical system administrators have full access to view and modify all files specific to the logical system.

    Logical system users and administrators can save and load configuration files at the logical-system level using the save and load configuration mode commands. In addition, they can also issue the show log, monitor, and file operational mode commands at the logical-system level.

    This example shows how to configure and view a BGP trace file on a logical system. The steps can be adapted to apply to trace operations for any Junos OS hierarchy level that supports trace operations.

    Tip: To view a list of hierarchy levels that support tracing operations, enter the help apropos traceoptions command in configuration mode.

    Configuration

    CLI Quick Configuration

    To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level.

    set logical-systems A protocols bgp group internal-peers traceoptions file bgp-log set logical-systems A protocols bgp group internal-peers traceoptions file size 10k set logical-systems A protocols bgp group internal-peers traceoptions file files 2 set logical-systems A protocols bgp group internal-peers traceoptions flag update detail

    Configuring Trace Operations

    Step-by-Step Procedure

    The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.

    To configure the trace operations:

    1. Configure trace operations on the logical system.

      [edit logical-systems A protocols bgp group internal-peers]user@host# set traceoptions file bgp-loguser@host# set traceoptions file size 10k user@host# set traceoptions file files 2 user@host# set traceoptions flag update detail
    2. If you are done configuring the device, commit the configuration.

      [edit]user@host# commit

    Viewing the Trace File

    Step-by-Step Procedure

    To view the trace file:

    1. In operational mode on the main router, list the directories on the logical system.
      user@host> file list /var/logical-systems/A
      /var/logical-systems/A:
      config/
      log/
      tmp/
    2. In operational mode on the main router, list the log files on the logical system.
      user@host> file list /var/logical-systems/A/log/
      /var/logical-systems/A/log:
      bgp-log
    3. View the contents of the bgp-log file.
      user@host> file show /var/logical-systems/A/log/bgp-log
      Aug 10 17:12:01 trace_on: Tracing to "/var/log/A/bgp-log" started
      Aug 10 17:14:22.826182 bgp_peer_mgmt_clear:5829: NOTIFICATION sent to 192.163.6.4 (Internal AS 17): code 6 (Cease) subcode 4 (Administratively Reset), Reason: Management session cleared BGP neighbor
      Aug 10 17:14:22.826445 bgp_send: sending 21 bytes to 192.163.6.4 (Internal AS 17)
      Aug 10 17:14:22.826499
      Aug 10 17:14:22.826499 BGP SEND 192.168.6.5+64965 -> 192.163.6.4+179
      Aug 10 17:14:22.826559 BGP SEND message type 3 (Notification) length 21
      Aug 10 17:14:22.826598 BGP SEND Notification code 6 (Cease) subcode 4 (Administratively Reset)
      Aug 10 17:14:22.831756 bgp_peer_mgmt_clear:5829: NOTIFICATION sent to 192.168.40.4 (Internal AS 17): code 6 (Cease) subcode 4 (Administratively Reset), Reason: Management session cleared BGP neighbor
      Aug 10 17:14:22.831851 bgp_send: sending 21 bytes to 192.168.40.4 (Internal AS 17)
      Aug 10 17:14:22.831901
      Aug 10 17:14:22.831901 BGP SEND 192.168.6.5+53889 -> 192.168.40.4+179
      Aug 10 17:14:22.831959 BGP SEND message type 3 (Notification) length 21
      Aug 10 17:14:22.831999 BGP SEND Notification code 6 (Cease) subcode 4 (Administratively Reset)
      ...
    4. Filter the output of the log file.
      user@host> file show /var/logical-systems/A/log/bgp-log | match "flags 0x40"
      Aug 10 17:14:54.867460 BGP SEND flags 0x40 code Origin(1): IGP
      Aug 10 17:14:54.867595 BGP SEND flags 0x40 code ASPath(2) length 0: <null>
      Aug 10 17:14:54.867650 BGP SEND flags 0x40 code NextHop(3): 192.168.6.5
      Aug 10 17:14:54.867692 BGP SEND flags 0x40 code LocalPref(5): 100
      Aug 10 17:14:54.884529 BGP RECV flags 0x40 code Origin(1): IGP
      Aug 10 17:14:54.884581 BGP RECV flags 0x40 code ASPath(2) length 0: <null>
      Aug 10 17:14:54.884628 BGP RECV flags 0x40 code NextHop(3): 192.163.6.4
      Aug 10 17:14:54.884667 BGP RECV flags 0x40 code LocalPref(5): 100
      Aug 10 17:14:54.911377 BGP RECV flags 0x40 code Origin(1): IGP
      Aug 10 17:14:54.911422 BGP RECV flags 0x40 code ASPath(2) length 0: <null>
      Aug 10 17:14:54.911466 BGP RECV flags 0x40 code NextHop(3): 192.168.40.4
      Aug 10 17:14:54.911507 BGP RECV flags 0x40 code LocalPref(5): 100
      Aug 10 17:14:54.916008 BGP SEND flags 0x40 code Origin(1): IGP
      Aug 10 17:14:54.916054 BGP SEND flags 0x40 code ASPath(2) length 0: <null>
      Aug 10 17:14:54.916100 BGP SEND flags 0x40 code NextHop(3): 192.168.6.5
      Aug 10 17:14:54.916143 BGP SEND flags 0x40 code LocalPref(5): 100
      Aug 10 17:14:54.920304 BGP RECV flags 0x40 code Origin(1): IGP
      Aug 10 17:14:54.920348 BGP RECV flags 0x40 code ASPath(2) length 0: <null>
      Aug 10 17:14:54.920393 BGP RECV flags 0x40 code NextHop(3): 10.0.0.10
      Aug 10 17:14:54.920434 BGP RECV flags 0x40 code LocalPref(5): 100
    5. View the tracing operations in real time.
      user@host> clear bgp neighbor logical-system A
      Cleared 2 connections

      Caution: Clearing the BGP neighbor table is disruptive in a production environment.

    6. Run the monitor start command with an optional match condition.
      user@host> monitor start A/bgp-log | match 0.0.0.0/0
      Aug 10 19:21:40.773467 BGP RECV         0.0.0.0/0
      Aug 10 19:21:40.773685 bgp_rcv_nlri: 0.0.0.0/0
      Aug 10 19:21:40.773778 bgp_rcv_nlri: 0.0.0.0/0 belongs to meshgroup 
      Aug 10 19:21:40.773832 bgp_rcv_nlri: 0.0.0.0/0 qualified bnp->ribact 0x0 l2afcb 0x0
    7. Pause the monitor command by pressing Esc-Q.
      To unpause the output, press Esc-Q again.
    8. Halt the monitor command by pressing Enter and typing monitor stop.
      [Enter]
      user@host> monitor stop
    9. When you are finished troubleshooting, consider deactivating trace logging to avoid any unnecessary impact to system resources.
      [edit protocols bgp group internal-peers]user@host:A# deactivate traceoptionsuser@host:A# commit

      When configuration is deactivated, it appears in the configuration with the inactive tag.To reactivate trace operations, use the activate configuration-mode statement.

      [edit protocols bgp group internal-peers]
      user@host:A# show
      type internal;
      inactive: traceoptions {
          file bgp-log size 10k files 2;
          flag update detail;
          flag all;
      }
      local-address 192.168.6.5;
      export send-direct;
      neighbor 192.163.6.4;
      neighbor 192.168.40.4;
    10. To reactivate trace operations, use the activate configuration-mode statement.
      [edit protocols bgp group internal-peers]user@host:A# activate traceoptionsuser@host:A# commit

    Deactivating and Reactivating Trace Logging

    Step-by-Step Procedure

    To deactivate and reactivate the trace file:

    1. When you are finished troubleshooting, consider deactivating trace logging to avoid an unnecessary impact to system resources.
      [edit protocols bgp group internal-peers]user@host:A# deactivate traceoptionsuser@host:A# commit

      When configuration is deactivated, the statement appears in the configuration with the inactive tag.

      [edit protocols bgp group internal-peers]
      user@host:A# show
      type internal;
      inactive: traceoptions {
          file bgp-log size 10k files 2;
          flag update detail;
          flag all;
      }
      local-address 192.168.6.5;
      export send-direct;
      neighbor 192.163.6.4;
      neighbor 192.168.40.4;
    2. To reactivate logging, use the activate configuration-mode statement.
      [edit protocols bgp group internal-peers]user@host:A# activate traceoptionsuser@host:A# commit

    Results

    From configuration mode, confirm your configuration by entering the show logical-systems A protocols bgp group internal-peers command. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.

    user@host# show logical-systems A protocols bgp group internal-peers
    traceoptions {file bgp-log size 10k files 2;flag update detail;}

    Verification

    Confirm that the configuration is working properly.

    Verifying That the Trace Log File Is Operating

    Purpose

    Make sure that events are being written to the log file.

    Action

    user@host:A> show log bgp-log
    Aug 12 11:20:57 trace_on: Tracing to "/var/log/A/bgp-log" started

    Example: Configuring System Logging on Logical Systems

    This example shows how to configure system logging on logical systems and how to view the logs.

    Requirements

    This example has the following requirements:

    • You must have the view privilege for the logical system.
    • Junos OS Release 11.4 or later.

    Overview

    Each logical systems has its individual directory structure created in the /var/logical-systems/logical-system-name directory. This directory contains the following subdirectories:

    • /config—Contains the active configuration specific to the logical system.
    • /log—Contains system log and tracing files specific to the logical system.

      To maintain backward compatibility for the log files with previous versions of Junos OS, a symbolic link (symlink) from the /var/log/logical-system-name directory to the /var/logical-systems/logical-system-name directory is created when a logical system is configured.

    • /tmp—Contains temporary files specific to the logical system.

    The file system for each logical system enables logical system users to view trace logs and modify logical system files. Logical system administrators have full access to view and modify all files specific to the logical system.

    Logical system users and administrators can save and load configuration files at the logical system level using the save and load configuration mode commands. In addition, they can issue the show log, monitor, and file operational mode commands at the logical system level.

    This example shows how to configure system logging on a logical system.

    Configuration

    CLI Quick Configuration

    To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level.

    set logical-systems lsys1 system syslog host 10.209.10.69 ftp critical set logical-systems lsys1 system syslog allow-duplicates set logical-systems lsys1 system syslog file lsys1-file1 daemon error set logical-systems lsys1 system syslog file lsys1-file1 firewall critical

    Step-by-Step Procedure

    The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.

    To configure system logging:

    1. Configure trace operations on the logical system.

      [edit logical-systems lsys1 system syslog]user@host# set host 10.209.10.69 ftp critical user@host# set allow-duplicates user@host# set file lsys1-file1 daemon error user@host# set file lsys1-file1 firewall critical
    2. If you are done configuring the device, commit the configuration.

      [edit]user@host# commituser@host# exit

    Results

    From configuration mode, confirm your configuration by entering the show logical-systems command. If the output does not display the intended configuration, repeat the instructions in this example to correct the configuration.

    user@host# show logical-systems
    lsys1 {system {syslog {host 10.209.10.69 {ftp critical;}allow-duplicates;file lsys1-file1 {daemon error;firewall critical;}}}}

    Verification

    Confirm that the configuration is working properly.

    Verifying That the System Log File Is Operating

    Purpose

    Make sure that events are being written to the log file.

    Action

    Tip: To make entries in the system log, you can use the start shell command and then use the logger shell command. For example: logger -e "firewall_crit" -p firewall.crit -l lsys1 TEST

    user@host> show log lsys1/lsys1-file1
    Sep 7 14:15:46 host clear-log[2752]: logfile cleared
    Sep  7 14:19:04  host logger: %-: firewall_crit: TEST
    ...
    user@host> file show /var/logical-systems/lsys1/log/lsys1-file1
    Sep  7 14:19:04  host logger: %-: firewall_crit: TEST
    ...

    Published: 2013-02-22