## /etc/bird.conf ################################################ # Variable header # ################################################ define OWNAS = 4242423521; define OWNIP = 172.21.99.81; define OWNIPv6 = fdd0:f8f8:a076::1; define OWNNET = 172.21.99.80/29; define OWNNETv6 = fdd0:f8f8:a076::/48; define OWNNETSET = [172.21.99.80/29+]; define OWNNETSETv6 = [fdd0:f8f8:a076::/48+]; ################################################ # Header end # ################################################ router id OWNIP; protocol device { scan time 10; } # log syslog { warning, error, fatal, remote, auth }; log syslog all; /* * Utility functions */ #filter only_my_v4 { # if net = 172.21.99.80/29 then accept; # reject; #} #filter only_my_v6 { # if net = fdd0:f8f8:a076::/48 then accept; # reject; #} function is_self_net() { return net ~ OWNNETSET; } function is_self_net_v6() { return net ~ OWNNETSETv6; } function is_valid_network() { return net ~ [ 172.20.0.0/14{21,29}, # dn42 172.20.0.0/24{28,32}, # dn42 Anycast 172.21.0.0/24{28,32}, # dn42 Anycast 172.22.0.0/24{28,32}, # dn42 Anycast 172.23.0.0/24{28,32}, # dn42 Anycast 172.31.0.0/16+, # ChaosVPN 10.100.0.0/14+, # ChaosVPN 10.127.0.0/16+, # neonetwork 10.0.0.0/8{15,24} # Freifunk.net ]; } roa4 table dn42_roa; roa6 table dn42_roa_v6; protocol static { roa4 { table dn42_roa; }; include "/tmp/roav4.conf"; }; protocol static { roa6 { table dn42_roa_v6; }; include "/tmp/roav6.conf"; }; function is_valid_network_v6() { return net ~ [ fd00::/8{44,64} # ULA address space as per RFC 4193 ]; } protocol kernel { scan time 20; ipv6 { import none; export filter { if source = RTS_STATIC then reject; krt_prefsrc = OWNIPv6; accept; }; }; }; protocol kernel { scan time 20; ipv4 { import none; export filter { if source = RTS_STATIC then reject; krt_prefsrc = OWNIP; accept; }; }; } protocol static { route OWNNET reject; ipv4 { import all; export none; }; } protocol static { route OWNNETv6 reject; ipv6 { import all; export none; }; } template bgp dnpeers { local as OWNAS; path metric 1; ipv4 { import filter { if is_valid_network() && !is_self_net() then { if (roa_check(dn42_roa, net, bgp_path.last) != ROA_VALID) then { # Reject when unknown or invalid according to ROA print "[dn42] ROA check failed for ", net, " ASN ", bgp_path.last; reject; } else accept; } else reject; }; export filter { if net ~ OWNNET then accept; reject; }; import limit 9000 action block; }; ipv6 { import filter { if is_valid_network_v6() && !is_self_net_v6() then { if (roa_check(dn42_roa_v6, net, bgp_path.last) != ROA_VALID) then { # Reject when unknown or invalid according to ROA print "[dn42] ROA check failed for ", net, " ASN ", bgp_path.last; reject; } else accept; } else reject; }; export filter { if net ~ OWNNETv6 then accept; reject; }; import limit 9000 action block; }; } include "/etc/bird/peers/*"; ## /etc/bird/peers/peer.comf ## <..> protocol bgp marek_v6 from dnpeers { neighbor fe80::42:815%dn42_marek as 4242422924; direct; #multihop; ipv4 { import all; extended next hop yes; }; } ## <..>