Command introduced before Junos OS Release 7.4.
Command introduced in Junos OS Release 9.0 for EX Series switches.
Test a policy configuration to determine which prefixes match routes in the routing table.
If you are using the test policy command on a logical system, you must first set the CLI to the logical system context. For example, if you want to test a routing policy that is configured on logical system R2, first run the set cli logical-system R2 command.
All prefixes in the default unicast routing table (inet.0) that match prefixes that are the same as or longer than the specific prefix are processed by the from clause in the specified policy. All prefixes accepted by the policy are displayed. The test policy command evaluates a policy differently from the BGP import process. When testing a policy that contains an interface match condition in the from clause, the test policy command uses the match condition. In contrast, BGP does not use the interface match condition when evaluating the policy against routes learned from internal BGP (IBGP) or external BGP (EGBP) multihop peers.
When testing a policy, you can see the length of time (in microseconds) required to evaluate the policy and the number of times it has been executed by running the show policy policy-name statistics command.
Required Privilege Level
List of Sample Outputtest policy
user@host> test policy test-statics 172.16.0.1/8
inet.0: 44 destinations, 44 routes (44 active, 0 holddown, 0 hidden) Prefixes passing policy: 172.16.3.0/8 *[BGP/170] 16:22:46, localpref 100, from 10.255.255.41 AS Path: 50888 I > to 10.11.4.32 via en0.2, label-switched-path l2 172.16.3.1/32 *[IS-IS/18] 2d 00:21:46, metric 0, tag 2 > to 10.0.4.7 via fxp0.0 172.16.3.2/32 *[IS-IS/18] 2d 00:21:46, metric 0, tag 2 > to 10.0.4.7 via fxp0.0 172.16.3.3/32 *[IS-IS/18] 2d 00:21:46, metric 0, tag 2 > to 10.0.4.7 via fxp0.0 172.16.3.4/32 *[IS-IS/18] 2d 00:21:46, metric 0, tag 2 > to 10.0.4.7 via fxp0.0 Policy test-statics: 5 prefixes accepted, 0 prefixes rejected