bird6_ms.conf.j2 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. # This file is managed by ansible, don't make changes here - they will be overwritten.
  2. log syslog { debug, trace, info, remote, warning, error, auth, fatal, bug };
  3. router id {{ vm_id }};
  4. table ffnet;
  5. filter freifunk {
  6. if net ~ {{ff_network.v6_network}} then accept;
  7. {% if not ffrl_tun is defined %}
  8. if net ~ [::/0] then accept;
  9. {% endif %}
  10. reject;
  11. }
  12. #protocol kernel {
  13. # scan time 20;
  14. # import all;
  15. # export all;
  16. # table ffnet;
  17. # kernel table 42;
  18. # device routes;
  19. # persist;
  20. #};
  21. {% if domaenenliste is defined %}
  22. protocol radv {
  23. {% for domaene in domaenenliste|dictsort %}
  24. interface "bat{{domaene[0]}}" {
  25. max ra interval 20;
  26. link mtu 1280;
  27. prefix {{domaenen[domaene[0]].ffv6_network}} {
  28. };
  29. rdnss {
  30. ns {{domaenen[domaene[0]].ffv6_network | ipaddr(domaene[1].server_id) | ipaddr('address') }};
  31. };
  32. dnssl "{{freifunk.search_domain}}";
  33. };
  34. {% endfor %}
  35. };
  36. {% endif %}
  37. protocol bfd {
  38. table ffnet;
  39. interface "gre*";
  40. interface "bck*";
  41. multihop {
  42. passive;
  43. };
  44. };
  45. protocol device {
  46. scan time 10;
  47. };
  48. protocol ospf {
  49. table ffnet;
  50. import filter freifunk;
  51. export all;
  52. area 0.0.0.0 {
  53. interface "bat*" {
  54. stub;
  55. };
  56. {% for host in groups['supernodes'] %}
  57. {% if hostvars[host].hoster|default('unknown') != hoster|default('unknown') %}
  58. interface "bck-{{host}}" {
  59. cost 1000;
  60. };
  61. {% endif %}
  62. {% endfor %}
  63. interface "bck-*";
  64. {% if ffrl_tun is defined %}
  65. interface "lo" {
  66. stub;
  67. };
  68. {% endif %}
  69. };
  70. };
  71. function is_default() {
  72. return (net ~ [::/0]);
  73. };
  74. {% if ffrl_tun is defined %}
  75. filter export_to_upstream_filter {
  76. if source = RTS_STATIC then accept;
  77. reject;
  78. };
  79. {% endif %}
  80. protocol static static_Gesamtnetzwerk {
  81. table ffnet;
  82. route {{ff_network.v6_network}} reject;
  83. };
  84. {% if domaenenliste is defined %}
  85. {% for domaene in domaenenliste|dictsort %}
  86. protocol static static_domaene{{domaene[0]}} {
  87. table ffnet;
  88. route {{domaenen[domaene[0]].ffv6_network | regex_replace('..::/\d+$','00::/56')}} reject;
  89. };
  90. {% endfor %}
  91. {% endif %}
  92. {% if dhcp is defined %}
  93. protocol static 'static_{{inventory_hostname_short}}' {
  94. table ffnet;
  95. route {{ff_network.v6_network | regex_replace('..::/\d+$','00::/56')}} reject;
  96. };
  97. {% endif %}
  98. #protocol kernel 'kernel_master' {
  99. # scan time 20;
  100. # table master;
  101. # kernel table 254;
  102. # import all;
  103. # export all;
  104. # persist;
  105. #};
  106. protocol static {
  107. table master;
  108. import all;
  109. export none;
  110. };
  111. protocol direct {
  112. interface "lo";
  113. interface "tun-ffrl*";
  114. interface "gre-*";
  115. interface "bck-*";
  116. interface "bat*";
  117. table ffnet;
  118. }
  119. template bgp internal {
  120. table ffnet;
  121. local as {{ff_network.as_number}};
  122. import filter {
  123. if is_default() then
  124. preference = 99;
  125. else
  126. preference = 160;
  127. accept;
  128. };
  129. export filter {
  130. if source = RTS_BGP then accept;
  131. {% if ffrl_tun is not defined %}
  132. if source = RTS_STATIC then accept;
  133. {% endif %}
  134. else reject;
  135. };
  136. gateway direct;
  137. direct;
  138. next hop self;
  139. };
  140. {% for host in groups['supernodes'] %}
  141. {% if hostvars[host].vm_id != vm_id %}
  142. protocol bgp ibgp_{{host|regex_replace('-','_')}} from internal {
  143. {% if hostvars[host].vm_id < vm_id %}
  144. neighbor 2a03:2260:115:ffa1::{{hostvars[host].vm_id}}:{{vm_id}}:1 as {{ff_network.as_number}};
  145. {% else %}
  146. neighbor 2a03:2260:115:ffa1::{{vm_id}}:{{hostvars[host].vm_id}}:0 as {{ff_network.as_number}};
  147. {% endif %}
  148. {% if hostvars[host].hoster|default('unknown') != hoster|default('unknown') %}
  149. import filter {
  150. preference = 50;
  151. accept;
  152. };
  153. {% endif %}
  154. }
  155. {% endif %}
  156. {% endfor %}
  157. {% if ffrl_tun is defined %}
  158. template bgp uplink {
  159. table ffnet;
  160. local as {{ff_network.as_number}};
  161. import where is_default();
  162. export filter export_to_upstream_filter;
  163. gateway recursive;
  164. }
  165. {% for tun in ffrl_tun %}
  166. protocol bgp ffrl_{{tun.name}} from uplink {
  167. description "Rheinland Backbone";
  168. source address {{ tun.v6_remote | ipaddr('2') | ipaddr('address') }};
  169. neighbor {{tun.v6_remote | ipaddr('address')}} as 201701;
  170. };
  171. {% endfor %}
  172. {% endif %}