ansible-ffibk/roles/service-bird/templates/bird.conf.j2

140 lines
2.7 KiB
Text
Raw Normal View History

2017-09-10 23:56:34 +02:00
#
# {{ ansible_managed }}
#
# Variables
define mwu_address = {{ bgp_ipv4_transfer_net | ipaddr('net') | ipaddr(magic) | ipaddr('address') }};
define mwu_as = {{ as_private_mwu }};
define router_id = {{ bgp_loopback_net | ipaddr('net') | ipaddr(magic) | ipaddr('address') }};
# 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+
];
}
function is_mwu_self_nets_loose() {
2017-09-10 23:56:34 +02:00
return net ~ [
{% for prefix in ffmwu_internal_prefixes %}
{{ prefix.ipv4 | ipaddr('net') }}+{{ "," if not loop.last else "" }}
{% endfor %}
];
}
function is_mwu_self_nets_strict() {
return net ~ [
{% for prefix in ffmwu_internal_prefixes %}
{{ prefix.ipv4 | ipaddr('net') }}{{ "," if not loop.last else "" }}
{% endfor %}
];
}
function is_mwu_loopback() {
return net ~ [
{{ ffmwu_loopback_net_ipv4 }}+
];
}
function is_mwu_anycast() {
return net ~ [
{{ ffmwu_anycast_ipv4 }}
];
}
2017-09-10 23:56:34 +02:00
# Protocols
protocol device {
scan time 30;
};
protocol direct mwu_subnets {
{% for mesh in meshes %}
2017-11-06 21:24:56 +01:00
interface "{{ mesh.id }}br";
2017-09-10 23:56:34 +02:00
{% endfor %}
import where is_mwu_self_nets_loose();
};
protocol direct mwu_loopback {
interface "loopback";
import where is_mwu_loopback();
};
{% if ffmwu_server_type == "gateway" %}
protocol direct mwu_anycast {
interface "anycast";
import where is_mwu_anycast();
};
{% endif %}
protocol static {
{% for prefix in ffmwu_internal_prefixes %}
route {{ prefix.ipv4 }} reject;
{% endfor %}
};
protocol kernel kernel_mwu {
scan time 30;
import none;
export filter {
if is_mwu_anycast() then reject;
if is_mwu_loopback() then accept;
reject;
};
kernel table ipt_mwu;
2017-09-10 23:56:34 +02:00
};
# Templates
template bgp ibgp_mwu {
local mwu_address as mwu_as;
import keep filtered on;
import filter {
if is_mwu_anycast() then reject;
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 {
if is_mwu_anycast() then reject;
if is_mwu_self_nets_loose() then accept;
if source = RTS_BGP then accept;
reject;
};
2017-09-10 23:56:34 +02:00
direct;
gateway direct;
};
# Include IPv4 MWU peers
include "mwu_ipv4_peers.con?";
{% if ffmwu_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?";
{% endif %}