2014-08-27 15:30:07 +02:00
|
|
|
table ibgp; # internal BGP peerings
|
|
|
|
table ebgp; # external (icvpn) BGP peerings
|
|
|
|
table freifunk; # synced to kernel table 42 for routing from ff network
|
|
|
|
table unreach; # synced to kernel table 43 to intercept in cases there
|
|
|
|
# is no default route via icvpn
|
2014-08-19 11:14:54 +02:00
|
|
|
|
2014-08-27 15:30:07 +02:00
|
|
|
# quite self explanatory :)
|
2014-08-19 11:14:54 +02:00
|
|
|
define ownas = <%= @ff_as %>;
|
|
|
|
|
2014-08-27 15:30:07 +02:00
|
|
|
# the router id in bird is 32 bit wide and bird allows the IPv4 notation
|
|
|
|
# to set it. quite confusing, but setting it to the gateway's IPv4 address
|
|
|
|
# is a good approach here.
|
2014-03-31 23:18:29 +02:00
|
|
|
router id <%= @own_ipv4 %>;
|
|
|
|
|
2014-08-19 11:14:54 +02:00
|
|
|
### functions ###
|
2014-03-31 23:18:29 +02:00
|
|
|
|
2014-08-27 15:30:07 +02:00
|
|
|
# own networks as of http://wiki.freifunk.net/IPv6:Prefixe and
|
|
|
|
# http://wiki.freifunk.net/IC-VPN
|
|
|
|
# the '+' defines to not only match the prefix length given but
|
|
|
|
# also any smaller prefixes (like 48 and 64)
|
2014-08-19 11:14:54 +02:00
|
|
|
function is_self_net() {
|
|
|
|
return net ~ [ fd51:2bb2:fd0d::/48+,
|
|
|
|
2001:bf7:180::/44+,
|
|
|
|
2001:bf7:190::/44+,
|
|
|
|
2001:bf7:200::/44+,
|
|
|
|
2001:bf7:210::/44+,
|
|
|
|
2001:bf7:220::/44+,
|
|
|
|
2001:bf7:230::/44+];
|
2014-03-31 23:18:29 +02:00
|
|
|
}
|
|
|
|
|
2014-08-19 11:14:54 +02:00
|
|
|
# freifunk ip ranges in general
|
2014-08-27 15:30:07 +02:00
|
|
|
# this is the public address space assigned to the
|
|
|
|
# Foerderverein freie Netzwerke e.V.
|
2014-08-19 11:14:54 +02:00
|
|
|
function is_freifunk() {
|
2014-08-27 15:30:07 +02:00
|
|
|
return net ~ [ 2001:bf7::/32+ ];
|
2014-03-31 23:18:29 +02:00
|
|
|
}
|
|
|
|
|
2014-08-27 15:30:07 +02:00
|
|
|
# unique local addresses
|
|
|
|
# this is the non-public address range used within freifunk
|
|
|
|
# communities and the IC-VPN
|
|
|
|
function is_ula() {
|
|
|
|
return net ~ [ fc00::/7{48,64} ];
|
|
|
|
}
|
|
|
|
|
|
|
|
# default route
|
|
|
|
# be careful with importing default routes from arbitrary peers
|
2014-08-19 11:14:54 +02:00
|
|
|
function is_default() {
|
|
|
|
return net ~ [ ::0/0 ];
|
2014-03-31 23:18:29 +02:00
|
|
|
}
|
|
|
|
|
2014-08-19 11:14:54 +02:00
|
|
|
### kernel ###
|
|
|
|
|
|
|
|
# synchronize from bird to main kernel routing table
|
|
|
|
# nothing in the other direction
|
2014-08-27 15:30:07 +02:00
|
|
|
# do not sync a default route we received to the main routing table
|
|
|
|
# as this might collide with the normal default route of the host
|
2014-08-19 11:14:54 +02:00
|
|
|
protocol kernel k_mast {
|
2014-08-27 15:30:07 +02:00
|
|
|
scan time 20;
|
2014-08-19 11:14:54 +02:00
|
|
|
import none;
|
|
|
|
export where !is_default();
|
|
|
|
};
|
|
|
|
|
|
|
|
# synchronize from birds freifunk table to kernel routing table 42
|
|
|
|
# nothing in the other direction
|
|
|
|
protocol kernel k_frei {
|
2014-08-27 15:30:07 +02:00
|
|
|
scan time 20;
|
2014-08-19 11:14:54 +02:00
|
|
|
table freifunk;
|
|
|
|
kernel table 42;
|
|
|
|
import none;
|
2014-03-31 23:18:29 +02:00
|
|
|
export all;
|
2014-08-19 11:14:54 +02:00
|
|
|
};
|
2014-03-31 23:18:29 +02:00
|
|
|
|
2014-08-27 15:30:07 +02:00
|
|
|
# syncronize from birds unreach table to kernel routing table 43
|
|
|
|
# nothing in the other direction
|
|
|
|
protocol kernel k_unreach {
|
|
|
|
scan time 20;
|
|
|
|
table unreach;
|
|
|
|
kernel table 43;
|
|
|
|
import none;
|
|
|
|
export all;
|
|
|
|
};
|
|
|
|
|
2014-08-19 11:14:54 +02:00
|
|
|
# this pseudo-protocol watches all interface up/down events
|
2014-03-31 23:18:29 +02:00
|
|
|
protocol device {
|
2014-08-27 15:30:07 +02:00
|
|
|
scan time 20;
|
2014-08-19 11:14:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
### pipes ###
|
|
|
|
|
|
|
|
# sync nothing from main routing table to ebgp
|
|
|
|
# sync routes (not own network) from ebgp to main routing table
|
|
|
|
protocol pipe p_maintbl {
|
|
|
|
peer table ebgp;
|
|
|
|
import where !is_self_net();
|
|
|
|
export none;
|
|
|
|
};
|
2014-03-31 23:18:29 +02:00
|
|
|
|
2014-08-19 11:14:54 +02:00
|
|
|
# sync routes (not own network) from ebgp to ibgp
|
|
|
|
# sync routes (all) from ibgp to ebgp
|
|
|
|
protocol pipe p_ibgptbl {
|
|
|
|
table ebgp;
|
|
|
|
peer table ibgp;
|
|
|
|
import all;
|
|
|
|
export where !is_self_net();
|
|
|
|
};
|
|
|
|
|
2014-08-27 15:30:07 +02:00
|
|
|
# sync routes (freifunk, ula and default routes we got) from ibgp to freifunk
|
2014-08-19 11:14:54 +02:00
|
|
|
# sync nothing from freifunk to ibgp
|
|
|
|
protocol pipe p_freitbl {
|
|
|
|
table ibgp;
|
|
|
|
peer table freifunk;
|
|
|
|
import none;
|
2014-08-27 15:30:07 +02:00
|
|
|
export where is_freifunk() || is_default() || is_ula();
|
2014-08-19 11:14:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
### static routes ###
|
|
|
|
|
2014-08-27 15:30:07 +02:00
|
|
|
# here you should define unreachable (=reject) routes for your own
|
|
|
|
# prefixes from http://wiki.freifunk.net/IC-VPN and
|
|
|
|
# http://wiki.freifunk.net/IPv6:Prefixe
|
2014-08-19 11:14:54 +02:00
|
|
|
protocol static static_ffhh {
|
2014-03-31 23:18:29 +02:00
|
|
|
route fd51:2bb2:fd0d::/48 reject;
|
2014-08-19 11:14:54 +02:00
|
|
|
route 2001:bf7:180::/44 reject;
|
|
|
|
route 2001:bf7:190::/44 reject;
|
|
|
|
route 2001:bf7:200::/44 reject;
|
|
|
|
route 2001:bf7:210::/44 reject;
|
|
|
|
route 2001:bf7:220::/44 reject;
|
|
|
|
route 2001:bf7:230::/44 reject;
|
|
|
|
table ebgp;
|
2014-03-31 23:18:29 +02:00
|
|
|
};
|
|
|
|
|
2014-08-27 15:30:07 +02:00
|
|
|
# these are the address ranges used in your network
|
|
|
|
# note that these should be /64 networks in most cases from within
|
|
|
|
# the above bigger ranges
|
2014-03-31 23:18:29 +02:00
|
|
|
protocol static local_ffhh {
|
2014-08-27 15:30:07 +02:00
|
|
|
route fd51:2bb2:fd0d::/64 via "br-ffhh"; # replace br-ffhh with the name
|
|
|
|
route 2001:bf7:180::/64 via "br-ffhh"; # of your freifunk interface
|
2014-08-19 11:14:54 +02:00
|
|
|
table freifunk;
|
2014-03-31 23:18:29 +02:00
|
|
|
};
|
|
|
|
|
2014-08-27 15:30:07 +02:00
|
|
|
# this defines an unreachable default route so that pakets are not forwarded
|
|
|
|
# via the main routing table if no default route exists within table 42
|
|
|
|
# note that this requires an additional rule within your policy routing
|
|
|
|
protocol static unreachable_default {
|
|
|
|
route ::/0 reject;
|
|
|
|
table unreach;
|
|
|
|
};
|
|
|
|
|
2014-08-19 11:14:54 +02:00
|
|
|
### templates ###
|
2014-03-31 23:18:29 +02:00
|
|
|
|
2014-08-19 11:14:54 +02:00
|
|
|
# template for same city freifunk gateways
|
2014-08-27 15:30:07 +02:00
|
|
|
# even the ones which do not have a direct IC-VPN connection
|
2014-05-19 22:17:18 +02:00
|
|
|
template bgp locals {
|
2014-08-19 11:14:54 +02:00
|
|
|
table ibgp;
|
|
|
|
local as ownas;
|
2014-03-31 23:18:29 +02:00
|
|
|
source address <%= @own_ipv6 %>;
|
2014-08-19 11:14:54 +02:00
|
|
|
import filter {
|
|
|
|
preference = 99;
|
|
|
|
accept;
|
|
|
|
};
|
2014-03-31 23:18:29 +02:00
|
|
|
export where source = RTS_BGP;
|
2014-05-19 22:17:18 +02:00
|
|
|
direct;
|
2014-03-31 23:18:29 +02:00
|
|
|
next hop self;
|
|
|
|
};
|
|
|
|
|
|
|
|
<% @peerings_v6.each_pair do |key, hash| -%><% if hash["ip"] != @own_ipv6 -%>
|
|
|
|
protocol bgp <%= key %> from <%= hash["template"] %> {
|
|
|
|
neighbor <%= hash["ip"] %> as <%= hash["as"] %>;
|
|
|
|
};
|
|
|
|
<% end -%><% end -%>
|
2014-04-01 00:05:53 +02:00
|
|
|
|
|
|
|
<% if @gw_do_ic_peering -%>
|
2014-08-19 11:14:54 +02:00
|
|
|
# template for icvpn gateways of other cities
|
2014-05-19 22:17:18 +02:00
|
|
|
template bgp peers {
|
2014-08-19 11:14:54 +02:00
|
|
|
table ebgp;
|
|
|
|
local as ownas;
|
2014-05-19 22:17:18 +02:00
|
|
|
source address <%= @ic_vpn_ip6 %>;
|
2014-08-19 11:14:54 +02:00
|
|
|
# ignore routes for our own network
|
2014-08-27 15:30:07 +02:00
|
|
|
import where (is_freifunk() || is_ula()) && !is_self_net();
|
|
|
|
export where (is_ula() || is_freifunk() || (source = RTS_BGP)) && !is_default();
|
2014-08-19 11:14:54 +02:00
|
|
|
route limit 10000;
|
|
|
|
};
|
|
|
|
|
|
|
|
# template for upstream gateways
|
2014-08-27 15:30:07 +02:00
|
|
|
# that are allowed to announce a default route to us
|
2014-08-19 11:14:54 +02:00
|
|
|
template bgp upstream from peers {
|
|
|
|
# accept freifunk networks and default route
|
2014-08-27 15:30:07 +02:00
|
|
|
import where (is_freifunk() || is_ula() || is_default()) && !is_self_net();
|
2014-05-19 22:17:18 +02:00
|
|
|
};
|
|
|
|
|
2014-04-01 00:05:53 +02:00
|
|
|
<% @ic_peerings_v6.each_pair do |key, hash| -%><% if hash["ip"] != @own_ipv6 -%>
|
|
|
|
protocol bgp <%= key %> from <%= hash["template"] %> {
|
|
|
|
neighbor <%= hash["ip"] %> as <%= hash["as"] %>;
|
|
|
|
};
|
|
|
|
<% end -%><% end -%>
|
|
|
|
<% end -%>
|
2014-08-19 11:14:54 +02:00
|
|
|
|
2014-08-27 15:30:07 +02:00
|
|
|
# this is for local peerings not managed by puppet
|
|
|
|
include "*.peering6";
|