fastd.conf 2.8 KB

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