dn42: bird4,6

/etc/bird/bird.conf

router id YOUR_INTERNAL_IP;
log syslog all;
define my_as = YOUR_ASN;

protocol kernel {
    persist;
    scan time 20;
    export all;
}

protocol device {
    scan time 10;
}

protocol static {
    route YOUR_INTERNAL_IP/NETMASK reject;
}

## DN42 FILTERING ##
function is_dn42_net(prefix p)
    prefix set include;
    prefix set exclude;
{
    exclude = [
        10.10.10.0/24+          # mgmt and kabel deutschland dns, dhcp
    ];

    include = [
        10.0.0.0/8{12,30},      # Freifunk
        172.22.0.0/15{22,28},       # DN42
        172.22.0.43/32,         # DN42 anycast WHOIS
        172.22.0.53/32,         # DN42 anycast DNS
        94.45.224.0/19,         # CCCV GmbH
        172.31.0.0/16{22,28},       # ChaosVPN
        195.191.196.0/23,       # ichdasich
        46.19.90.48/28,         # Planet Cyborg
        46.19.90.96/28,         # Planet Cyborg
        46.4.248.192/27         # welterde
    ];

    if p ~ exclude then return false;
    if p ~ include then return true;
    return false;
}

## DN42 PEERINGS ##
template bgp dn42_peer {
    local as my_as;
    source address YOUR_INTERNAL_IP;
    import keep filtered;
    import filter {
        if is_dn42_net(net) then {
            accept;
        } else {
            reject;
        }
    };
    export where source = RTS_BGP || source = RTS_STATIC;
}

protocol bgp PEERING_NAME from dn42_peer {
    neighbor INTERNAL_IP as ASN;
}
protocol bgp PEERING_NAME from dn42_peer {
    neighbor INTERNAL_IP as ASN;
}

/etc/bird/bird6.conf

log syslog { info, remote, warning, error, auth, fatal, bug };
router id MY_ROUTER_ID;

define my_as = MY_ASN;
table dn42;

filter dn42_out
prefix set include;
prefix set exclude;
{
#   exclude = [];
    include = [ fd00::/8{48,64}];
#   if net ~ exclude then reject;
    if net ~ include then accept;
    reject;
}

filter dn42_in
prefix set include;
prefix set exclude;
{
        exclude = [     INTERNAL_NETWORK::/64];       # eigenes Subnetz
        include = [     fd00::/8{48,64}];       # ULA dn42
        if net ~ exclude then reject;
        if net ~ include then accept;
        reject;
}

protocol kernel dn42k{
        scan time 10;           # Scan kernel routing table every 20 seconds
        table dn42;
        export filter {
                if net ~ [ INTERNAL_NETWORK ] then {
                        reject;
                }   
                accept;
        };  
        import none;
}

protocol device {
    scan time 10;       # Scan interfaces every 10 seconds
}

protocol static {
        table dn42;
        route INTERNAL_NETWORK via "lo";
}

protocol bgp dn42_PEERNAME {
    table dn42;
    local as my_as;

    source address INTERNAL_ADDRESS;
    neighbor EXTERNAL_ADDRESS as EXTERNAL_ASN;

    import keep filtered;
    import filter dn42_in;
    export filter dn42_out;
}