Match Conditions
Each term can consist of two statements,
fromandto, that define match conditions:[edit]policy-options {policy-statementpolicy-name{termterm-name{from {family family-name;match-conditions;policysubroutine-policy-name;prefix-listname;route-filterdestination-prefix match-type<actions>;source-address-filterdestination-prefix match-type<actions>;}to {match-conditions;policysubroutine-policy-name;}}}}In the
fromstatement, you define the criteria that an incoming route must match. You can specify one or more match conditions. If you specify more than one, they all must match the route for a match to occur.The
fromstatement is optional. If you omit it and thetostatement, all routes are considered to match.
NOTE: In export policies, omitting the
fromstatement from a routing policy term might lead to unexpected results. For more information, see Side Effects of Omitting the "from" Statement from an Export Policy.
In the
tostatement, you define the criteria that an outgoing route must match. You can specify one or more match conditions. If you specify more than one, they all must match the route for a match to occur. You can specify most of the same match conditions in thetostatement that you can in thefromstatement. In most cases, specifying a match condition in thetostatement produces the same result as specifying the same match condition in thefromstatement.The
tostatement is optional. If you omit both it and thefromstatement, all routes are considered to match.
NOTE: All conditions in the
fromandtostatements must match for the action to be taken. The match conditions are effectively a logical AND operation. Matching in prefix lists and route lists is handled differently. For more information about these match conditions, including how they are evaluated, see Configuring Prefix Lists and Configuring Route Lists.
Table 12 describes the match conditions available for matching an incoming or outgoing route. The table indicates whether you can use the match condition in both
fromandtostatements and whether the match condition functions the same or differently when used with both statements. If a match condition functions differently in afromstatement than in atostatement, or if the condition cannot be used in one type of statement, there is a separate description for each type of statement. Otherwise, the same description applies to both types of statements.Table 12 also indicates whether the match condition is standard or extended. In general, the extended match conditions include criteria that are defined separately from the routing policy (autonomous system [AS] path regular expressions, communities, and prefix lists) and are more complex than standard match conditions. The extended match conditions provide many powerful capabilities. For more information about them, see Extended Match Conditions Configuration. The standard match conditions include criteria that are defined within a routing policy and are less complex than the extended match conditions.
For examples of using the
fromandtostatements, see Examples: Routing Policy Configuration.
Match routes that are contributing to a configured aggregate. This match condition can be used to suppress a contributor in an aggregate route.
(Open Shortest Path First [OSPF] only) Area identifier.
In a
fromstatement used with anexportpolicy, match a route learned from the specified OSPF area when exporting OSPF routes into other protocols.(Border Gateway Protocol [BGP] only) Name of an AS path regular expression. For more information, see Configuring AS Path Regular Expressions.
(BGP only) Name of an AS path group regular expression. For more information, see Configuring AS Path Regular Expressions.
Color value. You can specify preference values (
colorandcolor2) that are finer-grained than those specified in thepreferenceandpreference2match conditions. The color value can be a number in the range from 0 through 4,294,967,295 (232 -1). A lower number indicates a more preferred route.
For more information about preference values, see the JUNOS Routing Protocols Configuration Guide.Name of one or more communities. If you list more than one name, only one name needs to match for a match to occur (the matching is effectively a logical OR operation). For more information, see Configuring Communities.
(OSPF only) Match external routes, including routes exported from one level to another.
typeis an optional keyword.metriccan either be 1 or 2. When you do not specifytype, this condition matches all external routes. When you specifytype, this condition matches only OSPF routes with the specified OSPF metric type.Name of an address family.
family-namecan be eitherinetorinet6. Match the address family IP version 4 (IPv4) or IP version 6 (IPv6) of the route. Default setting isinet.Name of one or more routing instances.
Match a route to be advertised over one of the specified instances.
Name or IP address of one or more router interfaces. Do not use this qualifier with protocols that are not interface-specific, such as internal BGP (IBGP).
Match a route learned from one of the specified interfaces. Direct routes match routes configured on the specified interface.
Name or IP address of one or more router interfaces. Do not use this qualifier with protocols that are not interface-specific, such as IBGP.
Match a route to be advertised from one of the specified interfaces.
Match a routing policy against the internal flag for simplified next-hop self policies.
(Intermediate System-to-Intermediate System [IS-IS] only) IS-IS level.
(BGP only) BGP local preference (
LOCAL_PREF) attribute. The preference value can be a number in the range 0 through 4,294,967,295 (232 - 1).Metric value. You can specify up to four metric values, starting with
metric(for the first metric value) and continuing withmetric2,metric3, andmetric4.(BGP only)
metriccorresponds to the multiple exit discriminator (MED), andmetric2corresponds to the interior gateway protocol (IGP) metric if the BGP next hop runs back through another route.
multicast-scoping (scoping-name|number) <(orhigher | orlower)>Multicast scope value of IPv4 or IPv6 multicast group address. The multicast-scoping name corresponds to an IPv4 prefix. You can match on a specific multicast-scoping prefix or on a range of prefixes. Specify
orhigherto match on a scope and numerically higher scopes, ororlowerto match on a scope and numerically lower scopes. For more information, see the JUNOS Multicast Configuration Guide.You can apply this scoping policy to the routing table by including the
scope-policystatement at the[edit routing-options]hierarchy level.The
numbervalue can be any hexadecimal number from 0 through F. The multicast-scope value is a number from 0 through 15, or one of the following keywords with the associated meanings:Address of one or more neighbors (peers).
For BGP, the address can be a directly connected or indirectly connected peer.
For all other protocols, the address is the neighbor from which the advertisement is received.
Address of one or more neighbors (peers).
For BGP import policies, specifying
toneighborproduces the same result as specifyingfromneighbor.For BGP export policies, specifying the
neighbormatch condition has no effect and is ignored.For all other protocols, the
tostatement matches the neighbor to which the advertisement is sent. (Not valid for Routing Information Protocol [RIP].)Next-hop address or addresses specified in the routing information for a particular route. For BGP routes, matches are performed against each protocol next hop.
(BGP only) BGP origin attribute, which is the origin of the AS path information. The value can be one of the following:
Name of a policy to evaluate as a subroutine.
For information about this extended match condition, see Configuring Subroutines.
Preference value. You can specify a primary preference value (
preference) and a secondary preference value (preference2). The preference value can be a number from 0 through 4,294,967,295 (232 - 1). A lower number indicates a more preferred route.To specify even finer-grained preference values, see the
colorandcolor2match conditions in this table.For more information about preference values, see the JUNOS Routing Protocols Configuration Guide.
Named list of IP addresses. You can specify an exact match with incoming routes.
For information about this extended match condition, see Configuring Prefix Lists.
Named prefix list. You can specify prefix length qualifiers for the list of prefixes in the prefix list.
For information about this extended match condition, see Configuring Prefix Lists.
Name of the protocol from which the route was learned or to which the route is being advertised. It can be one of the following:
aggregate,bgp,direct,dvmrp,isis,local,ospf,pim-dense,pim-sparse,rip,ripng, orstatic.Name of a routing table. The value of
routing-tablecan be one of the following:
inet.0—Unicast IPv4 routesinstance-name.inet.0—Unicast IPv4 routes for a particular routing instanceinet.1—Multicast IPv4 routesinet.2—Unicast IPv4 routes for multicast reverse-path forwarding (RPF) lookupinet.3—Multiprotocol Label Switching (MPLS) routesmpls.0—MPLS routes for label-switched path (LSP) next hopsinet6.0—Unicast IPv6 routesList of destination prefixes. When specifying a destination prefix, you can specify an exact match with a specific route or a less precise match using match types. You can configure either a common action that applies to the entire list or an action associated with each prefix. For more information, see Configuring Route Lists.
source-address-filterdestination-prefixmatch-type<actions>List of multicast source addresses. When specifying a source address, you can specify an exact match with a specific route or a less precise match using match types. You can configure either a common action that applies to the entire list or an action associated with each prefix. For more information, see Configuring Route Lists.
Tag value. You can specify two tag strings:
tag(for the first string) andtag2. These values are local to the router and can be set on configured routes or by using an import routing policy.You can specify multiple tags under one match condition by including the tags within a bracketed list. For example:
from tag [ tag1 tag2 tag3 ];For OSPF and IS-IS, the
tagandtag2match conditions match the 32-bit tag field in external link-state advertisement (LSA) packets.