private_network/roles/dhcp/templates/dhcpd.conf.j2

57 lines
1.7 KiB
Django/Jinja

# dhcpd.conf
{% if dhcp_is_authorative is defined and dhcp_is_authorative is sameas true %}
authoritative;
{% endif %}
# Global settings for DHCP lease times
default-lease-time {{ dhcp_default_lease_time }};
max-lease-time {{ dhcp_max_lease_time }};
# Global domain names and servers for all supported networks
{% if dhcp_common_domain_name is not none %}
option domain-name "{{ dhcp_common_domain_name }}";
{% endif %}
{% if dhcp_common_name_servers is not none %}
option domain-name-servers {{ dhcp_common_name_servers|join(', ') }};
{% endif %}
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;
# Subnet definitions
{% for subnet in dhcp_subnets %}
subnet {{ subnet.net }} netmask {{ subnet.netmask }} {
option routers {{ subnet.routers }};
option broadcast-address {{ subnet.broadcast }};
option domain-name "{{ subnet.domain_name }}";
option domain-name-servers {{ subnet.domain_name_servers|join(', ') }};
{% if subnet.domain_search is defined and subnet.domain_search|length > 0 %}
option domain-search {{ subnet.domain_search | map('regex_replace', '^(.*)$', '\"\\1\"') | join(', ') }};
{% endif %}
{% if subnet.range_start is defined and subnet.range_end is defined %}
range {{ subnet.range_start }} {{ subnet.range_end }};
{% endif %}
{% if subnet.allow_unknown is defined and subnet.allow_unknown is sameas false %}
deny unknown-clients;
{% else %}
allow unknown-clients;
{% endif %}
{% for host in subnet.hosts %}
host {{ host.name }} {
hardware ethernet {{ host.mac }};
{% if host.ip is defined %}
fixed-address {{ host.ip }};
{% endif %}
}
{% endfor %}
}
{% endfor %}