Cisco Systems OL-14356-01 Network Router User Manual


 
Implementing Routing Policy on Cisco IOS XR Software
Information About Implementing Routing Policy on Cisco IOS XR Software
RC-362
Cisco IOS XR Routing Configuration Guide
OL-14356-01
Set community based on MED
The following example shows how the policy tests the MED of a route and modifies the community
attribute of the route based on the value of the MED. If the MED value is 127, the policy adds the
community 123:456 to the route. If the MED value is 63, the policy adds the value 123:789 to the
community attribute of the route. Otherwise, the policy removes the community 123:123 from the route.
In any case, the policy instructs the protocol to accept the route.
route-policy quickstart-med
if med eq 127 then
set community (123:456) additive
elseif med eq 63 then
set community (123:789) additive
else
delete community in (123:123)
endif
pass
end-policy
Set local preference based on community
The following example shows how the community-set named quickstart-communities defines
community values. The route policy named quickstart-localpref tests a route for the presence of the
communities specified in the quickstart-communities community set. If any of the community values are
present in the route, the route policy sets the local preference attribute of the route to 31. In any case, the
policy instructs the protocol to accept the route.
community-set quickstart-communities
987:654,
987:543,
987:321,
987:210
end-set
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