Route Maps
You can use route maps to control and modify routing information and to define conditions for redistributing routes between routing domains. You can apply route maps to inbound, outbound, or redistribution routes. A route map consists of match clauses and set clauses.
Match clauses specify the attribute values that determine whether a route matches the route map. A route that has the same attribute values passes the match condition. Routes that pass all the match conditions match the route map. You issue match commands to define the match conditions for a route map. You can specify the match conditions in any order. If you do not specify any match conditions in a route map, that route map matches all routes.
Set clauses define how the attributes are modified for matching routes. The set conditions apply only to routes that pass all the match conditions (or a route map with no match conditions). When a route passes all the match conditions, the router software applies all set conditions. You issue set commands to define the set conditions for a route map.
You assign a unique string called the map tag to identify each route map. You can have multiple instances of a route map, where each instance consists of a different group of clauses. Each instance is identified by a sequence number. When you apply a route map, the routing protocol evaluates routes against the instance of the route map with the lowest sequence number. If the routes pass all the match conditions specified in the lowest-numbered instance, and if all set commands are successfully applied, no other instance of the route map is considered. However, any routes that do not pass all the match conditions are evaluated against the next instance of the route map. For example, suppose you create two instances of route map boston5, one with sequence number 10 and one with sequence number 25. When you apply boston5, routes are evaluated first against instance 10; any that do not match are evaluated against instance 25.
When you apply a route map, you specify the permit or deny keyword:
- If you specify the permit keyword, routes that match the route map are accepted, forwarded, or redistributed. Routes that do not match the route map are rejected or blocked.
- If you specify the deny keyword, routes that match the route map are rejected or blocked. Routes that do not match the route map are accepted, forwarded, or redistributed.
A route map must have at least one match clause or one set clause. If you have no match clauses, all routes match the route map, and the set conditions apply to all routes. If you have no set clauses, no action is taken other than that specified by the permit or deny keyword.
Route Map Configuration Example
Consider the network structure shown in Figure 1. Suppose you do not want router Boston to receive any routes that originate in or pass through router Chicago.
![]()
You can use a route map to filter routes based on the autonomous system (AS) path to accomplish this goal. Use the following commands to configure router NY:
host1(config)#router bgp 293host1(config-router)#network 192.168.5.0 mask 255.255.255.0host1(config-router)#neighbor 10.5.5.2 remote-as 32host1(config-router)#neighbor 10.2.2.2 remote-as 873host1(config-router)#neighbor 10.2.2.4 remote-as 17host1(config-router)#neighbor 10.2.2.4 route-map block1 outhost1(config-router)#exithost1(config)#ip as-path access-list boston deny _32_host1(config)#route-map block1 deny 1host1(config-route-map)#match as-path bostonMultiple Values in a Match Entry
You can specify more than one value in each match entry of a route map by using any of the following match commands:
A clause with multiple values matches a route that has any of the values; that is, the multiple values are logical ORed.
host1(config-route-map)#match ip address lisbon madridhost1(config-route-map)#match as-path 10 20 30You can also issue successive match commands to add new values to a route map entry for any of the commands listed above.
host1(config-route-map)#match ip address bostonhost1(config-route-map)#match ip address newyorkThis method is equivalent to issuing the following single command:
host1(config-route-map)#match ip address boston newyorkYou cannot specify multiple values for the match metric-type command, because it has only two acceptable values, which are mutually exclusive. Specifying both values has the same effect as not specifying a metric type at all; specifying the same value more than once has no meaning.
Negating Match Clauses
If you specify a value when you negate a match command configured in a route map, only that value for the match entry is deleted. The routing software deletes the entire match entry only if the entry contains no other values. In some earlier releases, any value specified with a no match command was ignored, and the entire match entry was deleted. This change applies to all match commands configured in a route map.
For example, consider the following match entry to route map miami:
host1(config)#ip community-list corporate5 permit 32 463 21host1(config)#ip community-list dade2 permit 41 53 22host1(config)#route-map miami permit 1host1(config-route-map)#match community corporate5 dade2host1(config-route-map)#exithost1(config)#exithost1#show route-maproute-map miami, permit, sequence 10Match clauses:match community corporate5 dade2In earlier releases, issuing a command like the following to remove a community (see Community Lists) not specified in the entry deleted the whole entry, but now nothing happens:
host1(config-route-map)#no match community southbeachhost1(config-route-map)#exithost1(config)#exithost1#show route-maproute-map miami, permit, sequence 10Match clauses:match community corporate5 dade2If you instead issue the following commands, the specified value is deleted:
host1(config-route-map)#no match community dade2host1(config-route-map)#exithost1(config)#exithost1#show route-maproute-map miami, permit, sequence 10Match clauses:match community corporate5Issue either of the following commands to delete the entire match community entry:
host1(config-route-map)#no match communityhost1(config-route-map)#no match community corporate5 dade2Matching a Community List Exactly
You can use the exact-match keyword for the match community command to specify that a match exists only for the exact community numbers specified in the community list. The exact-match keyword applies only to a standard community listthat is, one not specified by a regular expression. You cannot use the exact-match keyword with a community list that is specified by a regular expression.
Consider the following example:
host1(config)#ip community-list 1 permit 100 200 300host1(config)#exithost1#show ip community-listCommunity standard list 1permit 0:100 0:200 0:300host1(config)#route-map example1 permit 10host1(config-route-map)#match community 1 exact-matchhost1(config)#exithost1#show route-map example1route-map example, permit, sequence 10Match clauses:community (community-list filter): 1 exact-matchThe route map example1 permits a route only if the route contains community 100 and community 200 and community 300 and no additional communities.
If you do not specify the exact-match option, the route map also permits a match on a route that contains additional communities. For example, a route that contains communities 100, 200, 300, 400, and 450 matches.
Removing Community Lists from a Route Map
You can use the set comm-list delete command to remove the specified community list from routes matching the route map, provided that you created the community list with a single community number per list entry. For example, you cannot remove the community lists 231:10 and 231:20 with the set comm-list delete command if you created them with the following command:
host1(config)#ip community list 1 permit 231:10 231:20You can, however, remove the lists with the set comm-list delete command if you created them separately with the following commands:
host1(config)#ip community list 1 permit 231:10host1(config)#ip community list 1 permit 231:20Matching a Policy List
You can use the match policy-list command to reference a policy list within the route map. Policy lists are like route maps, but they contain only match clauses and no set clauses. You can create a policy list to contain a group of match clauses once, referencing the list in any number of route maps and avoiding the task of having to reenter the match clauses separately into each route map.
For more information about creating IP policy lists, see Match Policy Lists.
Redistributing Access Routes
Access-internal routes, such as DHCP and AAA/PPP host routes, are host routes to directly connected clients. Access routes, also known as AAA framed routes, are sourced by AAA.
The following example shows how you might redistribute access-internal routes and access routes by matching on a tag:
- Configure route map tagtest to match tag 30.
host1(config)#route-map tagtesthost1(config-route-map)#match tag 30- Configure redistribution into BGP of the access-internal routes and access routes with route map tagtest.
host1(config)#router bgp 405host1(config-router)#redistribute access route-map tagtesthost1(config-router)#redistribute access-internal route-map tagtestSetting Multicast Bandwidths
You can use the set admission-bandwidth command to set a multicast bandwidth for admission control. Admission control is performed for the join and mapped interface when the OIF is added to the mroute.
You can use the set qos-bandwidth command to set a multicast bandwidth for QoS control. The QoS adjustment is made to the join interface when the OIF is added to the mroute.
NOTE: Both the admission bandwidth and QoS bandwidth are a constant bit rate.
For more information about multicast admission control or QoS adjustment, see JUNOSe Multicast Routing Configuration Guide, Chapter 5, Configuring IPv4 Multicast or JUNOSe Multicast Routing Configuration Guide, Chapter 10, Configuring IPv6 Multicast.
match as-path
- Use to match an AS-path access list.
- The implemented weight is based on the first matched AS path.
- Example
host1(config-route-map)#match as-path pathlist5Use the no version to delete the match clause from a route map or a specified value from the match clause. match community
host1(config-route-map)#match community comm5Use the no version to delete the match clause from a route map or a specified value from the match clause. match distance
- Use to match any routes being redistributed out of the routing table that have the specified administrative distance.
- Distance is used to determine the relative preference between routes to the same prefix in order to pick the best route to that prefix in the routing table. Distance has no meaning in any other circumstance, and any attempt to match distance fails.
- Example
host1(config-route-map)#match distance 25Use the no version to delete the match clause from a route map or a specified value from the match clause. match extcommunity
- Use to match an extended community list in a route map.
- You can specify one or more extended community list names in a match clause. If you specify more than one extended community list, the lists are logically ORed.
- Example
host1(config-route-map)#match extcommunity topeka10Use the no version to remove the match clause from a route map or a specified value from the match clause. match ip address
- Use to match any route that has a destination network number that is permitted by an access list, a prefix list, or a prefix tree, or that performs policy routing on packets.
- Example
host1(config-route-map)#match ip address prefix-tree bostonUse the no version to delete the match clause from a route map or a specified value from the match clause. match ip next-hop
- Use to match any routes that have a next-hop router address passed by the specified access list, prefix list, or prefix tree.
- Example
host1(config-route-map)#match ip next-hop 5acl_192_54_24_1Use the no version to delete the match clause from a route map or a specified value from the match clause. match ipv6 address
- Use to match any routes that have a destination network number address that is permitted by the specified prefix list.
- Example
host1(config-route-map)#match ipv6 address prefix-list bostonUse the no version to delete all address match clauses from a route map unless you specify a prefix list, in which case only that prefix list match is removed from the route map. match ipv6 next-hop
- Use to match any routes that have a next-hop router address passed by the specified prefix list.
- Example
host1(config-route-map)#match ipv6 next-hop prefix-list next1Use the no version to delete all next-hop match clauses from a route map unless you specify a prefix list, in which case only that prefix list match is removed from the route map. match ipv6 route-source
- Use to match any routes that are advertised from addresses contained in the specified prefix list.
- Example
host1(config-route-map)#match ipv6 route-source prefix-list sourceUse the no version to delete all route-source match clauses from a route map unless you specify a prefix list, in which case only that prefix list match is removed from the route map. match level
host1(config-route-map)#match level level-1Use the no version to delete the match clause from a route map or a specified value from the match clause. match metric
host1(config-route-map)#match metric 10Use the no version to delete the match clause from a route map or a specified value from the match clause. match metric-type
host1(config-route-map)#match metric-type externalUse the no version to delete the match clause from a route map. match policy-list
host1(config-route-map)#match policy-list list1Use the no version to remove the match clause from a route map. match route-type
host1(config-route-map)#match route-type level-1Use the no version to delete the match clause from a route map or a specified value from the match clause. match-set summary prefix-tree
- Use to specify the prefix tree that summarizes routes for a particular route map.
- Use the ip prefix-tree command to set the conditions of the prefix tree, including which routes to summarize and how many bits of the network address to preserve.
- Example
host1(config-route-map)#match-set summary prefix-tree bostonUse the no version to disable the use of the prefix tree by the route map. match tag
host1(config)#route-map 1host1(config-route-map)#match tag 25Use the no version to delete the match clause from a route map or a specified value from the match clause. route-map
- Use to define the conditions for redistributing routes from one routing protocol to another, and for filtering or modifying updates sent to or received from peers.
- Each route-map command has a list of match and set commands associated with it. That is, the route map itself consists of a set of clauses; each clause (also called an entry) consists of a match or set command:
- match commands specify the match criteria, the conditions under which redistribution is allowed for the current route map.
- set commands specify the set actions, the redistribution actions to perform if the criteria enforced by the match commands is met.
- You can specify match and set clauses to modify attributes of redistributed routes.
- Use route maps when you want to have detailed control over how routes are redistributed between routing processes.
- You specify the destination routing protocol with the router command.
- You specify the source routing protocol with the redistribute command.
host1(config)#route-map nyc1 permit 10host1(config-route-map)#match ip address list1host1(config-route-map)#set metric-type internalUse the no version to delete the route map. set as-path prepend
- Use to modify an AS path for BGP routes by prepending one or more AS numbers or a list of AS numbers to the path list.
- The only global BGP metric available to influence the best path selection is the AS path length. By varying the length of the AS path, a BGP device can influence the best path selection by a peer farther away.
- Example
host1(config-route-map)#set as-path prepend list list10Use the no version to delete the set clause from a route map. set automatic-tag
host1(config-route-map)#set automatic-tagUse the no version to delete the set clause from a route map. set comm-list delete
- Use to remove communities specified by the community list from the community attribute of routes that match the route map.
- You can use this command to delete communities only if the community list was created with a single community per list entry, as the following sample configuration for router host1 shows:
host1(config)#ip community-list 1 permit 231:10host1(config)#ip community-list 1 permit 231:20host1(config)#router bgp 45host1(config-router)#neighbor 10.6.2.5 remote-as 5host1(config-router)#neighbor 10.6.2.5 route-map indelete inhost1(config-router)#route-map indelete permit 10host1(config-route-map)#set comm-list 1 deleteRouter host1 receives the same route from 10.6.2.5 and applies the indelete route map. BGP compares each list entry with the community attribute. A match is found for the list entry 231:10, and this community is deleted from the community attribute. Similarly, a match is found for the list entry of 231:20, and this community is deleted from the community attribute.
host1(config-route-map)#set comm-list 1 deleteUse the no version to delete the set clause from a route map. set community
- Use to set the community attribute in BGP updates.
- You can specify a community list number in the range 14294967295, or in the new community format of AA:NN, or one of the following well-known communities:
- local-asrPrevents advertisement outside the local AS
- no-advertisePrevents advertisement to any peer
- no-exportPrevents advertisement beyond the BGP confederation boundary
- Alternatively, you can use the list keyword to specify the name of a community list that you previously created with the ip community-list command.
- Example
host1(config-route-map)#set community no-advertiseUse the none keyword to remove the community attribute from a route. Use the no version to delete the set clause from a route map. set dampening
- Use to enable BGP route flap dampening only on routes that pass the match clauses of, and are redistributed by, a particular route map.
- BGP creates a dampening parameter block for each unique set of dampening parameterssuch as suppress threshold, reuse threshold, and so onused by BGP. For example, if you have a route map that sets the dampening parameters to one set of values for some routes and to another set of values for the remaining routes, BGP uses and stores two dampening parameter blocks, one for each set.
- Example
host1(config-route-map)#set dampening 5 1000 1500 45 15Use the no version to delete the set clause from a route map. set distance
- Use to set the administrative distance on routes being installed into the routing table that match the route map.
- Distance establishes preference between routes to the same prefix to identify the best route to that prefix. Setting distance in any other circumstance has no effect.
- Example
host1(config-route-map)#set distance 5Use the no version to delete the set clause from a route map. set extcommunity
- Use to set the extended community attributes in a route map for BGP updates.
- You can specify a site-of-origin (soo) extended community and a route target (rt) extended community at the same time in a set clause without overwriting the other.
- Example
host1(config-route-map)#set extcommunity rt 10.10.10.2:325Use the no version to delete the set clause from a route map. set ip next-hop
- Use to set the next hop attribute of a route that matches a route map.
- You can specify an IP address or an interface as the next hop.
- Use the peer-address keyword to have the following effect:
- On outbound route maps, disables the next-hop calculation by setting the next hop to the IP address of the BGP device
- On inbound route maps, overrides any third-party next-hop configuration by setting the next hop to the IP address of the peer
host1(config-route-map)#set ip next-hop 192.56.32.1Use the no version to delete the set clause from a route map. set ipv6 next-hop
- Use to set the next hop attribute of a route that matches a route map.
- You can specify an IPv6 address or an interface as the next hop.
- Example
host1(config-route-map)#set ipv6 next-hop 1::1Use the no version to delete the set clause from a route map. set level
host1(config-route-map)#set level level-2Use the no version to delete the set clause from a route map. set local-preference
host1(config-route-map)#set local-preference 200Use the no version to delete the set clause from a route map. set metric
- Use to set the metric value (for BGP, the MED) for a route.
- To establish an absolute metric, do not enter a plus or minus sign before the metric value.
- Example
host1(config-route-map)#set metric 10To establish a relative metric, specify a plus or minus sign immediately preceding the metric value. The value is added to or subtracted from the metric of any routes matching the route map. The relative metric value range is 04294967295. Example host1(config-route-map)#set metric -25You cannot use both an absolute metric and a relative metric within the same route map sequence. Setting either metric overrides any previously configured value. Use the no version to delete the set clause from a route map. set metric-type
- Use to set the metric type for a route.
- For BGP, this command affects BGP behavior only in outbound route maps and has no effect on other types of route maps. If the route map contains both a set metric-type and a set metric clause, the set metric clause takes precedence. If you specify the internal metric type in a BGP outbound route map, BGP sets the MED of the advertised routes to the IGP cost of the next hop of the advertised route. If the cost of the next hop changes, BGP is not forced to readvertise the route.
- For BGP, you can specify the following metrics:
- externalReverts to the normal BGP rules for propagating the MED; this is the BGP default
- internalSets the MED of a received route that is being propagated to an external peer equal to the IGP cost of the indirect next hop
- externalConsiders only the metric of the route itself is considered for comparison
- internalConsiders both the metric of the route and the cost to the router that advertised the route are considered for comparison; this is the IS-IS default
- 1Sets the cost of the external routes so that it is equal to the sum of all internal costs and the external cost
- 2Sets the cost of the external routes so that it is equal to the external cost alone; this is the OSPF default
host1(config-route-map)#set metric-type internalUse the no version to delete the set clause from a route map. set origin
host1(config-route-map)#set origin egpUse the no version to delete the set clause from a route map. set route-class
- Use to set the route class value. The route-class attribute enables you to associate a route class with incoming packets based on the destination or source address of the packet. For example, you can associate different route classes with different VPN services, while using the route classes to classify packets for quality of service (QoS).
- Example
host1(config-route-map)#set route-class 50Use the no version to delete the set clause from a route map. set route-type
- Use to set the routes of the specified type (internal, internal-intra, internal-inter, or external).
- Example
host1(config-route-map)#set route-type internalUse the no version to delete the set clause from a route map. set tag
host1(config-route-map)#set tag 23Use the no version to delete the set clause from a route map. set weight
- Use to specify the BGP weight for the routing table.
- The weights assigned with the set weight command in a route map override the weights assigned using the neighbor weight and neighbor filter-list weight commands.
- Example
host1(config-route-map)#set weight 200Use the no version to delete the set clause from a route map.