Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Example: Tracing Global Routing Protocol Operations

Understanding Global Routing Protocol Tracing Operations

Global routing protocol tracing operations track all general routing operations and record them in a log file. To set protocol-specific tracing operations and to modify the global tracing operations for an individual protocol, configure tracing for that protocol.

Using the traceoptions statement, you can specify the following global routing protocol tracing flags:

  • all—All tracing operations
  • condition-manager—Condition manager events
  • config-internal—Configuration internals
  • general—All normal operations and routing table changes (a combination of the normal and route trace operations)
  • graceful-restart—Graceful restart operations
  • normal—All normal operations
  • nsr-synchronization—Nonstop routing synchronization events
  • parse—Configuration parsing
  • policy—Policy operations and actions
  • regex-parse—Regular expression parsing
  • route—Routing table changes
  • state—State transitions
  • task—Interface transactions and processing
  • timer—Timer usage

Note: Use the all flag with caution. This flag might cause the CPU to become very busy.

Example: Tracing Global Routing Protocol Operations

This example shows how to list and view files that are created when you enable global routing trace operations.

Requirements

You must have the view privilege.

Overview

To configure global routing protocol tracing, include the traceoptions statement at the [edit routing-options] hierarchy level:

traceoptions {file filename <files number> <size size> <world-readable | no-world-readable>;flag flag <disable>;}

The flags in a traceoptions flag statement are identifiers. When you use the set command to configure a flag, any flags that might already be set are not modified. In the following example, setting the timer tracing flag has no effect on the already configured task flag. Use the delete command to delete a particular flag.

[edit routing-options traceoptions]user@host# showflag task;user@host# set traceoptions flag timeruser@host# showflag task;flag timer;user@host# delete traceoptions flag taskuser@host# showflag timer;

This example shows how to configure and view a trace file that tracks changes in the routing table. 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 routing-options traceoptions file routing-table-changesset routing-options traceoptions file size 10mset routing-options traceoptions file files 10set routing-options traceoptions flag routeset routing-options static route 1.1.1.2/32 next-hop 10.0.45.6

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.

    [edit routing-options traceoptions]user@host# set file routing-table-changesuser@host# set file size 10muser@host# set file files 10user@host# set flag route
  2. Configure a static route to cause a change in the routing table.

    [edit routing-options static]user@host# set route 1.1.1.2/32 next-hop 10.0.45.6
  3. 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, list the log files on the system.
    user@host> file list /var/log
    /var/log:
    ...
    routing-table-changes
    ...
  2. View the contents of the routing-table-changes file.
    user@host> file show /var/log/routing-table-changes
    Dec 15 11:09:29 trace_on: Tracing to "/var/log/routing-table-changes" started
    Dec 15 11:09:29.496507
    Dec 15 11:09:29.496507 Tracing flags enabled: route
    Dec 15 11:09:29.496507
    Dec 15 11:09:29.533203 inet_routerid_notify: Router ID: 192.168.4.1
    Dec 15 11:09:29.533334 inet_routerid_notify: No Router ID assigned
    Dec 15 11:09:29.533381 inet_routerid_notify: No Router ID assigned
    Dec 15 11:09:29.533420 inet_routerid_notify: No Router ID assigned
    Dec 15 11:09:29.534915 inet_routerid_notify: Router ID: 192.168.4.1
    Dec 15 11:09:29.542934 inet_routerid_notify: No Router ID assigned
    Dec 15 11:09:29.549253 inet_routerid_notify: No Router ID assigned
    Dec 15 11:09:29.556878 inet_routerid_notify: No Router ID assigned
    Dec 15 11:09:29.582990 rt_static_reinit: examined 3 static nexthops, 0 unreferenced
    Dec 15 11:09:29.589920
    Dec 15 11:09:29.589920 task_reconfigure reinitializing done
    ...
  3. Filter the output of the log file.
    user@host> file show /var/log/routing-table-changes | match 1.1.1.2
    Dec 15 11:15:30.780314 ADD      1.1.1.2/32          nhid 0 gw 10.0.45.6       Static   pref 5/0 metric  at-0/2/0.0 <ctive Int Ext>
    Dec 15 11:15:30.782276 KRT Request: send len 216 v104 seq 0 ADD route/user af 2 table 0 infot 0 addr 1.1.1.2 nhop-type unicast nhindex 663
  4. View the tracing operations in real time by running the monitor start command with an optional match condition.
    user@host> monitor start routing-table-changes | match 1.1.1.2
    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
  5. Deactivate the static route.
    user@host# deactivate routing-options static route 1.1.1.2/32user@host# commit
    *** routing-table-changes ***
    Dec 15 11:42:59.355557 CHANGE   1.1.1.2/32          nhid 663 gw 10.0.45.6       Static   pref 5/0 metric  at-0/2/0.0 <Delete Int Ext>
    Dec 15 11:42:59.426887 KRT Request: send len 216 v104 seq 0 DELETE route/user af 2 table 0 infot 0 addr 1.1.1.2 nhop-type discard filtidx 0
    Dec 15 11:42:59.427366 RELEASE  1.1.1.2/32          nhid 663 gw 10.0.45.6       Static   pref 5/0 metric  at-0/2/0.0 <Release Delete Int Ext>
  6. Halt the monitor command by pressing Enter and typing monitor stop.
    [Enter]
    user@host> monitor stop
  7. When you are finished troubleshooting, consider deactivating trace logging to avoid any unnecessary impact to system resources.

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

    [edit routing-options]user@host# deactivate traceoptionsuser@host# commit
    [edit routing-options]
    user@host# show
    inactive: traceoptions {
        file routing-table-changes size 10m files 10;
        flag route;
    }
    static {
        inactive: route 1.1.1.2/32 next-hop 10.0.45.6;
    }
  8. To reactivate trace operations, use the activate configuration-mode statement.
    [edit routing-options]user@host# activate traceoptionsuser@host# commit

Results

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

user@host# show routing-options
traceoptions {file routing-table-changes size 10m files 10;flag route;}
static {route 1.1.1.2/32 next-hop 10.0.45.6;}

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> show log routing-table-changes
Dec 15 11:09:29 trace_on: Tracing to "/var/log/routing-table-changes" started

Published: 2013-02-04