fastd.conf 2.8 KB

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