To trace BGP protocol traffic, you can specify options in the global
traceoptionsstatement at the[edit routing-options]hierarchy level, and you can specify BGP-specific options by including thetraceoptionsstatement at the[edit protocols bgp]hierarchy level. For routing instances, include the statement.traceoptions {filename<replace> <sizesize> <filesnumber> <no-stamp><(world-readable | no-world-readable)>;flagflag<flag-modifier> <disable>;}For a list of hierarchy levels at which you can configure this statement, see the statement summary section for this statement.
You can specify the following BGP-specific options in the BGP
traceoptionsstatement:
aspath—Trace AS path regular expression operations.damping—Trace damping operations.keepalive—Trace BGP keepalive messages.open—Trace BGP open packets. These packets are sent between peers when they are establishing a connection.packets—Trace all BGP protocol packets.update—Trace update packets. These packets provide routing updates to BGP systems.You can filter trace statements and output only the statement information that passes through the filter by specifying the
filterflag modifier. Thefiltermodifier is only supported for therouteanddampingtracing flags.
NOTE: Per-neighbor traceoption 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.
NOTE: Use the traceoption flags
detailandallwith caution. These flags may cause the CPU to become very busy.
The
match-onstatement specifies filter matches based on prefixes. It is used to match on route filters.For general information about tracing, see the tracing and logging information in the JUNOS System Basics Configuration Guide.
Examples: Tracing BGP Protocol Traffic
Trace only unusual or abnormal operations to
routing-log, and trace detailed information about all BGP messages tobgp-log:[edit]routing-options {traceoptions {file routing-log;}autonomous-system 23;}protocols {bgp {group 23 {type external;peer-as 56;traceoptions {file bgp-log size 10k files 5;flag packets detail;}0.0.0.0/0;}}}Trace only update messages received from the configured peer:
[edit]routing-options {autonomous-system 23;router-id 10.0.0.1;}protocols {bgp {group 23 {type external;peer-as 56;neighbor boojum.snark.net {traceoptions {file bgp-log size 10k files 2;flag update detail;}}}}}Trace only messages that pass the policy based on prefix match:
[edit]protocols {bgp {traceoptions {file bgp-tr size 5m files 10;flag route filter policy couple-route match-on prefix;}}}