|
| 1 | +{# EVPN config using mac-vrf & co #} |
| 2 | + |
| 3 | +{# Enable BGP EVPN for specific neighbors #} |
| 4 | +protocols { |
| 5 | + bgp { |
| 6 | +{% for af in ['ipv4','ipv6'] if bgp[af] is defined and loopback[af] is defined %} |
| 7 | + group ibgp-peers-{{ af }} { |
| 8 | +{% for n in bgp.neighbors if n[af] is defined and n.type == 'ibgp' and n.evpn|default(false) %} |
| 9 | + neighbor {{ n[af] }} { |
| 10 | + family evpn { |
| 11 | + signaling; |
| 12 | + } |
| 13 | + } |
| 14 | +{% endfor %} |
| 15 | + } |
| 16 | +{% endfor %} |
| 17 | + group ebgp-peers { |
| 18 | +{% for n in bgp.neighbors if n.type == 'ebgp' and n.evpn|default(false) %} |
| 19 | +{% for af in ['ipv4','ipv6'] if n[af] is defined %} |
| 20 | + neighbor {{ n[af] }} { |
| 21 | + accept-remote-nexthop; |
| 22 | + family evpn { |
| 23 | + signaling; |
| 24 | + } |
| 25 | + } |
| 26 | +{% endfor %} |
| 27 | +{% endfor %} |
| 28 | + } |
| 29 | + } |
| 30 | +} |
| 31 | + |
| 32 | +{# VERY DIRTY HACK here for initial testing - since we can specify only one vrf-target per vni-option, let's use the first import one #} |
| 33 | +{# - do it only if vxlan is defined - no need if we are RR only #} |
| 34 | +{% if vxlan is defined %} |
| 35 | +protocols { |
| 36 | + evpn { |
| 37 | + encapsulation vxlan; |
| 38 | + default-gateway no-gateway-community; |
| 39 | + extended-vni-list all; |
| 40 | +{% if vxlan.vlans is defined %} |
| 41 | + vni-options { |
| 42 | +{% for vname in vxlan.vlans if vlans[vname].vni is defined %} |
| 43 | +{% set vlan = vlans[vname] %} |
| 44 | + vni {{ vlan.vni }} { |
| 45 | + vrf-target target:{{ vlan.evpn.import[0] }}; |
| 46 | + } |
| 47 | +{% endfor %} |
| 48 | + } |
| 49 | +{% endif %} |
| 50 | + } |
| 51 | +} |
| 52 | +{% endif %} |
| 53 | + |
| 54 | + |
| 55 | +{# define L3VNI on vrf routing-instance #} |
| 56 | +{% if vrfs is defined %} |
| 57 | +routing-instances { |
| 58 | + |
| 59 | +{% for n,v in vrfs.items() if v.af is defined and v.evpn is defined %} |
| 60 | + {{ n }} { |
| 61 | + protocols { |
| 62 | + evpn { |
| 63 | + irb-symmetric-routing { |
| 64 | + vni {{ v.evpn.transit_vni }}; |
| 65 | + } |
| 66 | + ip-prefix-routes { |
| 67 | + advertise direct-nexthop; |
| 68 | + encapsulation vxlan; |
| 69 | + vni {{ v.evpn.transit_vni }}; |
| 70 | + export vrf-{{n}}-ebgp-export; |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + route-distinguisher {{ v.evpn.rd }}; |
| 75 | + } |
| 76 | +{% endfor %} |
| 77 | + |
| 78 | +} |
| 79 | + |
| 80 | +{# update ospf, ibgp and ebgp export policy options for VRFs #} |
| 81 | +policy-options { |
| 82 | +{% for n,v in vrfs.items() if v.af is defined and v.evpn is defined %} |
| 83 | + policy-statement vrf-{{n}}-ospf-export { |
| 84 | + term redis_evpn { |
| 85 | + from protocol evpn; |
| 86 | + then accept; |
| 87 | + } |
| 88 | + } |
| 89 | + policy-statement vrf-{{n}}-ibgp-export { |
| 90 | + term redis_evpn { |
| 91 | + from protocol evpn; |
| 92 | + then accept; |
| 93 | + } |
| 94 | + } |
| 95 | + policy-statement vrf-{{n}}-ebgp-export { |
| 96 | + term redis_evpn { |
| 97 | + from protocol evpn; |
| 98 | + then accept; |
| 99 | + } |
| 100 | + term redis_bgp { |
| 101 | + from protocol bgp; |
| 102 | + then accept; |
| 103 | + } |
| 104 | + } |
| 105 | +{% endfor %} |
| 106 | +} |
| 107 | + |
| 108 | +{# according to JunOS doc, in case NO ANYCAST GATEWAY is configured, enable 'proxy-macip-advertisement' on central IRB interfaces #} |
| 109 | +interfaces { |
| 110 | +{% for vname in vxlan.vlans|default([]) if vlans[vname].vni is defined and vlans[vname].mode|default('') == 'irb' and vlans[vname].vrf is defined %} |
| 111 | +{% set vlan = vlans[vname] %} |
| 112 | +{% if not vlan.gateway|default(false) %} |
| 113 | + irb.{{ vlan.id }} { |
| 114 | + proxy-macip-advertisement; |
| 115 | + } |
| 116 | +{% endif %} |
| 117 | +{% endfor %} |
| 118 | +} |
| 119 | + |
| 120 | +{% endif %} |
0 commit comments