Networking · Topic 5 of 8
Routing Policy Language and Route Maps
Control routes with IOS XR routing policy language and IOS XE route maps, using prefix sets, communities and set actions for BGP, OSPF and IS-IS policy.
- 5 min
- A route map has numbered clauses, each with
permitordeny,matchandset. - A route map ends in an implicit deny.
- RPL uses
if,then,elseandendif, and ends withend-policy.
What it is
Routing policy decides which routes a router accepts, advertises and redistributes, and with what attributes.
On IOS XR the tool is the routing policy language (RPL). On IOS and IOS XE the tool is the route map. Both match routes against conditions, and then act on them by permitting, dropping or changing them.
How it works
A policy is a list of tests with actions, and it is attached where routes enter, leave or are redistributed.
Route maps on IOS XE
A route map is a list of numbered clauses. Each clause is either permit or deny, has optional match lines, and has set lines for actions.
The router checks clauses in order of sequence number. The first clause that matches decides what happens. If no clause matches, the route is denied, because every route map ends with an implicit deny.
R1(config)# ip prefix-list CUST seq 5 permit 203.0.113.0/24 le 28
R1(config)# route-map CUST_IN permit 10
R1(config-route-map)# match ip address prefix-list CUST
R1(config-route-map)# set local-preference 200
R1(config)# router bgp 65000
R1(config-router)# address-family ipv4
R1(config-router-af)# neighbor 192.0.2.2 route-map CUST_IN in
A permit clause with no match line matches every route. Use that for a final catch all clause.
Routing policy language on IOS XR
RPL looks more like a program. It has sets, which are named lists of values, and policies, which use if, then, else and endif.
RP/0/RP0/CPU0:PE1(config)# prefix-set CUST_PFX
RP/0/RP0/CPU0:PE1(config-pfx)# 203.0.113.0/24 le 28
RP/0/RP0/CPU0:PE1(config-pfx)# end-set
RP/0/RP0/CPU0:PE1(config)# route-policy CUST_IN
RP/0/RP0/CPU0:PE1(config-rpl)# if destination in CUST_PFX then
RP/0/RP0/CPU0:PE1(config-rpl-if)# set local-preference 200
RP/0/RP0/CPU0:PE1(config-rpl-if)# pass
RP/0/RP0/CPU0:PE1(config-rpl-if)# else
RP/0/RP0/CPU0:PE1(config-rpl-else)# drop
RP/0/RP0/CPU0:PE1(config-rpl-else)# endif
RP/0/RP0/CPU0:PE1(config-rpl)# end-policy
The policy ends in pass, drop or done. A route that reaches the end of a policy without a pass is dropped. Sets exist for prefixes, communities, AS paths and more.
Comparing the two
| Feature | Route map (XE) | RPL (XR) |
|---|---|---|
| Structure | Numbered clauses | if and else blocks |
| Match lists | Prefix list, community list, AS path list | Prefix set, community set, AS path set |
| Default at the end | Deny | Drop unless passed |
| Reuse | Each map is separate | Policies can call each other with apply |
| Parameters | None | Policies can take parameters |
Policy in BGP
The common BGP actions are shown below. They map to the attributes in the earlier pages.
| Goal | Action |
|---|---|
| Prefer an exit | set local-preference |
| Influence inbound traffic | AS path prepend, or set med |
| Tag routes | set community |
| Filter | Match a prefix set and drop or deny |
Attach the policy to a neighbour as in or out. On IOS XR, an eBGP neighbour needs a policy in each direction, as covered on the BGP page.
Policy in OSPF and IS-IS
IGPs use policy mostly when redistributing. The policy decides which routes enter and what metric they get.
R1(config)# route-map BGP_TO_OSPF permit 10
R1(config-route-map)# match ip address prefix-list CUST
R1(config-route-map)# set metric 100
R1(config-route-map)# set metric-type type-1
R1(config)# router ospf 1
R1(config-router)# redistribute bgp 65000 subnets route-map BGP_TO_OSPF
On IS-IS, a route map can set the level of the redistributed routes, for example with set level level-2. On IOS XR, the same job uses route-policy NAME on the redistribute line in the OSPF or IS-IS process.
What to remember for the exam
Seven facts cover most questions on this topic.
- A route map has numbered clauses, each with
permitordeny,matchandset. - A route map ends in an implicit deny.
- RPL uses
if,then,elseandendif, and ends withend-policy. - In RPL a route that is not passed is dropped.
- RPL uses prefix sets, community sets and AS path sets.
- Policy is applied
inorouton a neighbour, and on aredistributeline. - In IGPs, policy mostly controls what is redistributed and the metric it gets.
When a route disappears after a policy change, check the end of the policy. On IOS XE it hits the implicit deny, and on IOS XR it needs pass.
Common mistakes
These four mistakes appear often.
Forgetting the catch all clause. Routes that match no earlier clause are denied.
Forgetting pass in RPL. The route is dropped even though the conditions matched.
Applying the policy in the wrong direction. An in policy affects what you learn, and an out policy affects what you send.
Redistributing without a filter. Unwanted routes, such as the full internet table, can flood an IGP.
On IOS XE, a policy change takes effect for new updates only. Use a soft reset or route refresh so that existing routes are checked again.
Check yourself
Work through these three questions.
What happens to a route that matches no clause in a route map?
It is denied, because every route map ends with an implicit deny.
What must an RPL policy do for a route to be accepted?
It must reach
pass, because a route that is not passed is dropped.Where is a policy used to control redistribution into OSPF?
On the
redistributeline, with a route map on IOS XE or a route policy on IOS XR.
Topic 5 of 8 in Networking
Test yourself on Networking
The full Cisco CCNP 350-501 SPCOR question bank has 738 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Cisco. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.