95 lines
2.0 KiB
Django/Jinja
95 lines
2.0 KiB
Django/Jinja
{%- if enable_ospf %}
|
|
{%- if ospf_import_routes %}
|
|
|
|
define ospf_accept4 = [
|
|
{% for route in ospf.accepted_routes[4] %}
|
|
{{ route }}{{"," if not loop.last}}
|
|
{% endfor %}
|
|
];
|
|
define ospf_accept6 = [
|
|
{% for route in ospf.accepted_routes[6] %}
|
|
{{ route }}{{"," if not loop.last}}
|
|
{% endfor %}
|
|
];
|
|
|
|
{% for afi in afis %}
|
|
{% if afi == 4 and enable_ipv4 or afi == 6 %}
|
|
|
|
filter int_ospf_in_v{{ afi }} {
|
|
if net !~ ospf_accept{{ afi }} then {
|
|
print "Reject: OSPF prefix not within ospf accepted routes: ", net;
|
|
reject;
|
|
}
|
|
{% if afi == 6 %}
|
|
if ( net.len = 128 ) then {
|
|
accept;
|
|
}
|
|
if ( net.len > 64 ) then {
|
|
print "Reject: OSPF prefix length not acceptable: ", net;
|
|
reject;
|
|
}
|
|
{% else %}
|
|
if ( net.len = 31 ) then {
|
|
reject;
|
|
}
|
|
{% endif %}
|
|
accept;
|
|
}
|
|
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
# Internal ospf
|
|
protocol ospf v3 {
|
|
ipv6 {
|
|
import keep filtered;
|
|
import {%- if ospf_import_routes %} filter int_ospf_in_v6{%- else %} none{% endif %};
|
|
export none; # do not export anything to ospf, ospf will figure things out itself
|
|
};
|
|
area 0.0.0.0 {
|
|
|
|
{% if enable_routermesh %}
|
|
{% for router in routers if not router == shortname %}
|
|
interface "int-{{ router }}" {
|
|
cost {{ ospf.default_cost }};
|
|
type pointopoint;
|
|
neighbors {
|
|
{{ routers[router]['wg_ll'] }};
|
|
};
|
|
};
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
{%- for interface in interfaces %}
|
|
{% if 'description' in interface %}
|
|
# desc: {{ interface.description }}
|
|
{% endif %}
|
|
interface "{{ interface.nic }}" {
|
|
{% if 'maintenance' in interface and interface.maintenance %}
|
|
cost 65535;
|
|
{% elif 'cost' in interface %}
|
|
cost {{ interface.cost }};
|
|
{% else %}
|
|
cost {{ ospf.default_cost }};
|
|
{% endif %}
|
|
{% if 'type' in interface and interface.type == 'p2p' %}
|
|
type pointopoint;
|
|
{% endif %}
|
|
{% if 'stub' in interface and interface.stub %}
|
|
stub yes;
|
|
{% endif %}
|
|
};
|
|
{% endfor %}
|
|
|
|
interface "dummy-*" {
|
|
cost 100;
|
|
stub yes;
|
|
};
|
|
};
|
|
}
|
|
|
|
{% else %}
|
|
# ospf is not enabled
|
|
{% endif %}
|