123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- ################################################
- # Variable header #
- ################################################
- define DN42AS = {{ dn42.asn }};
- define NEOAS = {{ neonetwork.asn }};
- # Default ASN
- define OWNAS = DN42AS;
- define DN42IP = {{ dnet.dn42 }};
- define DN42IPv6 = {{ dnet.dn42v6 }};
- define NEOIP = {{ dnet.neo }};
- define NEOIPv6 = {{ dnet.neov6 }};
- define CRXNIP = {{ dnet.crxn }};
- {% for net in dn42.ipv4nets %}
- define DN42NET{{ loop.index }} = {{ net }};
- {% endfor %}
- {% for net in dn42.ipv6nets %}
- define DN42NET{{ loop.index }}v6 = {{ net }};
- {% endfor %}
- {% for net in neonetwork.ipv4nets %}
- define NEONET{{ loop.index }} = {{ net }};
- {% endfor %}
- {% for net in neonetwork.ipv6nets %}
- define NEONET{{ loop.index }}v6 = {{ net }};
- {% endfor %}
- {% for net in crxn.nets %}
- define CRXNNET{{ loop.index }} = {{ net }};
- {% endfor %}
- {% set comma = joiner(",") %}
- define DN42NETSET = [{% for net in dn42.ipv4nets %}{{ comma() }}{{ net }}+{% endfor %}];
- {% set comma = joiner(",") %}
- define DN42NETSETv6 = [{% for net in dn42.ipv6nets %}{{ comma() }}{{ net }}+{% endfor %}];
- {% set comma = joiner(",") %}
- define NEONETSET = [{% for net in neonetwork.ipv4nets %}{{ comma() }}{{ net }}+{% endfor %}];
- {% set comma = joiner(",") %}
- define NEONETSETv6 = [{% for net in neonetwork.ipv6nets %}{{ comma() }}{{ net }}+{% endfor %}];
- {% set comma = joiner(",") %}
- define CRXNNETSET = [{% for net in crxn.nets %}{{ comma() }}{{ net }}+{% endfor %}];
- define DN_REGION_GEO = {{ dnet.region_geo }};
- define DN_REGION_COUNTRY = {{ dnet.region_country }};
- define BANDWIDTH = {{ dnet.bandwidth }};
- ################################################
- # Header end #
- ################################################
- router id DN42IP;
- protocol device {}
- include "/etc/bird/netids.conf";
- /*
- * Utility functions
- */
- function is_self_net() -> bool {
- return net ~ DN42NETSET || net ~ DN42NETSETv6 || net ~ NEONETSET || net ~ NEONETSETv6 || net ~ CRXNNETSET;
- }
- function is_neonetwork() -> bool {
- return net ~ [10.127.0.0/16+] || net ~ [fd10:127::/32+];
- }
- function is_valid_network() -> bool {
- 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{16,32}, # neonetwork
- 10.0.0.0/8{15,24} # Freifunk.net
- ] && net !~ [10.115.0.0/16+]) # Meshtastic
- || (net !~ [fd7a:115c:a1e0::/96+] && net ~ [ fd00::/8{44,64} ]);
- }
- function is_notsub_self_net() -> bool {
- {% set comma = joiner("||") %}
- return (
- {% for net in dn42.ipv4nets %}
- {{ comma() }} net = DN42NET{{ loop.index }}
- {% endfor %}
- {% for net in dn42.ipv6nets %}
- {{ comma() }} net = DN42NET{{ loop.index }}v6
- {% endfor %}
- {% for net in neonetwork.ipv4nets %}
- {{ comma() }} net = NEONET{{ loop.index }}
- {% endfor %}
- {% for net in neonetwork.ipv6nets %}
- {{ comma() }} net = NEONET{{ loop.index }}v6
- {% endfor %}
- {% for net in crxn.nets %}
- {{ comma() }} net = CRXNNET{{ loop.index }}
- {% endfor %}
- );
- }
- include "/etc/bird/crxn_utilits.conf";
- /*
- * ROA dn42 & neo
- */
- roa4 table dn42_roa;
- roa6 table dn42_roa_v6;
- protocol static {
- roa4 { table dn42_roa; };
- include "/var/lib/bird/dn42-roa4.conf";
- };
- protocol static {
- roa6 { table dn42_roa_v6; };
- include "/var/lib/bird/dn42-roa6.conf";
- };
- /*
- * Forward plane
- */
- protocol kernel {
- scan time 20;
- metric 500;
- ipv4 {
- import none;
- export filter {
- if source = RTS_DEVICE then reject;
- if (has_netid(0)) then {
- print "Warning: Netid 0 found", net;
- reject;
- } else if (has_netid(2)) then {
- print "Warning: CRXN netid in IPv4", net;
- reject;
- } else if (has_netid(4)) then {
- krt_prefsrc = NEOIP;
- } else {
- krt_prefsrc = DN42IP;
- }
- accept;
- };
- };
- }
- protocol kernel {
- scan time 20;
- metric 500;
- ipv6 {
- import none;
- export filter {
- if source = RTS_DEVICE then reject;
- if (has_netid(0)) then {
- print "Warning: Netid 0 found", net;
- reject;
- } else if (has_netid(2)) then {
- krt_prefsrc = CRXNIP;
- } else if (has_netid(4)) then {
- krt_prefsrc = NEOIPv6;
- } else {
- krt_prefsrc = DN42IPv6;
- }
- accept;
- };
- };
- };
- /*
- * OWNNET
- */
- protocol static {
- {% for net in dn42.ipv4nets %}
- route DN42NET{{ loop.index }} reject;
- {% endfor %}
- ipv4 {
- import filter { preference = 100; add_netid(1); accept; };
- export none;
- };
- }
- protocol static {
- {% for net in dn42.ipv6nets %}
- route DN42NET{{ loop.index }}v6 reject;
- {% endfor %}
- ipv6 {
- import filter { preference = 100; add_netid(1); accept; };
- export none;
- };
- }
- protocol static {
- {% for net in crxn.nets %}
- route CRXNNET{{ loop.index }} reject;
- {% endfor %}
- ipv6 {
- import filter { preference = 100; add_netid(2); accept; };
- export none;
- };
- }
- protocol static {
- {% for net in neonetwork.ipv4nets %}
- route NEONET{{ loop.index }} reject;
- {% endfor %}
- ipv4 {
- import filter { preference = 100; add_netid(4); accept; };
- export none;
- };
- }
- protocol static {
- {% for net in neonetwork.ipv6nets %}
- route NEONET{{ loop.index }}v6 reject;
- {% endfor %}
- ipv6 {
- import filter { preference = 100; add_netid(4); accept; };
- export none;
- };
- }
- /*
- * Other configurations
- */
- protocol bfd {}
- include "routes.conf";
- include "igp.conf";
- include "filters.conf";
- include "templates.conf";
- include "crxn_peers.conf";
- include "antiddos.conf";
- include "bgp_clients_filter.conf";
- include "bgp_clients.conf";
- include "dnpeers.conf";
- include "ibgp_nodes.conf";
- include "collector_peers.conf";
|