dhcpd.conf 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. {%- set dhcp_prefixes = salt['pillar.get']("node: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. {#- We must only define a pool when there's at least one range for the subnet #}
  25. {%- if "ranges" in prefix %}
  26. pool {
  27. {%- endif %}
  28. {%- if not prefix.get("authoritative", True) %}
  29. not authoritative;
  30. {%- endif %}
  31. # monitor: 75% 90% Y {{ grains['nodename'] }}/{{ prefix["description"] }}
  32. # Use our own IP as gateway for our clients
  33. option routers {{ prefix["routers"] }};
  34. {%- if prefix.get("role") == "mgmt" %}
  35. option ubnt.unifi-address 10.132.251.21;
  36. option domain-name "{{ dns_search_domain }}";
  37. {%- endif %}
  38. {% if "ranges" in prefix %}
  39. # Range(s) of IPs to lease to clients
  40. {%- for range in prefix["ranges"] %}
  41. range {{ range }};
  42. {%- endfor %}
  43. {%- else %}
  44. # No ranges defined, static leases only?
  45. {%- endif %}
  46. {%- if "ranges" in prefix %}
  47. }
  48. {%- endif %}
  49. }
  50. {% endfor %}