Configuring a Route-Policy
Each node of a route-policy can comprise a set of if-match, goto next-node and apply clauses.
Usage Scenario
A route-policy includes various matching rules and hence can meet the requirements of various scenarios. Except ACLs, IP prefix lists, and AS_Path filters, other filters need to be used with a route-policy.
A route-policy is used to match routes or attributes of routes, and to change the attributes when the matching rules are met. The matching rules of a route-policy can use other filters, such as ACLs, IP prefix lists, AS_Path filters, community filters, extended community filters, and RD filters.
A route-policy can consist of multiple nodes, and each node can comprise the following clauses:
if-match clauses: define the matching rules that are used to match certain route attributes. The matching rules are conditions defined by the route-policy against which routes are matched.
apply clauses: specify actions. When a route matches a node, the apply clauses set certain attributes for the route.
goto next-node clauses: further match routes against a specified node after the routes match the current node.
For more information about a route-policy, refer to the NE device Mid-End Router Feature Description - IP Routing.
- Creating a Route-Policy
By applying a route-policy, you can set attributes for the imported routes as required. - (Optional) Configuring an if-match Clause
The if-match clauses define the matching rules that are used to match certain route attributes. - (Optional) Configuring an apply Clause
The apply clauses specify actions to set certain route attributes. - (Optional) Further Matching Routes Against a Specified Node
A route-policy can be configured to match routes against two or more nodes. - Applying a Route-Policy
A route-policy takes effect only when it is applied to a routing protocol. - Verifying the Route-Policy Configuration
After configuring a route-policy, verify information about the route-policy.
Creating a Route-Policy
By applying a route-policy, you can set attributes for the imported routes as required.
Procedure
- Run system-view
The system view is displayed.
- Run route-policy route-policy-name { permit | deny } node node
A route-policy is created, and the route-policy view is displayed.
The matching modes of a node include permit and deny:
In permit mode, if a route matches a node, the actions specified by apply clauses are performed on the route, and the route does not continue to match against the next node. If the route fails to match the node, the route continues to match against the next node.
In deny mode, if a route matches a node, the actions specified by apply clauses are not performed on the route; if a route matches all the if-match clauses of a node, the route is denied by the node and does not continue to match against the next node; if the route does not match any if-match clause of the node, the route continues to match against the next node.
NOTE:
On the NE, by default, the routes that fail to match a route-policy are denied. If more than one node is defined in a route-policy, at least one node needs to be set to permit mode.
If a route does not match any node in the route-policy, the route is denied by the route-policy. If all the nodes in a route-policy are set to deny mode, all the routes are denied by the route-policy.
When a route-policy is used to filter routes, the node with a smaller value is matched first.
- Run commit
The configuration is committed.
(Optional) Configuring an if-match Clause
The if-match clauses define the matching rules that are used to match certain route attributes.
Procedure
- Run system-view
The system view is displayed.
- Run route-policy route-policy-name { permit | deny } node node
The route-policy view is displayed.
- Run the following command as required to configure if-match clauses for the route-policy:
To set a matching rule that is based on the basic ACL, perform the following steps:
Run the if-match acl command to configure the ACL to match the routes.
Run the quit command to return to the system view.
Run the acl { name basic-acl-name { basic | [ basic ] number basic-acl-number } | [ number ] basic-acl-number } [ match-order { config | auto } ] command to enter the basic ACL view.
Run the rule [ rule-id ] [ name rule-name ] { deny | permit } [ fragment-type { fragment | non-fragment | non-subseq | fragment-subseq | fragment-spe-first } | source { source-ip-address { source-wildcard | 0 | src-netmask } | any } | time-range time-name | vpn-instance vpn-instance-name ] * command to configure the rule for the basic ACL.
When the rule command is run to configure rules for a named ACL, only the source address range specified by source and the time period specified by time-range are valid as the rules.
When a filtering policy of a routing protocol is used to filter routes:If the action specified in an ACL rule is permit, a route that matches the rule will be received or advertised by the system.
If the action specified in an ACL rule is deny, a route that matches the rule will not be received or advertised by the system.
If a route has not matched any ACL rules, the route will not be received or advertised by the system.
If an ACL does not contain any rules, all routes matching the route-policy that references the ACL will not be received or advertised by the system.
If the ACL referenced by the route-policy does not exist, all routes matching the route-policy will be received or advertised by the system.
In the configuration order, the system first matches a route with a rule that has a smaller number and then matches the route with a rule with a larger number. Routes can be filtered using a blacklist or a whitelist:
Route filtering using a blacklist: Configure a rule with a smaller number and specify the action deny in this rule to filter out the unwanted routes. Then, configure another rule with a larger number in the same ACL and specify the action permit in this rule to receive or advertise the other routes.
Route filtering using a whitelist: Configure a rule with a smaller number and specify the action permit in this rule to permit the routes to be received or advertised by the system. Then, configure another rule with a larger number in the same ACL and specify the action deny in this rule to filter out unwanted routes.
Run if-match cost cost or if-match cost { greater-equal greater-equal-value [ less-equal less-equal-value ] | less-equal less-equal-value }
The route cost is set to match routes.
Run if-match preference preference
The route preference is set to match routes.
Run if-match ip { next-hop | route-source | group-address } { acl { acl-number | acl-name } | ip-prefix ip-prefix-name }
The next hop or source address is configured to match IPv4 routes.
Run if-match ip-prefix ip-prefix-name
The IP prefix list is configured to match routes.
NOTE:
For the same route-policy node, the if-match acl command and the if-match ip-prefix command cannot be both configured because the latest configuration overwrites the previous one.
Run if-match ipv6 { address | next-hop | route-source } { acl { acl-number | acl-name } | prefix-list ipv6-prefix-name }
An IPv6 prefix list is configured to match IPv6 routes.
- Run the following command as required to match the route type:
Run if-match route-type { external-type1 | external-type1or2 | external-type2 | internal | nssa-external-type1 | nssa-external-type1or2 | nssa-external-type2 }
OSPF is set to match routes.
Run if-match route-type { is-is-level-1 | is-is-level-2 }
IS-IS is set to match routes.
- Run if-match route-type { ibgp | ebgp }
BGP is set to match routes.
Run if-match tag tag
The route tag is set to match routes.
Run if-match protocol { direct | static | rip | ripng | ospf | ospfv3 | bgp | isis | unr } *
A protocol-based matching rule is set to match routes of a specified protocol.
The commands in Step 3 are not listed in sequence. A node can have multiple or no if-match clauses.
NOTE:
If multiple if-match clauses of a node in a route-policy define the same matching condition type, the relationship between them is "OR"; if the if-match clauses define different matching condition types, the relationship between these clauses is "AND". If you run any of the following commands more than once, the latest configuration overrides the previous one:- if-match acl { acl-number | acl-name }
- if-match cost cost
- if-match extcommunity-list soo extcomm-filter-name
- if-match ip next-hop { acl { acl-number | acl-name } | ip-prefix ip-prefix-name }
- if-match ip route-source{ acl { acl-number | acl-name } | ip-prefix ip-prefix-name }
- if-match ip group-address{ acl { acl-number | acl-name } | ip-prefix ip-prefix-name }
- if-match ip-prefix ip-prefix-name
- if-match ipv6 address { acl { acl-number | acl-name } | prefix-list ipv6-prefix-name }
- if-match ipv6 next-hop { acl { acl-number | acl-name } | prefix-list ipv6-prefix-name }
- if-match ipv6 route-source { acl { acl-number | acl-name } | prefix-list ipv6-prefix-name }
- if-match rd-filter rd-filter-number
- if-match rpki origin-as-validation { invalid | not-found | valid }
- if-match tag tag
- if-match protocol { direct | static | rip | ripng | ospf | ospfv3 | bgp | isis | unr } *
If no if-match clause is specified, all routes are matched.
- Run commit
The configuration is committed.
(Optional) Configuring an apply Clause
The apply clauses specify actions to set certain route attributes.
Procedure
- Run system-view
The system view is displayed.
- Run route-policy route-policy-name { permit | deny } node node
The route-policy view is displayed.
- Run the following command as required to configure apply clauses for the route-policy:
Run apply cost { [ + | - ] cost | inherit }
The route cost is set.
Run apply cost-type { external | internal | type-1 | type-2 | internal-inc-ibgp | med-plus-igp }
The cost type is set for routes.
Run apply dampening half-life-reach reuse suppress ceiling
The dampening parameters are set for EBGP routes.
Run apply ip-address next-hop { ipv4-address | peer-address }
The next hop address of the IPv4 route is set.
Run apply ipv6 next-hop { ipv6-address | peer-address | }
The next hop address of the IPv6 route is set.
Run apply isis { level-1 | level-1-2 | level-2 }
The level of the IS-IS route is set.
Run apply preference preference
The priority of the routing protocol is set.
Run apply tag tag
The route tag is set.
The commands in Step 3 are not listed in sequence. A node can have multiple or no apply clauses.
- Run commit
The configuration is committed.
(Optional) Further Matching Routes Against a Specified Node
A route-policy can be configured to match routes against two or more nodes.
Context
The relationship between the matching rules of nodes in the same route-policy is OR. Specifically, if a route matches a node, it matches the route-policy and is no longer matched against other nodes. If you need to match the route against two or more nodes, configure a route-policy and use it to match the route against a specified node after the route matches the current node.
Procedure
- Run system-view
The system view is displayed.
- Run route-policy route-policy-name { permit | deny } node node
The route-policy view is displayed.
- Run goto next-node [ node ]
The route-policy is configured to further match routes against a specified node after the routes match the current node.
If node is not specified in the command, the route will be further matched against the next node of the current node by default.
If the node specified in the command does not exist, the route will be further matched against the next node of the specified node by default. If the next node of the specified node does not exist either, the route fails to match the route-policy, and no apply clause will be applied to the route.
- Run commit
The configuration is committed.
Applying a Route-Policy
A route-policy takes effect only when it is applied to a routing protocol.
Context
- Apply a route-policy to direct routes.
- Apply a route-policy to static routes.
- Apply a route-policy to RIP routes.
- Apply a route-policy to RIPng routes.
- Apply a route-policy to IPv4 IS-IS routes.
- Apply a route-policy to IPv6 IS-IS routes.
- Apply a route-policy to OSPF routes.
- Apply a route-policy to OSPFv3 routes.
- Apply a route-policy to BGP routes.
- Apply a route-policy to BGP4+ routes.
- Apply a route-policy to BGP/MPLS IP VPN routes.
Procedure
- Apply a route-policy to direct routes.
- Apply a route-policy
to static routes.
- Apply a route-policy
to RIP routes.
- Apply a route-policy to RIPng routes.
- Apply a route-policy
to IPv4 IS-IS routes.
- To apply a route-policy in the IS-IS view, perform the following
operations:
- Run the system-view command to enter the system view.
- Run the isis [ process-id ] command to enter the IS-IS view.
- To apply a route-policy to IPv4 IS-IS routes in the IS-IS view,
see Table 12-5.
Table 12-5 Applying a route-policy to IPv4 IS-IS routes in the IS-IS view
Objectives
Command
Reference
To configure IS-IS to generate and advertise default routes to the IS-IS domain only when external routes that match a route-policy exist in the routing table of a Level-1-2 router
default-route-advertise route-policy route-policy-name [ cost cost | tag tag | [ level-1 | level-1-2 | level-2 ] ] * [ avoid-learning ]
To configure IS-IS to advertise the routes that are imported from another routing protocol and match a route-policy
filter-policy route-policy route-policy-name export [ protocol [ process-id ] ]
– To configure IS-IS to accept the routes that match a route-policy
filter-policy route-policy route-policy-name import
To configure IS-IS to import the routes from another routing protocol that match a route-policy
import-route { direct | static | { ospf | rip | isis } [ process-id ] | bgp [ permit-ibgp ] } [ cost-type { external | internal } | cost cost | tag tag | route-policy route-policy-name | [ level-1 | level-2 | level-1-2 ] ] *
import-route { { ospf | rip | isis } [ process-id ] | bgp [ permit-ibgp ] | direct } inherit-cost [ { level-1 | level-2 | level-1-2 } | tag tag | route-policy route-policy-name ] *
To configure Level-1 routes that match a route-policy to leak to a Level-2 area
import-route isis level-1 into level-2 [ filter-policy route-policy route-policy-name | tag tag ] *
To configure Level-2 routes that match a route-policy to leak to a Level-1 area
import-route isis level-2 into level-1 [ filter-policy route-policy route-policy-name | tag tag ] *
To configure a priority for the IS-IS routes that match a route-policy
preference { route-policy route-policy-name | preference } *
- Run the commit command to commit the configuration.
- To apply a route-policy in the IS-IS FRR view, perform the following
operations:
- Run the system-view command to enter the system view.
- Run the isis [ process-id ] command to enter the IS-IS view.
- Run the frr command to enter the IS-IS FRR view.
Run the frr-policy route route-policy route-policy-name command to configure IS-IS to add the backup routes that match a route-policy to the IP routing table.
For details on how to configure IS-IS Auto FRR (IPv4), see Configuring IS-IS Auto FRR.
- Run the commit command to commit the configuration.
- To apply a route-policy in the IS-IS view, perform the following
operations:
- Apply a route-policy to IPv6 IS-IS routes.
- To apply a route-policy in the IS-IS view, perform the following
operations:
- Run the system-view command to enter the system view.
- Run the isis [ process-id ] command to enter the IS-IS view.
- To apply a route-policy to IPv6 IS-IS routes in the IS-IS view,
see Table 12-6.
Table 12-6 Applying a route-policy to IPv6 IS-IS routes in the IS-IS view
Objectives
Command
Reference
To configure IS-IS to generate and advertise default IPv6 routes to the IS-IS domain only when external routes that match a route-policy exist in the routing table of a Level-1-2 router
ipv6 default-route-advertise route-policy route-policy-name [ cost cost | tag tag | [ level-1 | level-2 | level-1-2 ] ] * [ avoid-learning ]
To configure IS-IS to advertise the IPv6 routes that are imported from another routing protocol and match a route-policy
ipv6 filter-policy route-policy route-policy-name export [ protocol [ process-id ] ]
- To configure IS-IS to accept the IPv6 routes that match a route-policy
ipv6 filter-policy route-policy route-policy-name import
To configure IS-IS to import the IPv6 routes from another routing protocol that match a route-policy
ipv6 import-route { direct | static | | unr { ripng | isis | ospfv3 } [ process-id ] } | bgp [ permit-ibgp ] } [ cost cost | tag tag | route-policy route-policy-name | route-filter route-filter-name | [ level-1 | level-2 | level-1-2 ] ] *
ipv6 import-route { { ospfv3 | ripng | isis } [ process-id ] | bgp [ permit-ibgp ] | direct | unr } inherit-cost [ tag tag | route-policy route-policy-name | route-filter route-filter-name | [ level-1 | level-2 | level-1-2 ] ] *
To configure Level-1 IPv6 routes that match a route-policy to leak to a Level-2 area
ipv6 import-route isis level-1 into level-2 [ filter-policy route-policy route-policy-name | tag tag ] *
To configure Level-2 IPv6 routes that match a route-policy to leak to a Level-1 area
ipv6 import-route isis level-2 into level-1 [ filter-policy route-policy route-policy-name | tag tag ] *
To configure a priority for the IPv6 IS-IS routes that match a route-policy
ipv6 preference { route-policy route-policy-name | preference } *
- Run the commit command to commit the configuration.
- To apply a route-policy in the IS-IS IPv6 topology view, perform
the following operations:
- Run the system-view command to enter the system view.
- Run the isis [ process-id ] command to enter the IS-IS view.
- Run the ipv6 topology topology-name [ topology-id { multicast | topology-id } ] command to bind the IS-IS process to an IPv6 topology and enter the IS-IS IPv6 topology view.
Run the import-route { direct | { ospfv3 | ripng | isis } [ process-id ] | bgp [ permit-ibgp ] } inherit-cost [ tag tag | route-policy route-policy-name | { level-1 | level-2 | level-1-2 } ] * command to import routes to the IS-IS IPv6 topology.
For details on how to configure IPv6 IS-IS multi-topology, see Enabling MT for an IS-IS Process.
- Run the commit command to commit the configuration.
- To apply a route-policy in the IS-IS view, perform the following
operations:
- Apply a route-policy
to OSPF routes.
To apply a route-policy in the OSPF view, perform the following operations:
- Run the system-view command to enter the system view.
- Run the ospf [ process-id ] command to enable an OSPF process and enter the OSPF view.
- To apply a route-policy to OSPF routes in the OSPF view, see Table 12-7.
Table 12-7 Applying a route-policy to OSPF routes
Objectives
Command
Reference
To configure OSPF to advertise the default routes in the routing table that are not generated by OSPF to a common area based on the parameters of a route-policy
default-route-advertise [ [ always | permit-calculate-other ] | cost cost | type type | route-policy route-policy-name | distribute-delay delay-time ] *
To configure OSPF to accept the routes that match a route-policy
filter-policy route-policy route-policy-name [ secondary ] import
To configure OSPF to import the routes that match a route-policy
import-route { bgp [ permit-ibgp ] | direct | rip [ process-id-rip ] | static | isis [ process-id-isis ] | ospf [ process-id-ospf ] [ cost cost | route-policy route-policy-name | tag tag | type type ] * }
To configure a route-policy for OSPF local MT so that only the routes that match the route-policy are added to the MIGP routing table
local-mt filter-policy route-policy route-policy-name
-
To configure a priority for OSPF routes that match a route-policy
preference [ ase | inter | intra ] { preference | route-policy route-policy-name } *
- Run the commit command to commit the configuration.
To apply a route-policy in the OSPF area view, perform the following operations:
Run the system-view command to enter the system view.
Run the ospf [ process-id ] command to enable an OSPF process and enter the OSPF view.
Run the area area-id command to enter the OSPF area view.
Perform either of the following operations to apply a route-policy in the OSPF area view:
Run the filter route-policy route-policy-name export command to apply a route-policy to outgoing Type 3 LSAs (summary LSAs) in the area.
Run the filter route-policy route-policy-name import command to apply a route-policy to incoming Type 3 LSAs in the area.
- Run the commit command to commit the configuration.
To apply a route-policy in the OSPF FRR view, perform the following operations:
Run the system-view command to enter the system view.
Run the ospf [ process-id ] command to enable an OSPF process and enter the OSPF view.
Run the frr command to enter the OSPF FRR view.
Run the loop-free-alternate command to enable OSPF IP FRR to generate a loop-free backup link.
Run the frr-policy route route-policy route-policy-name command to configure OSPF to add the backup routes that match a route-policy to the IP routing table.
For details on how to configure OSPF IP FRR, see Configuring OSPF IP FRR.
- Run the commit command to commit the configuration.
- Apply a route-policy to OSPFv3 routes.
To apply a route-policy in the OSPFv3 view, perform the following operations:
Run the system-view command to enter the system view.
Run the ospfv3 [ process-id ] command to enable an OSPFv3 process and enter the OSPFv3 view.
To apply a route-policy to OSPFv3 routes in the OSPFv3 view, see Table 12-8.
Table 12-8 Applying a route-policy to OSPFv3 routesObjectives
Command
Reference
To configure OSPFv3 to advertise the default routes in the routing table that are not generated by OSPFv3 to an OSPFv3 routing area based on the parameters of a route-policy
default-route-advertise [ always | permit-calculate-other | cost cost | type type | tag tag | distribute-delay delay | route-policy route-policy-name ] *
To configure OSPFv3 to import the routes that match a route-policy
import-route { bgp [ permit-ibgp ] | direct | static | isis [ process-id ] | ripng [ process-id ] | ospfv3 [ process-id ] } [ cost cost | tag tag | type type | route-policy route-policy-name ] * }
To configure a priority for OSPFv3 routes that match a route-policy
preference [ ase ] { preference | route-policy route-policy-name } *
-
- Run the commit command to commit the configuration.
To apply a route-policy in the OSPFv3 area view, perform the following operations:
Run the system-view command to enter the system view.
Run the ospfv3 [ process-id ] command to enable an OSPFv3 process and enter the OSPFv3 view.
Run the area area-id command to enter the OSPFv3 area view.
Perform either of the following operations to apply a route-policy in the OSPFv3 area view:
Run the filter route-policy route-policy-name export command to apply a route-policy to outgoing Type 3 LSAs (Inter-Area-Prefix-LSAs) in the area.
Run the filter route-policy route-policy-name import command to apply a route-policy to incoming Type 3 LSAs in the area.
For details on how to apply a route-policy to Type 3 LSAs, see Configuring OSPFv3 to Filter LSAs in an Area.
- Run the commit command to commit the configuration.
To apply a route-policy in the OSPFv3 FRR view, perform the following operations:
Run the system-view command to enter the system view.
Run the ospfv3 [ process-id ] command to enable an OSPFv3 process and enter the OSPFv3 view.
Run the frr command to enter the OSPFv3 IP FRR view.
Run the loop-free-alternate command to enable OSPFv3 IP FRR.
Run the frr-policy route route-policy route-policy-name command to configure OSPFv3 to add the backup routes that match a route-policy to the IP routing table.
For details on how to configure OSPFv3 IP FRR, see Configuring OSPFv3 IP FRR.
- Run the commit command to commit the configuration.
- Apply a route-policy
to BGP routes.
- Apply a route-policy to BGP4+ routes.
- Apply a route-policy
to BGP/MPLS IP VPN routes.
To apply a route-policy in the BGP-VPNv4 address family view, perform the following operations:
- Run the system-view command to enter the system view.
- Run the bgp { as-number-plain | as-number-dot } command to enter the BGP view.
- Run the ipv4-family vpnv4 command to enter the BGP-VPNv4 address family view.
Run the nexthop recursive-lookup bit-error-detection { med + med-adjust-value | local-preference - localpref-adjust-value } * [ route-policy route-policy-name ] command to associate bit error events with the adjustment of the local preference or MED value for routes that match a route-policy. If route-policy route-policy-name is not specified in the command, the local preferences or MED values of all routes are adjusted.
For details on how to configure bit-error-triggered L3VPN route switching, see Configuring Bit-Error-Triggered VPN Route Switching.
Run the commit command to commit the configuration.
To apply a route-policy in the VPN instance view, perform the following operations:
- Run the system-view command to enter the system view.
- Run the ip vpn-instance vpn-instance-name command to enter the VPN instance view.
- Perform either of the following operations as required:
To associate the VPN instance IPv4 or IPv6 address family with one export route-policy, run the export route-policy route-policy-name [ add-ert-first ] command.
The export command can control route transmission between different VPN instances on a PE, while the peer route-policy export command can control only the VPNv4 or VPNv6 routes that a PE sends to other PE peers.
To associate the VPN instance IPv4 or IPv6 address family with one import route-policy, run the import route-policy route-policy-name command.
The import route-policy command can control route transmission between different VPN instances on a PE, while the peer route-policy import command can control only the VPNv4 or VPNv6 routes that a PE sends to other PE peers.
To configure a device to advertise ARP Vlink direct routes that match a route-policy on a VPN, run the arp vlink-direct-route advertise [ route-policy route-policy-name ] command. For details, see Configure a direct route between a PE and a CE.
Run the commit command to commit the configuration.
To apply a route-policy in the VPN instance IPv4 address family view, perform the following operations:
- Run the system-view command to enter the system view.
- Run the ip vpn-instance vpn-instance-name command to enter the VPN instance view.
- Run the ipv4-family command to enable the IPv4 address family for the VPN instance and enter the VPN instance IPv4 address family view.
Run the ip { direct-routing-table | static-routing-table } route-policy route-policy-name command to apply a route-policy to direct or static routes in the VPN instance IPv4 address family.
After the ip route-policy command is run, a device can modify attributes of direct or static routes based on the route-policy.
Run the commit command to commit the configuration.
To apply a route-policy in the VPN instance IPv6 address family view, perform the following operations:
- Run the system-view command to enter the system view.
- Run the ip vpn-instance vpn-instance-name command to enter the VPN instance view.
- Run the ipv6-family command to enable the IPv6 address family for the VPN instance and enter the VPN instance IPv6 address family view.
- Run the nd vlink-direct-route advertise [ route-policy route-policy-name ] command to configure a device to advertise NDP Vlink direct routes that match a route-policy on a VPN. For details, see Configure a direct route between a PE and a CE.
Run the commit command to commit the configuration.