forked from ipspace/netlab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouteros7.j2
More file actions
42 lines (34 loc) · 1.26 KB
/
Copy pathrouteros7.j2
File metadata and controls
42 lines (34 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{% import "routeros7.macro.j2" as bgpcfg %}
/routing/bgp/template add name=main as={{ bgp.as }} output.network=bgp-networks
{# Needed for > 7.18 #}
/routing/bgp/instance add name=main as={{ bgp.as }}
{% if bgp.router_id is defined %}
{# /routing/bgp/template set main router-id={{ bgp.router_id }} #}
{# Needed for > 7.18 #}
/routing/id add name=bgp_router_id id={{ bgp.router_id }} select-dynamic-id=""
{% endif %}
{% if bgp.rr|default(False) and bgp.rr_cluster_id|default(False) %}
/routing/bgp/template set main cluster-id={{ bgp.rr_cluster_id }}
{% endif %}
{% for n in bgp.neighbors %}
{% for af in ['ipv4','ipv6'] if n[af] is defined %}
{{ bgpcfg.neighbor(n,n[af],bgp,'main') }}
{% endfor %}
{% endfor %}
{# Set networks to announce #}
{% for af in ['ipv4','ipv6'] %}
{% if bgp[af] is defined %}
{% for l in netlab_interfaces if l.bgp.advertise|default("") and l[af] is defined and not 'vrf' in l %}
{{ bgpcfg.bgp_network(af,l[af]) }}
{% endfor %}
{% for pfx in bgp.originate|default([]) if af == 'ipv4' %}
{{ bgpcfg.bgp_network(af,pfx) }}
{% endfor %}
{% endif %}
{% endfor %}
{#
Add extra IPv4 prefixes
#}
{% for pfx in bgp.originate|default([]) %}
/ip route add blackhole dst-address={{ pfx|ansible.utils.ipaddr('0') }}
{% endfor %}