batman.j2 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # This file is managed by ansible, don't make changes here - they will be overwritten.
  2. # Batman Interface
  3. # - Erstellt das virtuelle Interface fuer das Batman-Modul und bindet dieses an die Netzwerkbruecke
  4. # - Die unten angelegte Routing-Tabelle wird spaeter fuer das Routing innerhalb von Freifunk (Router/VPN) verwendet
  5. {% for item in domaenenliste|dictsort %}
  6. auto bat{{item[0]}}
  7. iface bat{{item[0]}} inet static
  8. address {{domaenen[item[0]].ffv4_network | ipaddr(item[1].server_id) | ipaddr('address') }}
  9. netmask {{domaenen[item[0]].ffv4_network | ipaddr('netmask')}}
  10. pre-up modprobe batman-adv
  11. pre-up ip link add bat{{item[0]}} type batadv
  12. post-up ip link set dev bat{{item[0]}} up
  13. post-up batctl -m bat{{item[0]}} it 10000
  14. post-up batctl -m bat{{item[0]}} gw server {{batman.downstream}}/{{batman.upstream}}
  15. post-up batctl -m bat{{item[0]}} if add br{{item[0]}} ||:
  16. {% for host in groups['supernodes'] %}
  17. {% if host != inventory_hostname %}
  18. {% if hostvars[host].domaenenliste is defined %}
  19. {% for item2 in hostvars[host].domaenenliste|dictsort %}
  20. {% if item[0] == item2[0] %}
  21. post-up batctl -m bat{{item[0]}} if add t{{item[0]}}-{{host}} ||:
  22. {% endif %}
  23. {% endfor %}
  24. {% endif %}
  25. {% endif %}
  26. {% endfor %}
  27. post-up ip rule add from all fwmark 0x1 table ffnet pref 16000 ||:
  28. post-up ip rule add iif bat{{item[0]}} table ffnet pref 16000 ||:
  29. post-up ip rule add iif lo lookup ffnet suppress_prefixlength 0 pref 16500 ||:
  30. post-down ip rule del from all fwmark 0x1 table ffnet ||:
  31. post-down ip rule del iif bat{{item[0]}} table ffnet ||:
  32. post-down ip rule del iif lo lookup ffnet suppress_prefixlength 0 ||:
  33. iface bat{{item[0]}} inet6 static
  34. address {{domaenen[item[0]].ffv6_network | ipaddr(item[1].server_id) | ipaddr('address') }}
  35. netmask {{domaenen[item[0]].ffv6_network | ipaddr('prefix')}}
  36. post-up ip -6 rule add from all fwmark 0x1 table ffnet pref 16000 ||:
  37. post-up ip -6 rule add iif bat{{item[0]}} table ffnet pref 16000 ||:
  38. post-up ip -6 rule add iif lo lookup ffnet suppress_prefixlength 0 pref 16500 ||:
  39. post-up ip -6 rule add from {{domaenen[item[0]].ffv6_network | ipaddr(item[1].server_id) | ipaddr('address') }} lookup ffnet pref 16000 ||:
  40. post-down ip -6 rule del from all fwmark 0x1 table ffnet ||:
  41. post-down ip -6 rule del iif bat{{item[0]}} table ffnet ||:
  42. post-down ip -6 rule del iif lo lookup ffnet suppress_prefixlength 0 ||:
  43. post-down ip -6 rule del from {{domaenen[item[0]].ffv6_network | ipaddr(item[1].server_id) | ipaddr('address') }} lookup ffnet ||:
  44. {% endfor %}