fastd.conf 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #
  2. # {{ site }} / {{ network }} FASTd configuration (Salt managed)
  3. #
  4. {%- set meshif = "meshif" %}
  5. {%- if grains.oscodename != "buster" %}
  6. {%- set meshif = "-m" %}
  7. {%- endif %}
  8. log to syslog level info;
  9. interface "{{ site }}_{{ network }}";
  10. {%- if 'aes' in grains.cpu_flags and grains.oscodename not in [ "stretch" ] %}
  11. method "aes128-gcm";
  12. method "aes128-ctr+umac";
  13. {%- else %}
  14. #method "aes128-gcm"; # - Not supported by CPU on this machine
  15. #method "aes128-ctr+umac"; # - Not supported by CPU on this machine
  16. {%- endif %}
  17. method "salsa2012+umac";
  18. {#- Calculating FASTd port depending on network_type #}
  19. {%- set port = -1 %}
  20. {%- if network_type == 'nodes' %}
  21. {%- set port = 10000 + site_no|int %}
  22. {%- elif network_type == 'intergw' %}
  23. {%- set port = 11000 + site_no|int %}
  24. {%- endif %}
  25. {%- if network in ['nodes4', 'intergw'] %}
  26. bind 0.0.0.0:{{ port }} interface "vrf_external";
  27. {%- endif %}
  28. {%- if network in ['nodes6', 'intergw'] %}
  29. bind [::]:{{ port }} interface "vrf_external";
  30. {%- endif %}
  31. # Mark packets to make sure they are associated to VRF vrf_external.
  32. # Specifying the interface and setsockopt() isn't enough for fastd.
  33. packet mark 0x1023;
  34. secret "{{ secret }}";
  35. mtu 1406;
  36. status socket "/var/run/fastd.{{ site }}_{{ network }}.sock";
  37. on up "
  38. ip link set $INTERFACE down
  39. ip link set address {{ mac_address }} dev $INTERFACE
  40. ip link set $INTERFACE up
  41. batctl {{ meshif }} {{ bat_iface }} if add $INTERFACE
  42. {%- if grains.oscodename == "buster" or 'batman-iface-penalty' in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':tags', []) %}
  43. # Make VPN more expensive than intra DC/DCI/WBBL links
  44. batctl hardif $INTERFACE hop_penalty 50
  45. {%- endif %}
  46. ";
  47. on down "
  48. batctl {{ meshif }} {{ bat_iface }} if del $INTERFACE
  49. ";
  50. {%- if network_type == 'nodes' %}
  51. on verify "/etc/fastd/verify-peer.sh $PEER_KEY $PEER_ADDRESS";
  52. {%- if peer_limit %}
  53. peer limit {{ peer_limit }};
  54. {%- endif %}
  55. {%- elif network_type == 'intergw' %}
  56. #
  57. # Set up Inter-Gw-VPN link to all nodes of this site
  58. {%- set node_is_gw = True if grains.id.startswith('gw') else False %}
  59. {%- for peer, peer_config in salt['pillar.get']('nodes').items ()|sort if peer != grains.id %}
  60. {%- if site not in peer_config.get ('sites', {}) %}{% continue %}{% endif %}
  61. {%- if 'fastd' not in peer_config %}{% continue %}{% endif %}
  62. {#- non gw nodes are only allowed to connect to gw peers #}
  63. {%- set peer_is_gw = True if peer.startswith('gw') else False %}
  64. {%- if not node_is_gw and not peer_is_gw %}{% continue %}{% endif %}
  65. # Peer config for {{ peer }}
  66. peer "{{ peer }}" {
  67. key "{{ peer_config.get('fastd', {}).get('intergw_pubkey') }}";
  68. {%- if peer_is_gw %}
  69. {%- set ips = salt['ffho_net.get_node_iface_ips'](peer_config, 'vrf_external') %}
  70. {#- set peer IPv4 address #}
  71. {%- for ipv4 in ips['v4'] %}
  72. remote {{ ipv4 }}:{{ port }};
  73. {%- endfor %}
  74. {#- set peer IPv6 address if node has IPv6 #}
  75. {%- for ipv6 in ips['v6'] %}
  76. remote [{{ ipv6 }}]:{{ port }};
  77. {%- endfor %}
  78. {%- endif %}
  79. }
  80. {%- endfor %}
  81. {%- if grains.id == "gw04.in.ffho.net" and site == "pad-cty" %}
  82. # Peer config for biobluemchen
  83. peer "biobluemchen" {
  84. key "28755f3c50867a689f89925a7b6444ade78a55f249ab69f1244a1be2fe331a5e";
  85. }
  86. {%- endif %}
  87. {%- endif %}