From 6e35a7462da25f53f58f79382a6a79d89fcb33d4 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Mon, 5 Aug 2024 12:07:39 +0200 Subject: [PATCH] dnsmasq: get DHCP ranges from NetBox --- roles/dnsmasq/templates/10-ranges.conf.j2 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/roles/dnsmasq/templates/10-ranges.conf.j2 b/roles/dnsmasq/templates/10-ranges.conf.j2 index 4eed62c..69692a3 100644 --- a/roles/dnsmasq/templates/10-ranges.conf.j2 +++ b/roles/dnsmasq/templates/10-ranges.conf.j2 @@ -1,7 +1,9 @@ {% for prefix in prefixes | selectattr('custom_fields.dhcp_server') %} {% if prefix.custom_fields.dhcp_server.address | ipaddr('address') == primary_ip4 %} # {{ prefix.vlan.name }} -dhcp-range = set:{{ prefix.vlan.name }},{{ prefix.prefix | ipmath(100) }},{{ prefix.prefix | ipmath(200) }},{{ prefix.prefix | ipaddr('netmask') }} +{% for range in prefix.custom_fields.dhcp_ranges | default([], true) %} +dhcp-range = set:{{ prefix.vlan.name }},{{ range.start_address | ipaddr('address') }},{{ range.end_address | ipaddr('address') }},{{ prefix.prefix | ipaddr('netmask') }} +{% endfor %} {% if prefix.custom_fields.gateway %} dhcp-option = tag:{{ prefix.vlan.name }},option:router,{{ prefix.custom_fields.gateway.address | ipaddr('address') }} {% endif -%}