2017-09-10 23:56:34 +02:00
|
|
|
#
|
|
|
|
# {{ ansible_managed }}
|
|
|
|
#
|
|
|
|
|
|
|
|
# Variables
|
2019-03-20 10:21:38 +01:00
|
|
|
define router_id = {{ loopback_net_ipv4 | ipaddr('net') | ipaddr(magic) | ipaddr('address') }};
|
|
|
|
define loopback_address = {{ loopback_net_ipv4 | ipaddr('net') | ipaddr(magic) | ipaddr('address') }};
|
2019-03-19 15:23:12 +01:00
|
|
|
define mwu_address_legacy = {{ bgp_ipv4_transfer_net_legacy | ipaddr('net') | ipaddr(magic) | ipaddr('address') }};
|
2019-03-02 18:10:48 +01:00
|
|
|
define mwu_as = {{ as_private }};
|
2017-09-10 23:56:34 +02:00
|
|
|
|
|
|
|
# General
|
|
|
|
timeformat protocol iso long;
|
|
|
|
router id router_id;
|
|
|
|
|
|
|
|
# Functions
|
|
|
|
function is_default() {
|
|
|
|
return net ~ [
|
|
|
|
0.0.0.0/0
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function is_freifunk() {
|
|
|
|
return net ~ [
|
|
|
|
10.0.0.0/8{16,24}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function is_dn42() {
|
|
|
|
return net ~ [
|
|
|
|
172.20.0.0/14{20,28}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function is_chaosvpn() {
|
|
|
|
return net ~ [
|
|
|
|
172.31.0.0/16+
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2018-10-31 20:58:56 +01:00
|
|
|
function is_mwu_self_nets_loose() {
|
2017-09-10 23:56:34 +02:00
|
|
|
return net ~ [
|
2019-03-02 18:10:48 +01:00
|
|
|
{% for prefix in internal_prefixes %}
|
2018-10-31 20:58:56 +01:00
|
|
|
{{ prefix.ipv4 | ipaddr('net') }}+{{ "," if not loop.last else "" }}
|
2018-10-31 20:58:56 +01:00
|
|
|
{% endfor %}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2018-10-31 20:58:56 +01:00
|
|
|
function is_mwu_self_nets_strict() {
|
|
|
|
return net ~ [
|
2019-03-02 18:10:48 +01:00
|
|
|
{% for prefix in internal_prefixes %}
|
2018-10-31 20:58:56 +01:00
|
|
|
{{ prefix.ipv4 | ipaddr('net') }}{{ "," if not loop.last else "" }}
|
|
|
|
{% endfor %}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function is_mwu_loopback() {
|
|
|
|
return net ~ [
|
2019-03-02 18:10:48 +01:00
|
|
|
{{ loopback_net_ipv4 }}+
|
2018-10-31 20:58:56 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
function is_mwu_anycast() {
|
|
|
|
return net ~ [
|
2019-03-02 18:10:48 +01:00
|
|
|
{{ anycast_ipv4 }}
|
2018-10-31 20:58:56 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2017-09-10 23:56:34 +02:00
|
|
|
# Protocols
|
|
|
|
protocol device {
|
|
|
|
scan time 30;
|
|
|
|
};
|
|
|
|
|
|
|
|
protocol direct mwu_subnets {
|
2019-03-19 15:23:12 +01:00
|
|
|
{% if server_type == 'gateway' or server_type == 'monitoring' %}
|
2017-10-06 22:58:00 +02:00
|
|
|
{% for mesh in meshes %}
|
2017-11-06 21:24:56 +01:00
|
|
|
interface "{{ mesh.id }}br";
|
2019-03-19 15:23:12 +01:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% for network in my_wireguard_networks %}
|
|
|
|
interface "wg-{{ network.remote[:11] }}";
|
2017-09-10 23:56:34 +02:00
|
|
|
{% endfor %}
|
2018-10-31 20:58:56 +01:00
|
|
|
import where is_mwu_self_nets_loose();
|
|
|
|
};
|
|
|
|
|
|
|
|
protocol direct mwu_loopback {
|
|
|
|
interface "loopback";
|
|
|
|
import where is_mwu_loopback();
|
|
|
|
};
|
|
|
|
|
2019-03-02 18:10:48 +01:00
|
|
|
{% if server_type == "gateway" %}
|
2018-10-31 20:58:56 +01:00
|
|
|
protocol direct mwu_anycast {
|
|
|
|
interface "anycast";
|
|
|
|
import where is_mwu_anycast();
|
|
|
|
};
|
|
|
|
|
|
|
|
protocol static {
|
2019-03-02 18:10:48 +01:00
|
|
|
{% for prefix in internal_prefixes %}
|
2018-10-31 20:58:56 +01:00
|
|
|
route {{ prefix.ipv4 }} reject;
|
|
|
|
{% endfor %}
|
|
|
|
};
|
2019-03-19 15:23:12 +01:00
|
|
|
{% endif %}
|
2018-10-31 20:58:56 +01:00
|
|
|
|
|
|
|
protocol kernel kernel_mwu {
|
|
|
|
scan time 30;
|
|
|
|
import none;
|
|
|
|
export filter {
|
2019-03-20 10:21:38 +01:00
|
|
|
krt_prefsrc = loopback_address;
|
2019-03-02 18:10:48 +01:00
|
|
|
{% if server_type == "gateway" %}
|
2018-10-31 20:58:56 +01:00
|
|
|
if is_mwu_anycast() then reject;
|
2018-11-30 18:18:25 +01:00
|
|
|
{% else %}
|
|
|
|
if is_mwu_anycast() then accept;
|
2019-03-19 15:23:12 +01:00
|
|
|
if is_freifunk() then accept;
|
|
|
|
if is_chaosvpn() then accept;
|
|
|
|
if is_dn42() then accept;
|
2018-11-30 18:18:25 +01:00
|
|
|
{% endif %}
|
2018-10-31 20:58:56 +01:00
|
|
|
if is_mwu_loopback() then accept;
|
|
|
|
reject;
|
|
|
|
};
|
2019-05-22 09:18:40 +02:00
|
|
|
merge paths yes limit {{ groups['gateways'] | length }};
|
2018-10-31 20:58:56 +01:00
|
|
|
kernel table ipt_mwu;
|
2017-09-10 23:56:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
# Templates
|
|
|
|
template bgp ibgp_mwu {
|
2019-03-19 15:23:12 +01:00
|
|
|
local as mwu_as;
|
2017-09-10 23:56:34 +02:00
|
|
|
import keep filtered on;
|
2018-10-31 20:58:56 +01:00
|
|
|
import filter {
|
2019-03-02 18:10:48 +01:00
|
|
|
{% if server_type == "gateway" %}
|
2018-10-31 20:58:56 +01:00
|
|
|
if is_mwu_anycast() then reject;
|
2018-11-30 18:18:25 +01:00
|
|
|
{% endif %}
|
2019-03-19 15:23:12 +01:00
|
|
|
if is_mwu_loopback() then accept;
|
2018-10-31 20:58:56 +01:00
|
|
|
if is_mwu_self_nets_loose() then accept;
|
|
|
|
if is_freifunk() then accept;
|
|
|
|
if is_chaosvpn() then accept;
|
|
|
|
if is_dn42() then accept;
|
|
|
|
reject;
|
|
|
|
};
|
|
|
|
export filter {
|
2019-03-19 15:23:12 +01:00
|
|
|
{% if server_type == "gateway" %}
|
|
|
|
if is_mwu_loopback() then accept;
|
2018-10-31 20:58:56 +01:00
|
|
|
if is_mwu_self_nets_loose() then accept;
|
|
|
|
if source = RTS_BGP then accept;
|
2019-03-19 15:23:12 +01:00
|
|
|
{% else %}
|
|
|
|
if is_mwu_loopback() then accept;
|
|
|
|
{% endif %}
|
2018-10-31 20:58:56 +01:00
|
|
|
reject;
|
|
|
|
};
|
2017-09-10 23:56:34 +02:00
|
|
|
direct;
|
|
|
|
gateway direct;
|
|
|
|
};
|
|
|
|
|
|
|
|
# Include IPv4 MWU peers
|
|
|
|
include "mwu_ipv4_peers.con?";
|
2019-03-02 18:10:48 +01:00
|
|
|
{% if server_type == "gateway" %}
|
2017-09-10 23:56:34 +02:00
|
|
|
|
|
|
|
# Include IPv4 ICVPN configuration
|
|
|
|
include "icvpn_ipv4.con?";
|
|
|
|
|
|
|
|
# Include IPv4 FFRL configuration
|
|
|
|
include "ffrl_ipv4.con?";
|
2018-10-04 19:30:37 +02:00
|
|
|
{% endif %}
|