Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Example: Configuring BGP Trace Operations

Understanding Trace Operations for BGP Protocol Traffic

You can trace various BGP protocol traffic to help you debug BGP protocol issues. To trace BGP protocol traffic, include the traceoptions statement at the [edit protocols bgp] hierarchy level. For routing instances, include the traceoptions statement at the [edit routing-instances routing-instance-name protocols bgp] hierarchy level.

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

You can specify the following BGP protocol-specific trace options using the flag statement:

  • 4byte-as—4-byte AS events.
  • bfd—BFD protocol events.
  • damping—Damping operations.
  • graceful-restart—Graceful restart events.
  • keepalive—BGP keepalive messages.
  • nsr-synchronization—Nonstop active routing synchronization events.
  • open—BGP open packets. These packets are sent between peers when they are establishing a connection.
  • packets—All BGP protocol packets.
  • refresh—BGP refresh packets.
  • update—BGP update packets. These packets provide routing updates to BGP systems.

Global tracing options are inherited from the configuration set by the traceoptions statement at the [edit routing-options] hierarchy level. You can override the following global trace options for the BGP protocol using the traceoptions flag statement included at the [edit protocols bgp] hierarchy level:

  • all—All tracing operations
  • general—All normal operations and routing table changes (a combination of the normal and route trace operations)
  • normal—Normal events
  • policy—Policy processing
  • route—Routing information
  • state—State transitions
  • task—Routing protocol task processing
  • timer—Routing protocol timer processing

You can optionally specify one or more of the following flag modifiers:

  • detail—Detailed trace information.
  • filter—Filter trace information. Applies only to route and damping tracing flags.
  • receive—Packets being received.
  • send—Packets being transmitted.

Note: Use the all trace flag and the detail flag modifier with caution because these might cause the CPU to become very busy.

Note: If you only enable the update flag, received keepalive messages do not generate a trace message.

You can filter trace statements and display only the statement information that passes through the filter by specifying the filter flag modifier. The filter modifier is only supported for the route and damping tracing flags.

The match-on statement specifies filter matches based on prefixes. It is used to match on route filters.

Note: Per-neighbor trace filtering is not supported on a BGP per-neighbor level for route and damping flags. Trace option filtering support is on a peer group level.

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

Published: 2013-01-22