Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?


Routing policies for EVPN

SUMMARY Create routing policies to control the EVPN routing information that will be imported and exported to the different routing tables.

Routing policies allow you to control the routing information that the device imports and exports to the routing and forwarding tables. Starting in Junos OS 19.4R1, Junos has expanded routing policy support to include creating and applying policy filters specific to EVPN routes.

You can apply policies at the routing-instance level or at the BGP group level. When you apply policies at the BGP group level, they affect all EVPN routing instances. When applied at the routing-instance level, they affect the specified EVPN routing instance only. To apply the policy at the BGP group level, include the vpn-apply-export statement at the [edit protocols bgp] hierarchy level, and import or export the policy. To apply the policy at the routing-instance level, use the vrf-export or vrf-import statement to apply the policy for that routing instance.


You can modify EVPN Type 1 route advertisements through vrf-export policy configuration. You must configure the policy with the accept clause for the target communities you want advertised or they will be rejected by the default policy action.

Policies are composed of match conditions, actions, and terms. For more information on policies, see Policy Framework Overview.

Table 1 lists the match conditions supported for use in filtering EVPN routes.

Table 1: List of Match Conditions for Filtering EVPN Routes

Match Condition


community [names]

BGP EVPN routes can have a set of EVPN extended communities carried in the BGP update message path attribute, and as such, you can use these extended communities for filtering BGP EVPN routes. The EVPN specific information available in extended communities includes, for example, encapsulation type, MAC-mobility information, EVPN split-horizon label information, EVPN ESI split-horizon label, ESI mode, E-tree leaf label, and more.

Use the following syntax to specify BGP EVPN extended communities:

  • set policy-options community name members type:val1:val2

All values (including type) are in decimal; type is 2 octets, with the higher-order octet defining the type of extended community, and the low-order octet defining the community sub-type. val1 and val2 can be specified as [2 + 4] octets, or as [4 + 2] octets.

The extended communities most commonly used with BGP EVPN routes are provided here.


Low-order (Sub-type)

Type (Hex)

Type (Dec)






BGP Encapsulation





Default Gateway





EVPN MAC Mobility










EVPN ES-Import Route Target





EVPN Layer 2 Attributes






For full list of Extended Communities please refer to Border Gateway Protocol (BGP) Extended Communities .


You can filter BGP EVPN routes on the basis of Ethernet Segment Identifiers (ESIs) information for routes types 1, 2, 4, 7, and 8, which are the only types to include the ESI attribute in their prefix. (ESI values are encoded as 10-byte integers and are used to identify a multihomed segment.) Note that the evpn-esi matching statement is valid only together with “family evpn” matching statement.


You can filter BGP EVPN routes on the basis of EVPN Ethernet Tag information, which is part of the prefix of the EVPN route. This matching statement is valid only together with family evpn match statement.


Filtering BGP EVPN Type 2 routes based on if it has any IP address.

EVPN Type 2 MAC/IP Advertisement routes can have IP address in the prefix along with MAC address. The IP address carried in the MAC-IP Advertisement route can be either IPv4 or IPv6 address. It is possible to filter out Type 2 routes based on MAC address only, MAC+IPv4 address, or MAC+IPv6 address. To do so requires the following CLI statement be set:

  • from evpn-mac-route [ mac-ipv4 | mac-ipv6 | mac-only ]

Note that this match statement is valid only together with the family evpn match statement.


Set the local preference (LOCAL_PREF) attribute. The preference value can be a number in the range from 0 through 4,294,967,295.


(BGP only) Named MAC filter list. EVPN Type 2 routes have MAC address as part of the prefix, which you can use to create a list of MAC addresses.


Metric corresponds to the MED, and metric2 corresponds to the IGP metric if the BGP next hop loops through another router. You can specify up to four metric values, metric, metric2, metric3, and metric4.

next-hop (address | discard | next-table table-name | peer-address | reject | self)

Requires IBGP or EBGP confederations (third-party next hop must be advertised).

  • discard—The next-hop address is replaced by a discard next hop.

  • next-table—The routing device performs a forwarding lookup in the specified table.

  • self—The next-hop address is replaced by one of the local routing device’s addresses, as determined by the advertising protocol, typically the local IP address used for the BGP adjacency.

  • specify peer-address—The next-hop address is replaced by the peer’s IP address (import only), typically an advertising routing device or another directly connected routing device.


For EVPN, NLRI route types range from 1 to 8 (the first octet of the route prefix in the BGP update message is the EVPN route type).

Multiple route types can be specified in a single policy.


Set the BGP path origin attribute to one of the following values:

  • egp—Path information originated in another AS.

  • igp—Path information originated within the local AS.

  • incomplete—Path information learned by some other means.

prefix-list-filter prefix-list-name match-type

Both prefix-list and prefix-list-filter match conditions are supported. prefix-list is similar to prefix-list-filter,with the exception that a match-type can be specified only with prefix-list-filter. You can specify prefix length qualifiers for the list of prefixes in the prefix list.

When used with EVPN NRLI route Types 2 and 5, the following are supported:

  • from prefix-list-filter [ exact | longer | orlonger ]


Value of the route-distinguisher (RD).

Filtering BGP EVPN routes based on RD is supported. The RD information is carried in the prefix of the EVPN route.



Named route filter or route filter list. You can specify prefix length qualifiers for the list of routes in the route filter list.

When used with EVPN NRLI route types 2 and 5, the following are supported:

  • from route-filter [ address-mask | exact | longer | orlonger | prefix-length-range | through | upto ]

When using policy filters to filter EVPN routes, in Junos OS Release 19.4R1 and later, the following policy actions are supported (that is, they can be specified as the then qualifier in the policy).

Table 2 lists actions that can be used when filtering EVPN routes.

Table 2: List of Actions for Filtering EVPN Routes




Accept a route.

apply-groups group-name

Apply a configuration group to a policy. If you specify more than one group name, the first group listed takes priority over the next, and so on.

apply-groups-except group-name

Disable inheritance of a configuration group. This action is useful when you use the apply-group statement in a policy but also want to override the values inherited from the configuration group for a specific parameter.


Appends one or more AS numbers at the beginning of the AS path. If you are specifying more than one AS number, include the numbers in quotation marks.

The AS numbers are added after the local AS number has been added to the path. This action adds AS numbers to AS sequences only, not to AS sets. If the existing AS path begins with a confederation sequence or set, the appended AS numbers are placed within a confederation sequence. Otherwise, the appended AS numbers are placed with a non-confederation sequence.


Accept or Reject any action log protocol by overriding them. This is a non-terminating policy action.


Skip to next policy or term.


Sets the BGP local preference attribute for the route. The preference can be a number from 0 through 4,294,967,295), with lower numbers being more preferred. Selected routes are installed into the forwarding table.


Set the priority for route installation: high, low, or medium. High priority routes are updated first in the in the RIB (routing table) and the FIB (forwarding table), before medium and low priority routes. Routes are placed in different priority queues according to the priority.


Rejects the route and does not propagate it. After a route is rejected, no other terms in the routing policy and no other routing policies are evaluated.

tag (add | subtract) tag2 (add | subtract) number

Change the tag value by the specified amount.