Introducing Route Maps and Routing Policy Language
Introducing Route Maps and Routing Policy Language
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-1
• Route maps are a simple language to support complex routing policies,
in addition to filtering.
• Route maps are uniquely identified by a case-sensitive name.
• Each route map consists of one or more statements.
• Each statement contains zero or more match commands.
• Each statement contains zero or more set commands used to modify
routing updates.
• Route maps are available in Cisco IOS/IOS XE Software. (Cisco IOS XR
Software uses the Routing Policy Language.)
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-2
Route Map
Statement 10
Yes Yes No
Update Match? Permit Set Send Update
No Yes
No Drop Set
Statement 20
Yes Yes No
Match? Permit Set Send
No Yes
No Drop Set
Statement N
Yes Yes No
Match? Permit Set Send
No Yes
No Implicit drop Drop Set
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-3
Additional route-map options:
• The continue command can be used to jump to another statement
instead of exiting.
• Policy lists can be used to modularize and group match statements.
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-4
• Each route map is identified using a case-sensitive name.
• Each route map can have one or more ordered statements identified
using the sequence number.
• Each route-map statement can filter updates using permit or deny
options.
• Each statement processes updates matched by the match command
• Each statement can optionally modify or set parameters in an update.
• Match conditions of the same type are evaluated using a logical OR
operator; match conditions of different types are evaluated using a
logical AND operator.
Router(config)#
route-map map-tag [permit | deny] [sequence-number]
match condition
match condition
set parameter value
set parameter value
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-5
• Preferred paths for specific route-map Policy1 permit 10
prefixes match ip address prefix-list PL1
set local-preference 200
• Backup paths for specific prefixes
!
• Preferred paths for prefixes route-map Policy1 permit 20
based on AS path match ip address prefix-list PL2
set local-preference 50
• Backup paths for prefixes based
!
on AS path
route-map Policy1 permit 30
• Explicit permit at the end match as-path APACL1
set local-preference 200
!
route-map Policy1 permit 40
match as-path APACL2
set local-preference 50
!
route-map Policy1 permit 1000
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-6
• The first route-map statement
processes routes matched by
prefix list PL1 or PL2 and AS
path access list APACL1.
route-map Policy1 permit 10
• These routes are assigned local match ip address prefix-list PL1 PL2
preference 100 and MED 1000. match as-path APACL1
• All other routes are passed set local-preference 200
unchanged. set metric 1000
!
route-map Policy1 permit 1000
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-7
• RPL replaces route maps in Cisco IOS XR Software.
• RPL is a simple, yet powerful language, designed to process routing
updates.
• RPL addresses the deficiencies of route maps in Cisco IOS/IOS XE
Software:
- Better modularity
- Better reusability
- Parameterization
- Nesting of policies and conditions
- Powerful match options
- Reusable value sets
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-8
• Each routing policy is identified by a case-sensitive name.
• Entire policy is defined between route-policy and end-policy
commands.
• Main RPL functions:
- Filtering of updates (pass and drop commands)
- Modification of attributes (set commands)
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-9
EBGP
• Note: Cisco IOS XR Software Permit all routes to
does not automatically send EBGP peers.
BGP updates to external peers.
route-policy PermitAll
• A routing policy is required to pass
forward updates. end-policy
!
router bgp 1
neighbor 1.2.3.4
remote-as 64111
address-family ipv4 unicast
route-policy PermitAll out
!
!
!
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-10
• Using the explicit pass command
continues the processing of route route-policy DropOrPass1
Drop!
policy. end-policy
route-policy DropOrPass5
pass Drop!
drop
pass
end-policy
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-11
• RPL uses various match options for conditional update processing.
• Condition syntax:
if attribute operator value then
… do something … route-policy SetLP
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-12
Comparing attributes against values supports these operators:
• eq : An attribute numerically equal to specified value
• le : An attribute numerically lower than or equal to a specified value
• ge : An attribute numerically greater than or equal to a specified value
• is : An attribute equal to a specified value
• in : An attribute contained in a value set
• Many other attribute-specific options
route-policy SetLP
if med le 19 then
set local-preference 200
Simple elseif med eq 20 then
conditions set local-preference 150
elseif med ge 21 then
set local-preference 50
endif
end-policy
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-13
• Multiple match options can be combined using Boolean operators:
- and : both conditions must match
- or : at least one condition must match
- not : negate the following condition
Using composite
conditions
route-policy SetLP
if med eq 10 and not local-preference eq 100 then
set local-preference 200
elseif med eq 20 or local-preference eq 200 then
set local-preference 150
else
set local-preference 150
endif
end-policy
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-14
• Multiple match options can be combined using Boolean operators:
- not : highest precedence
- and : higher precedence than or, lower than not
- or : lowest precedence
• Influence precedence by grouping using parentheses.
vs.
if med eq 10 and (not local-preference eq 100 or med eq 50) then
vs.
if med eq 10 and not (local-preference eq 100 or med eq 50) then
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-15
• Two types of nesting are supported:
- “if” statement within another “if” statement
- A routing policy within another routing policy
• Multiple levels of nesting are supported.
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-16
• Use the set command to assign values to attributes and parameters.
• Note: All set statements are processed when the processing of policy
completes (e.g. matching on a previously set attribute is not possible).
Original update
route-policy SetLP MED= 10 LP=100 Weight=0
Match
if med eq 10 then 1
set local-preference 200
endif
Match
if local-preference eq 100 then 2 Set
set weight 100
Set
endif 3
if local-preference eq 200 then No match!
set weight 200
endif
end-policy 4 MED= 10 LP=200 Weight=100
Modified update
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-17
• Note: Last set wins when multiple sets are evaluated for a unique
parameter.
route-policy SetLP
set local-preference 100
set local-preference 200
set local-preference 300
end-policy
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-18
• Note: All set commands are evaluated in the same order for nonunique
attributes and operations.
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-19
• Standard BGP community attribute:
set community (value [value2 …]) [additive]
• MED attribute:
set med {[+|-]value | igp-cost | max-reachable}
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-20
• Delete standard BGP community attributes:
delete community {all | [not] in community-set}
• Prepend AS path:
prepend as-path {AS | most-recent} [count]
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-21
Route Flap Dampening
2200 points
2000 Suppress Limit
1100 points
1000
Forget Limit
t
Halve
Time
dampened
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-22
Conditional BGP Dampening
Conditional BGP dampening, where smaller prefixes
are more aggressively punished than larger prefixes
router bgp 1
address-family ipv4 unicast
bgp dampening route-policy BDamp
!
!
route-policy BDamp
if destination in (0.0.0.0/0 ge 25) then
set dampening max-suppress 30 halflife 10 reuse 750 suppress 1000
elseif destination in (0.0.0.0/0 ge 21) then
set dampening max-suppress 15 halflife 7 reuse 750 suppress 2000
elseif destination in (0.0.0.0/0 ge 17) then
set dampening max-suppress 10 halflife 5 reuse 750 suppress 3000
else
set dampening max-suppress 5 halflife 3 reuse 750 suppress 4000
endif
end-policy
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-23
• OSPF metric type:
set metric-type {type-1 | type-2]
• OSPF metric:
set ospf-metric value
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-24
RPL supports two types of parameters:
• Global parameters:
- Defined globally using the policy-global command
- Available for use in all routing policies
• Parameters passed to a nested routing policy:
- Defined when creating a routing policy
- Available in match and set statements within a policy or when calling another
nested routing policy
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-25
• Parameters are defined using the policy-global command, and are
separated by commas.
• Values are defined within single quotes.
• Parameters are referenced by prepending the $ sign to the name of the
parameter.
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-26
• Declare parameters when creating a routing policy.
• Nesting policies with parameters allows for greater modularization and
optimization of policies.
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-27
• Design a routing policy.
• Configure the policy.
• Test the policy by using show commands.
• Apply the policy if it is correct.
• Use routing policies in many places (attach points):
- Routing updates (e.g. BGP, OSPF, EIGRP, IS-IS, RIP)
- Route origination (e.g. redistribution, network commands)
- Route insertion into routing table
- show commands to filter output
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-28
Attach Points
OSPF Database BGP Table
Redistribution
default orig. network
area in neighbor in & out
aggregation
area out default orig.
show bgp
IS-IS Database dampening
retain RT clear dampening
default orig.
allocate label debug update
Import filter EXEC
EIGRP Database
default in/out Export tagging Table-policy Table-policy
filter in/out
filter intf. in/out VRF IPv4 IPv6
Routing Routing
RIP Database table table
default orig.
filter in/out Static routes
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-29
Validity Checking
• RPL validity checking is done in two phases:
- Syntax checking and value checking are performed during policy
configuration.
RP/0/RP1/CPU0:CRS(config-rpl)#set med 289314790283408912634789
^
% Invalid input detected at '^' marker.
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-30
• Trying to edit an existing routing policy through configuration-mode CLI
will result in the policy being rewritten:
RP/0/RP1/CPU0:CRS(config)#route-policy R1
% WARNING: Policy object 'route-policy R1' exists! Reconfiguring it via CLI
will replace current definition. Use 'abort' to cancel.
RP/0/RP1/CPU0:CRS(config-rpl)# abort
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-31
Using an Editor
• An editor can be used for routing policies and sets.
RP/0/RP1/CPU0:CRS#edit ?
as-path-set edit an as-path-set
community-set edit a community-set
extcommunity-set edit an extended-community-set
policy-global edit policy-global definitions
prefix-set edit a prefix-set
rd-set edit a rd-set
route-policy edit a route-policy
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-32
RPL can match attributes against a set of multiple values:
• Inline sets using parentheses for one-time use
• Named value sets for reusability as-path-set
community-set
Value sets: extcommunity-set
prefix-set
• AS path in AS path set
rd-set
• Standard community in community set
• Extended community in extcommunity set
• Prefix in prefix set Named value set
• Route distinguisher in route distinguisher set
xy-set set-name
Inline value set value,
value2
route-policy RP end-set
if attribute in (value, value2, …) !
then route-policy RP
set local-preference 200 if attr in set-name then
endif set local-preference 200
end-policy endif
end-policy
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-33
• Define an AS-path set using the as-path-set command.
• Use one or more comma-separated ios-regex commands to define
regular expression that define set membership.
• Use the in operator in routing policy to test for membership of AS path in
AS path set.
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-34
Predefined matching criteria Description
is-local matches any prefix with an empty AS path attribute
(equals regular expression '^$‘)
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-35
Using built-in AS-Path Equivalent regular
match options expressions
route-policy RP route-policy RP
if as-path is-local then if as-path in (ios-regex '^$')
set local-preference 200 then
endif set local-preference 200
if as-path neighbor-is '20' endif
then if as-path in (ios-regex '^20_')
set local-preference 190 then
endif set local-preference 190
if as-path originates-from '20' endif
then if as-path in (ios-regex '_20$')
set local-preference 180 then
endif set local-preference 180
if as-path passes-through '20' endif
then if as-path in (ios-regex '_20_')
set local-preference 170 then
endif set local-preference 170
end-policy endif
end-policy
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-36
• Define a standard community set using the community-set command.
• Use one or more comma-separated match options:
- ios-regex commands to define regular expressions that define set
membership
- numbered membership matching
- membership matching using well-known standard communities
• Use the matches-any operator to match routes that have at least one
community in the community set.
• Use the matches-every operator in routing policy to match routes that
have all communities in the community set.
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-37
• Use one or more comma-separated ios-regex commands to define
regular expressions that define set membership.
route-policy Comm2LP
if community matches-any ImpComms then
set local-preference 200
endif
end-policy
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-38
Use numbered matching:
• AS:num
• AS:[range]
• AS:*
Setting Local Preference
based on numbered
community matching
community-set ImpComms
123:1010
123:[2000..2099]
999:*
end-set
!
route-policy Comm2LP
if community matches-any ImpComms then
set local-preference 200
endif
end-policy
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-39
Use identifiers for well-known communities:
• Internet : Match all communities.
• local-as :Keep tagged prefixes in the local AS.
• no-advertise :Prevent tagged prefixes from being advertised to any peer.
• no-export :Prevent tagged prefixes from being announced to EBGP peers.
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-40
• Used to match prefixes in routing protocol updates: Prefix[/length [{le |
ge | eq} mask-len]]
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-41
• Use the show rpl route-policy [policy-name] [detail] commands to
display the policies.
• Detailed output also displays all referenced objects (e.g. sets and nested
route policies).
Display a policy and all
other associated objects.
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-43
• Some policies can be tested (e.g. outbound BGP filter).
• Use the show bgp route-policy policy-name command to list BGP
entries permitted by the policy.
• Note: Attributes modified by the policy are not displayed.
Test a new policy to
filter outgoing updates.
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-44
• When you migrate from Cisco IOS/IOS XE Software to Cisco IOS XR
Software, use the following guidelines to translate route maps to
policies:
- Each numbered entry is one if statement.
- Each match option is one condition:
• Match conditions of the same type should be joined using the OR logical
operator.
• Match conditions of different types should be joined using the AND logical
operator.
• Use parentheses to maintain proper precedence.
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-45
route-map RM permit 10
match ip address prefix-list PL1 Sample route map
set local-preference 200
!
route-map RM permit 20
match ip address prefix-list PL2
set local-preference 150
!
Translated routing
policy
route-policy RP
if destination in PL-Set1 then
set local-preference 200
elseif destination in PL-Set2 then
set local-preference 150
endif
end-policy
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-46
© 2012 Cisco and/or its affiliates. All rights reserved. SPROUTE v1.01—5-47