bird.conf 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. ################################################
  2. # Variable header #
  3. ################################################
  4. define DNAS = 4242422923;
  5. define NEOAS = 4201272923;
  6. define RCAS = 64507;
  7. define OWNAS = DNAS;
  8. define DNIP = {{ network.dnip.ipv4 }};
  9. define DNIPv6 = {{ network.dnip.ipv6 }};
  10. define NEOIP = {{ network.neoip.ipv4 }};
  11. define NEOIPv6 = {{ network.neoip.ipv6 }};
  12. define DNNET = 172.22.149.224/27;
  13. define DNNETv6 = fd04:234e:fc31::/48;
  14. define DNNET2 = 172.22.149.112/28;
  15. define NEONET = 10.127.149.224/27;
  16. define NEONETv6 = fd10:127:fc31::/48;
  17. define CRXNNET = fd92:58b6:2b2::/48;
  18. define CRXNIP = fd92:58b6:2b2::2;
  19. define RCNET = 172.24.7.0/24;
  20. define RCNETv6 = 2001:db8:dead:beef:4cbe::/80;
  21. define RCIP = 172.24.7.2;
  22. define RCIPv6 = 2001:db8:dead:beef:4cbe::2;
  23. define DNMYIPNET = 172.20.0.81/32;
  24. define DNMYIPNETv6 = fd42:d42:d42:81::/64;
  25. define NEODNS_AUTH = 10.127.255.53/32;
  26. define NEODNS_AUTHv6 = fd10:127:ffff:53::/64;
  27. define NEODNS_RECUR = 10.127.255.54/32;
  28. define NEODNS_RECURv6 = fd10:127:53:53::/64;
  29. define OWNNETSET = [172.22.149.224/27+, 10.127.149.224/27+, 172.20.0.81/32, 172.22.149.112/28+, 172.24.7.0/24+, 10.127.255.53/32+];
  30. define OWNNETSETv6 = [fd04:234e:fc31::/48+, fd10:127:fc31::/48+, fd42:d42:d42:81::/64+, fd92:58b6:2b2::/48+, 2001:db8:dead:beef:4cbe::/80+, fd10:127:ffff:53::/64+];
  31. define DN42_REGION_GEO = 41;
  32. define DN42_REGION_COUNTRY = 1276;
  33. define BANDWIDTH = 25;
  34. ################################################
  35. # Header end #
  36. ################################################
  37. router id DNIP;
  38. #router id 44.55.66.77;
  39. include "/etc/bird/netids.conf";
  40. protocol device {
  41. scan time 10;
  42. }
  43. /*
  44. * Utility functions
  45. */
  46. function is_self_net() {
  47. return net ~ OWNNETSET;
  48. }
  49. function is_self_net_v6() {
  50. return net ~ OWNNETSETv6;
  51. }
  52. function is_neonetwork() {
  53. return net ~ [10.127.0.0/16+] || net ~ [fd10:127::/32+];
  54. }
  55. function is_valid_network() {
  56. return net ~ [
  57. 172.20.0.0/14{21,29}, # dn42
  58. 172.20.0.0/24{28,32}, # dn42 Anycast
  59. 172.21.0.0/24{28,32}, # dn42 Anycast
  60. 172.22.0.0/24{28,32}, # dn42 Anycast
  61. 172.23.0.0/24{28,32}, # dn42 Anycast
  62. 172.31.0.0/16+, # ChaosVPN
  63. 10.100.0.0/14+, # ChaosVPN
  64. 10.127.0.0/16{16,32}, # neonetwork
  65. 10.0.0.0/8{15,24} # Freifunk.net
  66. ];
  67. }
  68. function is_valid_network_v6() {
  69. return net ~ [
  70. fd00::/8{44,64} # ULA address space as per RFC 4193
  71. ];
  72. }
  73. function is_own32ipv4() {
  74. return (net = DNMYIPNET || net = NEODNS_AUTH || net = NEODNS_RECUR);
  75. }
  76. include "/etc/bird/crxn_utilits.conf";
  77. /*
  78. * ROA dn42 & neo
  79. */
  80. roa4 table dn42_roa;
  81. roa6 table dn42_roa_v6;
  82. protocol static {
  83. roa4 { table dn42_roa; };
  84. include "/var/lib/bird/dn42-roa4.conf";
  85. };
  86. protocol static {
  87. roa6 { table dn42_roa_v6; };
  88. include "/var/lib/bird/dn42-roa6.conf";
  89. };
  90. /*
  91. * Forward plane
  92. */
  93. protocol kernel {
  94. scan time 20;
  95. metric 500;
  96. ipv4 {
  97. import none;
  98. export filter {
  99. if source = RTS_DEVICE then reject;
  100. if (has_netid(2)) then {
  101. print "Warning: CRXN netid in IPv4", net;
  102. reject;
  103. } else if (has_netid(3)) then {
  104. krt_prefsrc = RCIP;
  105. } else {
  106. if is_neonetwork() then {
  107. krt_prefsrc = NEOIP;
  108. } else {
  109. krt_prefsrc = DNIP;
  110. }
  111. }
  112. accept;
  113. };
  114. };
  115. }
  116. protocol kernel {
  117. scan time 20;
  118. metric 500;
  119. ipv6 {
  120. import none;
  121. export filter {
  122. if source = RTS_DEVICE then reject;
  123. if (has_netid(2)) then {
  124. krt_prefsrc = CRXNIP;
  125. } else if (has_netid(3)) then {
  126. krt_prefsrc = RCIPv6;
  127. } else {
  128. if is_neonetwork() then {
  129. krt_prefsrc = NEOIPv6;
  130. } else {
  131. krt_prefsrc = DNIPv6;
  132. }
  133. }
  134. accept;
  135. };
  136. };
  137. };
  138. /*
  139. * OWNNET
  140. */
  141. protocol static {
  142. route DNNET reject;
  143. route DNNET2 reject;
  144. ipv4 {
  145. import filter { add_netid(1); accept; };
  146. export none;
  147. };
  148. }
  149. protocol static {
  150. route DNNETv6 reject;
  151. route DNMYIPNETv6 reject;
  152. ipv6 {
  153. import filter { add_netid(1); accept; };
  154. export none;
  155. };
  156. }
  157. protocol static {
  158. route NEONET reject;
  159. ipv4 {
  160. import filter { add_netid(4); accept; };
  161. export none;
  162. };
  163. }
  164. protocol static {
  165. route NEONETv6 reject;
  166. route NEODNS_AUTHv6 reject;
  167. route NEODNS_RECURv6 reject;
  168. ipv6 {
  169. import filter { add_netid(4); accept; };
  170. export none;
  171. };
  172. }
  173. protocol static {
  174. route CRXNNET reject;
  175. ipv6 {
  176. import filter { add_netid(2); accept; };
  177. export none;
  178. };
  179. }
  180. protocol static {
  181. route RCNET reject;
  182. ipv4 {
  183. import filter { add_netid(3); accept; };
  184. export none;
  185. };
  186. }
  187. protocol static {
  188. route RCNETv6 reject;
  189. ipv6 {
  190. import filter { add_netid(3); accept; };
  191. export none;
  192. };
  193. }
  194. protocol static {
  195. route fd00::/8 reject;
  196. ipv6 {
  197. import filter { add_netid(30); accept; };
  198. export none;
  199. };
  200. }
  201. include "/etc/bird/templates.conf";
  202. /*
  203. * Other configurations
  204. */
  205. protocol bfd {}
  206. include "/etc/bird/babel.conf";
  207. include "/etc/bird/community_filters.conf";
  208. include "/etc/bird/crxn.conf";
  209. {% if network.routercity == "true" %}
  210. include "/etc/bird/routercity.conf";
  211. {% endif %}
  212. include "/etc/bird/peers/*";
  213. include "/etc/bird/ibgp_nodes/*";