Description

This article describes the behavior and limitations encountered when attempting to control the route preference of EVPN Type-5 routes during the migration from a legacy OSPF environment to an EVPN-based architecture on Juniper devices.

Symptoms

  • After migrating gateways for specific VLANs from OSPF to EVPN Type-5, border routers see the same prefixes learned from both OSPF and EVPN.
  • The OSPF external route (preference 150 by default) is always preferred over the EVPN T5 route (preference 170 by default).
  • Attempts to influence T5 route preference in the VRF using import policies (e.g., matching on communities or next-hop) are unsuccessful.
  • Routing loops or suboptimal routing may occur if both OSPF and EVPN advertise the same prefix during migration.
  • Only local preference and AS path attributes are inherited and can be manipulated for T5 routes using import policy; Junos protocol preference is fixed.

Solution

  • EVPN Type-5 preference is hardcoded at 170 in Junos and cannot be dynamically adjusted with import policy.
  • Supported attributes that can be set for Type-5 routes via vrf-import policy are local-preference and AS-path-prepend.
  • Protocol preference is used to select between routes from different protocols (e.g., OSPF vs. EVPN). Local preference and AS-path are used for BGP path selection between multiple EVPN T5 routes only.

Workarounds & Best Practices

  • To control which routes are preferred during migration, use OSPF import or export policy with prefix-lists to deny OSPF routes for subnets that have migrated to EVPN.
  • Alternatively, you can globally adjust the OSPF protocol preference to a value higher than 170 if all EVPN T5 routes should be preferred (not recommended for granular control).

Example: OSPF Policy to Prevent Routing Loops

policy-options {

  prefix-list MIGRATED_TO_EVPN {

    10.10.71.0/24;

    ...

  }

  policy-statement BLOCK_OSPF_MIGRATED {

    term DENY {

      from {

        prefix-list MIGRATED_TO_EVPN;

      }

      then reject;

    }

    term ACCEPT {

      then accept;

    }

  }

}

protocols {

  ospf {

    import BLOCK_OSPF_MIGRATED;

    ...

  }

}

Modification History

2025-07-29 : Article Created