Implementing Routing Policy on Cisco IOS XR Software
Information About Implementing Routing Policy
RC-213
Cisco IOS XR Routing Configuration Guide
route-policy quickstart-localpref
if community matches-any quickstart-communities then
set local-preference 31
endif
pass
end-policy
Persistent Remarks
The following example shows how comments are placed in the policy to clarify the meaning of the
entries in the set and the statements in the policy. The remarks are persistent, meaning they remain
attached to the policy. For example, remarks are displayed in the output of the show running-config
command. Adding remarks to the policy makes the policy easier to understand, modify at a later date,
and troubleshoot if an unexpected behavior occurs.
prefix-set rfc1918
# These are the networks defined as private in RFC1918 (including
# all subnets thereof)
10.0.0.0/8 ge 8,
172.16.0.0/12 ge 12,
192.168.0.0/16 ge 16
end-set
route-policy quickstart-remarks
# Handle routes to RFC1918 networks
if destination in rfc1918 then
# Set the community such that we do not export the route
set community (no-export) additive
endif
end-policy
Routing Policy Configuration Basics
Route policies comprise series of statements and expressions that are bracketed with the route-policy
and end-policy keywords. Rather than a collection of individual commands (one for each line), the
statements within a route policy have context relative to each other. Thus, instead of each line being an
individual command, each policy or set is an independent configuration object that can be used, entered,
and manipulated as a unit.
Each line of a policy configuration is a logical subunit. At least one new line must follow the then, else,
and end-policy keywords. A new line must also follow the closing parenthesis of a parameter list and
the name string in a reference to an AS path set, community set, extended community set, or prefix set.
At least one new line must precede the definition of a route policy, AS path set, community set, extended
community set, or prefix set. One or more new lines can follow an action statement. One or more new
lines can follow a comma separator in a named AS path set, community set, extended community set, or
prefix set. A new line must appear at the end of a logical unit of policy expression and may not appear
anywhere else.
Policy Definitions
Policy definitions create named sequences of policy statements. A policy definition consists of the CLI
route-policy keyword followed by a name, a sequence of policy statements, and the end-policy
keyword. For example, the following policy drops any route it encounters: