dhcpd.conf 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. {%- set dhcp_prefixes = salt['pillar.get']("nodes:" ~ grains["id"] ~ ":dhcp:server:prefixes", []) -%}
  2. {%- set dns_resolver_IP = salt["pillar.get"]("globals:dns:resolver_v4") -%}
  3. {%- set dns_search_domain = salt["pillar.get"]("globals:dns:search") -%}
  4. {%- set unifi_address = salt["pillar.get"]("globals:unifi:address") -%}
  5. #
  6. # DHCP server configuration (Salt managed)
  7. #
  8. authoritative;
  9. ddns-update-style none;
  10. log-facility local7;
  11. default-lease-time 600;
  12. max-lease-time 3600;
  13. option domain-name-servers {{ dns_resolver_IP }};
  14. option space ubnt;
  15. option ubnt.unifi-address code 1 = ip-address;
  16. class "ubnt" {
  17. match if substring (option vendor-class-identifier, 0, 4) = "ubnt";
  18. option vendor-class-identifier "ubnt";
  19. vendor-option-space ubnt;
  20. }
  21. {% for prefix in dhcp_prefixes %}
  22. # {{ prefix["description"] }}
  23. subnet {{ prefix["network"] }} netmask {{ prefix["netmask"] }} {
  24. pool {
  25. {%- if not prefix.get("authoritative", True) %}
  26. not authoritative;
  27. {%- endif %}
  28. # monitor: 75% 90% Y {{ grains['nodename'] }}/{{ prefix["description"] }}
  29. # Use our own IP as gateway for our clients
  30. option routers {{ prefix["routers"] }};
  31. {%- if prefix.get("role") == "mgmt" %}
  32. option ubnt.unifi-address 10.132.251.21;
  33. option domain-name "{{ dns_search_domain }}";
  34. {%- endif %}
  35. {% if "ranges" in prefix %}
  36. # Range(s) of IPs to lease to clients
  37. {%- for range in prefix["ranges"] %}
  38. range {{ range }};
  39. {%- endfor %}
  40. {%- else %}
  41. # No ranges defined, static leases only?
  42. {%- endif %}
  43. }
  44. }
  45. {% endfor %}